Manual Reference Source Test

src/models/discuss/Thread.js

/**
 * Model representing a thread.
 */
class ThreadModel {
  /**
   * @param {Object} response                             - JSON formatted response of a thread
   * @param {String} response.id                          - The thread id
   * @param {Object} response.attributes                  - Attributes for a thread
   * @param {String} response.attributes.status           - The thread text
   * @param {String} response.attributes.created_at       - The creation timestamp
   * @param {String} response.attributes.resolved_at      - The creation timestamp
   */
  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.status = attributes.status;

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

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

export default ThreadModel;