Manual Reference Source Test

src/models/gamification/AwardedBadge.js

/**
 * Model representing a awarded_badge.
 */
class AwardedBadgeModel {
  /**
   * @param {Object}  response                                - JSON formatted response of a single awarded badge
   * @param {!Number} response.id                             - The id of the awarded badge on the server
   * @param {!String} response.type                           - The type of this object ('awarded_badges')
   * @param {Number}  response.count                          - Count
   * @param {String}  response.created_at                     - Created at
   * @param {String}  response.earned_on_date                 - Date this badge was earned on
   * @param {String}  response.updated_at                     - Updated at
   */
  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 {Number} */
    this.count = attributes.count;

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

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

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

export default AwardedBadgeModel;