doboxa-js 1.0.1 → 1.0.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.
Files changed (56) hide show
  1. package/README.md +79 -72
  2. package/dist/chunk-CGJD4ZO5.mjs +107 -0
  3. package/dist/chunk-CGJD4ZO5.mjs.map +1 -0
  4. package/dist/chunk-WGEOQ35B.mjs +3097 -0
  5. package/dist/chunk-WGEOQ35B.mjs.map +1 -0
  6. package/dist/client-BfIS6ja2.d.mts +2759 -0
  7. package/dist/client-BfIS6ja2.d.ts +2759 -0
  8. package/dist/client.d.mts +1 -0
  9. package/dist/client.d.ts +1 -0
  10. package/dist/client.js +2066 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/client.mjs +8 -0
  13. package/dist/client.mjs.map +1 -0
  14. package/dist/errors-CtijMwu-.d.mts +161 -0
  15. package/dist/errors-CtijMwu-.d.ts +161 -0
  16. package/dist/errors.d.mts +1 -0
  17. package/dist/errors.d.ts +1 -0
  18. package/dist/errors.js +91 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/errors.mjs +15 -0
  21. package/dist/errors.mjs.map +1 -0
  22. package/dist/index.d.mts +153 -0
  23. package/dist/index.d.ts +153 -0
  24. package/dist/index.js +3744 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/index.mjs +719 -0
  27. package/dist/index.mjs.map +1 -0
  28. package/dist/models.d.mts +2 -0
  29. package/dist/models.d.ts +2 -0
  30. package/dist/models.js +1 -0
  31. package/dist/models.js.map +1 -0
  32. package/dist/models.mjs +1 -0
  33. package/dist/models.mjs.map +1 -0
  34. package/package.json +8 -1
  35. package/api-doc.yaml +0 -2013
  36. package/openapi-generator-config.yaml +0 -15
  37. package/openapitools.json +0 -7
  38. package/src/client.ts +0 -99
  39. package/src/errors.ts +0 -90
  40. package/src/http/client.ts +0 -156
  41. package/src/index.ts +0 -31
  42. package/src/models.ts +0 -0
  43. package/src/resources/authentication.ts +0 -73
  44. package/src/resources/clients.ts +0 -32
  45. package/src/resources/discountCodes.ts +0 -32
  46. package/src/resources/invoices.ts +0 -46
  47. package/src/resources/orderComments.ts +0 -38
  48. package/src/resources/orderStatusChanges.ts +0 -38
  49. package/src/resources/orders.ts +0 -123
  50. package/src/resources/trackingNumbers.ts +0 -38
  51. package/src/resources/users.ts +0 -28
  52. package/src/types/index.ts +0 -59
  53. package/src/utils/config.ts +0 -10
  54. package/src/utils/tokenManager.ts +0 -68
  55. package/tsconfig.json +0 -12
  56. package/tsup.config.ts +0 -30
package/dist/client.js ADDED
@@ -0,0 +1,2066 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ var __async = (__this, __arguments, generator) => {
36
+ return new Promise((resolve, reject) => {
37
+ var fulfilled = (value) => {
38
+ try {
39
+ step(generator.next(value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ };
44
+ var rejected = (value) => {
45
+ try {
46
+ step(generator.throw(value));
47
+ } catch (e) {
48
+ reject(e);
49
+ }
50
+ };
51
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
52
+ step((generator = generator.apply(__this, __arguments)).next());
53
+ });
54
+ };
55
+
56
+ // src/client.ts
57
+ var client_exports = {};
58
+ __export(client_exports, {
59
+ Doboxa: () => Doboxa
60
+ });
61
+ module.exports = __toCommonJS(client_exports);
62
+
63
+ // src/types/generated/src/runtime.ts
64
+ var BASE_PATH = "http://localhost".replace(/\/+$/, "");
65
+ var Configuration = class {
66
+ constructor(configuration = {}) {
67
+ this.configuration = configuration;
68
+ }
69
+ set config(configuration) {
70
+ this.configuration = configuration;
71
+ }
72
+ get basePath() {
73
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
74
+ }
75
+ get fetchApi() {
76
+ return this.configuration.fetchApi;
77
+ }
78
+ get middleware() {
79
+ return this.configuration.middleware || [];
80
+ }
81
+ get queryParamsStringify() {
82
+ return this.configuration.queryParamsStringify || querystring;
83
+ }
84
+ get username() {
85
+ return this.configuration.username;
86
+ }
87
+ get password() {
88
+ return this.configuration.password;
89
+ }
90
+ get apiKey() {
91
+ const apiKey = this.configuration.apiKey;
92
+ if (apiKey) {
93
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
94
+ }
95
+ return void 0;
96
+ }
97
+ get accessToken() {
98
+ const accessToken = this.configuration.accessToken;
99
+ if (accessToken) {
100
+ return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
101
+ return accessToken;
102
+ });
103
+ }
104
+ return void 0;
105
+ }
106
+ get headers() {
107
+ return this.configuration.headers;
108
+ }
109
+ get credentials() {
110
+ return this.configuration.credentials;
111
+ }
112
+ };
113
+ var DefaultConfig = new Configuration();
114
+ var _BaseAPI = class _BaseAPI {
115
+ constructor(configuration = DefaultConfig) {
116
+ this.configuration = configuration;
117
+ this.fetchApi = (url, init) => __async(this, null, function* () {
118
+ let fetchParams = { url, init };
119
+ for (const middleware of this.middleware) {
120
+ if (middleware.pre) {
121
+ fetchParams = (yield middleware.pre(__spreadValues({
122
+ fetch: this.fetchApi
123
+ }, fetchParams))) || fetchParams;
124
+ }
125
+ }
126
+ let response = void 0;
127
+ try {
128
+ response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
129
+ } catch (e) {
130
+ for (const middleware of this.middleware) {
131
+ if (middleware.onError) {
132
+ response = (yield middleware.onError({
133
+ fetch: this.fetchApi,
134
+ url: fetchParams.url,
135
+ init: fetchParams.init,
136
+ error: e,
137
+ response: response ? response.clone() : void 0
138
+ })) || response;
139
+ }
140
+ }
141
+ if (response === void 0) {
142
+ if (e instanceof Error) {
143
+ throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
144
+ } else {
145
+ throw e;
146
+ }
147
+ }
148
+ }
149
+ for (const middleware of this.middleware) {
150
+ if (middleware.post) {
151
+ response = (yield middleware.post({
152
+ fetch: this.fetchApi,
153
+ url: fetchParams.url,
154
+ init: fetchParams.init,
155
+ response: response.clone()
156
+ })) || response;
157
+ }
158
+ }
159
+ return response;
160
+ });
161
+ this.middleware = configuration.middleware;
162
+ }
163
+ withMiddleware(...middlewares) {
164
+ const next = this.clone();
165
+ next.middleware = next.middleware.concat(...middlewares);
166
+ return next;
167
+ }
168
+ withPreMiddleware(...preMiddlewares) {
169
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
170
+ return this.withMiddleware(...middlewares);
171
+ }
172
+ withPostMiddleware(...postMiddlewares) {
173
+ const middlewares = postMiddlewares.map((post) => ({ post }));
174
+ return this.withMiddleware(...middlewares);
175
+ }
176
+ /**
177
+ * Check if the given MIME is a JSON MIME.
178
+ * JSON MIME examples:
179
+ * application/json
180
+ * application/json; charset=UTF8
181
+ * APPLICATION/JSON
182
+ * application/vnd.company+json
183
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
184
+ * @return True if the given MIME is JSON, false otherwise.
185
+ */
186
+ isJsonMime(mime) {
187
+ if (!mime) {
188
+ return false;
189
+ }
190
+ return _BaseAPI.jsonRegex.test(mime);
191
+ }
192
+ request(context, initOverrides) {
193
+ return __async(this, null, function* () {
194
+ const { url, init } = yield this.createFetchParams(context, initOverrides);
195
+ const response = yield this.fetchApi(url, init);
196
+ if (response && (response.status >= 200 && response.status < 300)) {
197
+ return response;
198
+ }
199
+ throw new ResponseError(response, "Response returned an error code");
200
+ });
201
+ }
202
+ createFetchParams(context, initOverrides) {
203
+ return __async(this, null, function* () {
204
+ let url = this.configuration.basePath + context.path;
205
+ if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
206
+ url += "?" + this.configuration.queryParamsStringify(context.query);
207
+ }
208
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
209
+ Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
210
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
211
+ return initOverrides;
212
+ });
213
+ const initParams = {
214
+ method: context.method,
215
+ headers,
216
+ body: context.body,
217
+ credentials: this.configuration.credentials
218
+ };
219
+ const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
220
+ init: initParams,
221
+ context
222
+ }));
223
+ let body;
224
+ if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
225
+ body = overriddenInit.body;
226
+ } else if (this.isJsonMime(headers["Content-Type"])) {
227
+ body = JSON.stringify(overriddenInit.body);
228
+ } else {
229
+ body = overriddenInit.body;
230
+ }
231
+ const init = __spreadProps(__spreadValues({}, overriddenInit), {
232
+ body
233
+ });
234
+ return { url, init };
235
+ });
236
+ }
237
+ /**
238
+ * Create a shallow clone of `this` by constructing a new instance
239
+ * and then shallow cloning data members.
240
+ */
241
+ clone() {
242
+ const constructor = this.constructor;
243
+ const next = new constructor(this.configuration);
244
+ next.middleware = this.middleware.slice();
245
+ return next;
246
+ }
247
+ };
248
+ _BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
249
+ var BaseAPI = _BaseAPI;
250
+ function isBlob(value) {
251
+ return typeof Blob !== "undefined" && value instanceof Blob;
252
+ }
253
+ function isFormData(value) {
254
+ return typeof FormData !== "undefined" && value instanceof FormData;
255
+ }
256
+ var ResponseError = class extends Error {
257
+ constructor(response, msg) {
258
+ super(msg);
259
+ this.response = response;
260
+ this.name = "ResponseError";
261
+ }
262
+ };
263
+ var FetchError = class extends Error {
264
+ constructor(cause, msg) {
265
+ super(msg);
266
+ this.cause = cause;
267
+ this.name = "FetchError";
268
+ }
269
+ };
270
+ var RequiredError = class extends Error {
271
+ constructor(field, msg) {
272
+ super(msg);
273
+ this.field = field;
274
+ this.name = "RequiredError";
275
+ }
276
+ };
277
+ function querystring(params, prefix = "") {
278
+ return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
279
+ }
280
+ function querystringSingleKey(key, value, keyPrefix = "") {
281
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
282
+ if (value instanceof Array) {
283
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
284
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
285
+ }
286
+ if (value instanceof Set) {
287
+ const valueAsArray = Array.from(value);
288
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
289
+ }
290
+ if (value instanceof Date) {
291
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
292
+ }
293
+ if (value instanceof Object) {
294
+ return querystring(value, fullKey);
295
+ }
296
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
297
+ }
298
+ var JSONApiResponse = class {
299
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
300
+ this.raw = raw;
301
+ this.transformer = transformer;
302
+ }
303
+ value() {
304
+ return __async(this, null, function* () {
305
+ return this.transformer(yield this.raw.json());
306
+ });
307
+ }
308
+ };
309
+
310
+ // src/errors.ts
311
+ var DoboxaError = class _DoboxaError extends Error {
312
+ constructor(message) {
313
+ super(message);
314
+ this.name = "DoboxaError";
315
+ Object.setPrototypeOf(this, _DoboxaError.prototype);
316
+ }
317
+ };
318
+ var DoboxaAPIError = class _DoboxaAPIError extends DoboxaError {
319
+ constructor(statusCode, message, body) {
320
+ super(message);
321
+ this.name = "DoboxaAPIError";
322
+ this.statusCode = statusCode;
323
+ if (body) {
324
+ if ("result_code" in body) {
325
+ this.code = body.result_code;
326
+ }
327
+ if ("error_message" in body) {
328
+ this.errorMessage = body.error_message || void 0;
329
+ }
330
+ if ("invalid_parameters" in body && body.invalid_parameters) {
331
+ this.invalidParameters = body.invalid_parameters.map((param) => ({
332
+ parameter: param.parameter,
333
+ error_cause: param.error_cause
334
+ }));
335
+ }
336
+ }
337
+ Object.setPrototypeOf(this, _DoboxaAPIError.prototype);
338
+ }
339
+ };
340
+ var DoboxaAuthenticationError = class _DoboxaAuthenticationError extends DoboxaError {
341
+ constructor(message = "Authentication failed") {
342
+ super(message);
343
+ this.name = "DoboxaAuthenticationError";
344
+ Object.setPrototypeOf(this, _DoboxaAuthenticationError.prototype);
345
+ }
346
+ };
347
+ function parseErrorResponse(statusCode, body) {
348
+ if (typeof body === "object" && body !== null) {
349
+ if ("invalid_parameters" in body || "error_message" in body) {
350
+ return body;
351
+ }
352
+ if ("error_message" in body && "result_code" in body) {
353
+ return body;
354
+ }
355
+ }
356
+ return void 0;
357
+ }
358
+
359
+ // src/http/client.ts
360
+ var HTTPClient = class {
361
+ constructor(config) {
362
+ this.baseURL = config.baseURL || "http://localhost";
363
+ this.tokenManager = config.tokenManager;
364
+ this.onTokenRefresh = config.onTokenRefresh;
365
+ }
366
+ /**
367
+ * Make an HTTP request
368
+ */
369
+ request(_0) {
370
+ return __async(this, arguments, function* (path, options = {}) {
371
+ const url = `${this.baseURL}${path.startsWith("/") ? path : `/${path}`}`;
372
+ let accessToken = this.tokenManager.getAccessToken();
373
+ if (!accessToken || this.tokenManager.isTokenExpired()) {
374
+ if (this.onTokenRefresh) {
375
+ const refreshToken = this.tokenManager.getRefreshToken();
376
+ if (refreshToken) {
377
+ let refreshPromise = this.tokenManager.getRefreshPromise();
378
+ if (!refreshPromise) {
379
+ refreshPromise = this.onTokenRefresh(refreshToken);
380
+ this.tokenManager.setRefreshPromise(refreshPromise);
381
+ }
382
+ try {
383
+ accessToken = yield refreshPromise;
384
+ } finally {
385
+ this.tokenManager.setRefreshPromise(null);
386
+ }
387
+ }
388
+ }
389
+ }
390
+ const headers = new Headers(options.headers);
391
+ headers.set("Content-Type", "application/json");
392
+ headers.set("Authorization", `Bearer ${accessToken}`);
393
+ console.log("url", url);
394
+ const response = yield fetch(url, __spreadProps(__spreadValues({}, options), {
395
+ headers
396
+ }));
397
+ let responseBody;
398
+ const contentType = response.headers.get("content-type");
399
+ if (contentType && contentType.includes("application/json")) {
400
+ try {
401
+ responseBody = yield response.json();
402
+ } catch (e) {
403
+ }
404
+ } else {
405
+ responseBody = yield response.text();
406
+ }
407
+ if (!response.ok) {
408
+ const errorBody = parseErrorResponse(response.status, responseBody);
409
+ const errorMessage = (errorBody && "error_message" in errorBody ? errorBody.error_message : void 0) || response.statusText || `HTTP ${response.status}`;
410
+ if (response.status === 401 || response.status === 403) {
411
+ throw new DoboxaAuthenticationError(errorMessage);
412
+ }
413
+ throw new DoboxaAPIError(response.status, errorMessage, errorBody);
414
+ }
415
+ return responseBody;
416
+ });
417
+ }
418
+ /**
419
+ * GET request
420
+ */
421
+ get(path, options) {
422
+ return __async(this, null, function* () {
423
+ return this.request(path, __spreadProps(__spreadValues({}, options), { method: "GET" }));
424
+ });
425
+ }
426
+ /**
427
+ * POST request
428
+ */
429
+ post(path, body, options) {
430
+ return __async(this, null, function* () {
431
+ return this.request(path, __spreadProps(__spreadValues({}, options), {
432
+ method: "POST",
433
+ body: body ? JSON.stringify(body) : void 0
434
+ }));
435
+ });
436
+ }
437
+ /**
438
+ * PUT request
439
+ */
440
+ put(path, body, options) {
441
+ return __async(this, null, function* () {
442
+ return this.request(path, __spreadProps(__spreadValues({}, options), {
443
+ method: "PUT",
444
+ body: body ? JSON.stringify(body) : void 0
445
+ }));
446
+ });
447
+ }
448
+ /**
449
+ * DELETE request
450
+ */
451
+ delete(path, options) {
452
+ return __async(this, null, function* () {
453
+ return this.request(path, __spreadProps(__spreadValues({}, options), { method: "DELETE" }));
454
+ });
455
+ }
456
+ /**
457
+ * PATCH request
458
+ */
459
+ patch(path, body, options) {
460
+ return __async(this, null, function* () {
461
+ return this.request(path, __spreadProps(__spreadValues({}, options), {
462
+ method: "PATCH",
463
+ body: body ? JSON.stringify(body) : void 0
464
+ }));
465
+ });
466
+ }
467
+ };
468
+
469
+ // src/utils/tokenManager.ts
470
+ var TokenManager = class {
471
+ constructor() {
472
+ this.accessToken = null;
473
+ this.refreshToken = null;
474
+ this.tokenExpiry = null;
475
+ this.refreshPromise = null;
476
+ }
477
+ /**
478
+ * Set tokens and calculate expiry
479
+ */
480
+ setTokens(accessToken, refreshToken, expiresIn = 3600) {
481
+ this.accessToken = accessToken;
482
+ this.refreshToken = refreshToken;
483
+ this.tokenExpiry = Date.now() + (expiresIn - 5) * 1e3;
484
+ }
485
+ /**
486
+ * Get current access token
487
+ */
488
+ getAccessToken() {
489
+ return this.accessToken;
490
+ }
491
+ /**
492
+ * Get refresh token
493
+ */
494
+ getRefreshToken() {
495
+ return this.refreshToken;
496
+ }
497
+ /**
498
+ * Check if token is expired or will expire soon
499
+ */
500
+ isTokenExpired() {
501
+ if (!this.tokenExpiry || !this.accessToken) {
502
+ return true;
503
+ }
504
+ return Date.now() >= this.tokenExpiry;
505
+ }
506
+ /**
507
+ * Clear all tokens
508
+ */
509
+ clearTokens() {
510
+ this.accessToken = null;
511
+ this.refreshToken = null;
512
+ this.tokenExpiry = null;
513
+ this.refreshPromise = null;
514
+ }
515
+ /**
516
+ * Set refresh promise to prevent concurrent refresh requests
517
+ */
518
+ setRefreshPromise(promise) {
519
+ this.refreshPromise = promise;
520
+ }
521
+ /**
522
+ * Get current refresh promise
523
+ */
524
+ getRefreshPromise() {
525
+ return this.refreshPromise;
526
+ }
527
+ };
528
+
529
+ // src/utils/config.ts
530
+ function getBaseURL() {
531
+ if (typeof process !== "undefined" && process.env) {
532
+ return process.env.DOBOXA_API_URL;
533
+ }
534
+ return void 0;
535
+ }
536
+
537
+ // src/resources/authentication.ts
538
+ var AuthenticationResource = class {
539
+ constructor(httpClient, tokenManager) {
540
+ this.httpClient = httpClient;
541
+ this.tokenManager = tokenManager;
542
+ }
543
+ /**
544
+ * Login with username and password
545
+ */
546
+ login(params) {
547
+ return __async(this, null, function* () {
548
+ const request = {
549
+ username: params.username,
550
+ password: params.password
551
+ };
552
+ const response = yield this.httpClient.post(
553
+ "/api/v2/authentication/token",
554
+ request
555
+ );
556
+ if (response.token && response.refresh_token) {
557
+ this.tokenManager.setTokens(response.token, response.refresh_token, 3600);
558
+ }
559
+ return response;
560
+ });
561
+ }
562
+ /**
563
+ * Refresh access token using refresh token
564
+ */
565
+ refreshToken(refreshToken) {
566
+ return __async(this, null, function* () {
567
+ const request = {
568
+ refresh_token: refreshToken
569
+ };
570
+ const response = yield this.httpClient.post(
571
+ "/api/v2/authentication/refresh_token",
572
+ request
573
+ );
574
+ if (response.token && response.refresh_token) {
575
+ this.tokenManager.setTokens(response.token, response.refresh_token, 3600);
576
+ }
577
+ return response;
578
+ });
579
+ }
580
+ };
581
+
582
+ // src/types/generated/src/models/Bool.ts
583
+ function BoolFromJSON(json) {
584
+ return json;
585
+ }
586
+
587
+ // src/types/generated/src/models/Attachment.ts
588
+ function AttachmentToJSON(json) {
589
+ return AttachmentToJSONTyped(json, false);
590
+ }
591
+ function AttachmentToJSONTyped(value, ignoreDiscriminator = false) {
592
+ if (value == null) {
593
+ return value;
594
+ }
595
+ return {
596
+ "type": value["type"],
597
+ "file_path": value["file_path"],
598
+ "articles": value["articles"]
599
+ };
600
+ }
601
+
602
+ // src/types/generated/src/models/Client.ts
603
+ function ClientFromJSON(json) {
604
+ return ClientFromJSONTyped(json, false);
605
+ }
606
+ function ClientFromJSONTyped(json, ignoreDiscriminator) {
607
+ if (json == null) {
608
+ return json;
609
+ }
610
+ return {
611
+ "email": json["email"] == null ? void 0 : json["email"],
612
+ "token": json["token"] == null ? void 0 : json["token"]
613
+ };
614
+ }
615
+
616
+ // src/types/generated/src/models/CreateOrderComment.ts
617
+ function CreateOrderCommentToJSON(json) {
618
+ return CreateOrderCommentToJSONTyped(json, false);
619
+ }
620
+ function CreateOrderCommentToJSONTyped(value, ignoreDiscriminator = false) {
621
+ if (value == null) {
622
+ return value;
623
+ }
624
+ return {
625
+ "author_type": value["author_type"],
626
+ "author_email": value["author_email"],
627
+ "content": value["content"],
628
+ "created_at": value["created_at"].toISOString()
629
+ };
630
+ }
631
+
632
+ // src/types/generated/src/models/DeliveryAddress.ts
633
+ function DeliveryAddressToJSON(json) {
634
+ return DeliveryAddressToJSONTyped(json, false);
635
+ }
636
+ function DeliveryAddressToJSONTyped(value, ignoreDiscriminator = false) {
637
+ if (value == null) {
638
+ return value;
639
+ }
640
+ return {
641
+ "first_name": value["first_name"],
642
+ "last_name": value["last_name"],
643
+ "company_name": value["company_name"],
644
+ "phone_number": value["phone_number"],
645
+ "email": value["email"],
646
+ "address1": value["address1"],
647
+ "address2": value["address2"],
648
+ "city": value["city"],
649
+ "region": value["region"],
650
+ "post_code": value["post_code"],
651
+ "country_iso": value["country_iso"],
652
+ "delivery_point_id": value["delivery_point_id"],
653
+ "allegro_smart_account_id": value["allegro_smart_account_id"]
654
+ };
655
+ }
656
+
657
+ // src/types/generated/src/models/GetApiV2DiscountCodesExternal200ResponseItemsInner.ts
658
+ function GetApiV2DiscountCodesExternal200ResponseItemsInnerFromJSON(json) {
659
+ return GetApiV2DiscountCodesExternal200ResponseItemsInnerFromJSONTyped(json, false);
660
+ }
661
+ function GetApiV2DiscountCodesExternal200ResponseItemsInnerFromJSONTyped(json, ignoreDiscriminator) {
662
+ if (json == null) {
663
+ return json;
664
+ }
665
+ return {
666
+ "code": json["code"] == null ? void 0 : json["code"],
667
+ "type": json["type"] == null ? void 0 : json["type"],
668
+ "client_email": json["client_email"] == null ? void 0 : json["client_email"],
669
+ "domain": json["domain"] == null ? void 0 : json["domain"],
670
+ "currency": json["currency"] == null ? void 0 : json["currency"],
671
+ "action": json["action"] == null ? void 0 : json["action"],
672
+ "valid_until": json["valid_until"] == null ? void 0 : json["valid_until"]
673
+ };
674
+ }
675
+
676
+ // src/types/generated/src/models/GetApiV2DiscountCodesExternal200Response.ts
677
+ function GetApiV2DiscountCodesExternal200ResponseFromJSON(json) {
678
+ return GetApiV2DiscountCodesExternal200ResponseFromJSONTyped(json, false);
679
+ }
680
+ function GetApiV2DiscountCodesExternal200ResponseFromJSONTyped(json, ignoreDiscriminator) {
681
+ if (json == null) {
682
+ return json;
683
+ }
684
+ return {
685
+ "items": json["items"] == null ? void 0 : json["items"].map(GetApiV2DiscountCodesExternal200ResponseItemsInnerFromJSON),
686
+ "next_page": json["next_page"] == null ? void 0 : json["next_page"]
687
+ };
688
+ }
689
+
690
+ // src/types/generated/src/models/InvoiceItem.ts
691
+ function InvoiceItemFromJSON(json) {
692
+ return InvoiceItemFromJSONTyped(json, false);
693
+ }
694
+ function InvoiceItemFromJSONTyped(json, ignoreDiscriminator) {
695
+ if (json == null) {
696
+ return json;
697
+ }
698
+ return {
699
+ "doboxa_item_id": json["doboxa_item_id"] == null ? void 0 : json["doboxa_item_id"],
700
+ "foreign_item_id": json["foreign_item_id"] == null ? void 0 : json["foreign_item_id"],
701
+ "name": json["name"] == null ? void 0 : json["name"],
702
+ "qty": json["qty"] == null ? void 0 : json["qty"],
703
+ "unit": json["unit"] == null ? void 0 : json["unit"],
704
+ "net_unit_price": json["net_unit_price"] == null ? void 0 : json["net_unit_price"],
705
+ "net_value": json["net_value"] == null ? void 0 : json["net_value"],
706
+ "vat_value": json["vat_value"] == null ? void 0 : json["vat_value"],
707
+ "vat_rate": json["vat_rate"] == null ? void 0 : json["vat_rate"],
708
+ "currency": json["currency"] == null ? void 0 : json["currency"]
709
+ };
710
+ }
711
+
712
+ // src/types/generated/src/models/InvoiceOrderItem.ts
713
+ function InvoiceOrderItemFromJSON(json) {
714
+ return InvoiceOrderItemFromJSONTyped(json, false);
715
+ }
716
+ function InvoiceOrderItemFromJSONTyped(json, ignoreDiscriminator) {
717
+ if (json == null) {
718
+ return json;
719
+ }
720
+ return {
721
+ "doboxa_item_id": json["doboxa_item_id"] == null ? void 0 : json["doboxa_item_id"],
722
+ "foreign_item_id": json["foreign_item_id"] == null ? void 0 : json["foreign_item_id"]
723
+ };
724
+ }
725
+
726
+ // src/types/generated/src/models/InvoiceOrder.ts
727
+ function InvoiceOrderFromJSON(json) {
728
+ return InvoiceOrderFromJSONTyped(json, false);
729
+ }
730
+ function InvoiceOrderFromJSONTyped(json, ignoreDiscriminator) {
731
+ if (json == null) {
732
+ return json;
733
+ }
734
+ return {
735
+ "doboxa_order_id": json["doboxa_order_id"] == null ? void 0 : json["doboxa_order_id"],
736
+ "external_order_id": json["external_order_id"] == null ? void 0 : json["external_order_id"],
737
+ "items": json["items"] == null ? void 0 : json["items"].map(InvoiceOrderItemFromJSON)
738
+ };
739
+ }
740
+
741
+ // src/types/generated/src/models/Invoice.ts
742
+ function InvoiceFromJSON(json) {
743
+ return InvoiceFromJSONTyped(json, false);
744
+ }
745
+ function InvoiceFromJSONTyped(json, ignoreDiscriminator) {
746
+ if (json == null) {
747
+ return json;
748
+ }
749
+ return {
750
+ "id": json["id"] == null ? void 0 : json["id"],
751
+ "client": json["client"] == null ? void 0 : json["client"],
752
+ "file": json["file"] == null ? void 0 : json["file"],
753
+ "state": json["state"] == null ? void 0 : json["state"],
754
+ "document_number": json["document_number"] == null ? void 0 : json["document_number"],
755
+ "document_amount": json["document_amount"] == null ? void 0 : json["document_amount"],
756
+ "net_amount": json["net_amount"] == null ? void 0 : json["net_amount"],
757
+ "tax_amount": json["tax_amount"] == null ? void 0 : json["tax_amount"],
758
+ "tax_rate": json["tax_rate"] == null ? void 0 : json["tax_rate"],
759
+ "paid_amount": json["paid_amount"] == null ? void 0 : json["paid_amount"],
760
+ "currency": json["currency"] == null ? void 0 : json["currency"],
761
+ "date_of_issue": json["date_of_issue"] == null ? void 0 : new Date(json["date_of_issue"]),
762
+ "due_date": json["due_date"] == null ? void 0 : new Date(json["due_date"]),
763
+ "document_type": json["document_type"] == null ? void 0 : json["document_type"],
764
+ "orders": json["orders"] == null ? void 0 : json["orders"].map(InvoiceOrderFromJSON),
765
+ "invoice_items": json["invoice_items"] == null ? void 0 : json["invoice_items"].map(InvoiceItemFromJSON)
766
+ };
767
+ }
768
+
769
+ // src/types/generated/src/models/Me.ts
770
+ function MeFromJSON(json) {
771
+ return MeFromJSONTyped(json, false);
772
+ }
773
+ function MeFromJSONTyped(json, ignoreDiscriminator) {
774
+ if (json == null) {
775
+ return json;
776
+ }
777
+ return {
778
+ "username": json["username"] == null ? void 0 : json["username"]
779
+ };
780
+ }
781
+
782
+ // src/types/generated/src/models/OrderItemCropData.ts
783
+ function OrderItemCropDataToJSON(json) {
784
+ return OrderItemCropDataToJSONTyped(json, false);
785
+ }
786
+ function OrderItemCropDataToJSONTyped(value, ignoreDiscriminator = false) {
787
+ if (value == null) {
788
+ return value;
789
+ }
790
+ return {
791
+ "left": value["left"],
792
+ "top": value["top"],
793
+ "width": value["width"],
794
+ "height": value["height"],
795
+ "original_photo_width": value["original_photo_width"],
796
+ "original_photo_height": value["original_photo_height"],
797
+ "filter": value["filter"],
798
+ "reflection": value["reflection"],
799
+ "rotation": value["rotation"],
800
+ "scale": value["scale"]
801
+ };
802
+ }
803
+
804
+ // src/types/generated/src/models/OrderItem.ts
805
+ function OrderItemToJSON(json) {
806
+ return OrderItemToJSONTyped(json, false);
807
+ }
808
+ function OrderItemToJSONTyped(value, ignoreDiscriminator = false) {
809
+ if (value == null) {
810
+ return value;
811
+ }
812
+ return {
813
+ "foreign_id": value["foreign_id"],
814
+ "id": value["id"],
815
+ "additional_sku": value["additional_sku"],
816
+ "ean": value["ean"],
817
+ "symbol_code": value["symbol_code"],
818
+ "name": value["name"],
819
+ "qty": value["qty"],
820
+ "item_price": value["item_price"],
821
+ "width_in_cm": value["width_in_cm"],
822
+ "height_in_cm": value["height_in_cm"],
823
+ "custom_file": value["custom_file"],
824
+ "additional_custom_file": value["additional_custom_file"],
825
+ "additional_info": value["additional_info"],
826
+ "crop_data": OrderItemCropDataToJSON(value["crop_data"]),
827
+ "fulfillment_date": value["fulfillment_date"] == null ? value["fulfillment_date"] : value["fulfillment_date"].toISOString(),
828
+ "custom_file_id": value["custom_file_id"]
829
+ };
830
+ }
831
+
832
+ // src/types/generated/src/models/Waybill.ts
833
+ function WaybillToJSON(json) {
834
+ return WaybillToJSONTyped(json, false);
835
+ }
836
+ function WaybillToJSONTyped(value, ignoreDiscriminator = false) {
837
+ if (value == null) {
838
+ return value;
839
+ }
840
+ return {
841
+ "number": value["number"],
842
+ "delivery_method": value["delivery_method"],
843
+ "file_path": value["file_path"],
844
+ "articles": value["articles"]
845
+ };
846
+ }
847
+
848
+ // src/types/generated/src/models/Order.ts
849
+ function OrderToJSON(json) {
850
+ return OrderToJSONTyped(json, false);
851
+ }
852
+ function OrderToJSONTyped(value, ignoreDiscriminator = false) {
853
+ if (value == null) {
854
+ return value;
855
+ }
856
+ return {
857
+ "external_id": value["external_id"],
858
+ "deliver_address": DeliveryAddressToJSON(value["deliver_address"]),
859
+ "items": value["items"].map(OrderItemToJSON),
860
+ "order_time": value["order_time"].toISOString(),
861
+ "payment_time": value["payment_time"] == null ? value["payment_time"] : value["payment_time"].toISOString(),
862
+ "info": value["info"],
863
+ "order_channel": value["order_channel"],
864
+ "currency": value["currency"],
865
+ "company_name": value["company_name"],
866
+ "own_delivery": value["own_delivery"],
867
+ "waybills": value["waybills"] == null ? void 0 : value["waybills"].map(WaybillToJSON),
868
+ "attachments": value["attachments"] == null ? void 0 : value["attachments"].map(AttachmentToJSON)
869
+ };
870
+ }
871
+
872
+ // src/types/generated/src/models/OrderCancellation.ts
873
+ function OrderCancellationToJSON(json) {
874
+ return OrderCancellationToJSONTyped(json, false);
875
+ }
876
+ function OrderCancellationToJSONTyped(value, ignoreDiscriminator = false) {
877
+ if (value == null) {
878
+ return value;
879
+ }
880
+ return {
881
+ "order_id": value["order_id"]
882
+ };
883
+ }
884
+
885
+ // src/types/generated/src/models/OrderCancellationResponse.ts
886
+ function OrderCancellationResponseFromJSON(json) {
887
+ return OrderCancellationResponseFromJSONTyped(json, false);
888
+ }
889
+ function OrderCancellationResponseFromJSONTyped(json, ignoreDiscriminator) {
890
+ if (json == null) {
891
+ return json;
892
+ }
893
+ return {
894
+ "cancelled": json["cancelled"] == null ? void 0 : BoolFromJSON(json["cancelled"]),
895
+ "details": json["details"] == null ? void 0 : json["details"]
896
+ };
897
+ }
898
+
899
+ // src/types/generated/src/models/OrderComment.ts
900
+ function OrderCommentFromJSON(json) {
901
+ return OrderCommentFromJSONTyped(json, false);
902
+ }
903
+ function OrderCommentFromJSONTyped(json, ignoreDiscriminator) {
904
+ if (json == null) {
905
+ return json;
906
+ }
907
+ return {
908
+ "comment_id": json["comment_id"] == null ? void 0 : json["comment_id"],
909
+ "author_type": json["author_type"] == null ? void 0 : json["author_type"],
910
+ "author": json["author"] == null ? void 0 : json["author"],
911
+ "content": json["content"] == null ? void 0 : json["content"],
912
+ "created_at": json["created_at"] == null ? void 0 : new Date(json["created_at"])
913
+ };
914
+ }
915
+
916
+ // src/types/generated/src/models/OrderItemStatus.ts
917
+ function OrderItemStatusFromJSON(json) {
918
+ return OrderItemStatusFromJSONTyped(json, false);
919
+ }
920
+ function OrderItemStatusFromJSONTyped(json, ignoreDiscriminator) {
921
+ if (json == null) {
922
+ return json;
923
+ }
924
+ return {
925
+ "doboxa_order_id": json["doboxa_order_id"] == null ? void 0 : json["doboxa_order_id"],
926
+ "external_order_id": json["external_order_id"] == null ? void 0 : json["external_order_id"],
927
+ "doboxa_item_id": json["doboxa_item_id"] == null ? void 0 : json["doboxa_item_id"],
928
+ "foreign_item_id": json["foreign_item_id"] == null ? void 0 : json["foreign_item_id"],
929
+ "product_sku": json["product_sku"] == null ? void 0 : json["product_sku"],
930
+ "status": json["status"] == null ? void 0 : json["status"]
931
+ };
932
+ }
933
+
934
+ // src/types/generated/src/models/OrderStatus.ts
935
+ function OrderStatusFromJSON(json) {
936
+ return OrderStatusFromJSONTyped(json, false);
937
+ }
938
+ function OrderStatusFromJSONTyped(json, ignoreDiscriminator) {
939
+ if (json == null) {
940
+ return json;
941
+ }
942
+ return {
943
+ "status": json["status"] == null ? void 0 : json["status"],
944
+ "item_status": json["item_status"] == null ? void 0 : json["item_status"].map(OrderItemStatusFromJSON)
945
+ };
946
+ }
947
+
948
+ // src/types/generated/src/models/OrderStatusChange.ts
949
+ function OrderStatusChangeFromJSON(json) {
950
+ return OrderStatusChangeFromJSONTyped(json, false);
951
+ }
952
+ function OrderStatusChangeFromJSONTyped(json, ignoreDiscriminator) {
953
+ if (json == null) {
954
+ return json;
955
+ }
956
+ return {
957
+ "order_id": json["order_id"] == null ? void 0 : json["order_id"],
958
+ "status": json["status"] == null ? void 0 : json["status"],
959
+ "change_time": json["change_time"] == null ? void 0 : new Date(json["change_time"]),
960
+ "item_status": json["item_status"] == null ? void 0 : json["item_status"].map(OrderItemStatusFromJSON)
961
+ };
962
+ }
963
+
964
+ // src/types/generated/src/models/PageOfClients.ts
965
+ function PageOfClientsFromJSON(json) {
966
+ return PageOfClientsFromJSONTyped(json, false);
967
+ }
968
+ function PageOfClientsFromJSONTyped(json, ignoreDiscriminator) {
969
+ if (json == null) {
970
+ return json;
971
+ }
972
+ return {
973
+ "items": json["items"] == null ? void 0 : json["items"].map(ClientFromJSON),
974
+ "next_page": json["next_page"] == null ? void 0 : json["next_page"]
975
+ };
976
+ }
977
+
978
+ // src/types/generated/src/models/PageOfInvoices.ts
979
+ function PageOfInvoicesFromJSON(json) {
980
+ return PageOfInvoicesFromJSONTyped(json, false);
981
+ }
982
+ function PageOfInvoicesFromJSONTyped(json, ignoreDiscriminator) {
983
+ if (json == null) {
984
+ return json;
985
+ }
986
+ return {
987
+ "items": json["items"] == null ? void 0 : json["items"].map(InvoiceFromJSON),
988
+ "next_page": json["next_page"] == null ? void 0 : json["next_page"]
989
+ };
990
+ }
991
+
992
+ // src/types/generated/src/models/PageOfOrderComments.ts
993
+ function PageOfOrderCommentsFromJSON(json) {
994
+ return PageOfOrderCommentsFromJSONTyped(json, false);
995
+ }
996
+ function PageOfOrderCommentsFromJSONTyped(json, ignoreDiscriminator) {
997
+ if (json == null) {
998
+ return json;
999
+ }
1000
+ return {
1001
+ "items": json["items"] == null ? void 0 : json["items"].map(OrderCommentFromJSON),
1002
+ "next_page": json["next_page"] == null ? void 0 : json["next_page"]
1003
+ };
1004
+ }
1005
+
1006
+ // src/types/generated/src/models/PageOfOrderStatusChanges.ts
1007
+ function PageOfOrderStatusChangesFromJSON(json) {
1008
+ return PageOfOrderStatusChangesFromJSONTyped(json, false);
1009
+ }
1010
+ function PageOfOrderStatusChangesFromJSONTyped(json, ignoreDiscriminator) {
1011
+ if (json == null) {
1012
+ return json;
1013
+ }
1014
+ return {
1015
+ "items": json["items"] == null ? void 0 : json["items"].map(OrderStatusChangeFromJSON),
1016
+ "next_page": json["next_page"] == null ? void 0 : json["next_page"]
1017
+ };
1018
+ }
1019
+
1020
+ // src/types/generated/src/models/ReturnLabel.ts
1021
+ function ReturnLabelFromJSON(json) {
1022
+ return ReturnLabelFromJSONTyped(json, false);
1023
+ }
1024
+ function ReturnLabelFromJSONTyped(json, ignoreDiscriminator) {
1025
+ if (json == null) {
1026
+ return json;
1027
+ }
1028
+ return {
1029
+ "number": json["number"] == null ? void 0 : json["number"],
1030
+ "delivery_method": json["delivery_method"] == null ? void 0 : json["delivery_method"]
1031
+ };
1032
+ }
1033
+
1034
+ // src/types/generated/src/models/TrackingNumberItem.ts
1035
+ function TrackingNumberItemFromJSON(json) {
1036
+ return TrackingNumberItemFromJSONTyped(json, false);
1037
+ }
1038
+ function TrackingNumberItemFromJSONTyped(json, ignoreDiscriminator) {
1039
+ if (json == null) {
1040
+ return json;
1041
+ }
1042
+ return {
1043
+ "doboxa_item_id": json["doboxa_item_id"] == null ? void 0 : json["doboxa_item_id"],
1044
+ "foreign_item_id": json["foreign_item_id"] == null ? void 0 : json["foreign_item_id"],
1045
+ "product_sku": json["product_sku"] == null ? void 0 : json["product_sku"]
1046
+ };
1047
+ }
1048
+
1049
+ // src/types/generated/src/models/TrackingNumber.ts
1050
+ function TrackingNumberFromJSON(json) {
1051
+ return TrackingNumberFromJSONTyped(json, false);
1052
+ }
1053
+ function TrackingNumberFromJSONTyped(json, ignoreDiscriminator) {
1054
+ if (json == null) {
1055
+ return json;
1056
+ }
1057
+ return {
1058
+ "order_id": json["order_id"] == null ? void 0 : json["order_id"],
1059
+ "number": json["number"] == null ? void 0 : json["number"],
1060
+ "delivery_method": json["delivery_method"] == null ? void 0 : json["delivery_method"],
1061
+ "sent_at": json["sent_at"] == null ? void 0 : new Date(json["sent_at"]),
1062
+ "created_at": json["created_at"] == null ? void 0 : new Date(json["created_at"]),
1063
+ "return_label": json["return_label"] == null ? void 0 : ReturnLabelFromJSON(json["return_label"]),
1064
+ "order_items": json["order_items"] == null ? void 0 : json["order_items"].map(TrackingNumberItemFromJSON)
1065
+ };
1066
+ }
1067
+
1068
+ // src/types/generated/src/models/PageOfTrackingNumbers.ts
1069
+ function PageOfTrackingNumbersFromJSON(json) {
1070
+ return PageOfTrackingNumbersFromJSONTyped(json, false);
1071
+ }
1072
+ function PageOfTrackingNumbersFromJSONTyped(json, ignoreDiscriminator) {
1073
+ if (json == null) {
1074
+ return json;
1075
+ }
1076
+ return {
1077
+ "items": json["items"] == null ? void 0 : json["items"].map(TrackingNumberFromJSON),
1078
+ "next_page": json["next_page"] == null ? void 0 : json["next_page"]
1079
+ };
1080
+ }
1081
+
1082
+ // src/types/generated/src/models/PostOrderCommentResponse.ts
1083
+ function PostOrderCommentResponseFromJSON(json) {
1084
+ return PostOrderCommentResponseFromJSONTyped(json, false);
1085
+ }
1086
+ function PostOrderCommentResponseFromJSONTyped(json, ignoreDiscriminator) {
1087
+ if (json == null) {
1088
+ return json;
1089
+ }
1090
+ return {
1091
+ "result_code": json["result_code"] == null ? void 0 : json["result_code"],
1092
+ "comment_id": json["comment_id"] == null ? void 0 : json["comment_id"]
1093
+ };
1094
+ }
1095
+
1096
+ // src/types/generated/src/models/PostOrderResponse.ts
1097
+ function PostOrderResponseFromJSON(json) {
1098
+ return PostOrderResponseFromJSONTyped(json, false);
1099
+ }
1100
+ function PostOrderResponseFromJSONTyped(json, ignoreDiscriminator) {
1101
+ if (json == null) {
1102
+ return json;
1103
+ }
1104
+ return {
1105
+ "result_code": json["result_code"] == null ? void 0 : json["result_code"],
1106
+ "order_id": json["order_id"] == null ? void 0 : json["order_id"]
1107
+ };
1108
+ }
1109
+
1110
+ // src/types/generated/src/models/PostOrderStatusItem.ts
1111
+ function PostOrderStatusItemToJSON(json) {
1112
+ return PostOrderStatusItemToJSONTyped(json, false);
1113
+ }
1114
+ function PostOrderStatusItemToJSONTyped(value, ignoreDiscriminator = false) {
1115
+ if (value == null) {
1116
+ return value;
1117
+ }
1118
+ return {
1119
+ "doboxa_item_id": value["doboxa_item_id"],
1120
+ "status": value["status"]
1121
+ };
1122
+ }
1123
+
1124
+ // src/types/generated/src/models/PostOrderStatus.ts
1125
+ function PostOrderStatusToJSON(json) {
1126
+ return PostOrderStatusToJSONTyped(json, false);
1127
+ }
1128
+ function PostOrderStatusToJSONTyped(value, ignoreDiscriminator = false) {
1129
+ if (value == null) {
1130
+ return value;
1131
+ }
1132
+ return {
1133
+ "status": value["status"],
1134
+ "item_status": value["item_status"] == null ? void 0 : value["item_status"].map(PostOrderStatusItemToJSON)
1135
+ };
1136
+ }
1137
+
1138
+ // src/types/generated/src/models/PostOrderStatusResponse.ts
1139
+ function PostOrderStatusResponseFromJSON(json) {
1140
+ return PostOrderStatusResponseFromJSONTyped(json, false);
1141
+ }
1142
+ function PostOrderStatusResponseFromJSONTyped(json, ignoreDiscriminator) {
1143
+ if (json == null) {
1144
+ return json;
1145
+ }
1146
+ return {
1147
+ "result_code": json["result_code"] == null ? void 0 : json["result_code"]
1148
+ };
1149
+ }
1150
+
1151
+ // src/types/generated/src/apis/OrderApi.ts
1152
+ var OrderApi = class extends BaseAPI {
1153
+ /**
1154
+ * Get a specific order comments
1155
+ */
1156
+ getAppEcommerceApiV2GetordercommentsInvokeRaw(requestParameters, initOverrides) {
1157
+ return __async(this, null, function* () {
1158
+ if (requestParameters["orderId"] == null) {
1159
+ throw new RequiredError(
1160
+ "orderId",
1161
+ 'Required parameter "orderId" was null or undefined when calling getAppEcommerceApiV2GetordercommentsInvoke().'
1162
+ );
1163
+ }
1164
+ const queryParameters = {};
1165
+ const headerParameters = {};
1166
+ if (this.configuration && this.configuration.apiKey) {
1167
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1168
+ }
1169
+ let urlPath = `/api/v2/order/{order_id}/comment`;
1170
+ urlPath = urlPath.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters["orderId"])));
1171
+ const response = yield this.request({
1172
+ path: urlPath,
1173
+ method: "GET",
1174
+ headers: headerParameters,
1175
+ query: queryParameters
1176
+ }, initOverrides);
1177
+ return new JSONApiResponse(response, (jsonValue) => PageOfOrderCommentsFromJSON(jsonValue));
1178
+ });
1179
+ }
1180
+ /**
1181
+ * Get a specific order comments
1182
+ */
1183
+ getAppEcommerceApiV2GetordercommentsInvoke(orderId, initOverrides) {
1184
+ return __async(this, null, function* () {
1185
+ const response = yield this.getAppEcommerceApiV2GetordercommentsInvokeRaw({ orderId }, initOverrides);
1186
+ return yield response.value();
1187
+ });
1188
+ }
1189
+ /**
1190
+ * Get Order invoices
1191
+ */
1192
+ getAppEcommerceApiV2GetorderinvoicesInvokeRaw(requestParameters, initOverrides) {
1193
+ return __async(this, null, function* () {
1194
+ if (requestParameters["orderId"] == null) {
1195
+ throw new RequiredError(
1196
+ "orderId",
1197
+ 'Required parameter "orderId" was null or undefined when calling getAppEcommerceApiV2GetorderinvoicesInvoke().'
1198
+ );
1199
+ }
1200
+ const queryParameters = {};
1201
+ const headerParameters = {};
1202
+ if (this.configuration && this.configuration.apiKey) {
1203
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1204
+ }
1205
+ let urlPath = `/api/v2/order/{order_id}/invoice`;
1206
+ urlPath = urlPath.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters["orderId"])));
1207
+ const response = yield this.request({
1208
+ path: urlPath,
1209
+ method: "GET",
1210
+ headers: headerParameters,
1211
+ query: queryParameters
1212
+ }, initOverrides);
1213
+ return new JSONApiResponse(response, (jsonValue) => PageOfInvoicesFromJSON(jsonValue));
1214
+ });
1215
+ }
1216
+ /**
1217
+ * Get Order invoices
1218
+ */
1219
+ getAppEcommerceApiV2GetorderinvoicesInvoke(orderId, initOverrides) {
1220
+ return __async(this, null, function* () {
1221
+ const response = yield this.getAppEcommerceApiV2GetorderinvoicesInvokeRaw({ orderId }, initOverrides);
1222
+ return yield response.value();
1223
+ });
1224
+ }
1225
+ /**
1226
+ * Get current order status
1227
+ */
1228
+ getAppEcommerceApiV2GetorderstatusInvokeRaw(requestParameters, initOverrides) {
1229
+ return __async(this, null, function* () {
1230
+ if (requestParameters["orderId"] == null) {
1231
+ throw new RequiredError(
1232
+ "orderId",
1233
+ 'Required parameter "orderId" was null or undefined when calling getAppEcommerceApiV2GetorderstatusInvoke().'
1234
+ );
1235
+ }
1236
+ const queryParameters = {};
1237
+ const headerParameters = {};
1238
+ if (this.configuration && this.configuration.apiKey) {
1239
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1240
+ }
1241
+ let urlPath = `/api/v2/order/{order_id}/status`;
1242
+ urlPath = urlPath.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters["orderId"])));
1243
+ const response = yield this.request({
1244
+ path: urlPath,
1245
+ method: "GET",
1246
+ headers: headerParameters,
1247
+ query: queryParameters
1248
+ }, initOverrides);
1249
+ return new JSONApiResponse(response, (jsonValue) => OrderStatusFromJSON(jsonValue));
1250
+ });
1251
+ }
1252
+ /**
1253
+ * Get current order status
1254
+ */
1255
+ getAppEcommerceApiV2GetorderstatusInvoke(orderId, initOverrides) {
1256
+ return __async(this, null, function* () {
1257
+ const response = yield this.getAppEcommerceApiV2GetorderstatusInvokeRaw({ orderId }, initOverrides);
1258
+ return yield response.value();
1259
+ });
1260
+ }
1261
+ /**
1262
+ * Get Order tracking numbers
1263
+ */
1264
+ getAppEcommerceApiV2GetordertrackingnumbersInvokeRaw(requestParameters, initOverrides) {
1265
+ return __async(this, null, function* () {
1266
+ if (requestParameters["orderId"] == null) {
1267
+ throw new RequiredError(
1268
+ "orderId",
1269
+ 'Required parameter "orderId" was null or undefined when calling getAppEcommerceApiV2GetordertrackingnumbersInvoke().'
1270
+ );
1271
+ }
1272
+ const queryParameters = {};
1273
+ const headerParameters = {};
1274
+ if (this.configuration && this.configuration.apiKey) {
1275
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1276
+ }
1277
+ let urlPath = `/api/v2/order/{order_id}/tracking_number`;
1278
+ urlPath = urlPath.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters["orderId"])));
1279
+ const response = yield this.request({
1280
+ path: urlPath,
1281
+ method: "GET",
1282
+ headers: headerParameters,
1283
+ query: queryParameters
1284
+ }, initOverrides);
1285
+ return new JSONApiResponse(response, (jsonValue) => PageOfTrackingNumbersFromJSON(jsonValue));
1286
+ });
1287
+ }
1288
+ /**
1289
+ * Get Order tracking numbers
1290
+ */
1291
+ getAppEcommerceApiV2GetordertrackingnumbersInvoke(orderId, initOverrides) {
1292
+ return __async(this, null, function* () {
1293
+ const response = yield this.getAppEcommerceApiV2GetordertrackingnumbersInvokeRaw({ orderId }, initOverrides);
1294
+ return yield response.value();
1295
+ });
1296
+ }
1297
+ /**
1298
+ * Create an Order
1299
+ */
1300
+ postAppEcommerceApiV2PostorderInvokeRaw(requestParameters, initOverrides) {
1301
+ return __async(this, null, function* () {
1302
+ if (requestParameters["order"] == null) {
1303
+ throw new RequiredError(
1304
+ "order",
1305
+ 'Required parameter "order" was null or undefined when calling postAppEcommerceApiV2PostorderInvoke().'
1306
+ );
1307
+ }
1308
+ const queryParameters = {};
1309
+ const headerParameters = {};
1310
+ headerParameters["Content-Type"] = "application/json";
1311
+ if (this.configuration && this.configuration.apiKey) {
1312
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1313
+ }
1314
+ let urlPath = `/api/v2/order`;
1315
+ const response = yield this.request({
1316
+ path: urlPath,
1317
+ method: "POST",
1318
+ headers: headerParameters,
1319
+ query: queryParameters,
1320
+ body: OrderToJSON(requestParameters["order"])
1321
+ }, initOverrides);
1322
+ return new JSONApiResponse(response, (jsonValue) => PostOrderResponseFromJSON(jsonValue));
1323
+ });
1324
+ }
1325
+ /**
1326
+ * Create an Order
1327
+ */
1328
+ postAppEcommerceApiV2PostorderInvoke(order, initOverrides) {
1329
+ return __async(this, null, function* () {
1330
+ const response = yield this.postAppEcommerceApiV2PostorderInvokeRaw({ order }, initOverrides);
1331
+ return yield response.value();
1332
+ });
1333
+ }
1334
+ /**
1335
+ * Create an Order comment
1336
+ */
1337
+ postAppEcommerceApiV2PostordercommentInvokeRaw(requestParameters, initOverrides) {
1338
+ return __async(this, null, function* () {
1339
+ if (requestParameters["orderId"] == null) {
1340
+ throw new RequiredError(
1341
+ "orderId",
1342
+ 'Required parameter "orderId" was null or undefined when calling postAppEcommerceApiV2PostordercommentInvoke().'
1343
+ );
1344
+ }
1345
+ if (requestParameters["createOrderComment"] == null) {
1346
+ throw new RequiredError(
1347
+ "createOrderComment",
1348
+ 'Required parameter "createOrderComment" was null or undefined when calling postAppEcommerceApiV2PostordercommentInvoke().'
1349
+ );
1350
+ }
1351
+ const queryParameters = {};
1352
+ const headerParameters = {};
1353
+ headerParameters["Content-Type"] = "application/json";
1354
+ if (this.configuration && this.configuration.apiKey) {
1355
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1356
+ }
1357
+ let urlPath = `/api/v2/order/{order_id}/comment`;
1358
+ urlPath = urlPath.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters["orderId"])));
1359
+ const response = yield this.request({
1360
+ path: urlPath,
1361
+ method: "POST",
1362
+ headers: headerParameters,
1363
+ query: queryParameters,
1364
+ body: CreateOrderCommentToJSON(requestParameters["createOrderComment"])
1365
+ }, initOverrides);
1366
+ return new JSONApiResponse(response, (jsonValue) => PostOrderCommentResponseFromJSON(jsonValue));
1367
+ });
1368
+ }
1369
+ /**
1370
+ * Create an Order comment
1371
+ */
1372
+ postAppEcommerceApiV2PostordercommentInvoke(orderId, createOrderComment, initOverrides) {
1373
+ return __async(this, null, function* () {
1374
+ const response = yield this.postAppEcommerceApiV2PostordercommentInvokeRaw({ orderId, createOrderComment }, initOverrides);
1375
+ return yield response.value();
1376
+ });
1377
+ }
1378
+ /**
1379
+ * Change Order status (only commision type or test orders)
1380
+ */
1381
+ postAppEcommerceApiV2PostorderstatuschangeInvokeRaw(requestParameters, initOverrides) {
1382
+ return __async(this, null, function* () {
1383
+ if (requestParameters["orderId"] == null) {
1384
+ throw new RequiredError(
1385
+ "orderId",
1386
+ 'Required parameter "orderId" was null or undefined when calling postAppEcommerceApiV2PostorderstatuschangeInvoke().'
1387
+ );
1388
+ }
1389
+ if (requestParameters["postOrderStatus"] == null) {
1390
+ throw new RequiredError(
1391
+ "postOrderStatus",
1392
+ 'Required parameter "postOrderStatus" was null or undefined when calling postAppEcommerceApiV2PostorderstatuschangeInvoke().'
1393
+ );
1394
+ }
1395
+ const queryParameters = {};
1396
+ const headerParameters = {};
1397
+ headerParameters["Content-Type"] = "application/json";
1398
+ if (this.configuration && this.configuration.apiKey) {
1399
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1400
+ }
1401
+ let urlPath = `/api/v2/order/{order_id}/status`;
1402
+ urlPath = urlPath.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters["orderId"])));
1403
+ const response = yield this.request({
1404
+ path: urlPath,
1405
+ method: "POST",
1406
+ headers: headerParameters,
1407
+ query: queryParameters,
1408
+ body: PostOrderStatusToJSON(requestParameters["postOrderStatus"])
1409
+ }, initOverrides);
1410
+ return new JSONApiResponse(response, (jsonValue) => PostOrderStatusResponseFromJSON(jsonValue));
1411
+ });
1412
+ }
1413
+ /**
1414
+ * Change Order status (only commision type or test orders)
1415
+ */
1416
+ postAppEcommerceApiV2PostorderstatuschangeInvoke(orderId, postOrderStatus, initOverrides) {
1417
+ return __async(this, null, function* () {
1418
+ const response = yield this.postAppEcommerceApiV2PostorderstatuschangeInvokeRaw({ orderId, postOrderStatus }, initOverrides);
1419
+ return yield response.value();
1420
+ });
1421
+ }
1422
+ };
1423
+
1424
+ // src/types/generated/src/apis/OrderCancellationApi.ts
1425
+ var OrderCancellationApi = class extends BaseAPI {
1426
+ /**
1427
+ * Cancel an order if possible (orders already in production cannot be cancelled)
1428
+ */
1429
+ postAppEcommerceApiV2PostordercancellationInvokeRaw(requestParameters, initOverrides) {
1430
+ return __async(this, null, function* () {
1431
+ if (requestParameters["orderCancellation"] == null) {
1432
+ throw new RequiredError(
1433
+ "orderCancellation",
1434
+ 'Required parameter "orderCancellation" was null or undefined when calling postAppEcommerceApiV2PostordercancellationInvoke().'
1435
+ );
1436
+ }
1437
+ const queryParameters = {};
1438
+ const headerParameters = {};
1439
+ headerParameters["Content-Type"] = "application/json";
1440
+ if (this.configuration && this.configuration.apiKey) {
1441
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1442
+ }
1443
+ let urlPath = `/api/v2/order_cancellation`;
1444
+ const response = yield this.request({
1445
+ path: urlPath,
1446
+ method: "POST",
1447
+ headers: headerParameters,
1448
+ query: queryParameters,
1449
+ body: OrderCancellationToJSON(requestParameters["orderCancellation"])
1450
+ }, initOverrides);
1451
+ return new JSONApiResponse(response, (jsonValue) => OrderCancellationResponseFromJSON(jsonValue));
1452
+ });
1453
+ }
1454
+ /**
1455
+ * Cancel an order if possible (orders already in production cannot be cancelled)
1456
+ */
1457
+ postAppEcommerceApiV2PostordercancellationInvoke(orderCancellation, initOverrides) {
1458
+ return __async(this, null, function* () {
1459
+ const response = yield this.postAppEcommerceApiV2PostordercancellationInvokeRaw({ orderCancellation }, initOverrides);
1460
+ return yield response.value();
1461
+ });
1462
+ }
1463
+ };
1464
+
1465
+ // src/resources/orders.ts
1466
+ var OrdersResource = class {
1467
+ constructor(httpClient, config) {
1468
+ this.httpClient = httpClient;
1469
+ this.orderApi = new OrderApi(config);
1470
+ this.cancellationApi = new OrderCancellationApi(config);
1471
+ }
1472
+ /**
1473
+ * Create an order
1474
+ */
1475
+ create(params) {
1476
+ return __async(this, null, function* () {
1477
+ return this.orderApi.postAppEcommerceApiV2PostorderInvoke(params);
1478
+ });
1479
+ }
1480
+ /**
1481
+ * Get current order status
1482
+ */
1483
+ getStatus(orderId) {
1484
+ return __async(this, null, function* () {
1485
+ return this.orderApi.getAppEcommerceApiV2GetorderstatusInvoke(orderId);
1486
+ });
1487
+ }
1488
+ /**
1489
+ * Update order status
1490
+ */
1491
+ updateStatus(orderId, params) {
1492
+ return __async(this, null, function* () {
1493
+ return this.orderApi.postAppEcommerceApiV2PostorderstatuschangeInvoke(
1494
+ orderId,
1495
+ params
1496
+ );
1497
+ });
1498
+ }
1499
+ /**
1500
+ * Get order comments
1501
+ */
1502
+ getComments(orderId) {
1503
+ return __async(this, null, function* () {
1504
+ return this.orderApi.getAppEcommerceApiV2GetordercommentsInvoke(orderId);
1505
+ });
1506
+ }
1507
+ /**
1508
+ * Create an order comment
1509
+ */
1510
+ createComment(orderId, params) {
1511
+ return __async(this, null, function* () {
1512
+ return this.orderApi.postAppEcommerceApiV2PostordercommentInvoke(
1513
+ orderId,
1514
+ params
1515
+ );
1516
+ });
1517
+ }
1518
+ /**
1519
+ * Get order invoices
1520
+ */
1521
+ getInvoices(orderId) {
1522
+ return __async(this, null, function* () {
1523
+ return this.orderApi.getAppEcommerceApiV2GetorderinvoicesInvoke(orderId);
1524
+ });
1525
+ }
1526
+ /**
1527
+ * Get order tracking numbers
1528
+ */
1529
+ getTrackingNumbers(orderId) {
1530
+ return __async(this, null, function* () {
1531
+ return this.orderApi.getAppEcommerceApiV2GetordertrackingnumbersInvoke(orderId);
1532
+ });
1533
+ }
1534
+ /**
1535
+ * Cancel an order
1536
+ */
1537
+ cancel(params) {
1538
+ return __async(this, null, function* () {
1539
+ const cancellation = {
1540
+ order_id: params.order_id
1541
+ };
1542
+ return this.cancellationApi.postAppEcommerceApiV2PostordercancellationInvoke(
1543
+ cancellation
1544
+ );
1545
+ });
1546
+ }
1547
+ };
1548
+
1549
+ // src/types/generated/src/apis/InvoiceApi.ts
1550
+ var InvoiceApi = class extends BaseAPI {
1551
+ /**
1552
+ * Get a specific invoice
1553
+ */
1554
+ getAppEcommerceApiV2GetinvoiceInvokeRaw(requestParameters, initOverrides) {
1555
+ return __async(this, null, function* () {
1556
+ if (requestParameters["invoiceId"] == null) {
1557
+ throw new RequiredError(
1558
+ "invoiceId",
1559
+ 'Required parameter "invoiceId" was null or undefined when calling getAppEcommerceApiV2GetinvoiceInvoke().'
1560
+ );
1561
+ }
1562
+ const queryParameters = {};
1563
+ const headerParameters = {};
1564
+ if (this.configuration && this.configuration.apiKey) {
1565
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1566
+ }
1567
+ let urlPath = `/api/v2/invoice/{invoice_id}`;
1568
+ urlPath = urlPath.replace(`{${"invoice_id"}}`, encodeURIComponent(String(requestParameters["invoiceId"])));
1569
+ const response = yield this.request({
1570
+ path: urlPath,
1571
+ method: "GET",
1572
+ headers: headerParameters,
1573
+ query: queryParameters
1574
+ }, initOverrides);
1575
+ return new JSONApiResponse(response, (jsonValue) => InvoiceFromJSON(jsonValue));
1576
+ });
1577
+ }
1578
+ /**
1579
+ * Get a specific invoice
1580
+ */
1581
+ getAppEcommerceApiV2GetinvoiceInvoke(invoiceId, initOverrides) {
1582
+ return __async(this, null, function* () {
1583
+ const response = yield this.getAppEcommerceApiV2GetinvoiceInvokeRaw({ invoiceId }, initOverrides);
1584
+ return yield response.value();
1585
+ });
1586
+ }
1587
+ /**
1588
+ * Get latest invoices
1589
+ */
1590
+ getAppEcommerceApiV2GetinvoicesInvokeRaw(requestParameters, initOverrides) {
1591
+ return __async(this, null, function* () {
1592
+ const queryParameters = {};
1593
+ if (requestParameters["page"] != null) {
1594
+ queryParameters["page"] = requestParameters["page"];
1595
+ }
1596
+ if (requestParameters["from"] != null) {
1597
+ queryParameters["from"] = requestParameters["from"];
1598
+ }
1599
+ if (requestParameters["to"] != null) {
1600
+ queryParameters["to"] = requestParameters["to"];
1601
+ }
1602
+ const headerParameters = {};
1603
+ if (this.configuration && this.configuration.apiKey) {
1604
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1605
+ }
1606
+ let urlPath = `/api/v2/invoice`;
1607
+ const response = yield this.request({
1608
+ path: urlPath,
1609
+ method: "GET",
1610
+ headers: headerParameters,
1611
+ query: queryParameters
1612
+ }, initOverrides);
1613
+ return new JSONApiResponse(response, (jsonValue) => PageOfInvoicesFromJSON(jsonValue));
1614
+ });
1615
+ }
1616
+ /**
1617
+ * Get latest invoices
1618
+ */
1619
+ getAppEcommerceApiV2GetinvoicesInvoke(page, from, to, initOverrides) {
1620
+ return __async(this, null, function* () {
1621
+ const response = yield this.getAppEcommerceApiV2GetinvoicesInvokeRaw({ page, from, to }, initOverrides);
1622
+ return yield response.value();
1623
+ });
1624
+ }
1625
+ };
1626
+
1627
+ // src/resources/invoices.ts
1628
+ var InvoicesResource = class {
1629
+ constructor(httpClient, config) {
1630
+ this.httpClient = httpClient;
1631
+ this.invoiceApi = new InvoiceApi(config);
1632
+ }
1633
+ /**
1634
+ * List invoices
1635
+ */
1636
+ list(params) {
1637
+ return __async(this, null, function* () {
1638
+ return this.invoiceApi.getAppEcommerceApiV2GetinvoicesInvoke(
1639
+ params == null ? void 0 : params.page,
1640
+ (params == null ? void 0 : params.from) ? new Date(params.from) : void 0,
1641
+ (params == null ? void 0 : params.to) ? new Date(params.to) : void 0
1642
+ );
1643
+ });
1644
+ }
1645
+ /**
1646
+ * Retrieve a specific invoice
1647
+ */
1648
+ retrieve(invoiceId) {
1649
+ return __async(this, null, function* () {
1650
+ return this.invoiceApi.getAppEcommerceApiV2GetinvoiceInvoke(invoiceId);
1651
+ });
1652
+ }
1653
+ };
1654
+
1655
+ // src/types/generated/src/apis/ClientApi.ts
1656
+ var ClientApi = class extends BaseAPI {
1657
+ /**
1658
+ * Get clients (only commission type)
1659
+ */
1660
+ getAppEcommerceApiV2GetclientsInvokeRaw(requestParameters, initOverrides) {
1661
+ return __async(this, null, function* () {
1662
+ const queryParameters = {};
1663
+ if (requestParameters["page"] != null) {
1664
+ queryParameters["page"] = requestParameters["page"];
1665
+ }
1666
+ const headerParameters = {};
1667
+ if (this.configuration && this.configuration.apiKey) {
1668
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1669
+ }
1670
+ let urlPath = `/api/v2/client`;
1671
+ const response = yield this.request({
1672
+ path: urlPath,
1673
+ method: "GET",
1674
+ headers: headerParameters,
1675
+ query: queryParameters
1676
+ }, initOverrides);
1677
+ return new JSONApiResponse(response, (jsonValue) => PageOfClientsFromJSON(jsonValue));
1678
+ });
1679
+ }
1680
+ /**
1681
+ * Get clients (only commission type)
1682
+ */
1683
+ getAppEcommerceApiV2GetclientsInvoke(page, initOverrides) {
1684
+ return __async(this, null, function* () {
1685
+ const response = yield this.getAppEcommerceApiV2GetclientsInvokeRaw({ page }, initOverrides);
1686
+ return yield response.value();
1687
+ });
1688
+ }
1689
+ };
1690
+
1691
+ // src/resources/clients.ts
1692
+ var ClientsResource = class {
1693
+ constructor(httpClient, config) {
1694
+ this.httpClient = httpClient;
1695
+ this.clientApi = new ClientApi(config);
1696
+ }
1697
+ /**
1698
+ * List clients (only commission type)
1699
+ */
1700
+ list(params) {
1701
+ return __async(this, null, function* () {
1702
+ return this.clientApi.getAppEcommerceApiV2GetclientsInvoke(params == null ? void 0 : params.page);
1703
+ });
1704
+ }
1705
+ };
1706
+
1707
+ // src/types/generated/src/apis/DiscountCodeApi.ts
1708
+ var DiscountCodeApi = class extends BaseAPI {
1709
+ /**
1710
+ * Get discount codes (only commission type)
1711
+ */
1712
+ getApiV2DiscountCodesExternalRaw(requestParameters, initOverrides) {
1713
+ return __async(this, null, function* () {
1714
+ const queryParameters = {};
1715
+ if (requestParameters["page"] != null) {
1716
+ queryParameters["page"] = requestParameters["page"];
1717
+ }
1718
+ const headerParameters = {};
1719
+ if (this.configuration && this.configuration.apiKey) {
1720
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1721
+ }
1722
+ let urlPath = `/api/v2/discount_code`;
1723
+ const response = yield this.request({
1724
+ path: urlPath,
1725
+ method: "GET",
1726
+ headers: headerParameters,
1727
+ query: queryParameters
1728
+ }, initOverrides);
1729
+ return new JSONApiResponse(response, (jsonValue) => GetApiV2DiscountCodesExternal200ResponseFromJSON(jsonValue));
1730
+ });
1731
+ }
1732
+ /**
1733
+ * Get discount codes (only commission type)
1734
+ */
1735
+ getApiV2DiscountCodesExternal(page, initOverrides) {
1736
+ return __async(this, null, function* () {
1737
+ const response = yield this.getApiV2DiscountCodesExternalRaw({ page }, initOverrides);
1738
+ return yield response.value();
1739
+ });
1740
+ }
1741
+ };
1742
+
1743
+ // src/resources/discountCodes.ts
1744
+ var DiscountCodesResource = class {
1745
+ constructor(httpClient, config) {
1746
+ this.httpClient = httpClient;
1747
+ this.discountCodeApi = new DiscountCodeApi(config);
1748
+ }
1749
+ /**
1750
+ * List discount codes (only commission type)
1751
+ */
1752
+ list(params) {
1753
+ return __async(this, null, function* () {
1754
+ return this.discountCodeApi.getApiV2DiscountCodesExternal(params == null ? void 0 : params.page);
1755
+ });
1756
+ }
1757
+ };
1758
+
1759
+ // src/types/generated/src/apis/TrackingNumberApi.ts
1760
+ var TrackingNumberApi = class extends BaseAPI {
1761
+ /**
1762
+ * Get latest tracking numbers
1763
+ */
1764
+ getAppEcommerceApiV2GettrackingnumbersInvokeRaw(requestParameters, initOverrides) {
1765
+ return __async(this, null, function* () {
1766
+ const queryParameters = {};
1767
+ if (requestParameters["page"] != null) {
1768
+ queryParameters["page"] = requestParameters["page"];
1769
+ }
1770
+ if (requestParameters["from"] != null) {
1771
+ queryParameters["from"] = requestParameters["from"];
1772
+ }
1773
+ if (requestParameters["to"] != null) {
1774
+ queryParameters["to"] = requestParameters["to"];
1775
+ }
1776
+ const headerParameters = {};
1777
+ if (this.configuration && this.configuration.apiKey) {
1778
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1779
+ }
1780
+ let urlPath = `/api/v2/tracking_number`;
1781
+ const response = yield this.request({
1782
+ path: urlPath,
1783
+ method: "GET",
1784
+ headers: headerParameters,
1785
+ query: queryParameters
1786
+ }, initOverrides);
1787
+ return new JSONApiResponse(response, (jsonValue) => PageOfTrackingNumbersFromJSON(jsonValue));
1788
+ });
1789
+ }
1790
+ /**
1791
+ * Get latest tracking numbers
1792
+ */
1793
+ getAppEcommerceApiV2GettrackingnumbersInvoke(page, from, to, initOverrides) {
1794
+ return __async(this, null, function* () {
1795
+ const response = yield this.getAppEcommerceApiV2GettrackingnumbersInvokeRaw({ page, from, to }, initOverrides);
1796
+ return yield response.value();
1797
+ });
1798
+ }
1799
+ };
1800
+
1801
+ // src/resources/trackingNumbers.ts
1802
+ var TrackingNumbersResource = class {
1803
+ constructor(httpClient, config) {
1804
+ this.httpClient = httpClient;
1805
+ this.trackingNumberApi = new TrackingNumberApi(config);
1806
+ }
1807
+ /**
1808
+ * List tracking numbers
1809
+ */
1810
+ list(params) {
1811
+ return __async(this, null, function* () {
1812
+ return this.trackingNumberApi.getAppEcommerceApiV2GettrackingnumbersInvoke(
1813
+ params == null ? void 0 : params.page,
1814
+ (params == null ? void 0 : params.from) ? new Date(params.from) : void 0,
1815
+ (params == null ? void 0 : params.to) ? new Date(params.to) : void 0
1816
+ );
1817
+ });
1818
+ }
1819
+ };
1820
+
1821
+ // src/types/generated/src/apis/OrderCommentApi.ts
1822
+ var OrderCommentApi = class extends BaseAPI {
1823
+ /**
1824
+ * Get latest order comments.
1825
+ */
1826
+ getAppEcommerceApiV2GetorderscommentsInvokeRaw(requestParameters, initOverrides) {
1827
+ return __async(this, null, function* () {
1828
+ const queryParameters = {};
1829
+ if (requestParameters["page"] != null) {
1830
+ queryParameters["page"] = requestParameters["page"];
1831
+ }
1832
+ if (requestParameters["from"] != null) {
1833
+ queryParameters["from"] = requestParameters["from"];
1834
+ }
1835
+ if (requestParameters["to"] != null) {
1836
+ queryParameters["to"] = requestParameters["to"];
1837
+ }
1838
+ const headerParameters = {};
1839
+ if (this.configuration && this.configuration.apiKey) {
1840
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1841
+ }
1842
+ let urlPath = `/api/v2/order_comment`;
1843
+ const response = yield this.request({
1844
+ path: urlPath,
1845
+ method: "GET",
1846
+ headers: headerParameters,
1847
+ query: queryParameters
1848
+ }, initOverrides);
1849
+ return new JSONApiResponse(response, (jsonValue) => PageOfOrderCommentsFromJSON(jsonValue));
1850
+ });
1851
+ }
1852
+ /**
1853
+ * Get latest order comments.
1854
+ */
1855
+ getAppEcommerceApiV2GetorderscommentsInvoke(page, from, to, initOverrides) {
1856
+ return __async(this, null, function* () {
1857
+ const response = yield this.getAppEcommerceApiV2GetorderscommentsInvokeRaw({ page, from, to }, initOverrides);
1858
+ return yield response.value();
1859
+ });
1860
+ }
1861
+ };
1862
+
1863
+ // src/resources/orderComments.ts
1864
+ var OrderCommentsResource = class {
1865
+ constructor(httpClient, config) {
1866
+ this.httpClient = httpClient;
1867
+ this.orderCommentApi = new OrderCommentApi(config);
1868
+ }
1869
+ /**
1870
+ * List order comments
1871
+ */
1872
+ list(params) {
1873
+ return __async(this, null, function* () {
1874
+ return this.orderCommentApi.getAppEcommerceApiV2GetorderscommentsInvoke(
1875
+ params == null ? void 0 : params.page,
1876
+ (params == null ? void 0 : params.from) ? new Date(params.from) : void 0,
1877
+ (params == null ? void 0 : params.to) ? new Date(params.to) : void 0
1878
+ );
1879
+ });
1880
+ }
1881
+ };
1882
+
1883
+ // src/types/generated/src/apis/OrderStatusChangeApi.ts
1884
+ var OrderStatusChangeApi = class extends BaseAPI {
1885
+ /**
1886
+ * Get latest status changes. Note that only the latest order status change is provided.
1887
+ */
1888
+ getAppEcommerceApiV2GetorderstatuschangesInvokeRaw(requestParameters, initOverrides) {
1889
+ return __async(this, null, function* () {
1890
+ const queryParameters = {};
1891
+ if (requestParameters["page"] != null) {
1892
+ queryParameters["page"] = requestParameters["page"];
1893
+ }
1894
+ if (requestParameters["from"] != null) {
1895
+ queryParameters["from"] = requestParameters["from"];
1896
+ }
1897
+ if (requestParameters["to"] != null) {
1898
+ queryParameters["to"] = requestParameters["to"];
1899
+ }
1900
+ const headerParameters = {};
1901
+ if (this.configuration && this.configuration.apiKey) {
1902
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1903
+ }
1904
+ let urlPath = `/api/v2/order_status_change`;
1905
+ const response = yield this.request({
1906
+ path: urlPath,
1907
+ method: "GET",
1908
+ headers: headerParameters,
1909
+ query: queryParameters
1910
+ }, initOverrides);
1911
+ return new JSONApiResponse(response, (jsonValue) => PageOfOrderStatusChangesFromJSON(jsonValue));
1912
+ });
1913
+ }
1914
+ /**
1915
+ * Get latest status changes. Note that only the latest order status change is provided.
1916
+ */
1917
+ getAppEcommerceApiV2GetorderstatuschangesInvoke(page, from, to, initOverrides) {
1918
+ return __async(this, null, function* () {
1919
+ const response = yield this.getAppEcommerceApiV2GetorderstatuschangesInvokeRaw({ page, from, to }, initOverrides);
1920
+ return yield response.value();
1921
+ });
1922
+ }
1923
+ };
1924
+
1925
+ // src/resources/orderStatusChanges.ts
1926
+ var OrderStatusChangesResource = class {
1927
+ constructor(httpClient, config) {
1928
+ this.httpClient = httpClient;
1929
+ this.orderStatusChangeApi = new OrderStatusChangeApi(config);
1930
+ }
1931
+ /**
1932
+ * List order status changes
1933
+ */
1934
+ list(params) {
1935
+ return __async(this, null, function* () {
1936
+ return this.orderStatusChangeApi.getAppEcommerceApiV2GetorderstatuschangesInvoke(
1937
+ params == null ? void 0 : params.page,
1938
+ (params == null ? void 0 : params.from) ? new Date(params.from) : void 0,
1939
+ (params == null ? void 0 : params.to) ? new Date(params.to) : void 0
1940
+ );
1941
+ });
1942
+ }
1943
+ };
1944
+
1945
+ // src/types/generated/src/apis/UserApi.ts
1946
+ var UserApi = class extends BaseAPI {
1947
+ /**
1948
+ * Validate your access token
1949
+ */
1950
+ getAppEcommerceApiV2GetmeInvokeRaw(initOverrides) {
1951
+ return __async(this, null, function* () {
1952
+ const queryParameters = {};
1953
+ const headerParameters = {};
1954
+ if (this.configuration && this.configuration.apiKey) {
1955
+ headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization");
1956
+ }
1957
+ let urlPath = `/api/v2/user/me`;
1958
+ const response = yield this.request({
1959
+ path: urlPath,
1960
+ method: "GET",
1961
+ headers: headerParameters,
1962
+ query: queryParameters
1963
+ }, initOverrides);
1964
+ return new JSONApiResponse(response, (jsonValue) => MeFromJSON(jsonValue));
1965
+ });
1966
+ }
1967
+ /**
1968
+ * Validate your access token
1969
+ */
1970
+ getAppEcommerceApiV2GetmeInvoke(initOverrides) {
1971
+ return __async(this, null, function* () {
1972
+ const response = yield this.getAppEcommerceApiV2GetmeInvokeRaw(initOverrides);
1973
+ return yield response.value();
1974
+ });
1975
+ }
1976
+ };
1977
+
1978
+ // src/resources/users.ts
1979
+ var UsersResource = class {
1980
+ constructor(httpClient, config) {
1981
+ this.httpClient = httpClient;
1982
+ this.userApi = new UserApi(config);
1983
+ }
1984
+ /**
1985
+ * Get current user (validate access token)
1986
+ */
1987
+ me() {
1988
+ return __async(this, null, function* () {
1989
+ return this.userApi.getAppEcommerceApiV2GetmeInvoke();
1990
+ });
1991
+ }
1992
+ };
1993
+
1994
+ // src/client.ts
1995
+ var Doboxa = class {
1996
+ constructor(config = {}) {
1997
+ const baseURL = config.baseURL || getBaseURL() || "https://pl.doboxa.biz";
1998
+ this.tokenManager = new TokenManager();
1999
+ if (config.apiKey) {
2000
+ this.tokenManager.setTokens(config.apiKey, "", 3600);
2001
+ }
2002
+ this.config = new Configuration({
2003
+ basePath: baseURL,
2004
+ apiKey: (name) => __async(this, null, function* () {
2005
+ if (name === "Authorization") {
2006
+ const token = this.tokenManager.getAccessToken();
2007
+ if (!token) {
2008
+ throw new Error("No access token available");
2009
+ }
2010
+ return `Bearer ${token}`;
2011
+ }
2012
+ throw new Error(`Unknown API key name: ${name}`);
2013
+ })
2014
+ });
2015
+ const tempHttpClient = new HTTPClient({
2016
+ baseURL,
2017
+ tokenManager: this.tokenManager
2018
+ });
2019
+ this.httpClient = new HTTPClient({
2020
+ baseURL,
2021
+ tokenManager: this.tokenManager,
2022
+ onTokenRefresh: (refreshToken) => __async(this, null, function* () {
2023
+ const tempAuth = new AuthenticationResource(
2024
+ tempHttpClient,
2025
+ this.tokenManager
2026
+ );
2027
+ const response = yield tempAuth.refreshToken(refreshToken);
2028
+ this.tokenManager.setTokens(
2029
+ response.token,
2030
+ response.refresh_token,
2031
+ 3600
2032
+ );
2033
+ return response.token;
2034
+ })
2035
+ });
2036
+ this.authentication = new AuthenticationResource(
2037
+ this.httpClient,
2038
+ this.tokenManager
2039
+ );
2040
+ this.orders = new OrdersResource(this.httpClient, this.config);
2041
+ this.invoices = new InvoicesResource(this.httpClient, this.config);
2042
+ this.clients = new ClientsResource(this.httpClient, this.config);
2043
+ this.discountCodes = new DiscountCodesResource(
2044
+ this.httpClient,
2045
+ this.config
2046
+ );
2047
+ this.trackingNumbers = new TrackingNumbersResource(
2048
+ this.httpClient,
2049
+ this.config
2050
+ );
2051
+ this.orderComments = new OrderCommentsResource(
2052
+ this.httpClient,
2053
+ this.config
2054
+ );
2055
+ this.orderStatusChanges = new OrderStatusChangesResource(
2056
+ this.httpClient,
2057
+ this.config
2058
+ );
2059
+ this.users = new UsersResource(this.httpClient, this.config);
2060
+ }
2061
+ };
2062
+ // Annotate the CommonJS export names for ESM import in node:
2063
+ 0 && (module.exports = {
2064
+ Doboxa
2065
+ });
2066
+ //# sourceMappingURL=client.js.map