Manual Reference Source Test

src/models/Location.js

/**
 * Model representing a location object. Location must have, at a minimum, one of the following:
 * - latitude and longitude OR
 * - country, state, ZIP code, city, and street
 */
class LocationModel {
  /**
   * @param {Object} location                 - JSON formatted response of a location
   * @param {Float} location.latitude         - Latitude
   * @param {Float} location.longitude        - longitude
   * @param {String} location.country         - Country
   * @param {String} location.state           - State
   * @param {String} location.title           - Title
   * @param {String|Number} location.zip_code - Zipcode
   * @param {String} location.address_line_1  - Address Line 1
   * @param {String} location.address_line_2  - Address Line 2
   * @param {String} location.address_line_3  - Address Line 3
   * @param {String} location.city            - City
   */

  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.country = attributes.country;
    /** @type {String} */
    this.state = attributes.state;
    /** @type {String} */
    this.city = attributes.city;
    /** @type {Float} */
    this.latitude = attributes.latitude;
    /** @type {Float} */
    this.longitude = attributes.longitude;
    /** @type {String} */
    this.title = attributes.title;
    /** @type {String|Number} */
    this.zipCode = attributes.zip_code;
    /** @type {String} */
    this.addressLine1 = attributes.address_line_1;
    /** @type {String} */
    this.addressLine2 = attributes.address_line_2;
    /** @type {String} */
    this.addressLine3 = attributes.address_line_3;
  }
}

export default LocationModel;