Manual Reference Source Test

src/models/Device.js

/**
 * Model representing a device.
 */
class DeviceModel {
  /**
   * @param {Object} response               - JSON formatted response of a single device
   * @param {Number} response.id            - The id of the device on the server
   * @param {String} response.type          - The type of this object ('devices')
   * @param {String} response.udid          - Unique identifier for this installation
   * @param {String} response.technology    - ios, android, web
   * @param {String} response.access_token  - The access token
   * @param {String} response.push_id       - The push id used for push notifications
   * @param {String} response.created_at    - Created at
   * @param {String} response.updated_at    - Updated at
   * @param {String} response.app_version   - App Version
   */
  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.udid = attributes.udid;

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

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

    /** @type {String} */
    this.pushId = attributes.push_id || 'FAKE_ID';

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

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

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

    /**
     * @deprecated
     */
    this.appVersion = this.appVersion || attributes.version;
    this.udid = this.udid || attributes.uuid;
  }
}

export default DeviceModel;