Manual Reference Source Test

src/models/agreement/AgreementTemplateField.js

/**
 * Model representing a Agreement Template Field.
 *
 */
class AgreementTemplateFieldModel {
  /**
     * @param {Object} response                           - JSON formatted response of an agreement template field
     * @param {Number} response.id                        - The id of the agreement template field
     * @param {String} response.label                     - The agreement template field label
     * @param {String} response.field_name                - The field name of the agreement template field
     * @param {String} response.required                  - Is the agreement template field required?
     * @param {String} response.default_value             - Default value of the agreement template field
     * @param {String} response.attribute_name            - Attribute name of the agreement template field
     * @param {Number} response.signer_index              - Signer index of the agreement template field
     * @param {String} response.source_type               - Source type of the agreement template (mobile_user, user, etc)
     */
  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.label = attributes.label;

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

    /** @type {Boolean} */
    this.required = attributes.required;

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

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

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

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

export default AgreementTemplateFieldModel;