Manual Reference Source Test

src/models/AnalyticsMetric.js

/**
 * Model representing an analytics metric.
 */
class AnalyticsMetricModel {
  /**
   * @param {Object} response               - JSON formatted response of a AnalyticsMetric
   * @param {String} response.id            - The id value of the analytics metric
   * @param {String} response.type          - The type associated with the analytics metric
   * @param {Number} response.value         - The value of the analytics metric
   * @param {String} response.unit          - The unit title of the analytics metric
   * @param {String} response.name          - The name of the analytics metric
   */
  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 {String} */
      this.id = _response.id;
    }

    /** @type {Number} */
    this.value = attributes.value;

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

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

export default AnalyticsMetricModel;