@myparcel-dev/sdk 4.1.0

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 (107) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +15 -0
  3. package/lib/createMyParcelSdk.d.ts +14 -0
  4. package/lib/createMyParcelSdk.spec.d.ts +1 -0
  5. package/lib/createPrivateSdk.d.ts +7 -0
  6. package/lib/createPrivateSdk.spec.d.ts +1 -0
  7. package/lib/createPublicSdk.d.ts +7 -0
  8. package/lib/endpoints/endpoints.spec.d.ts +1 -0
  9. package/lib/endpoints/index.d.ts +2 -0
  10. package/lib/endpoints/private/account-messages/AccountMessages.types.d.ts +6 -0
  11. package/lib/endpoints/private/account-messages/DeleteAccountMessage.d.ts +19 -0
  12. package/lib/endpoints/private/account-messages/GetAccountMessages.d.ts +19 -0
  13. package/lib/endpoints/private/account-messages/index.d.ts +3 -0
  14. package/lib/endpoints/private/accounts/Account.types.d.ts +58 -0
  15. package/lib/endpoints/private/accounts/GetAccount.d.ts +19 -0
  16. package/lib/endpoints/private/accounts/GetAccounts.d.ts +13 -0
  17. package/lib/endpoints/private/accounts/PutAccount.d.ts +18 -0
  18. package/lib/endpoints/private/accounts/index.d.ts +4 -0
  19. package/lib/endpoints/private/api-key/ApiKey.types.d.ts +12 -0
  20. package/lib/endpoints/private/api-key/GetApiKeys.d.ts +16 -0
  21. package/lib/endpoints/private/api-key/PostApiKeys.d.ts +19 -0
  22. package/lib/endpoints/private/api-key/index.d.ts +3 -0
  23. package/lib/endpoints/private/carrier-options/CarrierOption.types.d.ts +46 -0
  24. package/lib/endpoints/private/carrier-options/DeleteCarrierOptions.d.ts +17 -0
  25. package/lib/endpoints/private/carrier-options/GetCarrierOptions.d.ts +17 -0
  26. package/lib/endpoints/private/carrier-options/PostCarrierOptions.d.ts +19 -0
  27. package/lib/endpoints/private/carrier-options/PutCarrierOptions.d.ts +21 -0
  28. package/lib/endpoints/private/carrier-options/index.d.ts +5 -0
  29. package/lib/endpoints/private/index.d.ts +13 -0
  30. package/lib/endpoints/private/locations/GetLocations.d.ts +14 -0
  31. package/lib/endpoints/private/locations/Location.types.d.ts +9 -0
  32. package/lib/endpoints/private/locations/index.d.ts +2 -0
  33. package/lib/endpoints/private/shipments/GetShipment.d.ts +19 -0
  34. package/lib/endpoints/private/shipments/GetShipments.d.ts +22 -0
  35. package/lib/endpoints/private/shipments/PatchShipment.d.ts +21 -0
  36. package/lib/endpoints/private/shipments/PostShipments.d.ts +23 -0
  37. package/lib/endpoints/private/shipments/Shipment.types.d.ts +175 -0
  38. package/lib/endpoints/private/shipments/index.d.ts +4 -0
  39. package/lib/endpoints/private/shops/GetShop.d.ts +19 -0
  40. package/lib/endpoints/private/shops/PostShop.d.ts +22 -0
  41. package/lib/endpoints/private/shops/PostShopDuplicate.d.ts +23 -0
  42. package/lib/endpoints/private/shops/PutShop.d.ts +16 -0
  43. package/lib/endpoints/private/shops/Shop.types.d.ts +80 -0
  44. package/lib/endpoints/private/shops/index.d.ts +5 -0
  45. package/lib/endpoints/private/subscription-capabilities/GetSubscriptionCapabilities.d.ts +17 -0
  46. package/lib/endpoints/private/subscription-capabilities/SubscriptionCapability.types.d.ts +23 -0
  47. package/lib/endpoints/private/subscription-capabilities/index.d.ts +2 -0
  48. package/lib/endpoints/private/subscriptions/DeleteSubscription.d.ts +16 -0
  49. package/lib/endpoints/private/subscriptions/GetSubscriptions.d.ts +17 -0
  50. package/lib/endpoints/private/subscriptions/PatchSubscriptions.d.ts +19 -0
  51. package/lib/endpoints/private/subscriptions/PostSubscriptions.d.ts +19 -0
  52. package/lib/endpoints/private/subscriptions/Subscriptions.types.d.ts +30 -0
  53. package/lib/endpoints/private/subscriptions/index.d.ts +5 -0
  54. package/lib/endpoints/private/system-country-codes/GetSystemCountryCodes.d.ts +14 -0
  55. package/lib/endpoints/private/system-country-codes/SystemCountryCodes.types.d.ts +10 -0
  56. package/lib/endpoints/private/system-country-codes/index.d.ts +2 -0
  57. package/lib/endpoints/private/system-messages/GetSystemMessages.d.ts +16 -0
  58. package/lib/endpoints/private/system-messages/SystemMessage.types.d.ts +18 -0
  59. package/lib/endpoints/private/system-messages/index.d.ts +2 -0
  60. package/lib/endpoints/private/track-traces/GetTrackAndTraceByShipment.d.ts +16 -0
  61. package/lib/endpoints/private/track-traces/TrackTraces.types.d.ts +50 -0
  62. package/lib/endpoints/private/track-traces/index.d.ts +2 -0
  63. package/lib/endpoints/private/webhook-subscriptions/DeleteWebhookSubscriptions.d.ts +16 -0
  64. package/lib/endpoints/private/webhook-subscriptions/GetWebhookSubscriptions.d.ts +14 -0
  65. package/lib/endpoints/private/webhook-subscriptions/PostWebhookSubscriptions.d.ts +19 -0
  66. package/lib/endpoints/private/webhook-subscriptions/Webhook.types.d.ts +13 -0
  67. package/lib/endpoints/private/webhook-subscriptions/index.d.ts +4 -0
  68. package/lib/endpoints/public/carriers/Carrier.types.d.ts +10 -0
  69. package/lib/endpoints/public/carriers/GetCarrier.d.ts +19 -0
  70. package/lib/endpoints/public/carriers/GetCarriers.d.ts +15 -0
  71. package/lib/endpoints/public/carriers/index.d.ts +3 -0
  72. package/lib/endpoints/public/delivery-options/DeliveryOption.types.d.ts +22 -0
  73. package/lib/endpoints/public/delivery-options/GetDeliveryOptions.d.ts +49 -0
  74. package/lib/endpoints/public/delivery-options/index.d.ts +2 -0
  75. package/lib/endpoints/public/index.d.ts +3 -0
  76. package/lib/endpoints/public/pickup-locations/GetPickupLocations.d.ts +17 -0
  77. package/lib/endpoints/public/pickup-locations/PickupLocation.types.d.ts +31 -0
  78. package/lib/endpoints/public/pickup-locations/index.d.ts +2 -0
  79. package/lib/index.cjs +1 -0
  80. package/lib/index.d.ts +6 -0
  81. package/lib/index.js +622 -0
  82. package/lib/index.spec.d.ts +1 -0
  83. package/lib/model/client/AbstractClient.d.ts +78 -0
  84. package/lib/model/client/AbstractClient.spec.d.ts +1 -0
  85. package/lib/model/client/AbstractClient.types.d.ts +49 -0
  86. package/lib/model/client/FetchClient.d.ts +6 -0
  87. package/lib/model/client/helper/addParameters.d.ts +3 -0
  88. package/lib/model/client/helper/addParameters.spec.d.ts +1 -0
  89. package/lib/model/client/helper/index.d.ts +2 -0
  90. package/lib/model/client/helper/isJson.d.ts +1 -0
  91. package/lib/model/client/helper/isJson.spec.d.ts +1 -0
  92. package/lib/model/client/index.d.ts +4 -0
  93. package/lib/model/endpoint/AbstractEndpoint.d.ts +56 -0
  94. package/lib/model/endpoint/AbstractEndpoint.types.d.ts +20 -0
  95. package/lib/model/endpoint/AbstractPrivateEndpoint.d.ts +13 -0
  96. package/lib/model/endpoint/AbstractPublicEndpoint.d.ts +5 -0
  97. package/lib/model/endpoint/index.d.ts +4 -0
  98. package/lib/model/exception/ApiException.d.ts +5 -0
  99. package/lib/model/exception/UserException.d.ts +4 -0
  100. package/lib/model/exception/index.d.ts +2 -0
  101. package/lib/model/index.d.ts +3 -0
  102. package/lib/types/common.types.d.ts +31 -0
  103. package/lib/types/data.types.d.ts +23 -0
  104. package/lib/types/global.types.d.ts +4 -0
  105. package/lib/types/index.d.ts +4 -0
  106. package/lib/types/request.types.d.ts +18 -0
  107. package/package.json +80 -0
package/lib/index.js ADDED
@@ -0,0 +1,622 @@
1
+ var x = Object.defineProperty;
2
+ var T = (s, t, r) => t in s ? x(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
3
+ var e = (s, t, r) => (T(s, typeof t != "symbol" ? t + "" : t, r), r);
4
+ import { isOfType as u } from "@myparcel/ts-utils";
5
+ class h extends Error {
6
+ constructor(r) {
7
+ super(r);
8
+ e(this, "name", "user");
9
+ Object.setPrototypeOf(this, h.prototype), this.name = "UserException";
10
+ }
11
+ }
12
+ class y extends Error {
13
+ constructor(r) {
14
+ super(r.message);
15
+ e(this, "data");
16
+ Object.setPrototypeOf(this, y.prototype), this.name = "ApiException", this.data = r;
17
+ }
18
+ }
19
+ const _ = (s, t) => {
20
+ if (t) {
21
+ const r = Object.entries(t).map(([a, i]) => `${a}=${i}`);
22
+ r.length && (s += `?${r.join("&")}`);
23
+ }
24
+ return s;
25
+ }, O = "https://api.myparcel.nl", C = ["POST", "PUT"];
26
+ class A {
27
+ constructor(t) {
28
+ /**
29
+ * Base URL to make requests to.
30
+ *
31
+ * @protected
32
+ */
33
+ e(this, "baseUrl");
34
+ /**
35
+ * Headers to use with requests.
36
+ *
37
+ * @protected
38
+ */
39
+ e(this, "headers");
40
+ /**
41
+ * @protected
42
+ */
43
+ e(this, "parameters");
44
+ /**
45
+ * Additional client specific options.
46
+ *
47
+ * @protected
48
+ */
49
+ e(this, "options");
50
+ /**
51
+ * Array of headers that are required. Client will throw an error if any are missing.
52
+ *
53
+ * @private
54
+ */
55
+ e(this, "_requiredHeaders", []);
56
+ this.baseUrl = ((t == null ? void 0 : t.baseUrl) ?? O).replace(/\/+$/, ""), this.headers = (t == null ? void 0 : t.headers) ?? {}, this.parameters = (t == null ? void 0 : t.parameters) ?? {}, this.options = (t == null ? void 0 : t.options) ?? {};
57
+ }
58
+ get requiredHeaders() {
59
+ return this._requiredHeaders;
60
+ }
61
+ set requiredHeaders(t) {
62
+ this._requiredHeaders = t;
63
+ }
64
+ /**
65
+ * Prepare and execute the final request and handle the response.
66
+ */
67
+ async doRequest(t, r) {
68
+ const a = this.normalizeOptions(t, { ...r, ...this.options });
69
+ this.validateHeaders(t, a);
70
+ const i = await this.request(t, a);
71
+ if (u(i, "errors"))
72
+ throw new y(i);
73
+ return this.getResponseBody(t, i);
74
+ }
75
+ getResponseBody(t, r) {
76
+ if (!u(r, "data"))
77
+ return r;
78
+ const a = t.getResponseProperty();
79
+ if (!a)
80
+ return r.data;
81
+ const { page: i, size: n, results: p } = r.data;
82
+ return i === void 0 && n === void 0 && p === void 0 ? r.data[a] : {
83
+ [a]: r.data[a],
84
+ ...i !== void 0 && { page: i },
85
+ ...n !== void 0 && { size: n },
86
+ ...p !== void 0 && { results: p }
87
+ };
88
+ }
89
+ /**
90
+ * Gets default and custom headers.
91
+ *
92
+ * @protected
93
+ */
94
+ getHeaders() {
95
+ return {
96
+ Accept: "application/json",
97
+ ...this.headers
98
+ };
99
+ }
100
+ /**
101
+ * Uses the base url, endpoint and options to create the final request url.
102
+ *
103
+ * @protected
104
+ */
105
+ createUrl(t, r) {
106
+ let a = t.getPath();
107
+ if (a.length && !a.startsWith("/") && (a = `/${a}`), r != null && r.path && (a = this.substitutePath(a, r.path)), a.includes("/:"))
108
+ throw new h(`One or more path variables are missing in ${a}`);
109
+ return r != null && r.parameters && (a = _(a, r.parameters)), this.baseUrl + a;
110
+ }
111
+ /**
112
+ * Replace path variables in an url path. Deletes optional parameters if
113
+ * they're not passed.
114
+ *
115
+ * @protected
116
+ */
117
+ substitutePath(t, r) {
118
+ if (r && Object.entries(r).forEach(([a, i]) => {
119
+ t = t.replace(`:${a}`, String(i));
120
+ }), t.includes(":")) {
121
+ const a = t.match(/:\w+?\?/g);
122
+ a == null || a.forEach((i) => {
123
+ t = t.replace(`/${i}`, "");
124
+ });
125
+ }
126
+ return t;
127
+ }
128
+ /**
129
+ * Validates headers passed in options.
130
+ *
131
+ * @protected
132
+ */
133
+ validateHeaders(t, r) {
134
+ const a = Object.entries(r.headers).reduce(
135
+ (n, [p, c]) => ({
136
+ ...n,
137
+ [p.toLowerCase()]: c
138
+ }),
139
+ {}
140
+ ), i = this.requiredHeaders.filter((n) => !(n.toLowerCase() in a));
141
+ if (i.length)
142
+ throw new h(`Required headers are missing: ${i.join(", ")}`);
143
+ }
144
+ /**
145
+ * Executes transformations on options before request.
146
+ *
147
+ * @protected
148
+ */
149
+ normalizeOptions(t, r) {
150
+ const a = {
151
+ ...r,
152
+ parameters: {
153
+ ...this.parameters,
154
+ ...r.parameters,
155
+ ...t.getParameters()
156
+ },
157
+ headers: {
158
+ ...C.includes(t.method) ? { "Content-Type": "application/json" } : {},
159
+ ...this.getHeaders(),
160
+ ...r.headers,
161
+ ...t.getHeaders()
162
+ }
163
+ };
164
+ if (u(r, "body")) {
165
+ const i = t.getProperty();
166
+ if (r.body instanceof FormData)
167
+ return a.body = r.body, delete a.headers["Content-Type"], a;
168
+ i === void 0 ? a.body = {
169
+ data: r.body
170
+ } : a.body = {
171
+ data: { [i]: r.body }
172
+ };
173
+ }
174
+ return a;
175
+ }
176
+ }
177
+ const k = (s) => {
178
+ try {
179
+ return JSON.parse(s), !0;
180
+ } catch {
181
+ return !1;
182
+ }
183
+ };
184
+ class H extends A {
185
+ constructor(r) {
186
+ super(r);
187
+ e(this, "request", async (r, a) => {
188
+ var b, g;
189
+ const i = r.getTimeout() ?? a.timeout, n = new AbortController(), p = setTimeout(() => n.abort(), i), c = {
190
+ method: r.method,
191
+ headers: a.headers,
192
+ ...i && { signal: n.signal }
193
+ };
194
+ u(a, "body") && (a.body instanceof FormData ? c.body = a.body : c.body = JSON.stringify(a.body));
195
+ const d = await fetch(this.createUrl(r, a), c);
196
+ if (clearTimeout(p), d.body) {
197
+ if ((b = d.headers.get("Content-Disposition")) != null && b.includes("attachment"))
198
+ return d.blob();
199
+ const l = await d.text();
200
+ return (g = d.headers.get("Content-Type")) != null && g.includes("application/json") && k(l) ? JSON.parse(l) : l;
201
+ }
202
+ });
203
+ }
204
+ }
205
+ class S {
206
+ constructor(t) {
207
+ /**
208
+ * HTTP method.
209
+ */
210
+ e(this, "method", "GET");
211
+ /**
212
+ * The property in the request body and response body. If the response body
213
+ * property differs, set responseProperty alongside property.
214
+ * If the property is undefined, the endpoint will be called without a namespace.
215
+ */
216
+ e(this, "property");
217
+ /**
218
+ * Property used in the response. Falls back to `this.property` if it's not
219
+ * set.
220
+ */
221
+ e(this, "responseProperty");
222
+ /**
223
+ * Timeout in milliseconds.
224
+ * This is used to override the default timeout of the client.
225
+ */
226
+ e(this, "timeout");
227
+ /**
228
+ * Headers to include when calling this endpoint.
229
+ */
230
+ e(this, "headers");
231
+ /**
232
+ * Parameters to include in the endpoint url.
233
+ */
234
+ e(this, "parameters");
235
+ this.headers = (t == null ? void 0 : t.headers) ?? {}, this.parameters = (t == null ? void 0 : t.parameters) ?? {};
236
+ }
237
+ getHeaders() {
238
+ return this.headers;
239
+ }
240
+ getParameters() {
241
+ return this.parameters;
242
+ }
243
+ getPath() {
244
+ return this.path;
245
+ }
246
+ getProperty() {
247
+ return this.property;
248
+ }
249
+ getResponseProperty() {
250
+ return this.responseProperty ?? this.property;
251
+ }
252
+ getTimeout() {
253
+ return this.timeout;
254
+ }
255
+ }
256
+ class o extends S {
257
+ }
258
+ class m extends S {
259
+ }
260
+ function P(s, t) {
261
+ if (!t.length)
262
+ throw new h("At least one endpoint must be passed.");
263
+ return t.reduce(
264
+ (r, a) => ({
265
+ ...r,
266
+ [a.name]: async (i) => s.doRequest(a, i ?? {})
267
+ }),
268
+ {}
269
+ );
270
+ }
271
+ const G = (s, t) => (s.requiredHeaders = ["Authorization"], P(s, t)), v = (s, t) => P(s, t);
272
+ class f extends o {
273
+ constructor() {
274
+ super(...arguments);
275
+ e(this, "method", "DELETE");
276
+ e(this, "name", "deleteAccountMessage");
277
+ e(this, "path", "account_messages/:id");
278
+ e(this, "property", "messages");
279
+ }
280
+ }
281
+ class D extends o {
282
+ constructor() {
283
+ super(...arguments);
284
+ e(this, "name", "getAccountMessages");
285
+ e(this, "path", "account_messages");
286
+ e(this, "property", "messages");
287
+ }
288
+ }
289
+ class j extends o {
290
+ constructor() {
291
+ super(...arguments);
292
+ e(this, "name", "getAccount");
293
+ e(this, "path", "accounts/:id");
294
+ e(this, "property", "accounts");
295
+ }
296
+ }
297
+ class q extends o {
298
+ constructor() {
299
+ super(...arguments);
300
+ e(this, "name", "getAccounts");
301
+ e(this, "path", "accounts");
302
+ e(this, "property", "accounts");
303
+ }
304
+ }
305
+ class U extends o {
306
+ constructor() {
307
+ super(...arguments);
308
+ e(this, "method", "PUT");
309
+ e(this, "name", "putAccount");
310
+ e(this, "path", "accounts");
311
+ e(this, "property", "accounts");
312
+ }
313
+ }
314
+ class L extends o {
315
+ constructor() {
316
+ super(...arguments);
317
+ e(this, "name", "getApiKeys");
318
+ e(this, "path", "keys");
319
+ e(this, "property", "api_keys");
320
+ }
321
+ }
322
+ class $ extends o {
323
+ constructor() {
324
+ super(...arguments);
325
+ e(this, "method", "POST");
326
+ e(this, "name", "postApiKeys");
327
+ e(this, "path", "keys");
328
+ e(this, "property", "api_keys");
329
+ }
330
+ }
331
+ class M extends o {
332
+ constructor() {
333
+ super(...arguments);
334
+ e(this, "method", "DELETE");
335
+ e(this, "name", "deleteCarrierOption");
336
+ e(this, "path", "accounts/:account_id/carrier_options/:contract_id");
337
+ e(this, "property", "carrier_options");
338
+ }
339
+ }
340
+ class R extends o {
341
+ constructor() {
342
+ super(...arguments);
343
+ e(this, "name", "getCarrierOptions");
344
+ e(this, "path", "carrier_management/accounts/:account_id/carrier_options");
345
+ e(this, "property", "carrier_options");
346
+ }
347
+ }
348
+ class W extends o {
349
+ constructor() {
350
+ super(...arguments);
351
+ e(this, "method", "POST");
352
+ e(this, "name", "postCarrierOptions");
353
+ e(this, "path", "accounts/:account_id/carrier_options");
354
+ e(this, "property", "carrier_options");
355
+ e(this, "responseProperty", "ids");
356
+ }
357
+ }
358
+ class N extends o {
359
+ constructor() {
360
+ super(...arguments);
361
+ e(this, "name", "putCarrierOptions");
362
+ e(this, "path", "carrier_management/accounts/:account_id/carrier_options");
363
+ e(this, "property", "carrier_options");
364
+ e(this, "method", "PUT");
365
+ }
366
+ }
367
+ class z extends o {
368
+ constructor() {
369
+ super(...arguments);
370
+ e(this, "name", "getLocations");
371
+ e(this, "path", "locations");
372
+ e(this, "property", "locations");
373
+ }
374
+ }
375
+ class J extends o {
376
+ constructor() {
377
+ super(...arguments);
378
+ e(this, "name", "getShipment");
379
+ e(this, "path", "shipments/:id");
380
+ e(this, "property", "shipments");
381
+ }
382
+ }
383
+ class K extends o {
384
+ constructor() {
385
+ super(...arguments);
386
+ e(this, "name", "getShipments");
387
+ e(this, "path", "shipments");
388
+ e(this, "property", "shipments");
389
+ }
390
+ }
391
+ class B extends o {
392
+ constructor() {
393
+ super(...arguments);
394
+ e(this, "method", "POST");
395
+ e(this, "name", "postShipments");
396
+ e(this, "path", "shipments");
397
+ e(this, "property", "shipments");
398
+ e(this, "responseProperty", "ids");
399
+ }
400
+ getHeaders() {
401
+ return {
402
+ ...super.getHeaders(),
403
+ "Content-Type": "application/vnd.shipment+json;charset=utf-8;version=1.1"
404
+ };
405
+ }
406
+ }
407
+ class F extends o {
408
+ constructor() {
409
+ super(...arguments);
410
+ e(this, "name", "getShop");
411
+ e(this, "path", "shops/:id");
412
+ e(this, "property", "shops");
413
+ }
414
+ }
415
+ class I extends o {
416
+ constructor() {
417
+ super(...arguments);
418
+ e(this, "method", "POST");
419
+ e(this, "name", "postShop");
420
+ e(this, "path", "shops/duplicate");
421
+ e(this, "property", "shops");
422
+ e(this, "responseProperty", "ids");
423
+ }
424
+ }
425
+ class Q extends o {
426
+ constructor() {
427
+ super(...arguments);
428
+ e(this, "method", "PUT");
429
+ e(this, "name", "putShop");
430
+ e(this, "path", "shops");
431
+ e(this, "property", "shops");
432
+ }
433
+ }
434
+ class X extends o {
435
+ constructor() {
436
+ super(...arguments);
437
+ e(this, "method", "POST");
438
+ e(this, "name", "postShopDuplicate");
439
+ e(this, "path", "shops/duplicate");
440
+ e(this, "property", "ids");
441
+ }
442
+ }
443
+ class Y extends o {
444
+ constructor() {
445
+ super(...arguments);
446
+ e(this, "name", "getSubscriptionsCapabilities");
447
+ e(this, "path", "subscriptions/capabilities");
448
+ e(this, "property", "capabilities");
449
+ }
450
+ }
451
+ class Z extends o {
452
+ constructor() {
453
+ super(...arguments);
454
+ e(this, "method", "DELETE");
455
+ e(this, "name", "deleteSubscription");
456
+ e(this, "path", "subscriptions/:id");
457
+ e(this, "property", "subscriptions");
458
+ }
459
+ }
460
+ class V extends o {
461
+ constructor() {
462
+ super(...arguments);
463
+ e(this, "name", "getSubscriptions");
464
+ e(this, "path", "subscriptions");
465
+ e(this, "property", "subscriptions");
466
+ }
467
+ }
468
+ class ee extends o {
469
+ constructor() {
470
+ super(...arguments);
471
+ e(this, "method", "PATCH");
472
+ e(this, "name", "patchSubscriptions");
473
+ e(this, "path", "subscriptions");
474
+ e(this, "property", "subscriptions");
475
+ e(this, "responseProperty", "ids");
476
+ }
477
+ }
478
+ class te extends o {
479
+ constructor() {
480
+ super(...arguments);
481
+ e(this, "method", "POST");
482
+ e(this, "name", "postSubscriptions");
483
+ e(this, "path", "subscriptions");
484
+ e(this, "property", "subscriptions");
485
+ e(this, "responseProperty", "ids");
486
+ }
487
+ }
488
+ class se extends o {
489
+ constructor() {
490
+ super(...arguments);
491
+ e(this, "name", "getSystemCountryCodes");
492
+ e(this, "path", "system_country_codes");
493
+ e(this, "property", "countries");
494
+ }
495
+ }
496
+ class re extends o {
497
+ constructor() {
498
+ super(...arguments);
499
+ e(this, "name", "getSystemMessages");
500
+ e(this, "path", "system_messages");
501
+ e(this, "property", "messages");
502
+ }
503
+ }
504
+ class ae extends o {
505
+ constructor() {
506
+ super(...arguments);
507
+ e(this, "name", "getTrackAndTrace");
508
+ e(this, "path", "tracktraces/:shipment_id");
509
+ e(this, "property", "tracktraces");
510
+ }
511
+ }
512
+ class oe extends o {
513
+ constructor() {
514
+ super(...arguments);
515
+ e(this, "method", "DELETE");
516
+ e(this, "name", "deleteWebhookSubscriptions");
517
+ e(this, "path", "webhook_subscriptions/:ids");
518
+ e(this, "property", "webhook_subscriptions");
519
+ }
520
+ }
521
+ class ie extends o {
522
+ constructor() {
523
+ super(...arguments);
524
+ e(this, "name", "getWebhookSubscriptions");
525
+ e(this, "path", "webhook_subscriptions");
526
+ e(this, "property", "webhook_subscriptions");
527
+ }
528
+ }
529
+ class ne extends o {
530
+ constructor() {
531
+ super(...arguments);
532
+ e(this, "method", "POST");
533
+ e(this, "name", "postWebhookSubscriptions");
534
+ e(this, "path", "webhook_subscriptions");
535
+ e(this, "property", "webhook_subscriptions");
536
+ e(this, "responseProperty", "ids");
537
+ }
538
+ }
539
+ class pe extends m {
540
+ constructor() {
541
+ super(...arguments);
542
+ e(this, "name", "getCarrier");
543
+ e(this, "path", "carriers/:carrier");
544
+ e(this, "property", "carriers");
545
+ }
546
+ }
547
+ class ce extends m {
548
+ constructor() {
549
+ super(...arguments);
550
+ e(this, "name", "getCarriers");
551
+ e(this, "path", "carriers");
552
+ e(this, "property", "carriers");
553
+ }
554
+ }
555
+ class de extends m {
556
+ constructor() {
557
+ super(...arguments);
558
+ e(this, "name", "getDeliveryOptions");
559
+ e(this, "path", "delivery_options");
560
+ e(this, "property", "deliveries");
561
+ }
562
+ getHeaders() {
563
+ return { ...super.getHeaders(), Accept: "application/json;version=2.0" };
564
+ }
565
+ }
566
+ class he extends m {
567
+ constructor() {
568
+ super(...arguments);
569
+ e(this, "name", "getPickupLocations");
570
+ e(this, "path", "pickup_locations");
571
+ e(this, "property", "pickup_locations");
572
+ }
573
+ }
574
+ export {
575
+ A as AbstractClient,
576
+ S as AbstractEndpoint,
577
+ o as AbstractPrivateEndpoint,
578
+ m as AbstractPublicEndpoint,
579
+ y as ApiException,
580
+ O as BASE_URL,
581
+ f as DeleteAccountMessage,
582
+ M as DeleteCarrierOptions,
583
+ Z as DeleteSubscription,
584
+ oe as DeleteWebhookSubscriptions,
585
+ H as FetchClient,
586
+ j as GetAccount,
587
+ D as GetAccountMessages,
588
+ q as GetAccounts,
589
+ L as GetApiKeys,
590
+ pe as GetCarrier,
591
+ R as GetCarrierOptions,
592
+ ce as GetCarriers,
593
+ de as GetDeliveryOptions,
594
+ z as GetLocations,
595
+ he as GetPickupLocations,
596
+ J as GetShipment,
597
+ K as GetShipments,
598
+ F as GetShop,
599
+ V as GetSubscriptions,
600
+ Y as GetSubscriptionsCapabilities,
601
+ se as GetSystemCountryCodes,
602
+ re as GetSystemMessages,
603
+ ae as GetTrackAndTrace,
604
+ ie as GetWebhookSubscriptions,
605
+ ee as PatchSubscriptions,
606
+ $ as PostApiKeys,
607
+ W as PostCarrierOptions,
608
+ B as PostShipments,
609
+ I as PostShop,
610
+ X as PostShopDuplicate,
611
+ te as PostSubscriptions,
612
+ ne as PostWebhookSubscriptions,
613
+ U as PutAccount,
614
+ N as PutCarrierOptions,
615
+ Q as PutShop,
616
+ h as UserException,
617
+ _ as addParameters,
618
+ P as createMyParcelSdk,
619
+ G as createPrivateSdk,
620
+ v as createPublicSdk,
621
+ k as isJson
622
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ import { type RequestHeader, type RequestHeaders } from '../../types/request.types';
2
+ import { type WithRequired } from '../../types';
3
+ import { type AbstractEndpoint } from '../endpoint/AbstractEndpoint';
4
+ import { type ClientConfig, type ClientOptions, type ClientRequest, type EndpointPath, type EndpointResponse, type PaginatedEndpointResponse, type Options } from './AbstractClient.types';
5
+ export declare const BASE_URL = "https://api.myparcel.nl";
6
+ export declare abstract class AbstractClient {
7
+ /**
8
+ * Executes the request. Should return a promise containing the response json as object.
9
+ */
10
+ protected abstract request: ClientRequest;
11
+ /**
12
+ * Base URL to make requests to.
13
+ *
14
+ * @protected
15
+ */
16
+ protected baseUrl: string;
17
+ /**
18
+ * Headers to use with requests.
19
+ *
20
+ * @protected
21
+ */
22
+ protected headers: RequestHeaders;
23
+ /**
24
+ * @protected
25
+ */
26
+ protected parameters: Record<string, string>;
27
+ /**
28
+ * Additional client specific options.
29
+ *
30
+ * @protected
31
+ */
32
+ protected options: ClientOptions;
33
+ /**
34
+ * Array of headers that are required. Client will throw an error if any are missing.
35
+ *
36
+ * @private
37
+ */
38
+ private _requiredHeaders;
39
+ protected constructor(config?: ClientConfig);
40
+ get requiredHeaders(): (RequestHeader | string)[];
41
+ set requiredHeaders(value: (RequestHeader | string)[]);
42
+ /**
43
+ * Prepare and execute the final request and handle the response.
44
+ */
45
+ doRequest<E extends AbstractEndpoint>(endpoint: E, options: Options<E>): Promise<EndpointResponse<E>>;
46
+ getResponseBody<E extends AbstractEndpoint>(endpoint: E, response: EndpointResponse<E>): EndpointResponse<E> | PaginatedEndpointResponse<E>;
47
+ /**
48
+ * Gets default and custom headers.
49
+ *
50
+ * @protected
51
+ */
52
+ protected getHeaders(): RequestHeaders;
53
+ /**
54
+ * Uses the base url, endpoint and options to create the final request url.
55
+ *
56
+ * @protected
57
+ */
58
+ protected createUrl<E extends AbstractEndpoint>(endpoint: E, options: Options<E>): string;
59
+ /**
60
+ * Replace path variables in an url path. Deletes optional parameters if
61
+ * they're not passed.
62
+ *
63
+ * @protected
64
+ */
65
+ protected substitutePath<E extends AbstractEndpoint>(urlPath: string, pathVariables?: EndpointPath<E>): string;
66
+ /**
67
+ * Validates headers passed in options.
68
+ *
69
+ * @protected
70
+ */
71
+ protected validateHeaders<E extends AbstractEndpoint>(endpoint: E, options: WithRequired<Options<E>, 'headers'>): void;
72
+ /**
73
+ * Executes transformations on options before request.
74
+ *
75
+ * @protected
76
+ */
77
+ protected normalizeOptions<E extends AbstractEndpoint>(endpoint: E, options: Options<E>): WithRequired<Options<E>, 'headers'>;
78
+ }
@@ -0,0 +1 @@
1
+ export {};