@crmcom/self-service-sdk 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account.js +144 -0
- package/authentication.js +475 -0
- package/communications.js +94 -0
- package/community.js +327 -0
- package/config.js +302 -0
- package/connectx.js +92 -0
- package/contacts.js +1109 -0
- package/dataUtil.js +2186 -0
- package/eventListener.js +41 -0
- package/httpBackOfficeUtil.js +396 -0
- package/httpJCCUtil.js +61 -0
- package/httpUtil.js +863 -0
- package/index.d.ts +527 -0
- package/index.js +24 -0
- package/jcccards.js +112 -0
- package/logger.js +40 -0
- package/mobilepass.js +64 -0
- package/orders.js +732 -0
- package/organisations.js +141 -0
- package/package.json +63 -0
- package/payment.js +338 -0
- package/paymentgateway.js +26 -0
- package/payouts.js +33 -0
- package/resultUtil.js +86 -0
- package/rewards.js +409 -0
- package/servicerequest.js +235 -0
- package/subscriptions.js +406 -0
- package/wallet.js +478 -0
package/community.js
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { httpUtil } from './httpUtil'
|
|
2
|
+
import { ErrorCodes, createResult, createCommonResult } from './resultUtil'
|
|
3
|
+
import { logger } from './logger';
|
|
4
|
+
|
|
5
|
+
export const community = {
|
|
6
|
+
getListJoinedCommunities,
|
|
7
|
+
getListCommunityPeople,
|
|
8
|
+
getCommunityPeople,
|
|
9
|
+
addCommunityPeople,
|
|
10
|
+
updateCommunityPeople,
|
|
11
|
+
deleteCommunityPeople,
|
|
12
|
+
getCommunityRelations,
|
|
13
|
+
switchRole,
|
|
14
|
+
leaveCommunity,
|
|
15
|
+
getContactGroups,
|
|
16
|
+
updateContactGroups,
|
|
17
|
+
getCommunityMembers,
|
|
18
|
+
getCommunityMember,
|
|
19
|
+
acceptRejectCommunityInvitation,
|
|
20
|
+
deleteCommunityRelationship
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function getListJoinedCommunities({
|
|
24
|
+
include_total,
|
|
25
|
+
page,
|
|
26
|
+
size = 20,
|
|
27
|
+
sort,
|
|
28
|
+
order,
|
|
29
|
+
}={},contactId) {
|
|
30
|
+
try {
|
|
31
|
+
let id = contactId ? contactId : httpUtil.getSession().sub;
|
|
32
|
+
let response = await httpUtil.get({
|
|
33
|
+
resourcePath: "/v2/contacts/" + id +"/communities",
|
|
34
|
+
queryParams:{
|
|
35
|
+
include_total,
|
|
36
|
+
page,
|
|
37
|
+
size,
|
|
38
|
+
sort,
|
|
39
|
+
order,
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return createCommonResult(response);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
logger.error("Exception getListJoinedCommunities:", e);
|
|
45
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function getListCommunityPeople({
|
|
50
|
+
include_total,
|
|
51
|
+
page,
|
|
52
|
+
size = 20,
|
|
53
|
+
sort,
|
|
54
|
+
order,
|
|
55
|
+
}={},contactId) {
|
|
56
|
+
try {
|
|
57
|
+
let id = contactId ? contactId : httpUtil.getSession().sub;
|
|
58
|
+
let response = await httpUtil.get({
|
|
59
|
+
resourcePath: "/v2/contacts/" + id +"/people",
|
|
60
|
+
queryParams:{
|
|
61
|
+
include_total,
|
|
62
|
+
page,
|
|
63
|
+
size,
|
|
64
|
+
sort,
|
|
65
|
+
order,
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return createCommonResult(response);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
logger.error("Exception getListCommunityPeople:", e);
|
|
71
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function addCommunityPeople({
|
|
76
|
+
email,
|
|
77
|
+
phone_number,
|
|
78
|
+
country_code,
|
|
79
|
+
relation_id,
|
|
80
|
+
is_admin,
|
|
81
|
+
permissions,
|
|
82
|
+
group,
|
|
83
|
+
contact,
|
|
84
|
+
}={},contactId) {
|
|
85
|
+
let body = {
|
|
86
|
+
email,
|
|
87
|
+
relation_id,
|
|
88
|
+
is_admin,
|
|
89
|
+
permissions,
|
|
90
|
+
group,
|
|
91
|
+
contact,
|
|
92
|
+
};
|
|
93
|
+
if(phone_number){
|
|
94
|
+
body.phone = {
|
|
95
|
+
country_code: country_code,
|
|
96
|
+
number: phone_number
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (contact) body.contact = contact;
|
|
100
|
+
try {
|
|
101
|
+
let id = contactId ? contactId : httpUtil.getSession().sub;
|
|
102
|
+
let response = await httpUtil.post({
|
|
103
|
+
resourcePath: "/v2/contacts/" + id +"/people",
|
|
104
|
+
body:body
|
|
105
|
+
});
|
|
106
|
+
return createCommonResult(response);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
logger.error("Exception addCommunityPeople:", e);
|
|
109
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function updateCommunityPeople({
|
|
114
|
+
relation_id,
|
|
115
|
+
is_admin,
|
|
116
|
+
permissions,
|
|
117
|
+
wallet_sharing,
|
|
118
|
+
termed_transfer,
|
|
119
|
+
usage_allowance,
|
|
120
|
+
group,
|
|
121
|
+
devices
|
|
122
|
+
}={},peopleId) {
|
|
123
|
+
try {
|
|
124
|
+
let id = httpUtil.getSession().sub;
|
|
125
|
+
let response = await httpUtil.put({
|
|
126
|
+
resourcePath: "/v2/contacts/" + id +"/people/" + peopleId,
|
|
127
|
+
body:{
|
|
128
|
+
relation_id,
|
|
129
|
+
is_admin,
|
|
130
|
+
permissions,
|
|
131
|
+
wallet_sharing,
|
|
132
|
+
termed_transfer,
|
|
133
|
+
usage_allowance,
|
|
134
|
+
group,
|
|
135
|
+
devices
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return createCommonResult(response);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
logger.error("Exception updateCommunityPeople:", e);
|
|
141
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function deleteCommunityPeople(peopleId) {
|
|
146
|
+
try {
|
|
147
|
+
let id = httpUtil.getSession().sub;
|
|
148
|
+
let response = await httpUtil.sendDelete({
|
|
149
|
+
resourcePath: "/v2/contacts/" + id +"/people/" + peopleId
|
|
150
|
+
});
|
|
151
|
+
return createCommonResult(response);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
logger.error("Exception deleteCommunityPeople:", e);
|
|
154
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function getCommunityPeople(peopleId) {
|
|
159
|
+
try {
|
|
160
|
+
let id = httpUtil.getSession().sub;
|
|
161
|
+
let response = await httpUtil.get({
|
|
162
|
+
resourcePath: "/v2/contacts/" + id +"/people/" + peopleId
|
|
163
|
+
});
|
|
164
|
+
return createCommonResult(response);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
logger.error("Exception getCommunityPeople:", e);
|
|
167
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function getCommunityMember(ownerId, memberId) {
|
|
172
|
+
try {
|
|
173
|
+
let id = httpUtil.getSession().sub;
|
|
174
|
+
let response = await httpUtil.get({
|
|
175
|
+
resourcePath: "/v2/contacts/" + ownerId +"/people/" + memberId
|
|
176
|
+
});
|
|
177
|
+
return createCommonResult(response);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
logger.error("Exception getCommunityPeople:", e);
|
|
180
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function getCommunityRelations({
|
|
185
|
+
include_total,
|
|
186
|
+
page,
|
|
187
|
+
size = 20,
|
|
188
|
+
sort,
|
|
189
|
+
order,
|
|
190
|
+
name
|
|
191
|
+
}={}) {
|
|
192
|
+
try {
|
|
193
|
+
let response = await httpUtil.get({
|
|
194
|
+
resourcePath: "/v2/communities/relations",
|
|
195
|
+
queryParams:{
|
|
196
|
+
include_total,
|
|
197
|
+
page,
|
|
198
|
+
size,
|
|
199
|
+
sort,
|
|
200
|
+
order,
|
|
201
|
+
name
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return createCommonResult(response);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
logger.error("Exception getCommunityRelations:", e);
|
|
207
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function switchRole(community_id,isMerchant) {
|
|
212
|
+
try {
|
|
213
|
+
let response = await httpUtil.post({
|
|
214
|
+
resourcePath: "/v2/contacts/" + community_id +"/switch",
|
|
215
|
+
});
|
|
216
|
+
if (response.code == "OK") {
|
|
217
|
+
httpUtil.switchSession(response.data,isMerchant);
|
|
218
|
+
}
|
|
219
|
+
return createCommonResult(response);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
logger.error("Exception switchRole:", e);
|
|
222
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
async function leaveCommunity(community_id) {
|
|
228
|
+
try {
|
|
229
|
+
let id = httpUtil.getSession().sub;
|
|
230
|
+
let response = await httpUtil.sendDelete({
|
|
231
|
+
resourcePath: "/v2/contacts/" +id + "/communities/" + community_id,
|
|
232
|
+
});
|
|
233
|
+
return createCommonResult(response);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
logger.error("Exception leaveCommunity:", e);
|
|
236
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function getContactGroups() {
|
|
241
|
+
try {
|
|
242
|
+
let id = httpUtil.getSession().sub;
|
|
243
|
+
let response = await httpUtil.get({
|
|
244
|
+
resourcePath: "/v2/contacts/" + id + "/groups",
|
|
245
|
+
withAccessToken: true,
|
|
246
|
+
});
|
|
247
|
+
//check return code here instead of put as there would be different intepretation for different API
|
|
248
|
+
return createCommonResult(response);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
logger.error("Exception getContactGroups:", e);
|
|
251
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function getCommunityMembers({
|
|
256
|
+
include_total,
|
|
257
|
+
page,
|
|
258
|
+
size = 20,
|
|
259
|
+
sort,
|
|
260
|
+
order,
|
|
261
|
+
owner_id,
|
|
262
|
+
group
|
|
263
|
+
}={}) {
|
|
264
|
+
try {
|
|
265
|
+
let response = await httpUtil.get({
|
|
266
|
+
resourcePath: "/v2/contacts/community/members",
|
|
267
|
+
queryParams:{
|
|
268
|
+
include_total,
|
|
269
|
+
page,
|
|
270
|
+
size,
|
|
271
|
+
sort,
|
|
272
|
+
order,
|
|
273
|
+
owner_id,
|
|
274
|
+
group
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
return createCommonResult(response);
|
|
278
|
+
} catch (e) {
|
|
279
|
+
logger.error("Exception getCommunityMembers:", e);
|
|
280
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
async function updateContactGroups(body, name) {
|
|
286
|
+
try {
|
|
287
|
+
let id = httpUtil.getSession().sub;
|
|
288
|
+
let response = await httpUtil.put({
|
|
289
|
+
resourcePath: "/v2/contacts/" + id + "/groups/" + name,
|
|
290
|
+
body: body,
|
|
291
|
+
withAccessToken: true,
|
|
292
|
+
});
|
|
293
|
+
return createCommonResult(response);
|
|
294
|
+
} catch (e) {
|
|
295
|
+
logger.error("Exception updateContactGroups:", e);
|
|
296
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function acceptRejectCommunityInvitation(body, ownerId, relationId) {
|
|
301
|
+
try {
|
|
302
|
+
let response = await httpUtil.post({
|
|
303
|
+
resourcePath: "/v2/contacts/" + ownerId + "/people/" + relationId + "/actions",
|
|
304
|
+
body: body,
|
|
305
|
+
withAccessToken: true,
|
|
306
|
+
});
|
|
307
|
+
return createCommonResult(response);
|
|
308
|
+
} catch (e) {
|
|
309
|
+
logger.error("Exception acceptRejectCommunityInvitation:", e);
|
|
310
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function deleteCommunityRelationship(ownerId, relationId) {
|
|
315
|
+
try {
|
|
316
|
+
let response = await httpUtil.sendDelete({
|
|
317
|
+
resourcePath: "/v2/contacts/" + ownerId + "/people/" + relationId,
|
|
318
|
+
withAccessToken: true,
|
|
319
|
+
});
|
|
320
|
+
return createCommonResult(response);
|
|
321
|
+
} catch (e) {
|
|
322
|
+
logger.error("Exception acceptRejectCommunityInvitation:", e);
|
|
323
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
package/config.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { httpUtil } from './httpUtil'
|
|
2
|
+
import { ErrorCodes, createResult, createCommonResult } from './resultUtil'
|
|
3
|
+
import { getData } from '../../utils/common';
|
|
4
|
+
import { logger } from './logger';
|
|
5
|
+
export const config = {
|
|
6
|
+
getAppCfg,
|
|
7
|
+
getApplicationTranslations,
|
|
8
|
+
getIndustries,
|
|
9
|
+
getIndustrySectors,
|
|
10
|
+
getTownCities,
|
|
11
|
+
getOrganisationTags,
|
|
12
|
+
getTags,
|
|
13
|
+
getLanguages,
|
|
14
|
+
findAddress,
|
|
15
|
+
getAddress,
|
|
16
|
+
findAddressV1,
|
|
17
|
+
getIntegrations,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function getAppCfg({
|
|
21
|
+
app_id,
|
|
22
|
+
use_cname = false,
|
|
23
|
+
cname
|
|
24
|
+
} = {}) {
|
|
25
|
+
try {
|
|
26
|
+
var appId = await getData("APP_ID");
|
|
27
|
+
if (!app_id) app_id = appId;
|
|
28
|
+
|
|
29
|
+
var queryParams = {}
|
|
30
|
+
if (use_cname) {
|
|
31
|
+
queryParams.cloud_name = cname;
|
|
32
|
+
} else {
|
|
33
|
+
queryParams.platform_app_id = app_id;
|
|
34
|
+
}
|
|
35
|
+
let response = await httpUtil.get({
|
|
36
|
+
resourcePath: '/v2/applications',
|
|
37
|
+
queryParams: queryParams,
|
|
38
|
+
logOutIfSessionInvalid: false
|
|
39
|
+
});
|
|
40
|
+
return createCommonResult(response);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
logger.error('Exception getAppCfg:', e);
|
|
43
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function getApplicationTranslations({
|
|
48
|
+
application_id
|
|
49
|
+
} = {}) {
|
|
50
|
+
try {
|
|
51
|
+
let response = await httpUtil.get({
|
|
52
|
+
resourcePath: "/v2/applications/" + application_id + "/translations",
|
|
53
|
+
withAccessToken: true,
|
|
54
|
+
});
|
|
55
|
+
//check return code here instead of put as there would be different intepretation for different API
|
|
56
|
+
return createCommonResult(response);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
logger.error("Exception getApplicationTranslations:", e);
|
|
59
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function getIndustries({
|
|
64
|
+
name,
|
|
65
|
+
page = 1,
|
|
66
|
+
size = 1000,
|
|
67
|
+
sort,
|
|
68
|
+
order,
|
|
69
|
+
} = {}) {
|
|
70
|
+
try {
|
|
71
|
+
let response = await httpUtil.get({
|
|
72
|
+
resourcePath: '/v2/industries',
|
|
73
|
+
queryParams: {
|
|
74
|
+
name,
|
|
75
|
+
page,
|
|
76
|
+
size,
|
|
77
|
+
sort,
|
|
78
|
+
order,
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return createCommonResult(response);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
logger.error('Exception getIndustries:', e);
|
|
84
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function getIndustrySectors({
|
|
89
|
+
industry_name,
|
|
90
|
+
industry_sector_ids,
|
|
91
|
+
name,
|
|
92
|
+
page = 1,
|
|
93
|
+
size = 1000,
|
|
94
|
+
sort,
|
|
95
|
+
order
|
|
96
|
+
} = {}) {
|
|
97
|
+
try {
|
|
98
|
+
let response = await httpUtil.get({
|
|
99
|
+
resourcePath: '/v2/industry_sectors',
|
|
100
|
+
queryParams: {
|
|
101
|
+
industry_name,
|
|
102
|
+
industry_sector_ids,
|
|
103
|
+
name,
|
|
104
|
+
page,
|
|
105
|
+
size,
|
|
106
|
+
sort,
|
|
107
|
+
order,
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return createCommonResult(response);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
logger.error('Exception getIndustries:', e);
|
|
113
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function getTownCities() {
|
|
118
|
+
try {
|
|
119
|
+
let response = await httpUtil.get({
|
|
120
|
+
resourcePath: '/v2/locations/towns',
|
|
121
|
+
});
|
|
122
|
+
return createCommonResult(response);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
logger.error('Exception getTownCities:', e);
|
|
125
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function getOrganisationTags({
|
|
130
|
+
industry,
|
|
131
|
+
industry_sector,
|
|
132
|
+
page = 1,
|
|
133
|
+
size = 1000,
|
|
134
|
+
sort,
|
|
135
|
+
order
|
|
136
|
+
} = {}) {
|
|
137
|
+
try {
|
|
138
|
+
|
|
139
|
+
//console.log('API: ', contact)
|
|
140
|
+
let response = await httpUtil.get({
|
|
141
|
+
resourcePath: '/v2/organisations/tags',
|
|
142
|
+
queryParams: {
|
|
143
|
+
page,
|
|
144
|
+
size,
|
|
145
|
+
sort,
|
|
146
|
+
order,
|
|
147
|
+
industry,
|
|
148
|
+
industry_sector
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return createCommonResult(response);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
logger.error('Exception getOrganisationTags:', e);
|
|
154
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function getTags({
|
|
159
|
+
entity,
|
|
160
|
+
search_value,
|
|
161
|
+
include_total,
|
|
162
|
+
page = 1,
|
|
163
|
+
size = 100,
|
|
164
|
+
sort,
|
|
165
|
+
order
|
|
166
|
+
} = {}) {
|
|
167
|
+
try {
|
|
168
|
+
|
|
169
|
+
//console.log('API: ', contact)
|
|
170
|
+
let response = await httpUtil.get({
|
|
171
|
+
resourcePath: '/v2/tags',
|
|
172
|
+
queryParams: {
|
|
173
|
+
entity,
|
|
174
|
+
search_value,
|
|
175
|
+
include_total,
|
|
176
|
+
page,
|
|
177
|
+
size,
|
|
178
|
+
sort,
|
|
179
|
+
order
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return createCommonResult(response);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
logger.error('Exception getTags:', e);
|
|
185
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function getLanguages({ unauthorize = true }) {
|
|
190
|
+
try {
|
|
191
|
+
let response = await httpUtil.get({
|
|
192
|
+
resourcePath: '/v2/languages',
|
|
193
|
+
logOutIfSessionInvalid: false,
|
|
194
|
+
});
|
|
195
|
+
return createCommonResult(response);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
logger.error('Exception getLanguages:', e);
|
|
198
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async function findAddress({
|
|
202
|
+
integration = 'GOOGLE',
|
|
203
|
+
input,
|
|
204
|
+
session_id,
|
|
205
|
+
} = {}) {
|
|
206
|
+
try {
|
|
207
|
+
let id = httpUtil.getSession().sub;
|
|
208
|
+
let response = await httpUtil.get({
|
|
209
|
+
resourcePath: "/v2/addresses",
|
|
210
|
+
queryParams: {
|
|
211
|
+
integration,
|
|
212
|
+
input,
|
|
213
|
+
session_id
|
|
214
|
+
},
|
|
215
|
+
withAccessToken: true,
|
|
216
|
+
});
|
|
217
|
+
//check return code here instead of put as there would be different intepretation for different API
|
|
218
|
+
return createCommonResult(response);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
logger.error("Exception findAddress:", e);
|
|
221
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async function getAddress({
|
|
226
|
+
integration = 'GOOGLE',
|
|
227
|
+
google_place_id,
|
|
228
|
+
session_id,
|
|
229
|
+
latlng,
|
|
230
|
+
} = {}) {
|
|
231
|
+
try {
|
|
232
|
+
let id = httpUtil.getSession().sub;
|
|
233
|
+
let response = await httpUtil.get({
|
|
234
|
+
resourcePath: "/v2/get_addresses",
|
|
235
|
+
queryParams: {
|
|
236
|
+
integration,
|
|
237
|
+
google_place_id,
|
|
238
|
+
session_id,
|
|
239
|
+
latlng,
|
|
240
|
+
},
|
|
241
|
+
withAccessToken: true,
|
|
242
|
+
});
|
|
243
|
+
//check return code here instead of put as there would be different intepretation for different API
|
|
244
|
+
return createCommonResult(response);
|
|
245
|
+
} catch (e) {
|
|
246
|
+
logger.error("Exception getAddress:", e);
|
|
247
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function findAddressV1({
|
|
252
|
+
integration = 'GOOGLE',
|
|
253
|
+
address,
|
|
254
|
+
latlng
|
|
255
|
+
} = {}) {
|
|
256
|
+
try {
|
|
257
|
+
let id = httpUtil.getSession().sub;
|
|
258
|
+
let response = await httpUtil.get({
|
|
259
|
+
resourcePath: "/v1/addresses",
|
|
260
|
+
queryParams: {
|
|
261
|
+
integration,
|
|
262
|
+
address,
|
|
263
|
+
latlng
|
|
264
|
+
},
|
|
265
|
+
withAccessToken: true,
|
|
266
|
+
});
|
|
267
|
+
//check return code here instead of put as there would be different intepretation for different API
|
|
268
|
+
return createCommonResult(response);
|
|
269
|
+
} catch (e) {
|
|
270
|
+
logger.error("Exception findAddressV1:", e);
|
|
271
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function getIntegrations({
|
|
276
|
+
connector,
|
|
277
|
+
finance,
|
|
278
|
+
payment_method,
|
|
279
|
+
rewards,
|
|
280
|
+
transactions,
|
|
281
|
+
type,
|
|
282
|
+
}, id) {
|
|
283
|
+
try {
|
|
284
|
+
|
|
285
|
+
//console.log('API: ', contact)
|
|
286
|
+
let response = await httpUtil.get({
|
|
287
|
+
resourcePath: '/v2/applications/' + id + '/integrations',
|
|
288
|
+
queryParams: {
|
|
289
|
+
connector,
|
|
290
|
+
finance,
|
|
291
|
+
payment_method,
|
|
292
|
+
rewards,
|
|
293
|
+
transactions,
|
|
294
|
+
type
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
return createCommonResult(response);
|
|
298
|
+
} catch (e) {
|
|
299
|
+
logger.error('Exception getIntegrations:', e);
|
|
300
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
301
|
+
}
|
|
302
|
+
}
|
package/connectx.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { httpUtil } from './httpUtil'
|
|
2
|
+
import { ErrorCodes, createResult, createCommonResult } from './resultUtil'
|
|
3
|
+
import { getData } from '../../utils/common';
|
|
4
|
+
import { logger } from './logger';
|
|
5
|
+
export const connectx = {
|
|
6
|
+
getBuckets,
|
|
7
|
+
simConfirmation,
|
|
8
|
+
simActivation,
|
|
9
|
+
simDownload,
|
|
10
|
+
portIn
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function getBuckets(serial_number) {
|
|
14
|
+
try {
|
|
15
|
+
let id = httpUtil.getSession().sub;
|
|
16
|
+
let response = await httpUtil.get({
|
|
17
|
+
plugin: 'connectx',
|
|
18
|
+
resourcePath: "/" + id + "/buckets?serial_number=" + serial_number,
|
|
19
|
+
withAccessToken: true,
|
|
20
|
+
});
|
|
21
|
+
return createCommonResult(response);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
logger.error("Exception updateServices:", e);
|
|
24
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function simConfirmation({subscription_service_id}, serialNumber) {
|
|
29
|
+
try {
|
|
30
|
+
let id = httpUtil.getSession().sub;
|
|
31
|
+
let response = await httpUtil.post({
|
|
32
|
+
plugin: 'connectx',
|
|
33
|
+
resourcePath: "/" + id + "/sim_confirmation/" + serialNumber,
|
|
34
|
+
body: {
|
|
35
|
+
subscription_service_id: subscription_service_id
|
|
36
|
+
},
|
|
37
|
+
withAccessToken: true,
|
|
38
|
+
});
|
|
39
|
+
return createCommonResult(response);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
logger.error("Exception updateServices:", e);
|
|
42
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function simActivation(body = {}, serialNumber) {
|
|
47
|
+
try {
|
|
48
|
+
let id = httpUtil.getSession().sub;
|
|
49
|
+
let response = await httpUtil.post({
|
|
50
|
+
plugin: 'connectx',
|
|
51
|
+
resourcePath: "/" + id + "/sim_activation/" + serialNumber,
|
|
52
|
+
body: body,
|
|
53
|
+
withAccessToken: true,
|
|
54
|
+
});
|
|
55
|
+
return createCommonResult(response);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
logger.error("Exception updateServices:", e);
|
|
58
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function simDownload(body = {}) {
|
|
63
|
+
try {
|
|
64
|
+
let id = httpUtil.getSession().sub;
|
|
65
|
+
let response = await httpUtil.post({
|
|
66
|
+
plugin: 'connectx',
|
|
67
|
+
resourcePath: "/" + id + "/sim_download",
|
|
68
|
+
body: body,
|
|
69
|
+
withAccessToken: true,
|
|
70
|
+
});
|
|
71
|
+
return createCommonResult(response);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
logger.error("Exception updateServices:", e);
|
|
74
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function portIn(body) {
|
|
79
|
+
try {
|
|
80
|
+
let id = httpUtil.getSession().sub;
|
|
81
|
+
let response = await httpUtil.post({
|
|
82
|
+
plugin: 'connectx',
|
|
83
|
+
resourcePath: "/" + id + "/port_in",
|
|
84
|
+
body: body,
|
|
85
|
+
withAccessToken: true,
|
|
86
|
+
});
|
|
87
|
+
return createCommonResult(response);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
logger.error("Exception updateServices:", e);
|
|
90
|
+
return createResult(ErrorCodes.UNKNOWN, e);
|
|
91
|
+
}
|
|
92
|
+
}
|