@myparcel-dev/sdk 4.1.1 → 5.0.1
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.
- package/README.md +2 -2
- package/lib/createMyParcelSdk.d.ts +8 -4
- package/lib/createPrivateSdk.d.ts +5 -4
- package/lib/createPublicSdk.d.ts +5 -4
- package/lib/endpoints/private/account-messages/DeleteAccountMessage.d.ts +3 -2
- package/lib/endpoints/private/account-messages/GetAccountMessages.d.ts +3 -2
- package/lib/endpoints/private/accounts/Account.types.d.ts +5 -4
- package/lib/endpoints/private/accounts/GetAccount.d.ts +3 -2
- package/lib/endpoints/private/accounts/GetAccounts.d.ts +3 -2
- package/lib/endpoints/private/accounts/PutAccount.d.ts +4 -3
- package/lib/endpoints/private/api-key/GetApiKeys.d.ts +3 -2
- package/lib/endpoints/private/api-key/PostApiKeys.d.ts +4 -3
- package/lib/endpoints/private/carrier-options/CarrierOption.types.d.ts +3 -2
- package/lib/endpoints/private/carrier-options/DeleteCarrierOptions.d.ts +3 -2
- package/lib/endpoints/private/carrier-options/GetCarrierOptions.d.ts +3 -2
- package/lib/endpoints/private/carrier-options/PostCarrierOptions.d.ts +4 -3
- package/lib/endpoints/private/carrier-options/PutCarrierOptions.d.ts +4 -3
- package/lib/endpoints/private/locations/GetLocations.d.ts +3 -2
- package/lib/endpoints/private/shipments/GetShipment.d.ts +3 -2
- package/lib/endpoints/private/shipments/GetShipments.d.ts +4 -3
- package/lib/endpoints/private/shipments/PostShipments.d.ts +4 -3
- package/lib/endpoints/private/shipments/Shipment.types.d.ts +4 -4
- package/lib/endpoints/private/shops/GetShop.d.ts +3 -2
- package/lib/endpoints/private/shops/PostShop.d.ts +4 -3
- package/lib/endpoints/private/shops/PostShopDuplicate.d.ts +4 -3
- package/lib/endpoints/private/shops/PutShop.d.ts +4 -3
- package/lib/endpoints/private/shops/Shop.types.d.ts +2 -1
- package/lib/endpoints/private/shops/index.d.ts +1 -1
- package/lib/endpoints/private/subscription-capabilities/GetSubscriptionCapabilities.d.ts +4 -3
- package/lib/endpoints/private/subscription-capabilities/SubscriptionCapability.types.d.ts +3 -2
- package/lib/endpoints/private/subscriptions/DeleteSubscription.d.ts +3 -2
- package/lib/endpoints/private/subscriptions/GetSubscriptions.d.ts +3 -2
- package/lib/endpoints/private/subscriptions/PatchSubscriptions.d.ts +4 -3
- package/lib/endpoints/private/subscriptions/PostSubscriptions.d.ts +4 -3
- package/lib/endpoints/private/system-country-codes/GetSystemCountryCodes.d.ts +3 -2
- package/lib/endpoints/private/system-country-codes/SystemCountryCodes.types.d.ts +2 -1
- package/lib/endpoints/private/system-messages/GetSystemMessages.d.ts +3 -2
- package/lib/endpoints/private/track-traces/GetTrackAndTraceByShipment.d.ts +3 -2
- package/lib/endpoints/private/track-traces/TrackTraces.types.d.ts +5 -4
- package/lib/endpoints/private/webhook-subscriptions/DeleteWebhookSubscriptions.d.ts +3 -2
- package/lib/endpoints/private/webhook-subscriptions/GetWebhookSubscriptions.d.ts +3 -2
- package/lib/endpoints/private/webhook-subscriptions/PostWebhookSubscriptions.d.ts +4 -3
- package/lib/endpoints/public/carriers/Carrier.types.d.ts +2 -1
- package/lib/endpoints/public/carriers/GetCarrier.d.ts +4 -3
- package/lib/endpoints/public/carriers/GetCarriers.d.ts +3 -2
- package/lib/endpoints/public/delivery-options/DeliveryOption.types.d.ts +4 -4
- package/lib/endpoints/public/delivery-options/GetDeliveryOptions.d.ts +6 -5
- package/lib/endpoints/public/pickup-locations/GetPickupLocations.d.ts +4 -3
- package/lib/endpoints/public/pickup-locations/PickupLocation.types.d.ts +3 -2
- package/lib/index.cjs +1 -1
- package/lib/index.js +154 -118
- package/lib/model/client/AbstractClient.d.ts +15 -4
- package/lib/model/client/AbstractClient.types.d.ts +9 -3
- package/lib/model/client/FetchClient.d.ts +2 -1
- package/lib/model/client/helper/addParameters.d.ts +4 -3
- package/lib/model/client/middleware/Interceptors.d.ts +8 -0
- package/lib/model/client/middleware/Interceptors.unit.spec.d.ts +1 -0
- package/lib/model/client/middleware/middleware.types.d.ts +1 -0
- package/lib/model/endpoint/AbstractEndpoint.d.ts +3 -2
- package/lib/model/endpoint/AbstractEndpoint.types.d.ts +4 -3
- package/lib/model/endpoint/AbstractPrivateEndpoint.d.ts +3 -2
- package/lib/model/endpoint/AbstractPublicEndpoint.d.ts +2 -1
- package/lib/model/exception/ApiException.d.ts +2 -1
- package/package.json +15 -16
- package/lib/endpoints/private/shipments/PatchShipment.d.ts +0 -21
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DeliveryTypeId, DeliveryTypeName } from '@myparcel-dev/constants';
|
|
2
|
+
import { StartEndDate, Timestamp, Weekday } from '../../../types';
|
|
3
|
+
|
|
3
4
|
export interface PickupLocation {
|
|
4
5
|
address: {
|
|
5
6
|
cc: string;
|
package/lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var G=(s,t,r)=>t in s?T(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"});function m(s,t){return(s==null?void 0:s[t])!==void 0}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},A="https://api.myparcel.nl",_=["POST","PUT"];class C{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)??A).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(i,"errors"))throw new l(i);return this.getResponseBody(t,i)}getResponseBody(t,r){if(!m(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(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 O=s=>{try{return JSON.parse(s),!0}catch{return!1}};class k extends C{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(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")&&O(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)),w=(s,t)=>S(s,t);class D extends o{constructor(){super(...arguments);e(this,"method","DELETE");e(this,"name","deleteAccountMessage");e(this,"path","account_messages/:id");e(this,"property","messages")}}class H extends o{constructor(){super(...arguments);e(this,"name","getAccountMessages");e(this,"path","account_messages");e(this,"property","messages")}}class v 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 L extends o{constructor(){super(...arguments);e(this,"method","PUT");e(this,"name","putAccount");e(this,"path","accounts");e(this,"property","accounts")}}class U 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 M 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 q 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=C;exports.AbstractEndpoint=b;exports.AbstractPrivateEndpoint=o;exports.AbstractPublicEndpoint=u;exports.ApiException=l;exports.BASE_URL=A;exports.DeleteAccountMessage=D;exports.DeleteCarrierOptions=M;exports.DeleteSubscription=X;exports.DeleteWebhookSubscriptions=re;exports.FetchClient=k;exports.GetAccount=v;exports.GetAccountMessages=H;exports.GetAccounts=f;exports.GetApiKeys=U;exports.GetCarrier=ie;exports.GetCarrierOptions=q;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=L;exports.PutCarrierOptions=R;exports.PutShop=F;exports.UserException=c;exports.addParameters=x;exports.createMyParcelSdk=S;exports.createPrivateSdk=E;exports.createPublicSdk=w;exports.isJson=O;
|
|
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.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var e = (s, t, r) => (
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var O = (s, t, r) => t in s ? T(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
|
|
3
|
+
var e = (s, t, r) => O(s, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
function u(s, t) {
|
|
5
5
|
return (s == null ? void 0 : s[t]) !== void 0;
|
|
6
6
|
}
|
|
7
|
+
class P {
|
|
8
|
+
constructor() {
|
|
9
|
+
e(this, "fns");
|
|
10
|
+
this.fns = [];
|
|
11
|
+
}
|
|
12
|
+
delete(t) {
|
|
13
|
+
const r = this.fns.indexOf(t);
|
|
14
|
+
r !== -1 && (this.fns = [...this.fns.slice(0, r), ...this.fns.slice(r + 1)]);
|
|
15
|
+
}
|
|
16
|
+
use(t) {
|
|
17
|
+
this.fns = [...this.fns, t];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
7
20
|
class h extends Error {
|
|
8
21
|
constructor(r) {
|
|
9
22
|
super(r);
|
|
@@ -24,9 +37,15 @@ const _ = (s, t) => {
|
|
|
24
37
|
r.length && (s += `?${r.join("&")}`);
|
|
25
38
|
}
|
|
26
39
|
return s;
|
|
27
|
-
},
|
|
28
|
-
class
|
|
40
|
+
}, C = "https://api.myparcel.nl", A = ["POST", "PUT"];
|
|
41
|
+
class k {
|
|
29
42
|
constructor(t) {
|
|
43
|
+
/**
|
|
44
|
+
* Interceptors for request and response.
|
|
45
|
+
*
|
|
46
|
+
* @protected
|
|
47
|
+
*/
|
|
48
|
+
e(this, "interceptors");
|
|
30
49
|
/**
|
|
31
50
|
* Base URL to make requests to.
|
|
32
51
|
*
|
|
@@ -55,7 +74,10 @@ class A {
|
|
|
55
74
|
* @private
|
|
56
75
|
*/
|
|
57
76
|
e(this, "_requiredHeaders", []);
|
|
58
|
-
this.baseUrl = ((t == null ? void 0 : t.baseUrl) ??
|
|
77
|
+
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 = {
|
|
78
|
+
request: new P(),
|
|
79
|
+
response: new P()
|
|
80
|
+
};
|
|
59
81
|
}
|
|
60
82
|
get requiredHeaders() {
|
|
61
83
|
return this._requiredHeaders;
|
|
@@ -69,7 +91,9 @@ class A {
|
|
|
69
91
|
async doRequest(t, r) {
|
|
70
92
|
const a = this.normalizeOptions(t, { ...r, ...this.options });
|
|
71
93
|
this.validateHeaders(t, a);
|
|
72
|
-
|
|
94
|
+
let i = await this.request(t, a);
|
|
95
|
+
for (const n of this.interceptors.response.fns)
|
|
96
|
+
i = await n(i);
|
|
73
97
|
if (u(i, "errors"))
|
|
74
98
|
throw new y(i);
|
|
75
99
|
return this.getResponseBody(t, i);
|
|
@@ -134,9 +158,9 @@ class A {
|
|
|
134
158
|
*/
|
|
135
159
|
validateHeaders(t, r) {
|
|
136
160
|
const a = Object.entries(r.headers).reduce(
|
|
137
|
-
(n, [p,
|
|
161
|
+
(n, [p, d]) => ({
|
|
138
162
|
...n,
|
|
139
|
-
[p.toLowerCase()]:
|
|
163
|
+
[p.toLowerCase()]: d
|
|
140
164
|
}),
|
|
141
165
|
{}
|
|
142
166
|
), i = this.requiredHeaders.filter((n) => !(n.toLowerCase() in a));
|
|
@@ -157,7 +181,7 @@ class A {
|
|
|
157
181
|
...t.getParameters()
|
|
158
182
|
},
|
|
159
183
|
headers: {
|
|
160
|
-
...
|
|
184
|
+
...A.includes(t.method) ? { "Content-Type": "application/json" } : {},
|
|
161
185
|
...this.getHeaders(),
|
|
162
186
|
...r.headers,
|
|
163
187
|
...t.getHeaders()
|
|
@@ -176,35 +200,44 @@ class A {
|
|
|
176
200
|
return a;
|
|
177
201
|
}
|
|
178
202
|
}
|
|
179
|
-
const
|
|
203
|
+
const w = (s) => {
|
|
180
204
|
try {
|
|
181
205
|
return JSON.parse(s), !0;
|
|
182
206
|
} catch {
|
|
183
207
|
return !1;
|
|
184
208
|
}
|
|
185
209
|
};
|
|
186
|
-
class
|
|
210
|
+
class H extends k {
|
|
187
211
|
constructor(r) {
|
|
188
212
|
super(r);
|
|
189
213
|
e(this, "request", async (r, a) => {
|
|
190
|
-
var b, g;
|
|
191
|
-
const
|
|
214
|
+
var b, g, S;
|
|
215
|
+
for (const c of this.interceptors.request.fns)
|
|
216
|
+
a = await c(a);
|
|
217
|
+
const i = r.getTimeout() ?? a.timeout, n = new AbortController(), p = {
|
|
192
218
|
method: r.method,
|
|
193
219
|
headers: a.headers,
|
|
194
|
-
|
|
220
|
+
signal: n.signal
|
|
195
221
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
222
|
+
let d;
|
|
223
|
+
i && (d = setTimeout(() => {
|
|
224
|
+
n.abort();
|
|
225
|
+
}, i)), u(a, "body") && (a.body instanceof FormData ? p.body = a.body : p.body = JSON.stringify(a.body));
|
|
226
|
+
try {
|
|
227
|
+
const c = await fetch(this.createUrl(r, a), p);
|
|
228
|
+
if (c.body) {
|
|
229
|
+
if ((b = c.headers.get("Content-Disposition")) != null && b.includes("attachment") || (g = c.headers.get("Content-Type")) != null && g.includes("application/pdf"))
|
|
230
|
+
return c.blob();
|
|
231
|
+
const l = await c.text();
|
|
232
|
+
return (S = c.headers.get("Content-Type")) != null && S.includes("application/json") && w(l) ? JSON.parse(l) : l;
|
|
233
|
+
}
|
|
234
|
+
} finally {
|
|
235
|
+
d && clearTimeout(d);
|
|
203
236
|
}
|
|
204
237
|
});
|
|
205
238
|
}
|
|
206
239
|
}
|
|
207
|
-
class
|
|
240
|
+
class x {
|
|
208
241
|
constructor(t) {
|
|
209
242
|
/**
|
|
210
243
|
* HTTP method.
|
|
@@ -255,23 +288,26 @@ class S {
|
|
|
255
288
|
return this.timeout;
|
|
256
289
|
}
|
|
257
290
|
}
|
|
258
|
-
class o extends
|
|
291
|
+
class o extends x {
|
|
259
292
|
}
|
|
260
|
-
class m extends
|
|
293
|
+
class m extends x {
|
|
261
294
|
}
|
|
262
|
-
function
|
|
295
|
+
function f(s, t) {
|
|
263
296
|
if (!t.length)
|
|
264
297
|
throw new h("At least one endpoint must be passed.");
|
|
265
|
-
return
|
|
266
|
-
(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
298
|
+
return {
|
|
299
|
+
...t.reduce(
|
|
300
|
+
(r, a) => ({
|
|
301
|
+
...r,
|
|
302
|
+
[a.name]: async (i) => s.doRequest(a, i ?? {})
|
|
303
|
+
}),
|
|
304
|
+
{}
|
|
305
|
+
),
|
|
306
|
+
client: s
|
|
307
|
+
};
|
|
272
308
|
}
|
|
273
|
-
const
|
|
274
|
-
class
|
|
309
|
+
const G = (s, t) => (s.requiredHeaders = ["Authorization"], f(s, t)), v = (s, t) => f(s, t);
|
|
310
|
+
class D extends o {
|
|
275
311
|
constructor() {
|
|
276
312
|
super(...arguments);
|
|
277
313
|
e(this, "method", "DELETE");
|
|
@@ -280,7 +316,7 @@ class f extends o {
|
|
|
280
316
|
e(this, "property", "messages");
|
|
281
317
|
}
|
|
282
318
|
}
|
|
283
|
-
class
|
|
319
|
+
class q extends o {
|
|
284
320
|
constructor() {
|
|
285
321
|
super(...arguments);
|
|
286
322
|
e(this, "name", "getAccountMessages");
|
|
@@ -288,7 +324,7 @@ class v extends o {
|
|
|
288
324
|
e(this, "property", "messages");
|
|
289
325
|
}
|
|
290
326
|
}
|
|
291
|
-
class
|
|
327
|
+
class j extends o {
|
|
292
328
|
constructor() {
|
|
293
329
|
super(...arguments);
|
|
294
330
|
e(this, "name", "getAccount");
|
|
@@ -296,7 +332,7 @@ class D extends o {
|
|
|
296
332
|
e(this, "property", "accounts");
|
|
297
333
|
}
|
|
298
334
|
}
|
|
299
|
-
class
|
|
335
|
+
class U extends o {
|
|
300
336
|
constructor() {
|
|
301
337
|
super(...arguments);
|
|
302
338
|
e(this, "name", "getAccounts");
|
|
@@ -304,7 +340,7 @@ class j extends o {
|
|
|
304
340
|
e(this, "property", "accounts");
|
|
305
341
|
}
|
|
306
342
|
}
|
|
307
|
-
class
|
|
343
|
+
class L extends o {
|
|
308
344
|
constructor() {
|
|
309
345
|
super(...arguments);
|
|
310
346
|
e(this, "method", "PUT");
|
|
@@ -313,7 +349,7 @@ class q extends o {
|
|
|
313
349
|
e(this, "property", "accounts");
|
|
314
350
|
}
|
|
315
351
|
}
|
|
316
|
-
class
|
|
352
|
+
class $ extends o {
|
|
317
353
|
constructor() {
|
|
318
354
|
super(...arguments);
|
|
319
355
|
e(this, "name", "getApiKeys");
|
|
@@ -321,7 +357,7 @@ class U extends o {
|
|
|
321
357
|
e(this, "property", "api_keys");
|
|
322
358
|
}
|
|
323
359
|
}
|
|
324
|
-
class
|
|
360
|
+
class M extends o {
|
|
325
361
|
constructor() {
|
|
326
362
|
super(...arguments);
|
|
327
363
|
e(this, "method", "POST");
|
|
@@ -330,7 +366,7 @@ class L extends o {
|
|
|
330
366
|
e(this, "property", "api_keys");
|
|
331
367
|
}
|
|
332
368
|
}
|
|
333
|
-
class
|
|
369
|
+
class R extends o {
|
|
334
370
|
constructor() {
|
|
335
371
|
super(...arguments);
|
|
336
372
|
e(this, "method", "DELETE");
|
|
@@ -339,7 +375,7 @@ class $ extends o {
|
|
|
339
375
|
e(this, "property", "carrier_options");
|
|
340
376
|
}
|
|
341
377
|
}
|
|
342
|
-
class
|
|
378
|
+
class W extends o {
|
|
343
379
|
constructor() {
|
|
344
380
|
super(...arguments);
|
|
345
381
|
e(this, "name", "getCarrierOptions");
|
|
@@ -347,7 +383,7 @@ class M extends o {
|
|
|
347
383
|
e(this, "property", "carrier_options");
|
|
348
384
|
}
|
|
349
385
|
}
|
|
350
|
-
class
|
|
386
|
+
class N extends o {
|
|
351
387
|
constructor() {
|
|
352
388
|
super(...arguments);
|
|
353
389
|
e(this, "method", "POST");
|
|
@@ -357,7 +393,7 @@ class R extends o {
|
|
|
357
393
|
e(this, "responseProperty", "ids");
|
|
358
394
|
}
|
|
359
395
|
}
|
|
360
|
-
class
|
|
396
|
+
class z extends o {
|
|
361
397
|
constructor() {
|
|
362
398
|
super(...arguments);
|
|
363
399
|
e(this, "name", "putCarrierOptions");
|
|
@@ -366,7 +402,7 @@ class W extends o {
|
|
|
366
402
|
e(this, "method", "PUT");
|
|
367
403
|
}
|
|
368
404
|
}
|
|
369
|
-
class
|
|
405
|
+
class J extends o {
|
|
370
406
|
constructor() {
|
|
371
407
|
super(...arguments);
|
|
372
408
|
e(this, "name", "getLocations");
|
|
@@ -374,7 +410,7 @@ class N extends o {
|
|
|
374
410
|
e(this, "property", "locations");
|
|
375
411
|
}
|
|
376
412
|
}
|
|
377
|
-
class
|
|
413
|
+
class K extends o {
|
|
378
414
|
constructor() {
|
|
379
415
|
super(...arguments);
|
|
380
416
|
e(this, "name", "getShipment");
|
|
@@ -382,7 +418,7 @@ class z extends o {
|
|
|
382
418
|
e(this, "property", "shipments");
|
|
383
419
|
}
|
|
384
420
|
}
|
|
385
|
-
class
|
|
421
|
+
class B extends o {
|
|
386
422
|
constructor() {
|
|
387
423
|
super(...arguments);
|
|
388
424
|
e(this, "name", "getShipments");
|
|
@@ -390,7 +426,7 @@ class J extends o {
|
|
|
390
426
|
e(this, "property", "shipments");
|
|
391
427
|
}
|
|
392
428
|
}
|
|
393
|
-
class
|
|
429
|
+
class F extends o {
|
|
394
430
|
constructor() {
|
|
395
431
|
super(...arguments);
|
|
396
432
|
e(this, "method", "POST");
|
|
@@ -406,7 +442,7 @@ class K extends o {
|
|
|
406
442
|
};
|
|
407
443
|
}
|
|
408
444
|
}
|
|
409
|
-
class
|
|
445
|
+
class I extends o {
|
|
410
446
|
constructor() {
|
|
411
447
|
super(...arguments);
|
|
412
448
|
e(this, "name", "getShop");
|
|
@@ -414,7 +450,7 @@ class B extends o {
|
|
|
414
450
|
e(this, "property", "shops");
|
|
415
451
|
}
|
|
416
452
|
}
|
|
417
|
-
class
|
|
453
|
+
class Q extends o {
|
|
418
454
|
constructor() {
|
|
419
455
|
super(...arguments);
|
|
420
456
|
e(this, "method", "POST");
|
|
@@ -424,16 +460,7 @@ class F extends o {
|
|
|
424
460
|
e(this, "responseProperty", "ids");
|
|
425
461
|
}
|
|
426
462
|
}
|
|
427
|
-
class
|
|
428
|
-
constructor() {
|
|
429
|
-
super(...arguments);
|
|
430
|
-
e(this, "method", "PUT");
|
|
431
|
-
e(this, "name", "putShop");
|
|
432
|
-
e(this, "path", "shops");
|
|
433
|
-
e(this, "property", "shops");
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
class Q extends o {
|
|
463
|
+
class X extends o {
|
|
437
464
|
constructor() {
|
|
438
465
|
super(...arguments);
|
|
439
466
|
e(this, "method", "POST");
|
|
@@ -442,7 +469,16 @@ class Q extends o {
|
|
|
442
469
|
e(this, "property", "ids");
|
|
443
470
|
}
|
|
444
471
|
}
|
|
445
|
-
class
|
|
472
|
+
class Y extends o {
|
|
473
|
+
constructor() {
|
|
474
|
+
super(...arguments);
|
|
475
|
+
e(this, "method", "PUT");
|
|
476
|
+
e(this, "name", "putShop");
|
|
477
|
+
e(this, "path", "shops");
|
|
478
|
+
e(this, "property", "shops");
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
class Z extends o {
|
|
446
482
|
constructor() {
|
|
447
483
|
super(...arguments);
|
|
448
484
|
e(this, "name", "getSubscriptionsCapabilities");
|
|
@@ -450,7 +486,7 @@ class X extends o {
|
|
|
450
486
|
e(this, "property", "capabilities");
|
|
451
487
|
}
|
|
452
488
|
}
|
|
453
|
-
class
|
|
489
|
+
class V extends o {
|
|
454
490
|
constructor() {
|
|
455
491
|
super(...arguments);
|
|
456
492
|
e(this, "method", "DELETE");
|
|
@@ -459,7 +495,7 @@ class Y extends o {
|
|
|
459
495
|
e(this, "property", "subscriptions");
|
|
460
496
|
}
|
|
461
497
|
}
|
|
462
|
-
class
|
|
498
|
+
class ee extends o {
|
|
463
499
|
constructor() {
|
|
464
500
|
super(...arguments);
|
|
465
501
|
e(this, "name", "getSubscriptions");
|
|
@@ -467,7 +503,7 @@ class Z extends o {
|
|
|
467
503
|
e(this, "property", "subscriptions");
|
|
468
504
|
}
|
|
469
505
|
}
|
|
470
|
-
class
|
|
506
|
+
class te extends o {
|
|
471
507
|
constructor() {
|
|
472
508
|
super(...arguments);
|
|
473
509
|
e(this, "method", "PATCH");
|
|
@@ -477,7 +513,7 @@ class V extends o {
|
|
|
477
513
|
e(this, "responseProperty", "ids");
|
|
478
514
|
}
|
|
479
515
|
}
|
|
480
|
-
class
|
|
516
|
+
class se extends o {
|
|
481
517
|
constructor() {
|
|
482
518
|
super(...arguments);
|
|
483
519
|
e(this, "method", "POST");
|
|
@@ -487,7 +523,7 @@ class ee extends o {
|
|
|
487
523
|
e(this, "responseProperty", "ids");
|
|
488
524
|
}
|
|
489
525
|
}
|
|
490
|
-
class
|
|
526
|
+
class re extends o {
|
|
491
527
|
constructor() {
|
|
492
528
|
super(...arguments);
|
|
493
529
|
e(this, "name", "getSystemCountryCodes");
|
|
@@ -495,7 +531,7 @@ class te extends o {
|
|
|
495
531
|
e(this, "property", "countries");
|
|
496
532
|
}
|
|
497
533
|
}
|
|
498
|
-
class
|
|
534
|
+
class ae extends o {
|
|
499
535
|
constructor() {
|
|
500
536
|
super(...arguments);
|
|
501
537
|
e(this, "name", "getSystemMessages");
|
|
@@ -503,7 +539,7 @@ class se extends o {
|
|
|
503
539
|
e(this, "property", "messages");
|
|
504
540
|
}
|
|
505
541
|
}
|
|
506
|
-
class
|
|
542
|
+
class oe extends o {
|
|
507
543
|
constructor() {
|
|
508
544
|
super(...arguments);
|
|
509
545
|
e(this, "name", "getTrackAndTrace");
|
|
@@ -511,7 +547,7 @@ class re extends o {
|
|
|
511
547
|
e(this, "property", "tracktraces");
|
|
512
548
|
}
|
|
513
549
|
}
|
|
514
|
-
class
|
|
550
|
+
class ie extends o {
|
|
515
551
|
constructor() {
|
|
516
552
|
super(...arguments);
|
|
517
553
|
e(this, "method", "DELETE");
|
|
@@ -520,7 +556,7 @@ class ae extends o {
|
|
|
520
556
|
e(this, "property", "webhook_subscriptions");
|
|
521
557
|
}
|
|
522
558
|
}
|
|
523
|
-
class
|
|
559
|
+
class ne extends o {
|
|
524
560
|
constructor() {
|
|
525
561
|
super(...arguments);
|
|
526
562
|
e(this, "name", "getWebhookSubscriptions");
|
|
@@ -528,7 +564,7 @@ class oe extends o {
|
|
|
528
564
|
e(this, "property", "webhook_subscriptions");
|
|
529
565
|
}
|
|
530
566
|
}
|
|
531
|
-
class
|
|
567
|
+
class pe extends o {
|
|
532
568
|
constructor() {
|
|
533
569
|
super(...arguments);
|
|
534
570
|
e(this, "method", "POST");
|
|
@@ -538,7 +574,7 @@ class ie extends o {
|
|
|
538
574
|
e(this, "responseProperty", "ids");
|
|
539
575
|
}
|
|
540
576
|
}
|
|
541
|
-
class
|
|
577
|
+
class ce extends m {
|
|
542
578
|
constructor() {
|
|
543
579
|
super(...arguments);
|
|
544
580
|
e(this, "name", "getCarrier");
|
|
@@ -546,7 +582,7 @@ class ne extends m {
|
|
|
546
582
|
e(this, "property", "carriers");
|
|
547
583
|
}
|
|
548
584
|
}
|
|
549
|
-
class
|
|
585
|
+
class de extends m {
|
|
550
586
|
constructor() {
|
|
551
587
|
super(...arguments);
|
|
552
588
|
e(this, "name", "getCarriers");
|
|
@@ -554,7 +590,7 @@ class pe extends m {
|
|
|
554
590
|
e(this, "property", "carriers");
|
|
555
591
|
}
|
|
556
592
|
}
|
|
557
|
-
class
|
|
593
|
+
class he extends m {
|
|
558
594
|
constructor() {
|
|
559
595
|
super(...arguments);
|
|
560
596
|
e(this, "name", "getDeliveryOptions");
|
|
@@ -565,7 +601,7 @@ class ce extends m {
|
|
|
565
601
|
return { ...super.getHeaders(), Accept: "application/json;version=2.0" };
|
|
566
602
|
}
|
|
567
603
|
}
|
|
568
|
-
class
|
|
604
|
+
class ue extends m {
|
|
569
605
|
constructor() {
|
|
570
606
|
super(...arguments);
|
|
571
607
|
e(this, "name", "getPickupLocations");
|
|
@@ -574,51 +610,51 @@ class de extends m {
|
|
|
574
610
|
}
|
|
575
611
|
}
|
|
576
612
|
export {
|
|
577
|
-
|
|
578
|
-
|
|
613
|
+
k as AbstractClient,
|
|
614
|
+
x as AbstractEndpoint,
|
|
579
615
|
o as AbstractPrivateEndpoint,
|
|
580
616
|
m as AbstractPublicEndpoint,
|
|
581
617
|
y as ApiException,
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
+
C as BASE_URL,
|
|
619
|
+
D as DeleteAccountMessage,
|
|
620
|
+
R as DeleteCarrierOptions,
|
|
621
|
+
V as DeleteSubscription,
|
|
622
|
+
ie as DeleteWebhookSubscriptions,
|
|
623
|
+
H as FetchClient,
|
|
624
|
+
j as GetAccount,
|
|
625
|
+
q as GetAccountMessages,
|
|
626
|
+
U as GetAccounts,
|
|
627
|
+
$ as GetApiKeys,
|
|
628
|
+
ce as GetCarrier,
|
|
629
|
+
W as GetCarrierOptions,
|
|
630
|
+
de as GetCarriers,
|
|
631
|
+
he as GetDeliveryOptions,
|
|
632
|
+
J as GetLocations,
|
|
633
|
+
ue as GetPickupLocations,
|
|
634
|
+
K as GetShipment,
|
|
635
|
+
B as GetShipments,
|
|
636
|
+
I as GetShop,
|
|
637
|
+
ee as GetSubscriptions,
|
|
638
|
+
Z as GetSubscriptionsCapabilities,
|
|
639
|
+
re as GetSystemCountryCodes,
|
|
640
|
+
ae as GetSystemMessages,
|
|
641
|
+
oe as GetTrackAndTrace,
|
|
642
|
+
ne as GetWebhookSubscriptions,
|
|
643
|
+
te as PatchSubscriptions,
|
|
644
|
+
M as PostApiKeys,
|
|
645
|
+
N as PostCarrierOptions,
|
|
646
|
+
F as PostShipments,
|
|
647
|
+
Q as PostShop,
|
|
648
|
+
X as PostShopDuplicate,
|
|
649
|
+
se as PostSubscriptions,
|
|
650
|
+
pe as PostWebhookSubscriptions,
|
|
651
|
+
L as PutAccount,
|
|
652
|
+
z as PutCarrierOptions,
|
|
653
|
+
Y as PutShop,
|
|
618
654
|
h as UserException,
|
|
619
655
|
_ as addParameters,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
656
|
+
f as createMyParcelSdk,
|
|
657
|
+
G as createPrivateSdk,
|
|
658
|
+
v as createPublicSdk,
|
|
659
|
+
w as isJson
|
|
624
660
|
};
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Interceptors } from './middleware/Interceptors';
|
|
2
|
+
import { RequestHeader, RequestHeaders, ResponseWrapper } from '../../types/request.types';
|
|
3
|
+
import { WithRequired } from '../../types';
|
|
4
|
+
import { AbstractEndpoint } from '../endpoint/AbstractEndpoint';
|
|
5
|
+
import { ClientConfig, ClientOptions, ClientRequest, EndpointPath, EndpointResponse, EndpointResponseBody, PaginatedEndpointResponse, Options, OptionsWithBody, OptionsWithoutBody } from './AbstractClient.types';
|
|
6
|
+
|
|
5
7
|
export declare const BASE_URL = "https://api.myparcel.nl";
|
|
6
8
|
export declare abstract class AbstractClient {
|
|
9
|
+
/**
|
|
10
|
+
* Interceptors for request and response.
|
|
11
|
+
*
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
interceptors: {
|
|
15
|
+
request: Interceptors<OptionsWithBody<AbstractEndpoint> | OptionsWithoutBody<AbstractEndpoint>>;
|
|
16
|
+
response: Interceptors<ResponseWrapper<EndpointResponseBody<AbstractEndpoint>>>;
|
|
17
|
+
};
|
|
7
18
|
/**
|
|
8
19
|
* Executes the request. Should return a promise containing the response json as object.
|
|
9
20
|
*/
|