Manual Reference Source Test

src/models/ediary/Entry.js

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

/**
 * Model representing an EDiary Entry.
 */
class EntryModel {
  /**
   * @param {Object}  response            - JSON formatted response of an entry.
   * @param {Number}  response.id         - The entry id value
   * @param {String}  response.created_at - Date in which the user was created
   * @param {String}  response.date       - Date
   * @param {String}  response.updated_at - Date in which the user 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.createdAt = attributes.created_at;

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

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

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

export default EntryModel;