@myparcel-dev/sdk 5.0.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 (109) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +15 -0
  3. package/lib/createMyParcelSdk.d.ts +18 -0
  4. package/lib/createMyParcelSdk.spec.d.ts +1 -0
  5. package/lib/createPrivateSdk.d.ts +8 -0
  6. package/lib/createPrivateSdk.spec.d.ts +1 -0
  7. package/lib/createPublicSdk.d.ts +8 -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 +20 -0
  12. package/lib/endpoints/private/account-messages/GetAccountMessages.d.ts +20 -0
  13. package/lib/endpoints/private/account-messages/index.d.ts +3 -0
  14. package/lib/endpoints/private/accounts/Account.types.d.ts +59 -0
  15. package/lib/endpoints/private/accounts/GetAccount.d.ts +20 -0
  16. package/lib/endpoints/private/accounts/GetAccounts.d.ts +14 -0
  17. package/lib/endpoints/private/accounts/PutAccount.d.ts +19 -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 +17 -0
  21. package/lib/endpoints/private/api-key/PostApiKeys.d.ts +20 -0
  22. package/lib/endpoints/private/api-key/index.d.ts +3 -0
  23. package/lib/endpoints/private/carrier-options/CarrierOption.types.d.ts +47 -0
  24. package/lib/endpoints/private/carrier-options/DeleteCarrierOptions.d.ts +18 -0
  25. package/lib/endpoints/private/carrier-options/GetCarrierOptions.d.ts +18 -0
  26. package/lib/endpoints/private/carrier-options/PostCarrierOptions.d.ts +20 -0
  27. package/lib/endpoints/private/carrier-options/PutCarrierOptions.d.ts +22 -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 +15 -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 +20 -0
  34. package/lib/endpoints/private/shipments/GetShipments.d.ts +23 -0
  35. package/lib/endpoints/private/shipments/PostShipments.d.ts +24 -0
  36. package/lib/endpoints/private/shipments/Shipment.types.d.ts +175 -0
  37. package/lib/endpoints/private/shipments/index.d.ts +4 -0
  38. package/lib/endpoints/private/shops/GetShop.d.ts +20 -0
  39. package/lib/endpoints/private/shops/PostShop.d.ts +23 -0
  40. package/lib/endpoints/private/shops/PostShopDuplicate.d.ts +24 -0
  41. package/lib/endpoints/private/shops/PutShop.d.ts +17 -0
  42. package/lib/endpoints/private/shops/Shop.types.d.ts +81 -0
  43. package/lib/endpoints/private/shops/index.d.ts +5 -0
  44. package/lib/endpoints/private/subscription-capabilities/GetSubscriptionCapabilities.d.ts +18 -0
  45. package/lib/endpoints/private/subscription-capabilities/SubscriptionCapability.types.d.ts +24 -0
  46. package/lib/endpoints/private/subscription-capabilities/index.d.ts +2 -0
  47. package/lib/endpoints/private/subscriptions/DeleteSubscription.d.ts +17 -0
  48. package/lib/endpoints/private/subscriptions/GetSubscriptions.d.ts +18 -0
  49. package/lib/endpoints/private/subscriptions/PatchSubscriptions.d.ts +20 -0
  50. package/lib/endpoints/private/subscriptions/PostSubscriptions.d.ts +20 -0
  51. package/lib/endpoints/private/subscriptions/Subscriptions.types.d.ts +30 -0
  52. package/lib/endpoints/private/subscriptions/index.d.ts +5 -0
  53. package/lib/endpoints/private/system-country-codes/GetSystemCountryCodes.d.ts +15 -0
  54. package/lib/endpoints/private/system-country-codes/SystemCountryCodes.types.d.ts +11 -0
  55. package/lib/endpoints/private/system-country-codes/index.d.ts +2 -0
  56. package/lib/endpoints/private/system-messages/GetSystemMessages.d.ts +17 -0
  57. package/lib/endpoints/private/system-messages/SystemMessage.types.d.ts +18 -0
  58. package/lib/endpoints/private/system-messages/index.d.ts +2 -0
  59. package/lib/endpoints/private/track-traces/GetTrackAndTraceByShipment.d.ts +17 -0
  60. package/lib/endpoints/private/track-traces/TrackTraces.types.d.ts +51 -0
  61. package/lib/endpoints/private/track-traces/index.d.ts +2 -0
  62. package/lib/endpoints/private/webhook-subscriptions/DeleteWebhookSubscriptions.d.ts +17 -0
  63. package/lib/endpoints/private/webhook-subscriptions/GetWebhookSubscriptions.d.ts +15 -0
  64. package/lib/endpoints/private/webhook-subscriptions/PostWebhookSubscriptions.d.ts +20 -0
  65. package/lib/endpoints/private/webhook-subscriptions/Webhook.types.d.ts +13 -0
  66. package/lib/endpoints/private/webhook-subscriptions/index.d.ts +4 -0
  67. package/lib/endpoints/public/carriers/Carrier.types.d.ts +11 -0
  68. package/lib/endpoints/public/carriers/GetCarrier.d.ts +20 -0
  69. package/lib/endpoints/public/carriers/GetCarriers.d.ts +16 -0
  70. package/lib/endpoints/public/carriers/index.d.ts +3 -0
  71. package/lib/endpoints/public/delivery-options/DeliveryOption.types.d.ts +22 -0
  72. package/lib/endpoints/public/delivery-options/GetDeliveryOptions.d.ts +50 -0
  73. package/lib/endpoints/public/delivery-options/index.d.ts +2 -0
  74. package/lib/endpoints/public/index.d.ts +3 -0
  75. package/lib/endpoints/public/pickup-locations/GetPickupLocations.d.ts +18 -0
  76. package/lib/endpoints/public/pickup-locations/PickupLocation.types.d.ts +32 -0
  77. package/lib/endpoints/public/pickup-locations/index.d.ts +2 -0
  78. package/lib/index.cjs +1 -0
  79. package/lib/index.d.ts +6 -0
  80. package/lib/index.js +660 -0
  81. package/lib/index.spec.d.ts +1 -0
  82. package/lib/model/client/AbstractClient.d.ts +89 -0
  83. package/lib/model/client/AbstractClient.spec.d.ts +1 -0
  84. package/lib/model/client/AbstractClient.types.d.ts +55 -0
  85. package/lib/model/client/FetchClient.d.ts +7 -0
  86. package/lib/model/client/helper/addParameters.d.ts +4 -0
  87. package/lib/model/client/helper/addParameters.spec.d.ts +1 -0
  88. package/lib/model/client/helper/index.d.ts +2 -0
  89. package/lib/model/client/helper/isJson.d.ts +1 -0
  90. package/lib/model/client/helper/isJson.spec.d.ts +1 -0
  91. package/lib/model/client/index.d.ts +4 -0
  92. package/lib/model/client/middleware/Interceptors.d.ts +8 -0
  93. package/lib/model/client/middleware/Interceptors.unit.spec.d.ts +1 -0
  94. package/lib/model/client/middleware/middleware.types.d.ts +1 -0
  95. package/lib/model/endpoint/AbstractEndpoint.d.ts +57 -0
  96. package/lib/model/endpoint/AbstractEndpoint.types.d.ts +21 -0
  97. package/lib/model/endpoint/AbstractPrivateEndpoint.d.ts +14 -0
  98. package/lib/model/endpoint/AbstractPublicEndpoint.d.ts +6 -0
  99. package/lib/model/endpoint/index.d.ts +4 -0
  100. package/lib/model/exception/ApiException.d.ts +6 -0
  101. package/lib/model/exception/UserException.d.ts +4 -0
  102. package/lib/model/exception/index.d.ts +2 -0
  103. package/lib/model/index.d.ts +3 -0
  104. package/lib/types/common.types.d.ts +31 -0
  105. package/lib/types/data.types.d.ts +23 -0
  106. package/lib/types/global.types.d.ts +4 -0
  107. package/lib/types/index.d.ts +4 -0
  108. package/lib/types/request.types.d.ts +18 -0
  109. package/package.json +79 -0
@@ -0,0 +1,2 @@
1
+ export * from './GetTrackAndTraceByShipment';
2
+ export * from './TrackTraces.types';
@@ -0,0 +1,17 @@
1
+ import { HttpMethod } from '../../../types';
2
+ import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
3
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
4
+
5
+ type DeleteWebhookSubscriptionsDefinition = CreateDefinition<{
6
+ name: typeof DeleteWebhookSubscriptions.name;
7
+ path: {
8
+ ids: string;
9
+ };
10
+ }>;
11
+ export declare class DeleteWebhookSubscriptions extends AbstractPrivateEndpoint<DeleteWebhookSubscriptionsDefinition> {
12
+ readonly method: HttpMethod;
13
+ readonly name = "deleteWebhookSubscriptions";
14
+ readonly path = "webhook_subscriptions/:ids";
15
+ readonly property = "webhook_subscriptions";
16
+ }
17
+ export {};
@@ -0,0 +1,15 @@
1
+ import { MyParcelWebhook, WebhookSubscriptionParameters } from './Webhook.types';
2
+ import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
3
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
4
+
5
+ type GetWebhookSubscriptionsDefinition = CreateDefinition<{
6
+ name: typeof GetWebhookSubscriptions.name;
7
+ parameters: WebhookSubscriptionParameters;
8
+ response: MyParcelWebhook[];
9
+ }>;
10
+ export declare class GetWebhookSubscriptions extends AbstractPrivateEndpoint<GetWebhookSubscriptionsDefinition> {
11
+ readonly name = "getWebhookSubscriptions";
12
+ readonly path = "webhook_subscriptions";
13
+ readonly property = "webhook_subscriptions";
14
+ }
15
+ export {};
@@ -0,0 +1,20 @@
1
+ import { MyParcelWebhook } from './Webhook.types';
2
+ import { HttpMethod } from '../../../types';
3
+ import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
4
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
5
+
6
+ type PostWebhookSubscriptionsDefinition = CreateDefinition<{
7
+ name: typeof PostWebhookSubscriptions.name;
8
+ body: MyParcelWebhook[];
9
+ response: {
10
+ id: number[];
11
+ };
12
+ }>;
13
+ export declare class PostWebhookSubscriptions extends AbstractPrivateEndpoint<PostWebhookSubscriptionsDefinition> {
14
+ readonly method: HttpMethod;
15
+ readonly name = "postWebhookSubscriptions";
16
+ readonly path = "webhook_subscriptions";
17
+ readonly property = "webhook_subscriptions";
18
+ readonly responseProperty = "ids";
19
+ }
20
+ export {};
@@ -0,0 +1,13 @@
1
+ export type WebhookSubscriptionParameters = {
2
+ account_id?: number;
3
+ shop_id?: number;
4
+ hook?: string;
5
+ ids?: string;
6
+ };
7
+ export interface MyParcelWebhook {
8
+ account_id: number;
9
+ hook: 'shipment_label_created' | 'shipment_status_change';
10
+ id: number;
11
+ shop_id: number;
12
+ url: string;
13
+ }
@@ -0,0 +1,4 @@
1
+ export * from './DeleteWebhookSubscriptions';
2
+ export * from './GetWebhookSubscriptions';
3
+ export * from './PostWebhookSubscriptions';
4
+ export * from './Webhook.types';
@@ -0,0 +1,11 @@
1
+ import { CarrierId, CarrierName } from '@myparcel-dev/constants';
2
+
3
+ export interface Carrier {
4
+ id: CarrierId;
5
+ name: CarrierName;
6
+ human: string;
7
+ meta: {
8
+ logo_svg: string;
9
+ logo_png: string;
10
+ };
11
+ }
@@ -0,0 +1,20 @@
1
+ import { CarrierNameOrId } from '@myparcel-dev/constants';
2
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
3
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
4
+ import { Carrier } from './Carrier.types';
5
+
6
+ export type GetCarrierDefinition = CreateDefinition<{
7
+ name: typeof GetCarrier.name;
8
+ path: {
9
+ carrier: CarrierNameOrId;
10
+ };
11
+ response: [Carrier];
12
+ }>;
13
+ /**
14
+ * Get a single carrier.
15
+ */
16
+ export declare class GetCarrier extends AbstractPublicEndpoint<GetCarrierDefinition> {
17
+ readonly name = "getCarrier";
18
+ readonly path = "carriers/:carrier";
19
+ readonly property = "carriers";
20
+ }
@@ -0,0 +1,16 @@
1
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
2
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
3
+ import { Carrier } from './Carrier.types';
4
+
5
+ export type GetCarriersDefinition = CreateDefinition<{
6
+ name: typeof GetCarriers.name;
7
+ response: Carrier[];
8
+ }>;
9
+ /**
10
+ * Get all carriers.
11
+ */
12
+ export declare class GetCarriers extends AbstractPublicEndpoint<GetCarriersDefinition> {
13
+ readonly name = "getCarriers";
14
+ readonly path = "carriers";
15
+ readonly property = "carriers";
16
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Carrier.types';
2
+ export * from './GetCarrier';
3
+ export * from './GetCarriers';
@@ -0,0 +1,22 @@
1
+ import { DeliveryTypeName, PackageTypeName, ShipmentOptionName } from '@myparcel-dev/constants';
2
+ import { EnumSchema, Timestamp } from '../../../types';
3
+
4
+ export interface PossibleShipmentOption {
5
+ name: ShipmentOptionName;
6
+ schema: EnumSchema<boolean>;
7
+ }
8
+ export interface DeliveryOption {
9
+ date: Timestamp;
10
+ possibilities: DeliveryPossibility[];
11
+ }
12
+ export interface DeliveryPossibility {
13
+ collect_date?: string;
14
+ delivery_time_frames: [DeliveryTimeFrame<'start'>, DeliveryTimeFrame<'end'>];
15
+ package_type: PackageTypeName;
16
+ shipment_options: PossibleShipmentOption[];
17
+ type: DeliveryTypeName;
18
+ }
19
+ export interface DeliveryTimeFrame<Type = 'start' | 'end'> {
20
+ date_time: Timestamp;
21
+ type: Type;
22
+ }
@@ -0,0 +1,50 @@
1
+ import { CarrierNameOrId, DeliveryTypeId, PackageTypeName, PlatformNameOrId } from '@myparcel-dev/constants';
2
+ import { RequestHeaders } from '../../../types/request.types';
3
+ import { WithRequired } from '../../../types/global.types';
4
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
5
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
6
+ import { DeliveryOption } from './DeliveryOption.types';
7
+
8
+ type Parameters = {
9
+ carrier: CarrierNameOrId;
10
+ cc: string;
11
+ platform: PlatformNameOrId;
12
+ postal_code: string;
13
+ city?: string;
14
+ cutoff_time?: string;
15
+ delivery_date?: string;
16
+ delivery_time?: string;
17
+ deliverydays_window?: number;
18
+ dropoff_days?: string;
19
+ dropoff_delay?: number;
20
+ exclude_delivery_type?: DeliveryTypeId;
21
+ exclude_parcel_lockers?: boolean;
22
+ include?: 'shipment_options' | string;
23
+ latitude?: string;
24
+ longitude?: string;
25
+ monday_delivery?: boolean;
26
+ number?: number;
27
+ package_type?: PackageTypeName;
28
+ saturday_delivery?: boolean;
29
+ same_day_delivery?: boolean;
30
+ street?: string;
31
+ };
32
+ /**
33
+ * Either number or full street is required.
34
+ */
35
+ export type DeliveryOptionsParameters = WithRequired<Parameters, 'number'> | WithRequired<Parameters, 'street'>;
36
+ type GetDeliveryOptionsDefinition = CreateDefinition<{
37
+ name: typeof GetDeliveryOptions.name;
38
+ parameters: DeliveryOptionsParameters;
39
+ response: DeliveryOption[];
40
+ }>;
41
+ /**
42
+ * Get available delivery options for given location. Note: This calls version 2 of the endpoint.
43
+ */
44
+ export declare class GetDeliveryOptions extends AbstractPublicEndpoint<GetDeliveryOptionsDefinition> {
45
+ readonly name = "getDeliveryOptions";
46
+ readonly path = "delivery_options";
47
+ readonly property = "deliveries";
48
+ getHeaders(): RequestHeaders;
49
+ }
50
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './DeliveryOption.types';
2
+ export * from './GetDeliveryOptions';
@@ -0,0 +1,3 @@
1
+ export * from './carriers';
2
+ export * from './delivery-options';
3
+ export * from './pickup-locations';
@@ -0,0 +1,18 @@
1
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
2
+ import { CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
3
+ import { PickupLocation } from './PickupLocation.types';
4
+ import { DeliveryOptionsParameters } from '../..';
5
+
6
+ export type GetPickupLocationsDefinition = CreateDefinition<{
7
+ name: typeof GetPickupLocations.name;
8
+ parameters: DeliveryOptionsParameters;
9
+ response: PickupLocation[];
10
+ }>;
11
+ /**
12
+ * Get available pickup locations for given location.
13
+ */
14
+ export declare class GetPickupLocations extends AbstractPublicEndpoint<GetPickupLocationsDefinition> {
15
+ readonly name = "getPickupLocations";
16
+ readonly path = "pickup_locations";
17
+ readonly property = "pickup_locations";
18
+ }
@@ -0,0 +1,32 @@
1
+ import { DeliveryTypeId, DeliveryTypeName } from '@myparcel-dev/constants';
2
+ import { StartEndDate, Timestamp, Weekday } from '../../../types';
3
+
4
+ export interface PickupLocation {
5
+ address: {
6
+ cc: string;
7
+ city: string;
8
+ number: string;
9
+ number_suffix: string;
10
+ postal_code: string;
11
+ street: string;
12
+ };
13
+ location: {
14
+ distance: string;
15
+ latitude: string;
16
+ location_code: string;
17
+ location_name: string;
18
+ longitude: string;
19
+ opening_hours: Record<Weekday, StartEndDate[]>;
20
+ phone_number: string | null;
21
+ retail_network_id: string;
22
+ };
23
+ possibilities: PickupPossibility[];
24
+ }
25
+ export interface PickupPossibility {
26
+ delivery_type_id: DeliveryTypeId;
27
+ delivery_type_name: DeliveryTypeName;
28
+ moment: {
29
+ start: Timestamp;
30
+ };
31
+ price?: number;
32
+ }
@@ -0,0 +1,2 @@
1
+ export * from './GetPickupLocations';
2
+ export * from './PickupLocation.types';
package/lib/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var G=Object.defineProperty;var _=(s,t,r)=>t in s?G(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var e=(s,t,r)=>_(s,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function m(s,t){return(s==null?void 0:s[t])!==void 0}class O{constructor(){e(this,"fns");this.fns=[]}delete(t){const r=this.fns.indexOf(t);r!==-1&&(this.fns=[...this.fns.slice(0,r),...this.fns.slice(r+1)])}use(t){this.fns=[...this.fns,t]}}class d extends Error{constructor(r){super(r);e(this,"name","user");Object.setPrototypeOf(this,d.prototype),this.name="UserException"}}class l extends Error{constructor(r){super(r.message);e(this,"data");Object.setPrototypeOf(this,l.prototype),this.name="ApiException",this.data=r}}const A=(s,t)=>{if(t){const r=Object.entries(t).map(([a,o])=>`${a}=${o}`);r.length&&(s+=`?${r.join("&")}`)}return s},C="https://api.myparcel.nl",k=["POST","PUT"];class T{constructor(t){e(this,"interceptors");e(this,"baseUrl");e(this,"headers");e(this,"parameters");e(this,"options");e(this,"_requiredHeaders",[]);this.baseUrl=((t==null?void 0:t.baseUrl)??C).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)??{},this.interceptors={request:new O,response:new O}}get requiredHeaders(){return this._requiredHeaders}set requiredHeaders(t){this._requiredHeaders=t}async doRequest(t,r){const a=this.normalizeOptions(t,{...r,...this.options});this.validateHeaders(t,a);let o=await this.request(t,a);for(const n of this.interceptors.response.fns)o=await n(o);if(m(o,"errors"))throw new l(o);return this.getResponseBody(t,o)}getResponseBody(t,r){if(!m(r,"data"))return r;const a=t.getResponseProperty();if(!a)return r.data;const{page:o,size:n,results:p}=r.data;return o===void 0&&n===void 0&&p===void 0?r.data[a]:{[a]:r.data[a],...o!==void 0&&{page:o},...n!==void 0&&{size:n},...p!==void 0&&{results:p}}}getHeaders(){return{Accept:"application/json",...this.headers}}createUrl(t,r){let a=t.getPath();if(a.length&&!a.startsWith("/")&&(a=`/${a}`),r!=null&&r.path&&(a=this.substitutePath(a,r.path)),a.includes("/:"))throw new d(`One or more path variables are missing in ${a}`);return r!=null&&r.parameters&&(a=A(a,r.parameters)),this.baseUrl+a}substitutePath(t,r){if(r&&Object.entries(r).forEach(([a,o])=>{t=t.replace(`:${a}`,String(o))}),t.includes(":")){const a=t.match(/:\w+?\?/g);a==null||a.forEach(o=>{t=t.replace(`/${o}`,"")})}return t}validateHeaders(t,r){const a=Object.entries(r.headers).reduce((n,[p,h])=>({...n,[p.toLowerCase()]:h}),{}),o=this.requiredHeaders.filter(n=>!(n.toLowerCase()in a));if(o.length)throw new d(`Required headers are missing: ${o.join(", ")}`)}normalizeOptions(t,r){const a={...r,parameters:{...this.parameters,...r.parameters,...t.getParameters()},headers:{...k.includes(t.method)?{"Content-Type":"application/json"}:{},...this.getHeaders(),...r.headers,...t.getHeaders()}};if(m(r,"body")){const o=t.getProperty();if(r.body instanceof FormData)return a.body=r.body,delete a.headers["Content-Type"],a;o===void 0?a.body={data:r.body}:a.body={data:{[o]:r.body}}}return a}}const f=s=>{try{return JSON.parse(s),!0}catch{return!1}};class E extends T{constructor(r){super(r);e(this,"request",async(r,a)=>{var P,g,x;for(const c of this.interceptors.request.fns)a=await c(a);const o=r.getTimeout()??a.timeout,n=new AbortController,p={method:r.method,headers:a.headers,signal:n.signal};let h;o&&(h=setTimeout(()=>{n.abort()},o)),m(a,"body")&&(a.body instanceof FormData?p.body=a.body:p.body=JSON.stringify(a.body));try{const c=await fetch(this.createUrl(r,a),p);if(c.body){if((P=c.headers.get("Content-Disposition"))!=null&&P.includes("attachment")||(g=c.headers.get("Content-Type"))!=null&&g.includes("application/pdf"))return c.blob();const y=await c.text();return(x=c.headers.get("Content-Type"))!=null&&x.includes("application/json")&&f(y)?JSON.parse(y):y}}finally{h&&clearTimeout(h)}})}}class b{constructor(t){e(this,"method","GET");e(this,"property");e(this,"responseProperty");e(this,"timeout");e(this,"headers");e(this,"parameters");this.headers=(t==null?void 0:t.headers)??{},this.parameters=(t==null?void 0:t.parameters)??{}}getHeaders(){return this.headers}getParameters(){return this.parameters}getPath(){return this.path}getProperty(){return this.property}getResponseProperty(){return this.responseProperty??this.property}getTimeout(){return this.timeout}}class i extends b{}class u extends b{}function S(s,t){if(!t.length)throw new d("At least one endpoint must be passed.");return{...t.reduce((r,a)=>({...r,[a.name]:async o=>s.doRequest(a,o??{})}),{}),client:s}}const w=(s,t)=>(s.requiredHeaders=["Authorization"],S(s,t)),D=(s,t)=>S(s,t);class H extends i{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteAccountMessage");e(this,"path","account_messages/:id");e(this,"property","messages")}}class v extends i{constructor(){super(...arguments);e(this,"name","getAccountMessages");e(this,"path","account_messages");e(this,"property","messages")}}class q extends i{constructor(){super(...arguments);e(this,"name","getAccount");e(this,"path","accounts/:id");e(this,"property","accounts")}}class L extends i{constructor(){super(...arguments);e(this,"name","getAccounts");e(this,"path","accounts");e(this,"property","accounts")}}class U extends i{constructor(){super(...arguments);e(this,"method","PUT");e(this,"name","putAccount");e(this,"path","accounts");e(this,"property","accounts")}}class j extends i{constructor(){super(...arguments);e(this,"name","getApiKeys");e(this,"path","keys");e(this,"property","api_keys")}}class M extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postApiKeys");e(this,"path","keys");e(this,"property","api_keys")}}class W extends i{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteCarrierOption");e(this,"path","accounts/:account_id/carrier_options/:contract_id");e(this,"property","carrier_options")}}class R extends i{constructor(){super(...arguments);e(this,"name","getCarrierOptions");e(this,"path","carrier_management/accounts/:account_id/carrier_options");e(this,"property","carrier_options")}}class $ extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postCarrierOptions");e(this,"path","accounts/:account_id/carrier_options");e(this,"property","carrier_options");e(this,"responseProperty","ids")}}class K extends i{constructor(){super(...arguments);e(this,"name","putCarrierOptions");e(this,"path","carrier_management/accounts/:account_id/carrier_options");e(this,"property","carrier_options");e(this,"method","PUT")}}class J extends i{constructor(){super(...arguments);e(this,"name","getLocations");e(this,"path","locations");e(this,"property","locations")}}class N extends i{constructor(){super(...arguments);e(this,"name","getShipment");e(this,"path","shipments/:id");e(this,"property","shipments")}}class z extends i{constructor(){super(...arguments);e(this,"name","getShipments");e(this,"path","shipments");e(this,"property","shipments")}}class B extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postShipments");e(this,"path","shipments");e(this,"property","shipments");e(this,"responseProperty","ids")}getHeaders(){return{...super.getHeaders(),"Content-Type":"application/vnd.shipment+json;charset=utf-8;version=1.1"}}}class F extends i{constructor(){super(...arguments);e(this,"name","getShop");e(this,"path","shops/:id");e(this,"property","shops")}}class I extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postShop");e(this,"path","shops/duplicate");e(this,"property","shops");e(this,"responseProperty","ids")}}class Q extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postShopDuplicate");e(this,"path","shops/duplicate");e(this,"property","ids")}}class X extends i{constructor(){super(...arguments);e(this,"method","PUT");e(this,"name","putShop");e(this,"path","shops");e(this,"property","shops")}}class Y extends i{constructor(){super(...arguments);e(this,"name","getSubscriptionsCapabilities");e(this,"path","subscriptions/capabilities");e(this,"property","capabilities")}}class Z extends i{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteSubscription");e(this,"path","subscriptions/:id");e(this,"property","subscriptions")}}class V extends i{constructor(){super(...arguments);e(this,"name","getSubscriptions");e(this,"path","subscriptions");e(this,"property","subscriptions")}}class ee extends i{constructor(){super(...arguments);e(this,"method","PATCH");e(this,"name","patchSubscriptions");e(this,"path","subscriptions");e(this,"property","subscriptions");e(this,"responseProperty","ids")}}class te extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postSubscriptions");e(this,"path","subscriptions");e(this,"property","subscriptions");e(this,"responseProperty","ids")}}class se extends i{constructor(){super(...arguments);e(this,"name","getSystemCountryCodes");e(this,"path","system_country_codes");e(this,"property","countries")}}class re extends i{constructor(){super(...arguments);e(this,"name","getSystemMessages");e(this,"path","system_messages");e(this,"property","messages")}}class ae extends i{constructor(){super(...arguments);e(this,"name","getTrackAndTrace");e(this,"path","tracktraces/:shipment_id");e(this,"property","tracktraces")}}class ie extends i{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteWebhookSubscriptions");e(this,"path","webhook_subscriptions/:ids");e(this,"property","webhook_subscriptions")}}class oe extends i{constructor(){super(...arguments);e(this,"name","getWebhookSubscriptions");e(this,"path","webhook_subscriptions");e(this,"property","webhook_subscriptions")}}class ne extends i{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postWebhookSubscriptions");e(this,"path","webhook_subscriptions");e(this,"property","webhook_subscriptions");e(this,"responseProperty","ids")}}class pe extends u{constructor(){super(...arguments);e(this,"name","getCarrier");e(this,"path","carriers/:carrier");e(this,"property","carriers")}}class ce extends u{constructor(){super(...arguments);e(this,"name","getCarriers");e(this,"path","carriers");e(this,"property","carriers")}}class de extends u{constructor(){super(...arguments);e(this,"name","getDeliveryOptions");e(this,"path","delivery_options");e(this,"property","deliveries")}getHeaders(){return{...super.getHeaders(),Accept:"application/json;version=2.0"}}}class he extends u{constructor(){super(...arguments);e(this,"name","getPickupLocations");e(this,"path","pickup_locations");e(this,"property","pickup_locations")}}exports.AbstractClient=T;exports.AbstractEndpoint=b;exports.AbstractPrivateEndpoint=i;exports.AbstractPublicEndpoint=u;exports.ApiException=l;exports.BASE_URL=C;exports.DeleteAccountMessage=H;exports.DeleteCarrierOptions=W;exports.DeleteSubscription=Z;exports.DeleteWebhookSubscriptions=ie;exports.FetchClient=E;exports.GetAccount=q;exports.GetAccountMessages=v;exports.GetAccounts=L;exports.GetApiKeys=j;exports.GetCarrier=pe;exports.GetCarrierOptions=R;exports.GetCarriers=ce;exports.GetDeliveryOptions=de;exports.GetLocations=J;exports.GetPickupLocations=he;exports.GetShipment=N;exports.GetShipments=z;exports.GetShop=F;exports.GetSubscriptions=V;exports.GetSubscriptionsCapabilities=Y;exports.GetSystemCountryCodes=se;exports.GetSystemMessages=re;exports.GetTrackAndTrace=ae;exports.GetWebhookSubscriptions=oe;exports.PatchSubscriptions=ee;exports.PostApiKeys=M;exports.PostCarrierOptions=$;exports.PostShipments=B;exports.PostShop=I;exports.PostShopDuplicate=Q;exports.PostSubscriptions=te;exports.PostWebhookSubscriptions=ne;exports.PutAccount=U;exports.PutCarrierOptions=K;exports.PutShop=X;exports.UserException=d;exports.addParameters=A;exports.createMyParcelSdk=S;exports.createPrivateSdk=w;exports.createPublicSdk=D;exports.isJson=f;
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './createMyParcelSdk';
2
+ export * from './createPrivateSdk';
3
+ export * from './createPublicSdk';
4
+ export * from './endpoints';
5
+ export * from './model';
6
+ export * from './types';