Manual Reference Source Test

src/models/user/Role.js

/**
 * Model representing a user role.
 */
class RoleModel {
  /**
     * @param {Object}  response                        - JSON formatted response of a user role.
     * @param {Number}  response.id                     - The user role ID value
     * @param {String}  response.permanent_link         - Permanent link of the user role
     * @param {String}  response.name                   - Name of the user role
     * @param {Boolean} response.is_super               - Whether this user role is a super role
     * @param {Boolean} response.is_admin               - Whether this user role is an admin role
     * @param {Boolean} response.is_mobile              - Whether this user role is for mobile users
     * @param {Boolean} response.is_default             - Whether this user role is the default role
     * @param {Boolean} response.description            - Description of the user role
     * @param {Boolean} response.can_view_pii           - Can the user view PII
     */
  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.permanentLink = attributes.permanent_link;

    /** @type {String} */
    this.name = attributes.name;

    /** @type {Boolean} */
    this.isSuper = attributes.is_super;

    /** @type {Boolean} */
    this.isAdmin = attributes.is_admin;

    /** @type {Boolean} */
    this.isMobile = attributes.is_mobile;

    /** @type {Boolean} */
    this.isDefault = attributes.is_default;

    /** @type {Boolean} */
    this.description = attributes.description;

    /** @type {Boolean} */
    this.canViewPii = attributes.can_view_pii;
  }
}

export default RoleModel;