@bontabil/sdk 0.1.3
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/dist/index.d.ts +966 -0
- package/dist/index.js +521 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
//#region src/api/constants.ts
|
|
2
|
+
const DEFAULT_REQUEST_HEADERS = {
|
|
3
|
+
"Accept": "application/json",
|
|
4
|
+
"Content-Type": "application/json"
|
|
5
|
+
};
|
|
6
|
+
const DEFAULT_REQUEST_OPTIONS = { headers: DEFAULT_REQUEST_HEADERS };
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/api/resource.ts
|
|
10
|
+
/**
|
|
11
|
+
* The base resource class.
|
|
12
|
+
*/
|
|
13
|
+
var Resource = class {
|
|
14
|
+
/**
|
|
15
|
+
* The base resource constructor.
|
|
16
|
+
*
|
|
17
|
+
* @param client The API client.
|
|
18
|
+
*/
|
|
19
|
+
constructor(client) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/api/chatbot/resource.ts
|
|
26
|
+
/**
|
|
27
|
+
* The chatbot resource.
|
|
28
|
+
*/
|
|
29
|
+
var ChatbotResource = class extends Resource {
|
|
30
|
+
/**
|
|
31
|
+
* Send a message to the chatbot.
|
|
32
|
+
*
|
|
33
|
+
* @param request The chatbot request.
|
|
34
|
+
* @returns The chatbot response.
|
|
35
|
+
*/
|
|
36
|
+
sendMessage(request) {
|
|
37
|
+
return this.client.request("chatbot", {
|
|
38
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: JSON.stringify(request)
|
|
41
|
+
}).then((res) => res.json());
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/api/utils.ts
|
|
47
|
+
/**
|
|
48
|
+
* Builds a query string for a list request.
|
|
49
|
+
*
|
|
50
|
+
* @param request The paginated request parameters.
|
|
51
|
+
* @param initUrlSearchParams The initial URL search parameters.
|
|
52
|
+
* @returns The query string for the paginated request.
|
|
53
|
+
*/
|
|
54
|
+
const buildListRequestQuery = (request, initUrlSearchParams) => {
|
|
55
|
+
return new URLSearchParams(buildPaginationRequestQuery(request, buildSortRequestQuery(request, buildIncludeRequestQuery(request, buildFilterRequestQuery(request, initUrlSearchParams))))).toString();
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Builds a query string for a filter request.
|
|
59
|
+
*
|
|
60
|
+
* @param request The filter request parameters.
|
|
61
|
+
* @param initUrlSearchParams The initial URL search parameters.
|
|
62
|
+
* @returns The query string for the filter request.
|
|
63
|
+
*/
|
|
64
|
+
const buildFilterRequestQuery = (request, initUrlSearchParams) => {
|
|
65
|
+
const result = new URLSearchParams(initUrlSearchParams);
|
|
66
|
+
Object.entries(request.filter ?? {}).forEach(([key, value]) => {
|
|
67
|
+
if (typeof value !== "undefined") result.append(`filter[${encodeURIComponent(key)}]`, String(value));
|
|
68
|
+
});
|
|
69
|
+
return result.toString();
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Builds a query string for a include request.
|
|
73
|
+
*
|
|
74
|
+
* @param request The include request parameters.
|
|
75
|
+
* @param initUrlSearchParams The initial URL search parameters.
|
|
76
|
+
* @returns The query string for the include request.
|
|
77
|
+
*/
|
|
78
|
+
const buildIncludeRequestQuery = (request, initUrlSearchParams) => {
|
|
79
|
+
const result = new URLSearchParams(initUrlSearchParams);
|
|
80
|
+
if (request.include && request.include.length > 0) result.append("include", request.include.join(","));
|
|
81
|
+
return result.toString();
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Builds a query string for a sort request.
|
|
85
|
+
*
|
|
86
|
+
* @param request The sort request parameters.
|
|
87
|
+
* @param initUrlSearchParams The initial URL search parameters.
|
|
88
|
+
* @returns The query string for the sort request.
|
|
89
|
+
*/
|
|
90
|
+
const buildSortRequestQuery = (request, initUrlSearchParams) => {
|
|
91
|
+
const result = new URLSearchParams(initUrlSearchParams);
|
|
92
|
+
if (request.sort) result.append("sort", request.sort.direction === "desc" ? `-${request.sort.field}` : request.sort.field);
|
|
93
|
+
return result.toString();
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Builds a query string for a pagination request.
|
|
97
|
+
*
|
|
98
|
+
* @param request The pagination request parameters.
|
|
99
|
+
* @param initUrlSearchParams The initial URL search parameters.
|
|
100
|
+
* @returns The query string for the pagination request.
|
|
101
|
+
*/
|
|
102
|
+
const buildPaginationRequestQuery = (request, initUrlSearchParams) => {
|
|
103
|
+
const result = new URLSearchParams(initUrlSearchParams);
|
|
104
|
+
if (typeof request.pagination?.page !== "undefined") result.append("page", String(request.pagination.page));
|
|
105
|
+
if (typeof request.pagination?.per_page !== "undefined") result.append("per_page", String(request.pagination.per_page));
|
|
106
|
+
return result.toString();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/api/cities/resource.ts
|
|
111
|
+
/**
|
|
112
|
+
* The cities resource.
|
|
113
|
+
*/
|
|
114
|
+
var CitiesResource = class extends Resource {
|
|
115
|
+
/**
|
|
116
|
+
* Get a paginated list of cities.
|
|
117
|
+
*
|
|
118
|
+
* @param request The cities request parameters.
|
|
119
|
+
* @returns The paginated list of cities.
|
|
120
|
+
*/
|
|
121
|
+
list(request) {
|
|
122
|
+
return this.client.request(`cities${request ? `?${buildListRequestQuery(request)}` : ""}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/client/errors.ts
|
|
128
|
+
/**
|
|
129
|
+
* The base response error class.
|
|
130
|
+
*/
|
|
131
|
+
var ResponseError = class extends Error {};
|
|
132
|
+
/**
|
|
133
|
+
* The unauthenticated error class.
|
|
134
|
+
*/
|
|
135
|
+
var UnauthenticatedError = class extends ResponseError {};
|
|
136
|
+
/**
|
|
137
|
+
* The forbidden error class.
|
|
138
|
+
*/
|
|
139
|
+
var ForbiddenError = class extends ResponseError {};
|
|
140
|
+
/**
|
|
141
|
+
* The not found error class.
|
|
142
|
+
*/
|
|
143
|
+
var NotFoundError = class extends ResponseError {};
|
|
144
|
+
/**
|
|
145
|
+
* The internal server error class.
|
|
146
|
+
*/
|
|
147
|
+
var InternalServerError = class extends ResponseError {};
|
|
148
|
+
/**
|
|
149
|
+
* The validation error class.
|
|
150
|
+
*/
|
|
151
|
+
var ValidationError = class extends ResponseError {
|
|
152
|
+
/**
|
|
153
|
+
* The validation error constructor.
|
|
154
|
+
*
|
|
155
|
+
* @param message The error message.
|
|
156
|
+
* @param errors The validation errors.
|
|
157
|
+
*/
|
|
158
|
+
constructor(message, errors) {
|
|
159
|
+
super(message);
|
|
160
|
+
this.errors = errors;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/client/constants.ts
|
|
166
|
+
const DEFAULT_ENDPOINT = "https://api.bontabil.ro/api";
|
|
167
|
+
const DEFAULT_OPTIONS = {
|
|
168
|
+
endpoint: DEFAULT_ENDPOINT,
|
|
169
|
+
requestOptions: {}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/client/client.ts
|
|
174
|
+
/**
|
|
175
|
+
* The API client.
|
|
176
|
+
*/
|
|
177
|
+
var Client = class {
|
|
178
|
+
/**
|
|
179
|
+
* The client options.
|
|
180
|
+
*/
|
|
181
|
+
options;
|
|
182
|
+
/**
|
|
183
|
+
* The client constructor.
|
|
184
|
+
*
|
|
185
|
+
* @param options The client options.
|
|
186
|
+
*/
|
|
187
|
+
constructor(options) {
|
|
188
|
+
this.options = {
|
|
189
|
+
...DEFAULT_OPTIONS,
|
|
190
|
+
...options
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Make a generic request to the API.
|
|
195
|
+
*
|
|
196
|
+
* @param path The path to request.
|
|
197
|
+
* @param options The request options.
|
|
198
|
+
* @returns The response.
|
|
199
|
+
*/
|
|
200
|
+
request(path, options) {
|
|
201
|
+
return fetch(this.buildUrl(path), {
|
|
202
|
+
...options,
|
|
203
|
+
...this.options.requestOptions,
|
|
204
|
+
headers: {
|
|
205
|
+
...this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {},
|
|
206
|
+
...options?.headers ?? {},
|
|
207
|
+
...this.options.requestOptions.headers ?? {}
|
|
208
|
+
}
|
|
209
|
+
}).then(async (res) => {
|
|
210
|
+
if (!res.ok) this.handleError(res, await res.json());
|
|
211
|
+
return res;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Handle an error response.
|
|
216
|
+
*
|
|
217
|
+
* @param res The response.
|
|
218
|
+
* @param data The response data.
|
|
219
|
+
*/
|
|
220
|
+
handleError(res, data) {
|
|
221
|
+
if (res.status >= 300 && res.status < 400) throw new ResponseError("Redirection not supported");
|
|
222
|
+
else if (res.status === 401) throw new UnauthenticatedError(data.message);
|
|
223
|
+
else if (res.status === 403) throw new ForbiddenError(data.message);
|
|
224
|
+
else if (res.status === 404) throw new NotFoundError(data.message);
|
|
225
|
+
else if (res.status === 422) throw new ValidationError(data.message, data.errors);
|
|
226
|
+
else if (res.status >= 500 && res.status < 600) throw new InternalServerError(data.message);
|
|
227
|
+
else throw new ResponseError(`Unexpected response status: ${res.status} ${res.statusText}`);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Builds a full URL from the given path.
|
|
231
|
+
*
|
|
232
|
+
* @param path The path to build the URL for.
|
|
233
|
+
* @returns The full URL.
|
|
234
|
+
*/
|
|
235
|
+
buildUrl(path) {
|
|
236
|
+
return new URL(this.options.endpoint.replace(/\/$/, "") + "/" + path.replace(/^\//, ""));
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/api/counties/resource.ts
|
|
242
|
+
/**
|
|
243
|
+
* The counties resource.
|
|
244
|
+
*/
|
|
245
|
+
var CountiesResource = class extends Resource {
|
|
246
|
+
/**
|
|
247
|
+
* Get a paginated list of counties.
|
|
248
|
+
*
|
|
249
|
+
* @param request The counties request parameters.
|
|
250
|
+
* @returns The paginated list of counties.
|
|
251
|
+
*/
|
|
252
|
+
list(request) {
|
|
253
|
+
return this.client.request(`counties${request ? `?${buildListRequestQuery(request)}` : ""}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/api/merchants/resource.ts
|
|
259
|
+
/**
|
|
260
|
+
* The merchants resource.
|
|
261
|
+
*/
|
|
262
|
+
var MerchantsResource = class extends Resource {
|
|
263
|
+
/**
|
|
264
|
+
* Get a paginated list of merchants.
|
|
265
|
+
*
|
|
266
|
+
* @param request The merchants request parameters.
|
|
267
|
+
* @returns The paginated list of merchants.
|
|
268
|
+
*/
|
|
269
|
+
list(request) {
|
|
270
|
+
return this.client.request(`merchants${request ? `?${buildListRequestQuery(request)}` : ""}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/api/personal-access-tokens/resource.ts
|
|
276
|
+
/**
|
|
277
|
+
* The personal access tokens resource.
|
|
278
|
+
*/
|
|
279
|
+
var PersonalAccessTokensResource = class extends Resource {
|
|
280
|
+
/**
|
|
281
|
+
* List all personal access tokens.
|
|
282
|
+
*
|
|
283
|
+
* @returns A list of personal access tokens.
|
|
284
|
+
*/
|
|
285
|
+
all() {
|
|
286
|
+
return this.client.request("personal-access-tokens", DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Create a new personal access token.
|
|
290
|
+
*
|
|
291
|
+
* @param request The create personal access token request.
|
|
292
|
+
* @returns The created personal access token.
|
|
293
|
+
*/
|
|
294
|
+
create(request) {
|
|
295
|
+
return this.client.request("personal-access-tokens", {
|
|
296
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
297
|
+
method: "POST",
|
|
298
|
+
body: JSON.stringify(request)
|
|
299
|
+
}).then((res) => res.json());
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Update a personal access token by ID.
|
|
303
|
+
*
|
|
304
|
+
* @param id The personal access token ID.
|
|
305
|
+
* @param request The update personal access token request.
|
|
306
|
+
* @returns The updated personal access token.
|
|
307
|
+
*/
|
|
308
|
+
update(id, request) {
|
|
309
|
+
return this.client.request(`personal-access-tokens/${id}`, {
|
|
310
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
311
|
+
method: "PATCH",
|
|
312
|
+
body: JSON.stringify(request)
|
|
313
|
+
}).then((res) => res.json());
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Get a personal access token by ID.
|
|
317
|
+
*
|
|
318
|
+
* @param id The personal access token ID.
|
|
319
|
+
* @returns The personal access token.
|
|
320
|
+
*/
|
|
321
|
+
get(id) {
|
|
322
|
+
return this.client.request(`personal-access-tokens/${id}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Delete a personal access token by ID.
|
|
326
|
+
*
|
|
327
|
+
* @param id The personal access token ID.
|
|
328
|
+
*/
|
|
329
|
+
async delete(id) {
|
|
330
|
+
await this.client.request(`personal-access-tokens/${id}`, {
|
|
331
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
332
|
+
method: "DELETE"
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/api/profile/resource.ts
|
|
339
|
+
/**
|
|
340
|
+
* The profile resource.
|
|
341
|
+
*/
|
|
342
|
+
var ProfileResource = class extends Resource {
|
|
343
|
+
/**
|
|
344
|
+
* Get the current user's profile.
|
|
345
|
+
*
|
|
346
|
+
* @returns The current user's profile.
|
|
347
|
+
*/
|
|
348
|
+
me() {
|
|
349
|
+
return this.client.request("me", DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/api/receipts/resource.ts
|
|
355
|
+
/**
|
|
356
|
+
* The receipts resource.
|
|
357
|
+
*/
|
|
358
|
+
var ReceiptsResource = class extends Resource {
|
|
359
|
+
/**
|
|
360
|
+
* Get a paginated list of receipts.
|
|
361
|
+
*
|
|
362
|
+
* @param request The receipts request parameters.
|
|
363
|
+
* @returns The paginated list of receipts.
|
|
364
|
+
*/
|
|
365
|
+
list(request) {
|
|
366
|
+
return this.client.request(`receipts${request ? `?${buildListRequestQuery(request)}` : ""}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Create a receipt.
|
|
370
|
+
*
|
|
371
|
+
* @param request The create receipt request.
|
|
372
|
+
* @returns The created receipt.
|
|
373
|
+
*/
|
|
374
|
+
create(request) {
|
|
375
|
+
const formData = new FormData();
|
|
376
|
+
formData.append("file", request.file);
|
|
377
|
+
return this.client.request("receipts", {
|
|
378
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
379
|
+
headers: { Accept: "application/json" },
|
|
380
|
+
method: "POST",
|
|
381
|
+
body: formData
|
|
382
|
+
}).then((res) => res.json());
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get a receipt by ID.
|
|
386
|
+
*
|
|
387
|
+
* @param id The receipt ID.
|
|
388
|
+
* @returns The receipt.
|
|
389
|
+
*/
|
|
390
|
+
get(id) {
|
|
391
|
+
return this.client.request(`receipts/${id}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Delete a receipt by ID.
|
|
395
|
+
*
|
|
396
|
+
* @param id The receipt ID.
|
|
397
|
+
*/
|
|
398
|
+
async delete(id) {
|
|
399
|
+
await this.client.request(`receipts/${id}`, {
|
|
400
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
401
|
+
method: "DELETE"
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Export receipts.
|
|
406
|
+
*
|
|
407
|
+
* @param request The export receipts request.
|
|
408
|
+
* @returns The exported receipts.
|
|
409
|
+
*/
|
|
410
|
+
export(request) {
|
|
411
|
+
return this.client.request(`receipts/export${request ? `?${buildListRequestQuery(request)}` : ""}`, {
|
|
412
|
+
...DEFAULT_REQUEST_OPTIONS,
|
|
413
|
+
headers: {
|
|
414
|
+
...DEFAULT_REQUEST_OPTIONS.headers,
|
|
415
|
+
Accept: "application/octet-stream"
|
|
416
|
+
}
|
|
417
|
+
}).then((res) => res.blob());
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/api/reports/resource.ts
|
|
423
|
+
/**
|
|
424
|
+
* The reports resource.
|
|
425
|
+
*/
|
|
426
|
+
var ReportsResource = class extends Resource {
|
|
427
|
+
/**
|
|
428
|
+
* Get spending by categories report.
|
|
429
|
+
*
|
|
430
|
+
* @param request The spending by categories request parameters.
|
|
431
|
+
* @returns The list of spending by category objects.
|
|
432
|
+
*/
|
|
433
|
+
spendingByCategories(request) {
|
|
434
|
+
return this.client.request(`reports/spending-by-categories${request ? `?${buildFilterRequestQuery(request)}` : ""}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/api/stores/resource.ts
|
|
440
|
+
/**
|
|
441
|
+
* The stores resource.
|
|
442
|
+
*/
|
|
443
|
+
var StoresResource = class extends Resource {
|
|
444
|
+
/**
|
|
445
|
+
* Get a paginated list of stores.
|
|
446
|
+
*
|
|
447
|
+
* @param request The stores request parameters.
|
|
448
|
+
* @returns The paginated list of stores.
|
|
449
|
+
*/
|
|
450
|
+
list(request) {
|
|
451
|
+
return this.client.request(`stores${request ? `?${buildListRequestQuery(request)}` : ""}`, DEFAULT_REQUEST_OPTIONS).then((res) => res.json());
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/api/api.ts
|
|
457
|
+
/**
|
|
458
|
+
* The Bontabil API.
|
|
459
|
+
*/
|
|
460
|
+
var BontabilApi = class {
|
|
461
|
+
/**
|
|
462
|
+
* The API client.
|
|
463
|
+
*/
|
|
464
|
+
client;
|
|
465
|
+
/**
|
|
466
|
+
* The profile resource.
|
|
467
|
+
*/
|
|
468
|
+
profile;
|
|
469
|
+
/**
|
|
470
|
+
* The personal access tokens resource.
|
|
471
|
+
*/
|
|
472
|
+
personalAccessTokens;
|
|
473
|
+
/**
|
|
474
|
+
* The counties resource.
|
|
475
|
+
*/
|
|
476
|
+
counties;
|
|
477
|
+
/**
|
|
478
|
+
* The cities resource.
|
|
479
|
+
*/
|
|
480
|
+
cities;
|
|
481
|
+
/**
|
|
482
|
+
* The stores resource.
|
|
483
|
+
*/
|
|
484
|
+
stores;
|
|
485
|
+
/**
|
|
486
|
+
* The merchants resource.
|
|
487
|
+
*/
|
|
488
|
+
merchants;
|
|
489
|
+
/**
|
|
490
|
+
* The chatbot resource.
|
|
491
|
+
*/
|
|
492
|
+
chatbot;
|
|
493
|
+
/**
|
|
494
|
+
* The receipts resource.
|
|
495
|
+
*/
|
|
496
|
+
receipts;
|
|
497
|
+
/**
|
|
498
|
+
* The reports resource.
|
|
499
|
+
*/
|
|
500
|
+
reports;
|
|
501
|
+
/**
|
|
502
|
+
* The Bontabil API constructor.
|
|
503
|
+
*
|
|
504
|
+
* @param client The API client or client options.
|
|
505
|
+
*/
|
|
506
|
+
constructor(client) {
|
|
507
|
+
this.client = client instanceof Client ? client : new Client(client);
|
|
508
|
+
this.profile = new ProfileResource(this.client);
|
|
509
|
+
this.personalAccessTokens = new PersonalAccessTokensResource(this.client);
|
|
510
|
+
this.counties = new CountiesResource(this.client);
|
|
511
|
+
this.cities = new CitiesResource(this.client);
|
|
512
|
+
this.stores = new StoresResource(this.client);
|
|
513
|
+
this.merchants = new MerchantsResource(this.client);
|
|
514
|
+
this.chatbot = new ChatbotResource(this.client);
|
|
515
|
+
this.receipts = new ReceiptsResource(this.client);
|
|
516
|
+
this.reports = new ReportsResource(this.client);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
//#endregion
|
|
521
|
+
export { BontabilApi, ChatbotResource, CitiesResource, Client, CountiesResource, DEFAULT_ENDPOINT, DEFAULT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_REQUEST_OPTIONS, MerchantsResource, PersonalAccessTokensResource, ProfileResource, ReceiptsResource, Resource, StoresResource };
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bontabil/sdk",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "The Bontabil SDK library",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^9.37.0",
|
|
21
|
+
"@types/node": "^22.18.8",
|
|
22
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
23
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
24
|
+
"eslint": "^9.37.0",
|
|
25
|
+
"eslint-config-prettier": "^10.1.8",
|
|
26
|
+
"globals": "^16.4.0",
|
|
27
|
+
"jiti": "^2.6.1",
|
|
28
|
+
"prettier": "3.6.2",
|
|
29
|
+
"tsdown": "^0.15.9",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"typescript-eslint": "^8.46.0",
|
|
32
|
+
"vitest": "^3.2.4"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsdown",
|
|
36
|
+
"dev": "tsdown --watch",
|
|
37
|
+
"test": "vitest",
|
|
38
|
+
"test:coverage": "vitest run --coverage",
|
|
39
|
+
"type:check": "tsc --noEmit",
|
|
40
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
41
|
+
"format:fix": "prettier --write \"src/**/*.ts\"",
|
|
42
|
+
"lint:check": "eslint \"src/**/*.ts\"",
|
|
43
|
+
"lint:fix": "eslint \"src/**/*.ts\" --fix"
|
|
44
|
+
}
|
|
45
|
+
}
|