@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
@@ -0,0 +1,16 @@
1
+ import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
2
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
3
+ import { type HttpMethod } from '../../../types';
4
+ type DeleteWebhookSubscriptionsDefinition = CreateDefinition<{
5
+ name: typeof DeleteWebhookSubscriptions.name;
6
+ path: {
7
+ ids: string;
8
+ };
9
+ }>;
10
+ export declare class DeleteWebhookSubscriptions extends AbstractPrivateEndpoint<DeleteWebhookSubscriptionsDefinition> {
11
+ readonly method: HttpMethod;
12
+ readonly name = "deleteWebhookSubscriptions";
13
+ readonly path = "webhook_subscriptions/:ids";
14
+ readonly property = "webhook_subscriptions";
15
+ }
16
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type MyParcelWebhook, type WebhookSubscriptionParameters } from './Webhook.types';
2
+ import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
3
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
4
+ type GetWebhookSubscriptionsDefinition = CreateDefinition<{
5
+ name: typeof GetWebhookSubscriptions.name;
6
+ parameters: WebhookSubscriptionParameters;
7
+ response: MyParcelWebhook[];
8
+ }>;
9
+ export declare class GetWebhookSubscriptions extends AbstractPrivateEndpoint<GetWebhookSubscriptionsDefinition> {
10
+ readonly name = "getWebhookSubscriptions";
11
+ readonly path = "webhook_subscriptions";
12
+ readonly property = "webhook_subscriptions";
13
+ }
14
+ export {};
@@ -0,0 +1,19 @@
1
+ import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
2
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
3
+ import { type HttpMethod } from '../../../types';
4
+ import { type MyParcelWebhook } from './Webhook.types';
5
+ type PostWebhookSubscriptionsDefinition = CreateDefinition<{
6
+ name: typeof PostWebhookSubscriptions.name;
7
+ body: MyParcelWebhook[];
8
+ response: {
9
+ id: number[];
10
+ };
11
+ }>;
12
+ export declare class PostWebhookSubscriptions extends AbstractPrivateEndpoint<PostWebhookSubscriptionsDefinition> {
13
+ readonly method: HttpMethod;
14
+ readonly name = "postWebhookSubscriptions";
15
+ readonly path = "webhook_subscriptions";
16
+ readonly property = "webhook_subscriptions";
17
+ readonly responseProperty = "ids";
18
+ }
19
+ 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,10 @@
1
+ import { type CarrierId, type CarrierName } from '@myparcel/constants';
2
+ export interface Carrier {
3
+ id: CarrierId;
4
+ name: CarrierName;
5
+ human: string;
6
+ meta: {
7
+ logo_svg: string;
8
+ logo_png: string;
9
+ };
10
+ }
@@ -0,0 +1,19 @@
1
+ import { type CarrierNameOrId } from '@myparcel/constants';
2
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
3
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
4
+ import { type Carrier } from './Carrier.types';
5
+ export type GetCarrierDefinition = CreateDefinition<{
6
+ name: typeof GetCarrier.name;
7
+ path: {
8
+ carrier: CarrierNameOrId;
9
+ };
10
+ response: [Carrier];
11
+ }>;
12
+ /**
13
+ * Get a single carrier.
14
+ */
15
+ export declare class GetCarrier extends AbstractPublicEndpoint<GetCarrierDefinition> {
16
+ readonly name = "getCarrier";
17
+ readonly path = "carriers/:carrier";
18
+ readonly property = "carriers";
19
+ }
@@ -0,0 +1,15 @@
1
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
2
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
3
+ import { type Carrier } from './Carrier.types';
4
+ export type GetCarriersDefinition = CreateDefinition<{
5
+ name: typeof GetCarriers.name;
6
+ response: Carrier[];
7
+ }>;
8
+ /**
9
+ * Get all carriers.
10
+ */
11
+ export declare class GetCarriers extends AbstractPublicEndpoint<GetCarriersDefinition> {
12
+ readonly name = "getCarriers";
13
+ readonly path = "carriers";
14
+ readonly property = "carriers";
15
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Carrier.types';
2
+ export * from './GetCarrier';
3
+ export * from './GetCarriers';
@@ -0,0 +1,22 @@
1
+ import { type DeliveryTypeName, type PackageTypeName, type ShipmentOptionName } from '@myparcel/constants';
2
+ import { type EnumSchema, type Timestamp } from '../../../types';
3
+ interface PossibleShipmentOption {
4
+ name: ShipmentOptionName;
5
+ schema: EnumSchema<boolean>;
6
+ }
7
+ export interface DeliveryOption {
8
+ date: Timestamp;
9
+ possibilities: DeliveryPossibility[];
10
+ }
11
+ export interface DeliveryPossibility {
12
+ collect_date?: string;
13
+ delivery_time_frames: [DeliveryTimeFrame<'start'>, DeliveryTimeFrame<'end'>];
14
+ package_type: PackageTypeName;
15
+ shipment_options: PossibleShipmentOption[];
16
+ type: DeliveryTypeName;
17
+ }
18
+ export interface DeliveryTimeFrame<Type = 'start' | 'end'> {
19
+ date_time: Timestamp;
20
+ type: Type;
21
+ }
22
+ export {};
@@ -0,0 +1,49 @@
1
+ import { type CarrierNameOrId, type DeliveryTypeId, type PackageTypeName, type PlatformNameOrId } from '@myparcel/constants';
2
+ import { type RequestHeaders } from '../../../types/request.types';
3
+ import { type WithRequired } from '../../../types/global.types';
4
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
5
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
6
+ import { type DeliveryOption } from './DeliveryOption.types';
7
+ type Parameters = {
8
+ carrier: CarrierNameOrId;
9
+ cc: string;
10
+ platform: PlatformNameOrId;
11
+ postal_code: string;
12
+ city?: string;
13
+ cutoff_time?: string;
14
+ delivery_date?: string;
15
+ delivery_time?: string;
16
+ deliverydays_window?: number;
17
+ dropoff_days?: string;
18
+ dropoff_delay?: number;
19
+ exclude_delivery_type?: DeliveryTypeId;
20
+ exclude_parcel_lockers?: boolean;
21
+ include?: 'shipment_options' | string;
22
+ latitude?: string;
23
+ longitude?: string;
24
+ monday_delivery?: boolean;
25
+ number?: number;
26
+ package_type?: PackageTypeName;
27
+ saturday_delivery?: boolean;
28
+ same_day_delivery?: boolean;
29
+ street?: string;
30
+ };
31
+ /**
32
+ * Either number or full street is required.
33
+ */
34
+ export type DeliveryOptionsParameters = WithRequired<Parameters, 'number'> | WithRequired<Parameters, 'street'>;
35
+ type GetDeliveryOptionsDefinition = CreateDefinition<{
36
+ name: typeof GetDeliveryOptions.name;
37
+ parameters: DeliveryOptionsParameters;
38
+ response: DeliveryOption[];
39
+ }>;
40
+ /**
41
+ * Get available delivery options for given location. Note: This calls version 2 of the endpoint.
42
+ */
43
+ export declare class GetDeliveryOptions extends AbstractPublicEndpoint<GetDeliveryOptionsDefinition> {
44
+ readonly name = "getDeliveryOptions";
45
+ readonly path = "delivery_options";
46
+ readonly property = "deliveries";
47
+ getHeaders(): RequestHeaders;
48
+ }
49
+ 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,17 @@
1
+ import { AbstractPublicEndpoint } from '../../../model/endpoint/AbstractPublicEndpoint';
2
+ import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
3
+ import { type PickupLocation } from './PickupLocation.types';
4
+ import { type DeliveryOptionsParameters } from '../..';
5
+ export type GetPickupLocationsDefinition = CreateDefinition<{
6
+ name: typeof GetPickupLocations.name;
7
+ parameters: DeliveryOptionsParameters;
8
+ response: PickupLocation[];
9
+ }>;
10
+ /**
11
+ * Get available pickup locations for given location.
12
+ */
13
+ export declare class GetPickupLocations extends AbstractPublicEndpoint<GetPickupLocationsDefinition> {
14
+ readonly name = "getPickupLocations";
15
+ readonly path = "pickup_locations";
16
+ readonly property = "pickup_locations";
17
+ }
@@ -0,0 +1,31 @@
1
+ import { type DeliveryTypeId, type DeliveryTypeName } from '@myparcel/constants';
2
+ import { type StartEndDate, type Timestamp, type Weekday } from '../../../types';
3
+ export interface PickupLocation {
4
+ address: {
5
+ cc: string;
6
+ city: string;
7
+ number: string;
8
+ number_suffix: string;
9
+ postal_code: string;
10
+ street: string;
11
+ };
12
+ location: {
13
+ distance: string;
14
+ latitude: string;
15
+ location_code: string;
16
+ location_name: string;
17
+ longitude: string;
18
+ opening_hours: Record<Weekday, StartEndDate[]>;
19
+ phone_number: string | null;
20
+ retail_network_id: string;
21
+ };
22
+ possibilities: PickupPossibility[];
23
+ }
24
+ export interface PickupPossibility {
25
+ delivery_type_id: DeliveryTypeId;
26
+ delivery_type_name: DeliveryTypeName;
27
+ moment: {
28
+ start: Timestamp;
29
+ };
30
+ price?: number;
31
+ }
@@ -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 C=Object.defineProperty;var G=(s,t,r)=>t in s?C(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var e=(s,t,r)=>(G(s,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@myparcel/ts-utils");class c extends Error{constructor(r){super(r);e(this,"name","user");Object.setPrototypeOf(this,c.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 x=(s,t)=>{if(t){const r=Object.entries(t).map(([a,i])=>`${a}=${i}`);r.length&&(s+=`?${r.join("&")}`)}return s},O="https://api.myparcel.nl",_=["POST","PUT"];class T{constructor(t){e(this,"baseUrl");e(this,"headers");e(this,"parameters");e(this,"options");e(this,"_requiredHeaders",[]);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)??{}}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);const i=await this.request(t,a);if(m.isOfType(i,"errors"))throw new l(i);return this.getResponseBody(t,i)}getResponseBody(t,r){if(!m.isOfType(r,"data"))return r;const a=t.getResponseProperty();if(!a)return r.data;const{page:i,size:n,results:p}=r.data;return i===void 0&&n===void 0&&p===void 0?r.data[a]:{[a]:r.data[a],...i!==void 0&&{page:i},...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 c(`One or more path variables are missing in ${a}`);return r!=null&&r.parameters&&(a=x(a,r.parameters)),this.baseUrl+a}substitutePath(t,r){if(r&&Object.entries(r).forEach(([a,i])=>{t=t.replace(`:${a}`,String(i))}),t.includes(":")){const a=t.match(/:\w+?\?/g);a==null||a.forEach(i=>{t=t.replace(`/${i}`,"")})}return t}validateHeaders(t,r){const a=Object.entries(r.headers).reduce((n,[p,d])=>({...n,[p.toLowerCase()]:d}),{}),i=this.requiredHeaders.filter(n=>!(n.toLowerCase()in a));if(i.length)throw new c(`Required headers are missing: ${i.join(", ")}`)}normalizeOptions(t,r){const a={...r,parameters:{...this.parameters,...r.parameters,...t.getParameters()},headers:{..._.includes(t.method)?{"Content-Type":"application/json"}:{},...this.getHeaders(),...r.headers,...t.getHeaders()}};if(m.isOfType(r,"body")){const i=t.getProperty();if(r.body instanceof FormData)return a.body=r.body,delete a.headers["Content-Type"],a;i===void 0?a.body={data:r.body}:a.body={data:{[i]:r.body}}}return a}}const A=s=>{try{return JSON.parse(s),!0}catch{return!1}};class k extends T{constructor(r){super(r);e(this,"request",async(r,a)=>{var P,g;const i=r.getTimeout()??a.timeout,n=new AbortController,p=setTimeout(()=>n.abort(),i),d={method:r.method,headers:a.headers,...i&&{signal:n.signal}};m.isOfType(a,"body")&&(a.body instanceof FormData?d.body=a.body:d.body=JSON.stringify(a.body));const h=await fetch(this.createUrl(r,a),d);if(clearTimeout(p),h.body){if((P=h.headers.get("Content-Disposition"))!=null&&P.includes("attachment"))return h.blob();const y=await h.text();return(g=h.headers.get("Content-Type"))!=null&&g.includes("application/json")&&A(y)?JSON.parse(y):y}})}}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 o extends b{}class u extends b{}function S(s,t){if(!t.length)throw new c("At least one endpoint must be passed.");return t.reduce((r,a)=>({...r,[a.name]:async i=>s.doRequest(a,i??{})}),{})}const E=(s,t)=>(s.requiredHeaders=["Authorization"],S(s,t)),v=(s,t)=>S(s,t);class w extends o{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteAccountMessage");e(this,"path","account_messages/:id");e(this,"property","messages")}}class D extends o{constructor(){super(...arguments);e(this,"name","getAccountMessages");e(this,"path","account_messages");e(this,"property","messages")}}class H extends o{constructor(){super(...arguments);e(this,"name","getAccount");e(this,"path","accounts/:id");e(this,"property","accounts")}}class f extends o{constructor(){super(...arguments);e(this,"name","getAccounts");e(this,"path","accounts");e(this,"property","accounts")}}class U extends o{constructor(){super(...arguments);e(this,"method","PUT");e(this,"name","putAccount");e(this,"path","accounts");e(this,"property","accounts")}}class L extends o{constructor(){super(...arguments);e(this,"name","getApiKeys");e(this,"path","keys");e(this,"property","api_keys")}}class j extends o{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postApiKeys");e(this,"path","keys");e(this,"property","api_keys")}}class q extends o{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 M extends o{constructor(){super(...arguments);e(this,"name","getCarrierOptions");e(this,"path","carrier_management/accounts/:account_id/carrier_options");e(this,"property","carrier_options")}}class W extends o{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 R extends o{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 $ extends o{constructor(){super(...arguments);e(this,"name","getLocations");e(this,"path","locations");e(this,"property","locations")}}class K extends o{constructor(){super(...arguments);e(this,"name","getShipment");e(this,"path","shipments/:id");e(this,"property","shipments")}}class J extends o{constructor(){super(...arguments);e(this,"name","getShipments");e(this,"path","shipments");e(this,"property","shipments")}}class N extends o{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 z extends o{constructor(){super(...arguments);e(this,"name","getShop");e(this,"path","shops/:id");e(this,"property","shops")}}class B extends o{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 F extends o{constructor(){super(...arguments);e(this,"method","PUT");e(this,"name","putShop");e(this,"path","shops");e(this,"property","shops")}}class I extends o{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postShopDuplicate");e(this,"path","shops/duplicate");e(this,"property","ids")}}class Q extends o{constructor(){super(...arguments);e(this,"name","getSubscriptionsCapabilities");e(this,"path","subscriptions/capabilities");e(this,"property","capabilities")}}class X extends o{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteSubscription");e(this,"path","subscriptions/:id");e(this,"property","subscriptions")}}class Y extends o{constructor(){super(...arguments);e(this,"name","getSubscriptions");e(this,"path","subscriptions");e(this,"property","subscriptions")}}class Z extends o{constructor(){super(...arguments);e(this,"method","PATCH");e(this,"name","patchSubscriptions");e(this,"path","subscriptions");e(this,"property","subscriptions");e(this,"responseProperty","ids")}}class V extends o{constructor(){super(...arguments);e(this,"method","POST");e(this,"name","postSubscriptions");e(this,"path","subscriptions");e(this,"property","subscriptions");e(this,"responseProperty","ids")}}class ee extends o{constructor(){super(...arguments);e(this,"name","getSystemCountryCodes");e(this,"path","system_country_codes");e(this,"property","countries")}}class te extends o{constructor(){super(...arguments);e(this,"name","getSystemMessages");e(this,"path","system_messages");e(this,"property","messages")}}class se extends o{constructor(){super(...arguments);e(this,"name","getTrackAndTrace");e(this,"path","tracktraces/:shipment_id");e(this,"property","tracktraces")}}class re extends o{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteWebhookSubscriptions");e(this,"path","webhook_subscriptions/:ids");e(this,"property","webhook_subscriptions")}}class ae extends o{constructor(){super(...arguments);e(this,"name","getWebhookSubscriptions");e(this,"path","webhook_subscriptions");e(this,"property","webhook_subscriptions")}}class oe extends o{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 ie extends u{constructor(){super(...arguments);e(this,"name","getCarrier");e(this,"path","carriers/:carrier");e(this,"property","carriers")}}class ne extends u{constructor(){super(...arguments);e(this,"name","getCarriers");e(this,"path","carriers");e(this,"property","carriers")}}class pe 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 ce 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=o;exports.AbstractPublicEndpoint=u;exports.ApiException=l;exports.BASE_URL=O;exports.DeleteAccountMessage=w;exports.DeleteCarrierOptions=q;exports.DeleteSubscription=X;exports.DeleteWebhookSubscriptions=re;exports.FetchClient=k;exports.GetAccount=H;exports.GetAccountMessages=D;exports.GetAccounts=f;exports.GetApiKeys=L;exports.GetCarrier=ie;exports.GetCarrierOptions=M;exports.GetCarriers=ne;exports.GetDeliveryOptions=pe;exports.GetLocations=$;exports.GetPickupLocations=ce;exports.GetShipment=K;exports.GetShipments=J;exports.GetShop=z;exports.GetSubscriptions=Y;exports.GetSubscriptionsCapabilities=Q;exports.GetSystemCountryCodes=ee;exports.GetSystemMessages=te;exports.GetTrackAndTrace=se;exports.GetWebhookSubscriptions=ae;exports.PatchSubscriptions=Z;exports.PostApiKeys=j;exports.PostCarrierOptions=W;exports.PostShipments=N;exports.PostShop=B;exports.PostShopDuplicate=I;exports.PostSubscriptions=V;exports.PostWebhookSubscriptions=oe;exports.PutAccount=U;exports.PutCarrierOptions=R;exports.PutShop=F;exports.UserException=c;exports.addParameters=x;exports.createMyParcelSdk=S;exports.createPrivateSdk=E;exports.createPublicSdk=v;exports.isJson=A;
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';