@bisondesk/core-sdk 1.0.353 → 1.0.354
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/lib/apis/crm.d.ts.map +1 -1
- package/lib/apis/crm.js +60 -32
- package/lib/apis/crm.js.map +1 -1
- package/lib/apis/debtors.d.ts.map +1 -1
- package/lib/apis/debtors.js +7 -3
- package/lib/apis/debtors.js.map +1 -1
- package/lib/apis/internet-vehicles.d.ts.map +1 -1
- package/lib/apis/internet-vehicles.js +5 -3
- package/lib/apis/internet-vehicles.js.map +1 -1
- package/lib/apis/leasing-administration.d.ts.map +1 -1
- package/lib/apis/leasing-administration.js +10 -6
- package/lib/apis/leasing-administration.js.map +1 -1
- package/lib/apis/leasing.d.ts.map +1 -1
- package/lib/apis/leasing.js +39 -25
- package/lib/apis/leasing.js.map +1 -1
- package/lib/apis/tenants.d.ts.map +1 -1
- package/lib/apis/tenants.js +15 -10
- package/lib/apis/tenants.js.map +1 -1
- package/lib/apis/users.d.ts.map +1 -1
- package/lib/apis/users.js +9 -7
- package/lib/apis/users.js.map +1 -1
- package/lib/apis/vehicles.d.ts.map +1 -1
- package/lib/apis/vehicles.js +38 -24
- package/lib/apis/vehicles.js.map +1 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/types/vehicles.d.ts +2 -8
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js.map +1 -1
- package/package.json +2 -2
- package/src/apis/crm.ts +128 -130
- package/src/apis/debtors.ts +13 -12
- package/src/apis/internet-vehicles.ts +5 -3
- package/src/apis/leasing-administration.ts +26 -28
- package/src/apis/leasing.ts +88 -101
- package/src/apis/tenants.ts +31 -38
- package/src/apis/users.ts +9 -7
- package/src/apis/vehicles.ts +90 -103
- package/src/constants.ts +1 -0
- package/src/types/vehicles.ts +2 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.deploy.json +0 -5
- package/tsconfig.deploy.tsbuildinfo +0 -1
package/src/apis/crm.ts
CHANGED
|
@@ -21,16 +21,14 @@ export const getCrmOrganization = async (
|
|
|
21
21
|
opts?: { serviceId: string }
|
|
22
22
|
): Promise<Organization | undefined> => {
|
|
23
23
|
const auth = await getAdminAuth();
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
);
|
|
24
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/${organizationId}`;
|
|
25
|
+
const response: Response = await fetch(url, {
|
|
26
|
+
headers: cleanHeaders({
|
|
27
|
+
Authorization: auth,
|
|
28
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
29
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
34
32
|
|
|
35
33
|
if (response.ok) {
|
|
36
34
|
return (response.status === 200 ? response.json() : undefined) as Promise<
|
|
@@ -39,7 +37,7 @@ export const getCrmOrganization = async (
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
const body = await response.text();
|
|
42
|
-
throw new XError(response.statusText, { body, tenantId, organizationId, opts });
|
|
40
|
+
throw new XError(response.statusText, { url, body, tenantId, organizationId, opts });
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
export const getCrmOrganizationByExternalId = async (
|
|
@@ -48,16 +46,14 @@ export const getCrmOrganizationByExternalId = async (
|
|
|
48
46
|
opts?: { serviceId: string }
|
|
49
47
|
): Promise<Organization | undefined> => {
|
|
50
48
|
const auth = await getAdminAuth();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
);
|
|
49
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/external-id/${externalId}`;
|
|
50
|
+
const response: Response = await fetch(url, {
|
|
51
|
+
headers: cleanHeaders({
|
|
52
|
+
Authorization: auth,
|
|
53
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
54
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
61
57
|
|
|
62
58
|
if (response.ok) {
|
|
63
59
|
return (response.status === 200 ? response.json() : undefined) as Promise<
|
|
@@ -66,7 +62,7 @@ export const getCrmOrganizationByExternalId = async (
|
|
|
66
62
|
}
|
|
67
63
|
|
|
68
64
|
const body = await response.text();
|
|
69
|
-
throw new XError(response.statusText, { body, tenantId, externalId, opts });
|
|
65
|
+
throw new XError(response.statusText, { url, body, tenantId, externalId, opts });
|
|
70
66
|
};
|
|
71
67
|
|
|
72
68
|
export const saveCrmOrganization = async (
|
|
@@ -75,8 +71,10 @@ export const saveCrmOrganization = async (
|
|
|
75
71
|
opts?: { serviceId: string }
|
|
76
72
|
): Promise<Organization> => {
|
|
77
73
|
const auth = await getAdminAuth();
|
|
78
|
-
const
|
|
79
|
-
|
|
74
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations`;
|
|
75
|
+
const method = 'POST';
|
|
76
|
+
const response: Response = await fetch(url, {
|
|
77
|
+
method,
|
|
80
78
|
headers: cleanHeaders({
|
|
81
79
|
Authorization: auth,
|
|
82
80
|
'Content-Type': 'application/json',
|
|
@@ -91,7 +89,7 @@ export const saveCrmOrganization = async (
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
const body = await response.text();
|
|
94
|
-
throw new XError(response.statusText, { body, tenantId, org, opts });
|
|
92
|
+
throw new XError(response.statusText, { method, url, body, tenantId, org, opts });
|
|
95
93
|
};
|
|
96
94
|
|
|
97
95
|
export const patchCrmOrganization = async (
|
|
@@ -101,26 +99,33 @@ export const patchCrmOrganization = async (
|
|
|
101
99
|
opts?: { serviceId: string }
|
|
102
100
|
): Promise<Organization> => {
|
|
103
101
|
const auth = await getAdminAuth();
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
102
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/${organizationId}`;
|
|
103
|
+
const method = 'PATCH';
|
|
104
|
+
const response: Response = await fetch(url, {
|
|
105
|
+
method,
|
|
106
|
+
headers: cleanHeaders({
|
|
107
|
+
Authorization: auth,
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
110
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
111
|
+
}),
|
|
112
|
+
body: JSON.stringify(changes),
|
|
113
|
+
});
|
|
117
114
|
|
|
118
115
|
if (response.ok) {
|
|
119
116
|
return response.json() as Promise<Organization>;
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
const body = await response.text();
|
|
123
|
-
throw new XError(response.statusText, {
|
|
120
|
+
throw new XError(response.statusText, {
|
|
121
|
+
method,
|
|
122
|
+
url,
|
|
123
|
+
tenantId,
|
|
124
|
+
organizationId,
|
|
125
|
+
changes,
|
|
126
|
+
body,
|
|
127
|
+
opts,
|
|
128
|
+
});
|
|
124
129
|
};
|
|
125
130
|
|
|
126
131
|
export const searchCrmOrganizations = async (
|
|
@@ -129,26 +134,25 @@ export const searchCrmOrganizations = async (
|
|
|
129
134
|
opts?: { serviceId: string }
|
|
130
135
|
): Promise<PaginatedList<SearchOrganization, ReferenceData>> => {
|
|
131
136
|
const auth = await getAdminAuth();
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
);
|
|
137
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/search/results`;
|
|
138
|
+
const method = 'POST';
|
|
139
|
+
const response: Response = await fetch(url, {
|
|
140
|
+
method,
|
|
141
|
+
headers: cleanHeaders({
|
|
142
|
+
Authorization: auth,
|
|
143
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
144
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
145
|
+
'Content-Type': 'application/json',
|
|
146
|
+
}),
|
|
147
|
+
body: JSON.stringify(req),
|
|
148
|
+
});
|
|
145
149
|
|
|
146
150
|
if (response.ok) {
|
|
147
151
|
return response.status === 200 ? (response.json() as any) : undefined;
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
const body = await response.text();
|
|
151
|
-
throw new XError(response.statusText, { body, tenantId, req, opts });
|
|
155
|
+
throw new XError(response.statusText, { method, url, body, tenantId, req, opts });
|
|
152
156
|
};
|
|
153
157
|
|
|
154
158
|
export const searchCrmContacts = async (
|
|
@@ -157,26 +161,25 @@ export const searchCrmContacts = async (
|
|
|
157
161
|
opts?: { serviceId: string }
|
|
158
162
|
): Promise<PaginatedList<SearchContact, ReferenceData>> => {
|
|
159
163
|
const auth = await getAdminAuth();
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
);
|
|
164
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/contacts/search/results`;
|
|
165
|
+
const method = 'POST';
|
|
166
|
+
const response: Response = await fetch(url, {
|
|
167
|
+
method,
|
|
168
|
+
headers: cleanHeaders({
|
|
169
|
+
Authorization: auth,
|
|
170
|
+
'Content-Type': 'application/json',
|
|
171
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
172
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
173
|
+
}),
|
|
174
|
+
body: JSON.stringify(req),
|
|
175
|
+
});
|
|
173
176
|
|
|
174
177
|
if (response.ok) {
|
|
175
178
|
return response.status === 200 ? (response.json() as any) : undefined;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
const body = await response.text();
|
|
179
|
-
throw new XError(response.statusText, { body, tenantId, req, opts });
|
|
182
|
+
throw new XError(response.statusText, { method, url, body, tenantId, req, opts });
|
|
180
183
|
};
|
|
181
184
|
|
|
182
185
|
export const deleteCrmOrganization = async (
|
|
@@ -185,21 +188,20 @@ export const deleteCrmOrganization = async (
|
|
|
185
188
|
opts?: { serviceId: string }
|
|
186
189
|
): Promise<void> => {
|
|
187
190
|
const auth = await getAdminAuth();
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
);
|
|
191
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/${orgId}`;
|
|
192
|
+
const method = 'DELETE';
|
|
193
|
+
const response: Response = await fetch(url, {
|
|
194
|
+
method,
|
|
195
|
+
headers: cleanHeaders({
|
|
196
|
+
Authorization: auth,
|
|
197
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
198
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
199
201
|
|
|
200
202
|
if (!response.ok) {
|
|
201
203
|
const body = await response.text();
|
|
202
|
-
throw new XError(response.statusText, { body, tenantId, orgId, opts });
|
|
204
|
+
throw new XError(response.statusText, { method, url, body, tenantId, orgId, opts });
|
|
203
205
|
}
|
|
204
206
|
};
|
|
205
207
|
|
|
@@ -209,23 +211,21 @@ export const listCrmContacts = async (
|
|
|
209
211
|
opts?: { serviceId: string }
|
|
210
212
|
): Promise<Contact[]> => {
|
|
211
213
|
const auth = await getAdminAuth();
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
);
|
|
214
|
+
const url = `${process.env.CORE_API_ORIGIN}/admin/crm/organizations/${organizationId}/contacts`;
|
|
215
|
+
const response: Response = await fetch(url, {
|
|
216
|
+
headers: cleanHeaders({
|
|
217
|
+
Authorization: auth,
|
|
218
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
219
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
222
222
|
|
|
223
223
|
if (response.ok) {
|
|
224
224
|
return response.status === 200 ? (response.json() as any) : undefined;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
const body = await response.text();
|
|
228
|
-
throw new XError(response.statusText, { body, tenantId, organizationId, opts });
|
|
228
|
+
throw new XError(response.statusText, { url, body, tenantId, organizationId, opts });
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
export const listPotentialDuplicateOrgs = async (
|
|
@@ -236,26 +236,25 @@ export const listPotentialDuplicateOrgs = async (
|
|
|
236
236
|
const auth = await getAdminAuth();
|
|
237
237
|
const limit = opts?.limit ?? '';
|
|
238
238
|
const offset = opts?.offset ?? '';
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
);
|
|
239
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/duplicate-check?limit=${limit}&offset=${offset}`;
|
|
240
|
+
const method = 'POST';
|
|
241
|
+
const response: Response = await fetch(url, {
|
|
242
|
+
method,
|
|
243
|
+
headers: cleanHeaders({
|
|
244
|
+
'Content-Type': 'application/json',
|
|
245
|
+
Authorization: auth,
|
|
246
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
247
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
248
|
+
}),
|
|
249
|
+
body: JSON.stringify(org),
|
|
250
|
+
});
|
|
252
251
|
|
|
253
252
|
if (response.ok) {
|
|
254
253
|
return response.status === 200 ? (response.json() as any) : undefined;
|
|
255
254
|
}
|
|
256
255
|
|
|
257
256
|
const body = await response.text();
|
|
258
|
-
throw new XError(response.statusText, { body, tenantId, org, opts });
|
|
257
|
+
throw new XError(response.statusText, { method, url, body, tenantId, org, opts });
|
|
259
258
|
};
|
|
260
259
|
|
|
261
260
|
export const getCrmContact = async (
|
|
@@ -264,23 +263,21 @@ export const getCrmContact = async (
|
|
|
264
263
|
opts?: { serviceId: string }
|
|
265
264
|
): Promise<Contact | undefined> => {
|
|
266
265
|
const auth = await getAdminAuth();
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
{
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
);
|
|
266
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/contacts/${contactId}`;
|
|
267
|
+
const response: Response = await fetch(url, {
|
|
268
|
+
headers: cleanHeaders({
|
|
269
|
+
Authorization: auth,
|
|
270
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
271
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
272
|
+
}),
|
|
273
|
+
});
|
|
277
274
|
|
|
278
275
|
if (response.ok) {
|
|
279
276
|
return response.status === 200 ? (response.json() as any) : undefined;
|
|
280
277
|
}
|
|
281
278
|
|
|
282
279
|
const body = await response.text();
|
|
283
|
-
throw new XError(response.statusText, { body, tenantId, contactId, opts });
|
|
280
|
+
throw new XError(response.statusText, { url, body, tenantId, contactId, opts });
|
|
284
281
|
};
|
|
285
282
|
|
|
286
283
|
export const saveCrmContact = async (
|
|
@@ -289,8 +286,10 @@ export const saveCrmContact = async (
|
|
|
289
286
|
opts?: { serviceId: string }
|
|
290
287
|
): Promise<Contact> => {
|
|
291
288
|
const auth = await getAdminAuth();
|
|
292
|
-
const
|
|
293
|
-
|
|
289
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/contacts`;
|
|
290
|
+
const method = 'POST';
|
|
291
|
+
const response: Response = await fetch(url, {
|
|
292
|
+
method,
|
|
294
293
|
headers: cleanHeaders({
|
|
295
294
|
Authorization: auth,
|
|
296
295
|
'Content-Type': 'application/json',
|
|
@@ -305,7 +304,7 @@ export const saveCrmContact = async (
|
|
|
305
304
|
}
|
|
306
305
|
|
|
307
306
|
const body = await response.text();
|
|
308
|
-
throw new XError(response.statusText, { body, contact, tenantId, opts });
|
|
307
|
+
throw new XError(response.statusText, { method, url, body, contact, tenantId, opts });
|
|
309
308
|
};
|
|
310
309
|
|
|
311
310
|
export const deleteCrmContact = async (
|
|
@@ -315,20 +314,19 @@ export const deleteCrmContact = async (
|
|
|
315
314
|
opts?: { serviceId: string }
|
|
316
315
|
): Promise<void> => {
|
|
317
316
|
const auth = await getAdminAuth();
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
);
|
|
317
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/crm/contacts/${contactId}?orgId=${orgId}`;
|
|
318
|
+
const method = 'DELETE';
|
|
319
|
+
const response: Response = await fetch(url, {
|
|
320
|
+
method,
|
|
321
|
+
headers: cleanHeaders({
|
|
322
|
+
Authorization: auth,
|
|
323
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
324
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
325
|
+
}),
|
|
326
|
+
});
|
|
329
327
|
|
|
330
328
|
if (!response.ok) {
|
|
331
329
|
const body = await response.text();
|
|
332
|
-
throw new XError(response.statusText, { body, tenantId, contactId, orgId, opts });
|
|
330
|
+
throw new XError(response.statusText, { method, url, body, tenantId, contactId, orgId, opts });
|
|
333
331
|
}
|
|
334
332
|
};
|
package/src/apis/debtors.ts
CHANGED
|
@@ -11,17 +11,16 @@ export const searchDebtorsInfo = async (
|
|
|
11
11
|
request: SearchRequest
|
|
12
12
|
): Promise<PaginatedList<SearchDebtorInfo, ReferenceData> | undefined> => {
|
|
13
13
|
const auth = await getAdminAuth();
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
14
|
+
const method = 'POST';
|
|
15
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/leasing/debtors/search/results`;
|
|
16
|
+
const response: Response = await fetch(url, {
|
|
17
|
+
method,
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: auth,
|
|
20
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify(request),
|
|
23
|
+
});
|
|
25
24
|
|
|
26
25
|
if (response.status === 200) {
|
|
27
26
|
return response.json() as any;
|
|
@@ -29,9 +28,11 @@ export const searchDebtorsInfo = async (
|
|
|
29
28
|
|
|
30
29
|
const body = await response.text();
|
|
31
30
|
throw new XError('core-sdk.search-debtors-info', {
|
|
31
|
+
method,
|
|
32
|
+
url,
|
|
32
33
|
tenantId,
|
|
33
34
|
request,
|
|
34
|
-
|
|
35
|
+
body,
|
|
35
36
|
status: response.status,
|
|
36
37
|
});
|
|
37
38
|
};
|
|
@@ -5,8 +5,10 @@ import { SearchInternetVehicle } from '../types/internet-vehicles.js';
|
|
|
5
5
|
|
|
6
6
|
export const upsertInternetVehicles = async (vehicles: SearchInternetVehicle[]): Promise<void> => {
|
|
7
7
|
const auth = await getAdminAuth();
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/internet-vehicles`;
|
|
9
|
+
const method = 'POST';
|
|
10
|
+
const response: Response = await fetch(url, {
|
|
11
|
+
method,
|
|
10
12
|
headers: {
|
|
11
13
|
'Content-Type': 'application/json',
|
|
12
14
|
Authorization: auth,
|
|
@@ -19,5 +21,5 @@ export const upsertInternetVehicles = async (vehicles: SearchInternetVehicle[]):
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
const body = await response.text();
|
|
22
|
-
throw new XError(response.statusText, { body });
|
|
24
|
+
throw new XError(response.statusText, { method, url, body });
|
|
23
25
|
};
|
|
@@ -14,26 +14,25 @@ export const createLeasingAdminUpload = async (
|
|
|
14
14
|
opts?: { serviceId: string }
|
|
15
15
|
): Promise<LeasingAdminUpload> => {
|
|
16
16
|
const auth = await getAdminAuth();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
17
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/leasing/administration/uploads`;
|
|
18
|
+
const method = 'POST';
|
|
19
|
+
const response: Response = await fetch(url, {
|
|
20
|
+
method,
|
|
21
|
+
headers: cleanHeaders({
|
|
22
|
+
Authorization: auth,
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
25
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
26
|
+
}),
|
|
27
|
+
body: JSON.stringify(data),
|
|
28
|
+
});
|
|
30
29
|
|
|
31
30
|
if (response.ok) {
|
|
32
31
|
return response.json() as Promise<LeasingAdminUpload>;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
const body = await response.text();
|
|
36
|
-
throw new XError(response.statusText, { body, data, opts });
|
|
35
|
+
throw new XError(response.statusText, { method, url, body, data, opts });
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
export const updateLeasingAdminUploadStatus = async (
|
|
@@ -44,24 +43,23 @@ export const updateLeasingAdminUploadStatus = async (
|
|
|
44
43
|
opts?: { serviceId: string }
|
|
45
44
|
): Promise<LeasingAdminUpload> => {
|
|
46
45
|
const auth = await getAdminAuth();
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
46
|
+
const url = `${process.env.CORE_API_ORIGIN}/api/leasing/administration/uploads/${handlerId}/${uploadId}/status`;
|
|
47
|
+
const method = 'PUT';
|
|
48
|
+
const response: Response = await fetch(url, {
|
|
49
|
+
method,
|
|
50
|
+
headers: cleanHeaders({
|
|
51
|
+
Authorization: auth,
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
54
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
55
|
+
}),
|
|
56
|
+
body: JSON.stringify({ status: newStatus }),
|
|
57
|
+
});
|
|
60
58
|
|
|
61
59
|
if (response.ok) {
|
|
62
60
|
return response.json() as Promise<LeasingAdminUpload>;
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
const body = await response.text();
|
|
66
|
-
throw new XError(response.statusText, { body, tenantId, handlerId, uploadId, opts });
|
|
64
|
+
throw new XError(response.statusText, { method, url, body, tenantId, handlerId, uploadId, opts });
|
|
67
65
|
};
|