Manual Reference Source Test

src/models/import/GenericFile.js

/**
 * Model representing a generic file.
 */
class GenericFileModel {
  /**
   * @param {Object}    response                  - JSON formatted response of a single generic file
   * @param {!Number}   response.id               - The id of the generic file on the server
   * @param {!String}   response.type             - The type of this object ('generic_files')
   * @param {!String}   response.name             - Name for the generic file `myfile.csv`
   * @param {!Boolean}  response.public           - Whether or not the file is public
   * @param {!Date}     [response.visible_until]  - Datetime until it's no longer visible `2018-10-17 00:58:56 UTC`
   * @param {!Date}     [response.created_at]     - Time at which the generic file was created
   * @param {!Date}     [response.updated_at]     - Time at which the generic file was updated
   */
  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.name = attributes.name;

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

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

    /** @type {Date} */
    this.visibleUntil = attributes.visible_until;

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

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

export default GenericFileModel;