Manual Reference Source Test

src/models/user/InvitationStatus.js

import { stringToCamel } from '../../utilities/FormatUtility';
import { fieldsToSnake } from '../../utilities/ClassUtility';

/**
 * Model representing a User Invitation Model.
 */
class InvitationStatusModel {
  /**
   * @param {Object}  response                  - JSON formatted response of an invitation.
   * @param {Any}  response.id               - The invitation id value
   * @param {String}  response.email            - User email
   * @param {String}  response.invitation_token - Invitation Token
   * @param {String}  response.status           - Invitation Status
   */
  constructor(response = {}) {
    const _response = response.data || response; // if json api is passed in directly
    const attributes = fieldsToSnake(_response.attributes || _response); // if json api is passed in directly or camel format fields

    if (_response.id) {
      /** @type {Any} */
      this.id = _response.id;
    }

    Object.keys(attributes).forEach((key) => {
      if (['id', 'type', 'role', 'language', 'followed'].indexOf(key) === -1) {
        /** @type {Any} */
        this[stringToCamel(key)] = attributes[key];
      }
    });

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

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

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

export default InvitationStatusModel;