Manual Reference Source Test

src/models/consent/ConsentGrant.js

/**
 * Model representing a consent grant.
 */
class ConsentGrantModel {
  /**
           * @param {Object}  response                       - JSON formatted response of a consent grant.
           * @param {Number}  response.id                    - The consent grant ID value
           * @param {String}  response.signing_password      - Password to use for electronic consent
           * @param {String}  response.sign_url              - The url of the signing document
           * @param {String}  response.created_at            - Date when the consent grant was created
           * @param {String}  response.updated_at            - Date when the consent grant was last updated
           * @param {String}  response.document.url          - URL of the agreement document
           */
  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.signingPassword = attributes.signing_password;

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

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

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

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

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

    /** @type {String} */
    if (attributes.document) {
      this.documentUrl = attributes.document.url;
    }
  }
}

export default ConsentGrantModel;