Manual Reference Source Test

src/models/flow/FlowData.js

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

/**
 * Model representing an Flow Data (data_collection__captured_values).
 */
class FlowDataModel {
  /**
     * @param {Object}  response      - JSON formatted response of a captured value.
     * @param {Number}  response.id   - The id value
     * @param {Object}  response.data - 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 {Object} */
    this.data = attributes.data;

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

export default FlowDataModel;