doboxa-js 1.0.1 → 1.0.2

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