-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitemToLicensee.ts
More file actions
32 lines (27 loc) · 857 Bytes
/
itemToLicensee.ts
File metadata and controls
32 lines (27 loc) · 857 Bytes
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
/**
* @author Labs64 <netlicensing@labs64.com>
* @license Apache-2.0
* @link https://netlicensing.io
* @copyright 2017 Labs64 NetLicensing
*/
import itemToObject from '@/converters/itemToObject';
import Licensee from '@/entities/Licensee';
// types
import { Item } from '@/types/api/response';
import { LicenseeProps } from '@/types/entities/Licensee';
export default <T extends object = LicenseeProps>(item?: Item) => {
const props = itemToObject<Record<string, unknown>>(item, {
active: 'boolean',
number: 'string',
name: 'string',
markedForTransfer: 'boolean',
productNumber: 'string',
aliases: 'string',
inUse: 'boolean',
});
const { aliases } = props;
if (aliases && typeof aliases === 'string') {
props.aliases = aliases.split(',');
}
return Licensee<T>(props as LicenseeProps<T>);
};