@zenky/storefront-api 0.0.27 → 0.0.28
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.
|
@@ -74,7 +74,7 @@ class S extends d {
|
|
|
74
74
|
return this.getResponse(await this.client.request("GET", s));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class E extends Error {
|
|
78
78
|
constructor(e, s) {
|
|
79
79
|
super(e);
|
|
80
80
|
l(this, "err");
|
|
@@ -86,9 +86,9 @@ class A {
|
|
|
86
86
|
const e = await t.json();
|
|
87
87
|
switch (t.status) {
|
|
88
88
|
case 401:
|
|
89
|
-
return new
|
|
89
|
+
return new E((e == null ? void 0 : e.message) ?? "Unauthenticated.", null);
|
|
90
90
|
default:
|
|
91
|
-
return new
|
|
91
|
+
return new E(e == null ? void 0 : e.message, (e == null ? void 0 : e.error) || null);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -380,7 +380,7 @@ class V extends d {
|
|
|
380
380
|
}
|
|
381
381
|
async revokeToken(t, e) {
|
|
382
382
|
const s = this.getStoreUrl(t, "/me/logout");
|
|
383
|
-
return await this.client.request("
|
|
383
|
+
return await this.client.request("POST", s, null, e), !0;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
/**
|
|
@@ -413,7 +413,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
413
413
|
* @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
|
|
414
414
|
* @return {Boolean}
|
|
415
415
|
*/
|
|
416
|
-
},
|
|
416
|
+
}, O = function(t, e) {
|
|
417
417
|
return !(typeof e == "string" && t.origin !== e || !t.data || typeof t.data == "object" && !("postmate" in t.data) || t.data.type !== p || !M[t.data.postmate]);
|
|
418
418
|
}, z = function(t, e) {
|
|
419
419
|
var s = typeof t[e] == "function" ? t[e]() : t[e];
|
|
@@ -422,7 +422,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
422
422
|
function r(e) {
|
|
423
423
|
var s = this;
|
|
424
424
|
this.parent = e.parent, this.frame = e.frame, this.child = e.child, this.childOrigin = e.childOrigin, this.events = {}, process.env.NODE_ENV !== "production" && (u("Parent: Registering API"), u("Parent: Awaiting messages...")), this.listener = function(n) {
|
|
425
|
-
if (!
|
|
425
|
+
if (!O(n, s.childOrigin))
|
|
426
426
|
return !1;
|
|
427
427
|
var i = ((n || {}).data || {}).value || {}, a = i.data, o = i.name;
|
|
428
428
|
n.data.postmate === "emit" && (process.env.NODE_ENV !== "production" && u("Parent: Received event emission: " + o), o in s.events && s.events[o].call(s, a));
|
|
@@ -458,7 +458,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
458
458
|
function r(e) {
|
|
459
459
|
var s = this;
|
|
460
460
|
this.model = e.model, this.parent = e.parent, this.parentOrigin = e.parentOrigin, this.child = e.child, process.env.NODE_ENV !== "production" && (u("Child: Registering API"), u("Child: Awaiting messages...")), this.child.addEventListener("message", function(n) {
|
|
461
|
-
if (
|
|
461
|
+
if (O(n, s.parentOrigin)) {
|
|
462
462
|
process.env.NODE_ENV !== "production" && u("Child: Received request", n.data);
|
|
463
463
|
var i = n.data, a = i.property, o = i.uid, c = i.data;
|
|
464
464
|
if (n.data.postmate === "call") {
|
|
@@ -498,7 +498,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
498
498
|
var n = this, i = L(s), a = 0, o;
|
|
499
499
|
return new r.Promise(function(c, h) {
|
|
500
500
|
var m = function v(y) {
|
|
501
|
-
return
|
|
501
|
+
return O(y, i) ? y.data.postmate === "handshake-reply" ? (clearInterval(o), process.env.NODE_ENV !== "production" && u("Parent: Received handshake reply from Child"), n.parent.removeEventListener("message", v, !1), n.childOrigin = y.origin, process.env.NODE_ENV !== "production" && u("Parent: Saving Child origin", n.childOrigin), c(new j(n))) : (process.env.NODE_ENV !== "production" && u("Parent: Invalid handshake reply"), h("Failed handshake")) : !1;
|
|
502
502
|
};
|
|
503
503
|
n.parent.addEventListener("message", m, !1);
|
|
504
504
|
var f = function() {
|
|
@@ -663,7 +663,7 @@ export {
|
|
|
663
663
|
me as TernaryFilter,
|
|
664
664
|
le as UnitType,
|
|
665
665
|
he as VariantOptionType,
|
|
666
|
-
|
|
666
|
+
E as ZenkyError,
|
|
667
667
|
A as ZenkyErrorBuilder,
|
|
668
668
|
ke as ZenkyStorefront
|
|
669
669
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.zenkyStorefrontApi={}))})(this,function(i){"use strict";var we=Object.defineProperty;var ke=(i,g,h)=>g in i?we(i,g,{enumerable:!0,configurable:!0,writable:!0,value:h}):i[g]=h;var u=(i,g,h)=>(ke(i,typeof g!="symbol"?g+"":g,h),h);var g=(r=>(r.DADATA="dadata",r))(g||{});class h{constructor(t){this.client=t}getStoreUrl(t,e,s={}){return this.getUrl(`/store/${t}${e}`,s)}getUrl(t,e={}){if(!Object.keys(e).length)return t;const s=[];Object.keys(e).forEach(a=>{s.push(`${a}=${e[a]}`)});const n=t.includes("?")?"&":"?";return`${t}${n}${s.join("&")}`}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const e=t.data,s=t.meta.pagination;return{items:e,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class U extends h{async getArticleCategories(t){const e=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",e))}async getArticleCategory(t,e){const s=this.getStoreUrl(t,`/articles/categories/${e}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,e){const s=this.getStoreUrl(t,"/articles",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,e,s){const n=this.getStoreUrl(t,`/articles/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class S extends h{async getCategories(t,e){const s=this.getStoreUrl(t,"/categories",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,e){const s=this.getStoreUrl(t,"/categories/tree",e);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,e,s){const n=this.getStoreUrl(t,`/categories/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getFeaturesGroups(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features`);return this.getResponse(await this.client.request("GET",s))}}class O extends Error{constructor(e,s){super(e);u(this,"err");this.err=s}}class q{static async build(t){const e=await t.json();switch(t.status){case 401:return new O((e==null?void 0:e.message)??"Unauthenticated.",null);default:return new O(e==null?void 0:e.message,(e==null?void 0:e.error)||null)}}}class R{constructor(t,e,s,n,a,o,l){u(this,"baseUrl");u(this,"baseAuthUrl");u(this,"token");u(this,"client");u(this,"timezone");u(this,"fetchFunction");u(this,"fetchOptions");this.baseUrl=t,this.baseAuthUrl=e,this.token=s,this.client=n,this.timezone=a,this.fetchFunction=typeof o=="function"?o:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,e){return new R((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.baseAuthUrl)||"https://auth.zenky.io/",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",e,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}getBaseAuthUrl(){return this.baseAuthUrl}async request(t,e,s,n){const a={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};n?a.Authorization=`Bearer ${n}`:this.token&&(a.Authorization=`Bearer ${this.token}`);const o={method:t,mode:"cors",...this.fetchOptions};s&&(a["Content-Type"]="application/json",o.body=JSON.stringify(s)),o.headers=a;const l=await this.fetchFunction.call(null,`${this.baseUrl}${e}`,o);if(l.ok)return l.status===204?!0:l.json();throw await q.build(l)}}class T extends h{async getStore(t){const e=this.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",e))}async getStoreByBundleId(t){const e=this.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",e))}}class A extends h{async getCollections(t,e){const s=this.getStoreUrl(t,"/collections",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,e){const s=this.getStoreUrl(t,`/collections/${e}`);return this.getResponse(await this.client.request("GET",s))}}class b extends h{async getOffers(t,e){const s=this.getStoreUrl(t,"/offers",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,e,s){const n=this.getStoreUrl(t,`/offers/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class _ extends h{async createFeedback(t,e){const s=this.getStoreUrl(t,"/feedback",e);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,e){const s=this.getStoreUrl(t,"/callback",e);return await this.client.request("POST",s),!0}}class C extends h{async getProducts(t,e){const s=this.getStoreUrl(t,"/products",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,e,s){const n=this.getStoreUrl(t,`/products/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getProductVariantPrice(t,e,s,n){const a=this.getStoreUrl(t,`/products/${e}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",a,n))}}class N extends h{getOrderUrl(t,e,s,n){const a=typeof e=="string"?e:e.id,o=typeof e=="string"?void 0:e.token;return this.getStoreUrl(t,`/orders/${a}${s}${o?"?token="+o:""}`,n)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,e,s){const n=this.getStoreUrl(t,"/orders",e);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,s))}async createOrder(t,e,s){const n=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",n,e,s))}async getOrder(t,e,s){const n=this.getOrderUrl(t,e,"",s);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderSettings(t,e){const s=this.getOrderUrl(t,e,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async addProductVariantToOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async removeProductVariantFromOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async checkProducts(t,e){const s=this.getOrderUrl(t,e,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e)))}async getOrderCheckoutUrl(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/url");return this.getResponse(await this.client.request("POST",n,{redirect_url:s},this.getApiToken(e))).url}async setOrderCustomer(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/customer");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async setOrderDeliveryMethod(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/delivery");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async setOrderPayments(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async getOrderBonusesPreview(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments/bonuses",{amount:s});return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderTotal(t,e){const s=this.getOrderUrl(t,e,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async checkoutOrder(t,e,s){const n=this.getOrderUrl(t,e,"/checkout");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async confirmOrder(t,e,s){const n=this.getOrderUrl(t,e,"/confirm");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async resendOrderConfirmationCode(t,e){const s=this.getOrderUrl(t,e,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(e)),!0}async getOrderBonusesTransactions(t,e,s){const n=this.getOrderUrl(t,e,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderCashbackTransaction(t,e){const s=this.getOrderUrl(t,e,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async dispatchPromotionsChecker(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e))).dispatched}async getOrderPromotionRewards(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async getCloudpaymentsReceipt(t,e,s){const n=this.getOrderUrl(t,e,`/payments/${s}/receipt`);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}}class oe extends h{async getAddressSuggestions(t,e){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,e))}}class le extends h{async getProfile(t,e,s){const n=this.getStoreUrl(t,"/me",e);return this.getResponse(await this.client.request("GET",n,null,s))}async updateProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",n,e,s))}async removeProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",n,e,s),!0}async getSettings(t,e){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,e))}async updateSettings(t,e,s){const n=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",n,e,s))}async getAddresses(t,e,s){const n=this.getStoreUrl(t,"/me/addresses",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async createAddress(t,e,s){const n=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",n,e,s))}async updateAddress(t,e,s,n){const a=this.getStoreUrl(t,`/me/addresses/${e}`);return this.getResponse(await this.client.request("PUT",a,s,n))}async deleteAddress(t,e,s){const n=this.getStoreUrl(t,`/me/addresses/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getPaymentMethods(t,e,s){const n=this.getStoreUrl(t,"/me/payment-methods",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async deletePaymentMethod(t,e,s){const n=this.getStoreUrl(t,`/me/payment-methods/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getBonusesTransactions(t,e,s){const n=this.getStoreUrl(t,"/me/loyalty/transactions",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async getBonusesBalance(t,e){const s=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",s,null,e))}async revokeToken(t,e){const s=this.getStoreUrl(t,"/me/logout");return await this.client.request("GET",s,null,e),!0}}/**
|
|
1
|
+
(function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.zenkyStorefrontApi={}))})(this,function(i){"use strict";var we=Object.defineProperty;var ke=(i,g,h)=>g in i?we(i,g,{enumerable:!0,configurable:!0,writable:!0,value:h}):i[g]=h;var u=(i,g,h)=>(ke(i,typeof g!="symbol"?g+"":g,h),h);var g=(r=>(r.DADATA="dadata",r))(g||{});class h{constructor(t){this.client=t}getStoreUrl(t,e,s={}){return this.getUrl(`/store/${t}${e}`,s)}getUrl(t,e={}){if(!Object.keys(e).length)return t;const s=[];Object.keys(e).forEach(a=>{s.push(`${a}=${e[a]}`)});const n=t.includes("?")?"&":"?";return`${t}${n}${s.join("&")}`}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const e=t.data,s=t.meta.pagination;return{items:e,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class U extends h{async getArticleCategories(t){const e=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",e))}async getArticleCategory(t,e){const s=this.getStoreUrl(t,`/articles/categories/${e}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,e){const s=this.getStoreUrl(t,"/articles",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,e,s){const n=this.getStoreUrl(t,`/articles/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class S extends h{async getCategories(t,e){const s=this.getStoreUrl(t,"/categories",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,e){const s=this.getStoreUrl(t,"/categories/tree",e);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,e,s){const n=this.getStoreUrl(t,`/categories/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getFeaturesGroups(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features`);return this.getResponse(await this.client.request("GET",s))}}class O extends Error{constructor(e,s){super(e);u(this,"err");this.err=s}}class q{static async build(t){const e=await t.json();switch(t.status){case 401:return new O((e==null?void 0:e.message)??"Unauthenticated.",null);default:return new O(e==null?void 0:e.message,(e==null?void 0:e.error)||null)}}}class R{constructor(t,e,s,n,a,o,l){u(this,"baseUrl");u(this,"baseAuthUrl");u(this,"token");u(this,"client");u(this,"timezone");u(this,"fetchFunction");u(this,"fetchOptions");this.baseUrl=t,this.baseAuthUrl=e,this.token=s,this.client=n,this.timezone=a,this.fetchFunction=typeof o=="function"?o:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,e){return new R((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.baseAuthUrl)||"https://auth.zenky.io/",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",e,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}getBaseAuthUrl(){return this.baseAuthUrl}async request(t,e,s,n){const a={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};n?a.Authorization=`Bearer ${n}`:this.token&&(a.Authorization=`Bearer ${this.token}`);const o={method:t,mode:"cors",...this.fetchOptions};s&&(a["Content-Type"]="application/json",o.body=JSON.stringify(s)),o.headers=a;const l=await this.fetchFunction.call(null,`${this.baseUrl}${e}`,o);if(l.ok)return l.status===204?!0:l.json();throw await q.build(l)}}class T extends h{async getStore(t){const e=this.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",e))}async getStoreByBundleId(t){const e=this.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",e))}}class A extends h{async getCollections(t,e){const s=this.getStoreUrl(t,"/collections",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,e){const s=this.getStoreUrl(t,`/collections/${e}`);return this.getResponse(await this.client.request("GET",s))}}class b extends h{async getOffers(t,e){const s=this.getStoreUrl(t,"/offers",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,e,s){const n=this.getStoreUrl(t,`/offers/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class _ extends h{async createFeedback(t,e){const s=this.getStoreUrl(t,"/feedback",e);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,e){const s=this.getStoreUrl(t,"/callback",e);return await this.client.request("POST",s),!0}}class C extends h{async getProducts(t,e){const s=this.getStoreUrl(t,"/products",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,e,s){const n=this.getStoreUrl(t,`/products/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getProductVariantPrice(t,e,s,n){const a=this.getStoreUrl(t,`/products/${e}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",a,n))}}class N extends h{getOrderUrl(t,e,s,n){const a=typeof e=="string"?e:e.id,o=typeof e=="string"?void 0:e.token;return this.getStoreUrl(t,`/orders/${a}${s}${o?"?token="+o:""}`,n)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,e,s){const n=this.getStoreUrl(t,"/orders",e);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,s))}async createOrder(t,e,s){const n=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",n,e,s))}async getOrder(t,e,s){const n=this.getOrderUrl(t,e,"",s);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderSettings(t,e){const s=this.getOrderUrl(t,e,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async addProductVariantToOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async removeProductVariantFromOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async checkProducts(t,e){const s=this.getOrderUrl(t,e,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e)))}async getOrderCheckoutUrl(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/url");return this.getResponse(await this.client.request("POST",n,{redirect_url:s},this.getApiToken(e))).url}async setOrderCustomer(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/customer");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async setOrderDeliveryMethod(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/delivery");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async setOrderPayments(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async getOrderBonusesPreview(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments/bonuses",{amount:s});return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderTotal(t,e){const s=this.getOrderUrl(t,e,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async checkoutOrder(t,e,s){const n=this.getOrderUrl(t,e,"/checkout");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async confirmOrder(t,e,s){const n=this.getOrderUrl(t,e,"/confirm");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async resendOrderConfirmationCode(t,e){const s=this.getOrderUrl(t,e,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(e)),!0}async getOrderBonusesTransactions(t,e,s){const n=this.getOrderUrl(t,e,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderCashbackTransaction(t,e){const s=this.getOrderUrl(t,e,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async dispatchPromotionsChecker(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e))).dispatched}async getOrderPromotionRewards(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async getCloudpaymentsReceipt(t,e,s){const n=this.getOrderUrl(t,e,`/payments/${s}/receipt`);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}}class oe extends h{async getAddressSuggestions(t,e){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,e))}}class le extends h{async getProfile(t,e,s){const n=this.getStoreUrl(t,"/me",e);return this.getResponse(await this.client.request("GET",n,null,s))}async updateProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",n,e,s))}async removeProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",n,e,s),!0}async getSettings(t,e){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,e))}async updateSettings(t,e,s){const n=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",n,e,s))}async getAddresses(t,e,s){const n=this.getStoreUrl(t,"/me/addresses",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async createAddress(t,e,s){const n=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",n,e,s))}async updateAddress(t,e,s,n){const a=this.getStoreUrl(t,`/me/addresses/${e}`);return this.getResponse(await this.client.request("PUT",a,s,n))}async deleteAddress(t,e,s){const n=this.getStoreUrl(t,`/me/addresses/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getPaymentMethods(t,e,s){const n=this.getStoreUrl(t,"/me/payment-methods",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async deletePaymentMethod(t,e,s){const n=this.getStoreUrl(t,`/me/payment-methods/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getBonusesTransactions(t,e,s){const n=this.getStoreUrl(t,"/me/loyalty/transactions",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async getBonusesBalance(t,e){const s=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",s,null,e))}async revokeToken(t,e){const s=this.getStoreUrl(t,"/me/logout");return await this.client.request("POST",s,null,e),!0}}/**
|
|
2
2
|
postmate - A powerful, simple, promise-based postMessage library
|
|
3
3
|
@version v1.5.2
|
|
4
4
|
@link https://github.com/dollarshaveclub/postmate
|