Manual Reference Source Test

src/models/trial/SiteContact.js

/**
 * Model representing a site contact.
 */
class SiteContactModel {
  /**
   * @param {Object}  response                                - JSON formatted response of a single site contact
   * @param {!Number} response.id                             - The id of the site contact on the server
   * @param {!String} response.first_name                     - Site contact's first name
   * @param {!String} response.last_name                      - Last name of the site contact
   * @param {!String} response.email                          - Email Address of the site contact
   * @param {!String} response.phone                          - Phone number of the site contact
   * @param {String}  response.fax                            - Fax number of the site contact
   * @param {String}  response.primary_contact                - Is this a primary contact?
   * @param {String}  response.created_at                     - Created at
   * @param {String}  response.updated_at                     - Updated at
   */
  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.firstName = attributes.first_name;

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

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

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

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

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

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

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

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

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

export default SiteContactModel;