src/helpers/version/Version.js
import VersionModel from '../../models/version/Version';
import Helper from '../Helper';
import { aggregate, fieldsToCamel } from '../../utilities/ClassUtility';
/**
* Helper class representing an Audit Version.
*
* @extends {VersionModel}
* @extends {Helper}
*
* @example
* // To get a list of Versions use clinical6.get
* import { clinical6, Version } from 'clinical6';
* clinical6.get(Version).then(v => console.log(v));
*
* // To get a single Version, you can also use clinical6
* clinical6.get({ id: 5, type: 'versions'});
*
*/
class Version extends aggregate(VersionModel, Helper) {
/**
* Constructor for helper class representing an Audit Version
*
* @param {Object} json - json api response from server
*/
constructor(json = {}) {
super(json);
this.deserializeRelationshipStubs(json);
this.syncRelationships(json);
if (this._relationships.item) {
fieldsToCamel(this._relationships.item);
}
}
/** @type {String} - The type */
static get type() {
return 'versions';
}
/** @type {User} */
get user() {
return this._relationships.whodunnitable;
}
/** @type {User} */
set user(whodunnitable) {
/** @type {User} */
this._relationships.whodunnitable = whodunnitable;
}
/** @type {Object} */
/* Item will have a type if there's an associated database record in the platform.
If a returned item is not a database record, it will come back as an object w/o a type.
Item examples include: sections, profiles, user_roles, users, permissions, brand (no type),
authentication even (no type).
*/
get item() {
return this._relationships.item;
}
/** @type {Object} */
set item(item) {
/** @type {Object} */
this._relationships.item = item;
}
}
export default Version;