src/models/identifier/TemporaryId.js
/**
* Model representing a temporary identifier.
*/
class TemporaryIdModel {
/**
* @param {Object} response - JSON formatted response of a temporary identifier.
* @param {Number} response.id - The temporary ID value
* @param {String} response.token - The temporary identifier token
* @param {String} response.expires_at - When the temporary identifier expires
*/
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.token = attributes.token;
/** @type {String} */
this.expiresAt = attributes.expires_at;
}
}
export default TemporaryIdModel;