-
Notifications
You must be signed in to change notification settings - Fork 41
/
UboDeclarations.js
133 lines (119 loc) · 4.14 KB
/
UboDeclarations.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var Service = require('../service');
var UboDeclaration = require('../models/UboDeclaration');
var Ubo = require('../models/Ubo');
var UboDeclarations = Service.extend({
/**
* Create a UBO declaration object from the API
* @param {String} userId user Unique identifier
* @param {Function} callback
* @param {Object} options
*/
create: function (userId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
userId: userId
}
});
return this._api.method('ubo_declaration_create', callback, options);
},
/**
* Retrieves a UBO declaration object from the API.
* @param {String} userId User Unique identifier
* @param {String} id Unique identifier
* @param {Function} callback
* @param {Object} options
*/
get: function (userId, id, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
userId: userId,
declarationId: id
}
});
return this._api.method('ubo_declaration_get', callback, options);
},
/**
* Retrieves a UBO declaration object from the API.
* @param {String} id Unique identifier
* @param {Function} callback
* @param {Object} options
*/
getById: function (id, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
declarationId: id
}
});
return this._api.method('ubo_declaration_get_by_id', callback, options);
},
getAll: function (userId, callback, options) {
if (options && !options.hasOwnProperty('parameters'))
Object.assign(options, {parameters: {...options}});
options = this._api._getOptions(callback, options, {
path: {
userId: userId
}
});
return this._api.method('ubo_declarations_get', callback, options);
},
/**
* Updates a UBO declaration entity.
* @param {String} userId User Unique Identifier
* @param {Object} uboDeclaration Updated UBO declaration entity - must have ID!
* @param {Function} callback
* @param {Object} options
*/
update: function (userId, uboDeclaration, callback, options) {
if (!uboDeclaration.Id) {
this._api.errorHandler('Cannot update UBO declaration: Missing Id');
}
if (!uboDeclaration.Ubos) {
this._api.errorHandler('Cannot update UBO declaration: Ubos null');
}
options = this._api._getOptions(callback, options, {
data: uboDeclaration,
path: {
userId: userId,
declarationId: uboDeclaration.Id
}
});
return this._api.method('ubo_declaration_update', callback, options);
},
createUbo: function (userId, uboDeclarationId, ubo, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
userId: userId,
declarationId: uboDeclarationId
},
data: ubo,
dataClass: Ubo
});
return this._api.method('ubo_create', callback, options);
},
getUbo: function (userId, uboDeclarationId, uboId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
userId: userId,
declarationId: uboDeclarationId,
uboId: uboId
}
});
return this._api.method('ubo_get', callback, options);
},
updateUbo: function (userId, uboDeclarationId, ubo, callback, options) {
if (!ubo.Id) {
this._api.errorHandler('Cannot update UBO: Ubo Id null');
}
options = this._api._getOptions(callback, options, {
path: {
userId: userId,
declarationId: uboDeclarationId,
uboId: ubo.Id
},
data: ubo,
dataClass: Ubo
});
return this._api.method('ubo_update', callback, options);
}
});
module.exports = UboDeclarations;