Manual Reference Source Test

src/models/Section.js

/**
 * Model representing section.  This is specifically for eating cookies.
 *
 */
class SectionModel {
  /**
   * @param {Object}   response               - JSON formatted response of a single section
   * @param {String}   response.label         - The label of the section
   * @param {String}   response.object        - The object of the section
   * @param {String}   response.owner         - The owner of the section
   * @param {String}   response.ownerType     - The ownerType of the section
   * @param {String}   response.type          - The type of the section.  Type can be 'section',
   *                                            'flow', or 'custom'.
   * @param {String}   response.value         - The status of the section.  For example 'initial',
   *                                            'in_progress' or 'completed'
   * @param {Object[]} response.sub_statuses  -  An array of children
   * @param {String}   response.access_class  -  Access class of section.For example 'MobileUser'
   */
  constructor(response = {}) {
    const _response = response.data || response; // if json api is passed in directly
    const attributes = _response.attributes || _response; // if json api is passed in directly

    if (_response.id) {
      /** @type {Number} */
      this.id = parseInt(_response.id, 10);
    }

    /** @type {String} */
    this.object = response.object;
    /** @type {String} */
    this.label = attributes.label;
    /** @type {String} */
    this.type = response.type;
    /** @type {String} */
    this.status = attributes.value;
    /** @type {String} */
    this.owner = attributes.owner;
    /** @type {String} */
    this.ownerType = attributes.ownerType;
    /** @type {Object[]} */
    this.sub_statuses = attributes.sub_statuses;
    /** @type {String} */
    this.accessClass = attributes.access_class;
  }
}

export default SectionModel;