@zenky/storefront-api 0.0.26 → 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.
package/dist/index.d.ts
CHANGED
|
@@ -1311,7 +1311,8 @@ declare class CustomersResource extends AbstractResource {
|
|
|
1311
1311
|
getPaymentMethods(storeId: string, request?: PaginationRequest, apiToken?: string): Promise<PaginatedResponse<CustomerPaymentMethod>>;
|
|
1312
1312
|
deletePaymentMethod(storeId: string, paymentMethodId: string, apiToken?: string): Promise<boolean>;
|
|
1313
1313
|
getBonusesTransactions(storeId: string, request?: ListCustomerBonusesTransactionsRequest, apiToken?: string): Promise<PaginatedResponse<BonusesTransaction>>;
|
|
1314
|
-
getBonusesBalance(storeId: string): Promise<ResolverBonusesBalance>;
|
|
1314
|
+
getBonusesBalance(storeId: string, apiToken?: string): Promise<ResolverBonusesBalance>;
|
|
1315
|
+
revokeToken(storeId: string, apiToken?: string): Promise<boolean>;
|
|
1315
1316
|
}
|
|
1316
1317
|
declare class AuthenticationResource extends AbstractResource {
|
|
1317
1318
|
checkPhone(storeId: string, request: CheckPhoneRequest): Promise<PhoneCheckResult>;
|
|
@@ -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
|
}
|
|
@@ -374,9 +374,13 @@ class V extends d {
|
|
|
374
374
|
const n = this.getStoreUrl(t, "/me/loyalty/transactions", e);
|
|
375
375
|
return this.getPaginatedResponse(await this.client.request("GET", n, null, s));
|
|
376
376
|
}
|
|
377
|
-
async getBonusesBalance(t) {
|
|
378
|
-
const
|
|
379
|
-
return this.getResponse(await this.client.request("GET",
|
|
377
|
+
async getBonusesBalance(t, e) {
|
|
378
|
+
const s = this.getStoreUrl(t, "/me/loyalty/balance");
|
|
379
|
+
return this.getResponse(await this.client.request("GET", s, null, e));
|
|
380
|
+
}
|
|
381
|
+
async revokeToken(t, e) {
|
|
382
|
+
const s = this.getStoreUrl(t, "/me/logout");
|
|
383
|
+
return await this.client.request("POST", s, null, e), !0;
|
|
380
384
|
}
|
|
381
385
|
}
|
|
382
386
|
/**
|
|
@@ -409,7 +413,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
409
413
|
* @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
|
|
410
414
|
* @return {Boolean}
|
|
411
415
|
*/
|
|
412
|
-
},
|
|
416
|
+
}, O = function(t, e) {
|
|
413
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]);
|
|
414
418
|
}, z = function(t, e) {
|
|
415
419
|
var s = typeof t[e] == "function" ? t[e]() : t[e];
|
|
@@ -418,7 +422,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
418
422
|
function r(e) {
|
|
419
423
|
var s = this;
|
|
420
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) {
|
|
421
|
-
if (!
|
|
425
|
+
if (!O(n, s.childOrigin))
|
|
422
426
|
return !1;
|
|
423
427
|
var i = ((n || {}).data || {}).value || {}, a = i.data, o = i.name;
|
|
424
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));
|
|
@@ -454,7 +458,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
454
458
|
function r(e) {
|
|
455
459
|
var s = this;
|
|
456
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) {
|
|
457
|
-
if (
|
|
461
|
+
if (O(n, s.parentOrigin)) {
|
|
458
462
|
process.env.NODE_ENV !== "production" && u("Child: Received request", n.data);
|
|
459
463
|
var i = n.data, a = i.property, o = i.uid, c = i.data;
|
|
460
464
|
if (n.data.postmate === "call") {
|
|
@@ -494,7 +498,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
|
|
|
494
498
|
var n = this, i = L(s), a = 0, o;
|
|
495
499
|
return new r.Promise(function(c, h) {
|
|
496
500
|
var m = function v(y) {
|
|
497
|
-
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;
|
|
498
502
|
};
|
|
499
503
|
n.parent.addEventListener("message", m, !1);
|
|
500
504
|
var f = function() {
|
|
@@ -659,7 +663,7 @@ export {
|
|
|
659
663
|
me as TernaryFilter,
|
|
660
664
|
le as UnitType,
|
|
661
665
|
he as VariantOptionType,
|
|
662
|
-
|
|
666
|
+
E as ZenkyError,
|
|
663
667
|
A as ZenkyErrorBuilder,
|
|
664
668
|
ke as ZenkyStorefront
|
|
665
669
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
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 A 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 T 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){const e=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",e,null,null))}}/**
|
|
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
|
|
5
5
|
@author Jacob Kelley <jakie8@gmail.com>
|
|
6
6
|
@license MIT
|
|
7
|
-
**/var f="application/x-postmate-v1+json",ue=5,ce=0,he=function(){return++ce},c=function(){var t;return m.debug?(t=console).log.apply(t,arguments):null},de=function(t){var e=document.createElement("a");e.href=t;var s=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||s+"//"+n},ge={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},E=function(t,e){return!(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==f||!ge[t.data.postmate])},pe=function(t,e){var s=typeof t[e]=="function"?t[e]():t[e];return m.Promise.resolve(s)},me=function(){function r(e){var s=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},process.env.NODE_ENV!=="production"&&(c("Parent: Registering API"),c("Parent: Awaiting messages...")),this.listener=function(n){if(!E(n,s.childOrigin))return!1;var a=((n||{}).data||{}).value||{},o=a.data,l=a.name;n.data.postmate==="emit"&&(process.env.NODE_ENV!=="production"&&c("Parent: Received event emission: "+l),l in s.events&&s.events[l].call(s,o))},this.parent.addEventListener("message",this.listener,!1),process.env.NODE_ENV!=="production"&&c("Parent: Awaiting event emissions from Child")}var t=r.prototype;return t.get=function(s){var n=this;return new m.Promise(function(a){var o=he(),l=function d(p){p.data.uid===o&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(p.data.value))};n.parent.addEventListener("message",l,!1),n.child.postMessage({postmate:"request",type:f,property:s,uid:o},n.childOrigin)})},t.call=function(s,n){this.child.postMessage({postmate:"call",type:f,property:s,data:n},this.childOrigin)},t.on=function(s,n){this.events[s]=n},t.destroy=function(){process.env.NODE_ENV!=="production"&&c("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},r}(),fe=function(){function r(e){var s=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,process.env.NODE_ENV!=="production"&&(c("Child: Registering API"),c("Child: Awaiting messages...")),this.child.addEventListener("message",function(n){if(E(n,s.parentOrigin)){process.env.NODE_ENV!=="production"&&c("Child: Received request",n.data);var a=n.data,o=a.property,l=a.uid,d=a.data;if(n.data.postmate==="call"){o in s.model&&typeof s.model[o]=="function"&&s.model[o](d);return}pe(s.model,o).then(function(p){return n.source.postMessage({property:o,postmate:"reply",type:f,uid:l,value:p},n.origin)})}})}var t=r.prototype;return t.emit=function(s,n){process.env.NODE_ENV!=="production"&&c('Child: Emitting Event "'+s+'"',n),this.parent.postMessage({postmate:"emit",type:f,value:{name:s,data:n}},this.parentOrigin)},r}(),m=function(){function r(e){var s=e.container,n=s===void 0?typeof n<"u"?n:document.body:s,a=e.model,o=e.url,l=e.name,d=e.classListArray,p=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=l||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(o)}var t=r.prototype;return t.sendHandshake=function(s){var n=this,a=de(s),o=0,l;return new r.Promise(function(d,p){var v=function y(P){return E(P,a)?P.data.postmate==="handshake-reply"?(clearInterval(l),process.env.NODE_ENV!=="production"&&c("Parent: Received handshake reply from Child"),n.parent.removeEventListener("message",y,!1),n.childOrigin=P.origin,process.env.NODE_ENV!=="production"&&c("Parent: Saving Child origin",n.childOrigin),d(new me(n))):(process.env.NODE_ENV!=="production"&&c("Parent: Invalid handshake reply"),p("Failed handshake")):!1};n.parent.addEventListener("message",v,!1);var w=function(){o++,process.env.NODE_ENV!=="production"&&c("Parent: Sending handshake attempt "+o,{childOrigin:a}),n.child.postMessage({postmate:"handshake",type:f,model:n.model},a),o===ue&&clearInterval(l)},k=function(){w(),l=setInterval(w,500)};n.frame.attachEvent?n.frame.attachEvent("onload",k):n.frame.onload=k,process.env.NODE_ENV!=="production"&&c("Parent: Loading frame",{url:s}),n.frame.src=s})},r}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),m.Model=function(){function r(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=r.prototype;return t.sendHandshakeReply=function(){var s=this;return new m.Promise(function(n,a){var o=function l(d){if(d.data.postmate){if(d.data.postmate==="handshake"){process.env.NODE_ENV!=="production"&&c("Child: Received handshake from Parent"),s.child.removeEventListener("message",l,!1),process.env.NODE_ENV!=="production"&&c("Child: Sending handshake reply to Parent"),d.source.postMessage({postmate:"handshake-reply",type:f},d.origin),s.parentOrigin=d.origin;var p=d.data.model;return p&&(Object.keys(p).forEach(function(v){s.model[v]=p[v]}),process.env.NODE_ENV!=="production"&&c("Child: Inherited and extended model from Parent")),process.env.NODE_ENV!=="production"&&c("Child: Saving Parent origin",s.parentOrigin),n(new fe(s))}return a("Handshake Reply Failed")}};s.child.addEventListener("message",o,!1)})},r}();class ve extends h{async checkPhone(t,e){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,e))}async register(t,e){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,e))}async confirmRegistration(t,e){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,e))}async resendRegistrationConfirmation(t,e){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,e))}async login(t,e){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,e))}async dispatchPasswordReset(t,e){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,e))}async resetPassword(t,e){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,e))}useAuthenticationModal(t,e,s,n={}){const a=`${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;let o=null,l=null;return{initAuthenticationModal:async()=>new Promise(v=>{const w=typeof e=="string"?document.querySelector(e):e;o=new m({...n,container:w,url:a}),o.then(k=>{l=k,l.on("zenky:auth:token",s),l.on("zenky:auth:resize",y=>{l.frame.style.height=`${y}px`}),v(!0)})}),destroyAuthenticationModal:()=>{l&&l.destroy()}}}}class ye{constructor(t,e){u(this,"client");u(this,"store");u(this,"auth");u(this,"customer");u(this,"categories");u(this,"products");u(this,"addresses");u(this,"orders");u(this,"collections");u(this,"offers");u(this,"articles");u(this,"feedback");const s=R.build(t,e);this.store=new A(s),this.auth=new ve(s),this.customer=new le(s),this.categories=new S(s),this.products=new C(s),this.addresses=new oe(s),this.orders=new N(s),this.collections=new T(s),this.offers=new b(s),this.articles=new U(s),this.feedback=new _(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var $=(r=>(r.Female="female",r.Male="male",r.Other="other",r))($||{}),G=(r=>(r.CloudPayments="cloudpayments",r))(G||{}),D=(r=>(r.Visa="visa",r.MasterCard="master-card",r.MIR="mir",r.Maestro="maestro",r.AmericanExpress="american-express",r.DinersClub="diners-club",r.Discover="discover",r.JCB="jcb",r.UnionPay="union-pay",r))(D||{}),V=(r=>(r.Select="select",r.MutipleSelect="mutiple_select",r.Checkboxes="checkboxes",r.Radios="radios",r.Range="range",r.Text="text",r))(V||{}),I=(r=>(r.Integer="integer",r.Float="float",r))(I||{}),M=(r=>(r.Increase="increase",r.Decrease="decrease",r))(M||{}),L=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.Rejected="rejected",r.Refunded="refunded",r.PartiallyRefunded="partially_refunded",r))(L||{}),z=(r=>(r.Manual="manual",r.Cashback="cashback",r.ReferralReward="referral_reward",r.RecruitReward="recruit_reward",r.Payment="payment",r.Cancellation="cancellation",r.Refund="refund",r.Adjustment="adjustment",r.WelcomeBonuses="welcome_bonuses",r.PromotionReward="promotion_reward",r.External="external",r))(z||{}),j=(r=>(r.Delivery="delivery",r.Pickup="pickup",r.OnPremise="on_premise",r))(j||{}),F=(r=>(r.Payment="payment",r.Refund="refund",r))(F||{}),H=(r=>(r.Cash="cash",r.CreditCard="credit-card",r.CloudPayments="cloudpayments",r.CardToken="card_token",r.Bonuses="bonuses",r))(H||{}),Z=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.PendingRefund="pending_refund",r.Refunding="refunding",r.Refunded="refunded",r))(Z||{}),W=(r=>(r.Auth="auth",r.Charge="charge",r))(W||{}),B=(r=>(r.PersonsCount="persons_count",r.DeliveryTime="delivery_time",r.DeliveryIntervals="delivery_intervals",r))(B||{}),J=(r=>(r.PriceMismatch="price_mismatch",r.OutOfStock="out_of_stock",r.Unavailable="unavailable",r))(J||{}),X=(r=>(r.None="none",r.Cleanup="cleanup",r))(X||{}),Y=(r=>(r.Piece="piece",r.Gram="gram",r.Kilogram="kilogram",r.Meter="meter",r))(Y||{}),K=(r=>(r.Weight="weight",r.Width="width",r.Height="height",r.Length="length",r))(K||{}),Q=(r=>(r.Netto="netto",r.Brutto="brutto",r))(Q||{}),x=(r=>(r.Color="color",r))(x||{}),ee=(r=>(r.Category="category",r.Group="group",r.VariantOption="variant_option",r.VariantOptionValue="variant_option_value",r))(ee||{}),te=(r=>(r.Amount="amount",r.Percentage="percentage",r))(te||{}),re=(r=>(r.Email="email",r.Website="website",r.Vk="vk",r.Facebook="facebook",r.Instagram="instagram",r.Twitter="twitter",r.Ok="ok",r.Tiktok="tiktok",r))(re||{}),se=(r=>(r.Yes="yes",r.No="no",r.Both="both",r))(se||{}),ne=(r=>(r.Disabled="disabled",r.Preauth="preauth",r.Confirmation="confirmation",r))(ne||{}),ie=(r=>(r.Dadata="dadata",r.Manual="manual",r))(ie||{}),ae=(r=>(r.Registration="registration",r.ResendRegistrationCode="resend_registration_code",r.ResetPassword="reset_password",r.OrderSubmission="order_submission",r.FeedbackRequest="feedback_request",r.CallbackRequest="callback_request",r))(ae||{});i.AcquiringType=G,i.AddressSuggestionsProvider=g,i.AddressesProvider=ie,i.ArticlesResource=U,i.BonusesTransactionReason=z,i.BonusesTransactionStatus=L,i.BonusesTransactionType=M,i.CategoriesResource=S,i.CloudpaymentsChargeType=W,i.CollectionsResource=T,i.ContactType=re,i.DeliveryMethod=j,i.Dimension=K,i.DimensionType=Q,i.DiscountType=te,i.FeatureRange=I,i.FeatureType=V,i.FeedbackResource=_,i.Gender=$,i.OffersResource=b,i.OrderAuthenticationMethod=ne,i.OrderCartCheckerResultAction=X,i.OrderCartCheckerResultReason=J,i.OrderOptionKind=B,i.OrderPaymentTransactionStatus=Z,i.OrderPaymentTransactionType=F,i.OrdersResource=N,i.PaymentMethod=H,i.PaymentSystemType=D,i.ProductContextType=ee,i.ProductsResource=C,i.RecaptchaAction=ae,i.StoreResource=A,i.TernaryFilter=se,i.UnitType=Y,i.VariantOptionType=x,i.ZenkyError=O,i.ZenkyErrorBuilder=q,i.ZenkyStorefront=ye,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
7
|
+
**/var f="application/x-postmate-v1+json",ue=5,ce=0,he=function(){return++ce},c=function(){var t;return m.debug?(t=console).log.apply(t,arguments):null},de=function(t){var e=document.createElement("a");e.href=t;var s=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||s+"//"+n},ge={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},E=function(t,e){return!(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==f||!ge[t.data.postmate])},pe=function(t,e){var s=typeof t[e]=="function"?t[e]():t[e];return m.Promise.resolve(s)},me=function(){function r(e){var s=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},process.env.NODE_ENV!=="production"&&(c("Parent: Registering API"),c("Parent: Awaiting messages...")),this.listener=function(n){if(!E(n,s.childOrigin))return!1;var a=((n||{}).data||{}).value||{},o=a.data,l=a.name;n.data.postmate==="emit"&&(process.env.NODE_ENV!=="production"&&c("Parent: Received event emission: "+l),l in s.events&&s.events[l].call(s,o))},this.parent.addEventListener("message",this.listener,!1),process.env.NODE_ENV!=="production"&&c("Parent: Awaiting event emissions from Child")}var t=r.prototype;return t.get=function(s){var n=this;return new m.Promise(function(a){var o=he(),l=function d(p){p.data.uid===o&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(p.data.value))};n.parent.addEventListener("message",l,!1),n.child.postMessage({postmate:"request",type:f,property:s,uid:o},n.childOrigin)})},t.call=function(s,n){this.child.postMessage({postmate:"call",type:f,property:s,data:n},this.childOrigin)},t.on=function(s,n){this.events[s]=n},t.destroy=function(){process.env.NODE_ENV!=="production"&&c("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},r}(),fe=function(){function r(e){var s=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,process.env.NODE_ENV!=="production"&&(c("Child: Registering API"),c("Child: Awaiting messages...")),this.child.addEventListener("message",function(n){if(E(n,s.parentOrigin)){process.env.NODE_ENV!=="production"&&c("Child: Received request",n.data);var a=n.data,o=a.property,l=a.uid,d=a.data;if(n.data.postmate==="call"){o in s.model&&typeof s.model[o]=="function"&&s.model[o](d);return}pe(s.model,o).then(function(p){return n.source.postMessage({property:o,postmate:"reply",type:f,uid:l,value:p},n.origin)})}})}var t=r.prototype;return t.emit=function(s,n){process.env.NODE_ENV!=="production"&&c('Child: Emitting Event "'+s+'"',n),this.parent.postMessage({postmate:"emit",type:f,value:{name:s,data:n}},this.parentOrigin)},r}(),m=function(){function r(e){var s=e.container,n=s===void 0?typeof n<"u"?n:document.body:s,a=e.model,o=e.url,l=e.name,d=e.classListArray,p=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=l||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(o)}var t=r.prototype;return t.sendHandshake=function(s){var n=this,a=de(s),o=0,l;return new r.Promise(function(d,p){var v=function y(P){return E(P,a)?P.data.postmate==="handshake-reply"?(clearInterval(l),process.env.NODE_ENV!=="production"&&c("Parent: Received handshake reply from Child"),n.parent.removeEventListener("message",y,!1),n.childOrigin=P.origin,process.env.NODE_ENV!=="production"&&c("Parent: Saving Child origin",n.childOrigin),d(new me(n))):(process.env.NODE_ENV!=="production"&&c("Parent: Invalid handshake reply"),p("Failed handshake")):!1};n.parent.addEventListener("message",v,!1);var w=function(){o++,process.env.NODE_ENV!=="production"&&c("Parent: Sending handshake attempt "+o,{childOrigin:a}),n.child.postMessage({postmate:"handshake",type:f,model:n.model},a),o===ue&&clearInterval(l)},k=function(){w(),l=setInterval(w,500)};n.frame.attachEvent?n.frame.attachEvent("onload",k):n.frame.onload=k,process.env.NODE_ENV!=="production"&&c("Parent: Loading frame",{url:s}),n.frame.src=s})},r}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),m.Model=function(){function r(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=r.prototype;return t.sendHandshakeReply=function(){var s=this;return new m.Promise(function(n,a){var o=function l(d){if(d.data.postmate){if(d.data.postmate==="handshake"){process.env.NODE_ENV!=="production"&&c("Child: Received handshake from Parent"),s.child.removeEventListener("message",l,!1),process.env.NODE_ENV!=="production"&&c("Child: Sending handshake reply to Parent"),d.source.postMessage({postmate:"handshake-reply",type:f},d.origin),s.parentOrigin=d.origin;var p=d.data.model;return p&&(Object.keys(p).forEach(function(v){s.model[v]=p[v]}),process.env.NODE_ENV!=="production"&&c("Child: Inherited and extended model from Parent")),process.env.NODE_ENV!=="production"&&c("Child: Saving Parent origin",s.parentOrigin),n(new fe(s))}return a("Handshake Reply Failed")}};s.child.addEventListener("message",o,!1)})},r}();class ve extends h{async checkPhone(t,e){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,e))}async register(t,e){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,e))}async confirmRegistration(t,e){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,e))}async resendRegistrationConfirmation(t,e){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,e))}async login(t,e){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,e))}async dispatchPasswordReset(t,e){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,e))}async resetPassword(t,e){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,e))}useAuthenticationModal(t,e,s,n={}){const a=`${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;let o=null,l=null;return{initAuthenticationModal:async()=>new Promise(v=>{const w=typeof e=="string"?document.querySelector(e):e;o=new m({...n,container:w,url:a}),o.then(k=>{l=k,l.on("zenky:auth:token",s),l.on("zenky:auth:resize",y=>{l.frame.style.height=`${y}px`}),v(!0)})}),destroyAuthenticationModal:()=>{l&&l.destroy()}}}}class ye{constructor(t,e){u(this,"client");u(this,"store");u(this,"auth");u(this,"customer");u(this,"categories");u(this,"products");u(this,"addresses");u(this,"orders");u(this,"collections");u(this,"offers");u(this,"articles");u(this,"feedback");const s=R.build(t,e);this.store=new T(s),this.auth=new ve(s),this.customer=new le(s),this.categories=new S(s),this.products=new C(s),this.addresses=new oe(s),this.orders=new N(s),this.collections=new A(s),this.offers=new b(s),this.articles=new U(s),this.feedback=new _(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var $=(r=>(r.Female="female",r.Male="male",r.Other="other",r))($||{}),G=(r=>(r.CloudPayments="cloudpayments",r))(G||{}),D=(r=>(r.Visa="visa",r.MasterCard="master-card",r.MIR="mir",r.Maestro="maestro",r.AmericanExpress="american-express",r.DinersClub="diners-club",r.Discover="discover",r.JCB="jcb",r.UnionPay="union-pay",r))(D||{}),V=(r=>(r.Select="select",r.MutipleSelect="mutiple_select",r.Checkboxes="checkboxes",r.Radios="radios",r.Range="range",r.Text="text",r))(V||{}),I=(r=>(r.Integer="integer",r.Float="float",r))(I||{}),M=(r=>(r.Increase="increase",r.Decrease="decrease",r))(M||{}),L=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.Rejected="rejected",r.Refunded="refunded",r.PartiallyRefunded="partially_refunded",r))(L||{}),z=(r=>(r.Manual="manual",r.Cashback="cashback",r.ReferralReward="referral_reward",r.RecruitReward="recruit_reward",r.Payment="payment",r.Cancellation="cancellation",r.Refund="refund",r.Adjustment="adjustment",r.WelcomeBonuses="welcome_bonuses",r.PromotionReward="promotion_reward",r.External="external",r))(z||{}),j=(r=>(r.Delivery="delivery",r.Pickup="pickup",r.OnPremise="on_premise",r))(j||{}),F=(r=>(r.Payment="payment",r.Refund="refund",r))(F||{}),H=(r=>(r.Cash="cash",r.CreditCard="credit-card",r.CloudPayments="cloudpayments",r.CardToken="card_token",r.Bonuses="bonuses",r))(H||{}),Z=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.PendingRefund="pending_refund",r.Refunding="refunding",r.Refunded="refunded",r))(Z||{}),W=(r=>(r.Auth="auth",r.Charge="charge",r))(W||{}),B=(r=>(r.PersonsCount="persons_count",r.DeliveryTime="delivery_time",r.DeliveryIntervals="delivery_intervals",r))(B||{}),J=(r=>(r.PriceMismatch="price_mismatch",r.OutOfStock="out_of_stock",r.Unavailable="unavailable",r))(J||{}),X=(r=>(r.None="none",r.Cleanup="cleanup",r))(X||{}),Y=(r=>(r.Piece="piece",r.Gram="gram",r.Kilogram="kilogram",r.Meter="meter",r))(Y||{}),K=(r=>(r.Weight="weight",r.Width="width",r.Height="height",r.Length="length",r))(K||{}),Q=(r=>(r.Netto="netto",r.Brutto="brutto",r))(Q||{}),x=(r=>(r.Color="color",r))(x||{}),ee=(r=>(r.Category="category",r.Group="group",r.VariantOption="variant_option",r.VariantOptionValue="variant_option_value",r))(ee||{}),te=(r=>(r.Amount="amount",r.Percentage="percentage",r))(te||{}),re=(r=>(r.Email="email",r.Website="website",r.Vk="vk",r.Facebook="facebook",r.Instagram="instagram",r.Twitter="twitter",r.Ok="ok",r.Tiktok="tiktok",r))(re||{}),se=(r=>(r.Yes="yes",r.No="no",r.Both="both",r))(se||{}),ne=(r=>(r.Disabled="disabled",r.Preauth="preauth",r.Confirmation="confirmation",r))(ne||{}),ie=(r=>(r.Dadata="dadata",r.Manual="manual",r))(ie||{}),ae=(r=>(r.Registration="registration",r.ResendRegistrationCode="resend_registration_code",r.ResetPassword="reset_password",r.OrderSubmission="order_submission",r.FeedbackRequest="feedback_request",r.CallbackRequest="callback_request",r))(ae||{});i.AcquiringType=G,i.AddressSuggestionsProvider=g,i.AddressesProvider=ie,i.ArticlesResource=U,i.BonusesTransactionReason=z,i.BonusesTransactionStatus=L,i.BonusesTransactionType=M,i.CategoriesResource=S,i.CloudpaymentsChargeType=W,i.CollectionsResource=A,i.ContactType=re,i.DeliveryMethod=j,i.Dimension=K,i.DimensionType=Q,i.DiscountType=te,i.FeatureRange=I,i.FeatureType=V,i.FeedbackResource=_,i.Gender=$,i.OffersResource=b,i.OrderAuthenticationMethod=ne,i.OrderCartCheckerResultAction=X,i.OrderCartCheckerResultReason=J,i.OrderOptionKind=B,i.OrderPaymentTransactionStatus=Z,i.OrderPaymentTransactionType=F,i.OrdersResource=N,i.PaymentMethod=H,i.PaymentSystemType=D,i.ProductContextType=ee,i.ProductsResource=C,i.RecaptchaAction=ae,i.StoreResource=T,i.TernaryFilter=se,i.UnitType=Y,i.VariantOptionType=x,i.ZenkyError=O,i.ZenkyErrorBuilder=q,i.ZenkyStorefront=ye,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|