blob: 2874ebff6ea88d4234d1d9d0d80835e48a228923 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import AbstractConverter from './AbstractConverter';
import ObjectClone from '../Utility/ObjectClone';
export default class PasswordConverter extends AbstractConverter {
/**
* @param {BasicPasswordsClient} api
*/
constructor(api) {
super(api, 'password');
/** @type CustomFieldConverter **/
this._customFieldConverter = this._api.getInstance('converter.field');
}
/**
* @param {Object} object
* @return {AbstractRevisionModel}
*/
fromObject(object) {
let clone = ObjectClone.clone(object);
if(typeof clone.customFields === 'string') {
clone.customFields = this._customFieldConverter.fromJSON(clone.customFields);
} else {
clone.customFields = this._customFieldConverter.fromArray([]);
}
if(clone.hasOwnProperty('created') && !(clone.created instanceof Date)) {
clone.created = new Date(clone.created * 1e3);
}
if(clone.hasOwnProperty('updated') && !(clone.updated instanceof Date)) {
clone.updated = new Date(clone.updated * 1e3);
}
if(clone.hasOwnProperty('edited') && !(clone.edited instanceof Date)) {
clone.edited = new Date(clone.edited * 1e3);
}
return this._api.getClass(`model.${this._type}`, clone, this._api);
}
}
|