@zenky/storefront-api 0.0.24 → 0.0.26

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
@@ -244,6 +244,7 @@ export interface Media {
244
244
  }
245
245
  export interface ClientConfig {
246
246
  baseUrl?: string;
247
+ baseAuthUrl?: string;
247
248
  token?: string;
248
249
  client?: string;
249
250
  timezone?: string;
@@ -308,6 +309,7 @@ export interface ListArticlesRequest extends ListRequest {
308
309
  }
309
310
  declare class Client {
310
311
  private readonly baseUrl;
312
+ private readonly baseAuthUrl;
311
313
  private token;
312
314
  private readonly client;
313
315
  private readonly timezone;
@@ -316,6 +318,7 @@ declare class Client {
316
318
  static build(config?: ClientConfig | null | undefined, fetcher?: any): Client;
317
319
  private constructor();
318
320
  setToken(token: string | null): Client;
321
+ getBaseAuthUrl(): string;
319
322
  request(method: string, path: string, body?: any, apiToken?: string | null): Promise<any>;
320
323
  }
321
324
  declare abstract class AbstractResource {
@@ -919,6 +922,10 @@ export interface PhoneCheckResult {
919
922
  registered: boolean;
920
923
  confirmed: boolean;
921
924
  }
925
+ export interface AuthenticationModalProvider {
926
+ initAuthenticationModal: () => Promise<boolean>;
927
+ destroyAuthenticationModal: () => void;
928
+ }
922
929
  export type OrderCredentials = string | {
923
930
  id: string;
924
931
  token: string;
@@ -1273,6 +1280,7 @@ export declare class OrdersResource extends AbstractResource {
1273
1280
  addProductVariantToOrder(storeId: string, credentials: OrderCredentials, request: OrderProductVariantRequest): Promise<Order>;
1274
1281
  removeProductVariantFromOrder(storeId: string, credentials: OrderCredentials, request: OrderProductVariantRequest): Promise<Order>;
1275
1282
  checkProducts(storeId: string, credentials: OrderCredentials): Promise<OrderCartCheckerResult>;
1283
+ getOrderCheckoutUrl(storeId: string, credentials: OrderCredentials, redirectUrl?: string): Promise<string>;
1276
1284
  setOrderCustomer(storeId: string, credentials: OrderCredentials, request: SetOrderCustomerRequest): Promise<boolean>;
1277
1285
  setOrderDeliveryMethod(storeId: string, credentials: OrderCredentials, request: SetOrderDeliveryRequest): Promise<Order>;
1278
1286
  setOrderPayments(storeId: string, credentials: OrderCredentials, request: SetOrderPaymentsRequest): Promise<Order>;
@@ -1313,6 +1321,7 @@ declare class AuthenticationResource extends AbstractResource {
1313
1321
  login(storeId: string, request: LoginRequest): Promise<AuthResult>;
1314
1322
  dispatchPasswordReset(storeId: string, request: DispatchPasswordResetRequest): Promise<AuthConfirmationStatus>;
1315
1323
  resetPassword(storeId: string, request: ResetPasswordRequest): Promise<AuthResult>;
1324
+ useAuthenticationModal(storeId: string, iframeContainer: string | HTMLElement, callback: (token: string, phone: PhoneRequest, storeId: string) => void, postmateParams?: any): AuthenticationModalProvider;
1316
1325
  }
1317
1326
  export declare class ZenkyStorefront {
1318
1327
  protected readonly client: Client;
@@ -1,463 +1,665 @@
1
- var g = Object.defineProperty;
2
- var d = (t, e, r) => e in t ? g(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var n = (t, e, r) => (d(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- var p = /* @__PURE__ */ ((t) => (t.DADATA = "dadata", t))(p || {});
5
- class o {
6
- constructor(e) {
7
- this.client = e;
8
- }
9
- getStoreUrl(e, r, s = {}) {
10
- return this.getUrl(`/store/${e}${r}`, s);
11
- }
12
- getUrl(e, r = {}) {
13
- if (!Object.keys(r).length)
14
- return e;
1
+ var P = Object.defineProperty;
2
+ var R = (r, t, e) => t in r ? P(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var l = (r, t, e) => (R(r, typeof t != "symbol" ? t + "" : t, e), e);
4
+ var U = /* @__PURE__ */ ((r) => (r.DADATA = "dadata", r))(U || {});
5
+ class d {
6
+ constructor(t) {
7
+ this.client = t;
8
+ }
9
+ getStoreUrl(t, e, s = {}) {
10
+ return this.getUrl(`/store/${t}${e}`, s);
11
+ }
12
+ getUrl(t, e = {}) {
13
+ if (!Object.keys(e).length)
14
+ return t;
15
15
  const s = [];
16
- Object.keys(r).forEach((a) => {
17
- s.push(`${a}=${r[a]}`);
16
+ Object.keys(e).forEach((i) => {
17
+ s.push(`${i}=${e[i]}`);
18
18
  });
19
- const i = e.includes("?") ? "&" : "?";
20
- return `${e}${i}${s.join("&")}`;
19
+ const n = t.includes("?") ? "&" : "?";
20
+ return `${t}${n}${s.join("&")}`;
21
21
  }
22
- getPaginatedResponse(e) {
23
- if (!e || !Array.isArray(e.data) || !e.meta || !e.meta.pagination)
22
+ getPaginatedResponse(t) {
23
+ if (!t || !Array.isArray(t.data) || !t.meta || !t.meta.pagination)
24
24
  throw new Error("getPaginatedResponse(): Invalid response.");
25
- const r = e.data, s = e.meta.pagination;
25
+ const e = t.data, s = t.meta.pagination;
26
26
  return {
27
- items: r,
27
+ items: e,
28
28
  pagination: s
29
29
  };
30
30
  }
31
- getResponse(e) {
32
- if (!e || !e.data)
31
+ getResponse(t) {
32
+ if (!t || !t.data)
33
33
  throw new Error("getResponse(): Invalid response.");
34
- return e.data;
34
+ return t.data;
35
35
  }
36
36
  }
37
- class w extends o {
38
- async getArticleCategories(e) {
39
- const r = this.getStoreUrl(e, "/articles/categories");
40
- return this.getPaginatedResponse(await this.client.request("GET", r));
37
+ class q extends d {
38
+ async getArticleCategories(t) {
39
+ const e = this.getStoreUrl(t, "/articles/categories");
40
+ return this.getPaginatedResponse(await this.client.request("GET", e));
41
41
  }
42
- async getArticleCategory(e, r) {
43
- const s = this.getStoreUrl(e, `/articles/categories/${r}`);
42
+ async getArticleCategory(t, e) {
43
+ const s = this.getStoreUrl(t, `/articles/categories/${e}`);
44
44
  return this.getResponse(await this.client.request("GET", s));
45
45
  }
46
- async getArticles(e, r) {
47
- const s = this.getStoreUrl(e, "/articles", r);
46
+ async getArticles(t, e) {
47
+ const s = this.getStoreUrl(t, "/articles", e);
48
48
  return this.getPaginatedResponse(await this.client.request("GET", s));
49
49
  }
50
- async getArticle(e, r, s) {
51
- const i = this.getStoreUrl(e, `/articles/${r}`, s);
52
- return this.getResponse(await this.client.request("GET", i));
50
+ async getArticle(t, e, s) {
51
+ const n = this.getStoreUrl(t, `/articles/${e}`, s);
52
+ return this.getResponse(await this.client.request("GET", n));
53
53
  }
54
54
  }
55
- class k extends o {
56
- async getCategories(e, r) {
57
- const s = this.getStoreUrl(e, "/categories", r);
55
+ class S extends d {
56
+ async getCategories(t, e) {
57
+ const s = this.getStoreUrl(t, "/categories", e);
58
58
  return this.getPaginatedResponse(await this.client.request("GET", s));
59
59
  }
60
- async getCategoriesTree(e, r) {
61
- const s = this.getStoreUrl(e, "/categories/tree", r);
60
+ async getCategoriesTree(t, e) {
61
+ const s = this.getStoreUrl(t, "/categories/tree", e);
62
62
  return this.getResponse(await this.client.request("GET", s));
63
63
  }
64
- async getCategory(e, r, s) {
65
- const i = this.getStoreUrl(e, `/categories/${r}`, s);
66
- return this.getResponse(await this.client.request("GET", i));
64
+ async getCategory(t, e, s) {
65
+ const n = this.getStoreUrl(t, `/categories/${e}`, s);
66
+ return this.getResponse(await this.client.request("GET", n));
67
67
  }
68
- async getFeaturesGroups(e, r) {
69
- const s = this.getStoreUrl(e, `/categories/${r}/features/groups`);
68
+ async getFeaturesGroups(t, e) {
69
+ const s = this.getStoreUrl(t, `/categories/${e}/features/groups`);
70
70
  return this.getResponse(await this.client.request("GET", s));
71
71
  }
72
- async getFeatures(e, r) {
73
- const s = this.getStoreUrl(e, `/categories/${r}/features`);
72
+ async getFeatures(t, e) {
73
+ const s = this.getStoreUrl(t, `/categories/${e}/features`);
74
74
  return this.getResponse(await this.client.request("GET", s));
75
75
  }
76
76
  }
77
- class h extends Error {
78
- constructor(r, s) {
79
- super(r);
80
- n(this, "err");
77
+ class O extends Error {
78
+ constructor(e, s) {
79
+ super(e);
80
+ l(this, "err");
81
81
  this.err = s;
82
82
  }
83
83
  }
84
- class m {
85
- static async build(e) {
86
- const r = await e.json();
87
- switch (e.status) {
84
+ class A {
85
+ static async build(t) {
86
+ const e = await t.json();
87
+ switch (t.status) {
88
88
  case 401:
89
- return new h((r == null ? void 0 : r.message) ?? "Unauthenticated.", null);
89
+ return new O((e == null ? void 0 : e.message) ?? "Unauthenticated.", null);
90
90
  default:
91
- return new h(r == null ? void 0 : r.message, (r == null ? void 0 : r.error) || null);
91
+ return new O(e == null ? void 0 : e.message, (e == null ? void 0 : e.error) || null);
92
92
  }
93
93
  }
94
94
  }
95
- class c {
96
- constructor(e, r, s, i, a, u) {
97
- n(this, "baseUrl");
98
- n(this, "token");
99
- n(this, "client");
100
- n(this, "timezone");
101
- n(this, "fetchFunction");
102
- n(this, "fetchOptions");
103
- this.baseUrl = e, this.token = r, this.client = s, this.timezone = i, this.fetchFunction = typeof a == "function" ? a : fetch, this.fetchOptions = typeof u < "u" ? u : {};
104
- }
105
- static build(e, r) {
106
- return new c(
107
- (e == null ? void 0 : e.baseUrl) || "https://storefront.zenky.io/v1",
108
- (e == null ? void 0 : e.token) || null,
109
- (e == null ? void 0 : e.client) || "web",
110
- (e == null ? void 0 : e.timezone) || "UTC",
111
- r,
112
- e == null ? void 0 : e.fetchOptions
95
+ class k {
96
+ constructor(t, e, s, n, i, a, o) {
97
+ l(this, "baseUrl");
98
+ l(this, "baseAuthUrl");
99
+ l(this, "token");
100
+ l(this, "client");
101
+ l(this, "timezone");
102
+ l(this, "fetchFunction");
103
+ l(this, "fetchOptions");
104
+ this.baseUrl = t, this.baseAuthUrl = e, this.token = s, this.client = n, this.timezone = i, this.fetchFunction = typeof a == "function" ? a : fetch, this.fetchOptions = typeof o < "u" ? o : {};
105
+ }
106
+ static build(t, e) {
107
+ return new k(
108
+ (t == null ? void 0 : t.baseUrl) || "https://storefront.zenky.io/v1",
109
+ (t == null ? void 0 : t.baseAuthUrl) || "https://auth.zenky.io/",
110
+ (t == null ? void 0 : t.token) || null,
111
+ (t == null ? void 0 : t.client) || "web",
112
+ (t == null ? void 0 : t.timezone) || "UTC",
113
+ e,
114
+ t == null ? void 0 : t.fetchOptions
113
115
  );
114
116
  }
115
- setToken(e) {
116
- return this.token = e, this;
117
+ setToken(t) {
118
+ return this.token = t, this;
117
119
  }
118
- async request(e, r, s, i) {
119
- const a = {
120
+ getBaseAuthUrl() {
121
+ return this.baseAuthUrl;
122
+ }
123
+ async request(t, e, s, n) {
124
+ const i = {
120
125
  Accept: "application/json",
121
126
  "X-Zenky-Client": this.client,
122
127
  "X-Timezone": this.timezone
123
128
  };
124
- i ? a.Authorization = `Bearer ${i}` : this.token && (a.Authorization = `Bearer ${this.token}`);
125
- const u = {
126
- method: e,
129
+ n ? i.Authorization = `Bearer ${n}` : this.token && (i.Authorization = `Bearer ${this.token}`);
130
+ const a = {
131
+ method: t,
127
132
  mode: "cors",
128
133
  ...this.fetchOptions
129
134
  };
130
- s && (a["Content-Type"] = "application/json", u.body = JSON.stringify(s)), u.headers = a;
131
- const l = await this.fetchFunction.call(null, `${this.baseUrl}${r}`, u);
132
- if (l.ok)
133
- return l.status === 204 ? !0 : l.json();
134
- throw await m.build(l);
135
+ s && (i["Content-Type"] = "application/json", a.body = JSON.stringify(s)), a.headers = i;
136
+ const o = await this.fetchFunction.call(null, `${this.baseUrl}${e}`, a);
137
+ if (o.ok)
138
+ return o.status === 204 ? !0 : o.json();
139
+ throw await A.build(o);
135
140
  }
136
141
  }
137
- class R extends o {
138
- async getStore(e) {
139
- const r = this.getUrl(`/store/${e}`);
140
- return this.getResponse(await this.client.request("GET", r));
142
+ class b extends d {
143
+ async getStore(t) {
144
+ const e = this.getUrl(`/store/${t}`);
145
+ return this.getResponse(await this.client.request("GET", e));
141
146
  }
142
- async getStoreByBundleId(e) {
143
- const r = this.getUrl(`/store/by-bundle/${e}`);
144
- return this.getResponse(await this.client.request("GET", r));
147
+ async getStoreByBundleId(t) {
148
+ const e = this.getUrl(`/store/by-bundle/${t}`);
149
+ return this.getResponse(await this.client.request("GET", e));
145
150
  }
146
151
  }
147
- class U extends o {
148
- async getCollections(e, r) {
149
- const s = this.getStoreUrl(e, "/collections", r);
152
+ class _ extends d {
153
+ async getCollections(t, e) {
154
+ const s = this.getStoreUrl(t, "/collections", e);
150
155
  return this.getPaginatedResponse(await this.client.request("GET", s));
151
156
  }
152
- async getCollection(e, r) {
153
- const s = this.getStoreUrl(e, `/collections/${r}`);
157
+ async getCollection(t, e) {
158
+ const s = this.getStoreUrl(t, `/collections/${e}`);
154
159
  return this.getResponse(await this.client.request("GET", s));
155
160
  }
156
161
  }
157
- class q extends o {
158
- async getOffers(e, r) {
159
- const s = this.getStoreUrl(e, "/offers", r);
162
+ class T extends d {
163
+ async getOffers(t, e) {
164
+ const s = this.getStoreUrl(t, "/offers", e);
160
165
  return this.getPaginatedResponse(await this.client.request("GET", s));
161
166
  }
162
- async getOffer(e, r, s) {
163
- const i = this.getStoreUrl(e, `/offers/${r}`, s);
164
- return this.getResponse(await this.client.request("GET", i));
167
+ async getOffer(t, e, s) {
168
+ const n = this.getStoreUrl(t, `/offers/${e}`, s);
169
+ return this.getResponse(await this.client.request("GET", n));
165
170
  }
166
171
  }
167
- class v extends o {
168
- async createFeedback(e, r) {
169
- const s = this.getStoreUrl(e, "/feedback", r);
172
+ class C extends d {
173
+ async createFeedback(t, e) {
174
+ const s = this.getStoreUrl(t, "/feedback", e);
170
175
  return this.getResponse(await this.client.request("POST", s));
171
176
  }
172
- async createCallback(e, r) {
173
- const s = this.getStoreUrl(e, "/callback", r);
177
+ async createCallback(t, e) {
178
+ const s = this.getStoreUrl(t, "/callback", e);
174
179
  return await this.client.request("POST", s), !0;
175
180
  }
176
181
  }
177
- class y extends o {
178
- async getProducts(e, r) {
179
- const s = this.getStoreUrl(e, "/products", r);
182
+ class N extends d {
183
+ async getProducts(t, e) {
184
+ const s = this.getStoreUrl(t, "/products", e);
180
185
  return this.getPaginatedResponse(await this.client.request("GET", s));
181
186
  }
182
- async getProduct(e, r, s) {
183
- const i = this.getStoreUrl(e, `/products/${r}`, s);
184
- return this.getResponse(await this.client.request("GET", i));
187
+ async getProduct(t, e, s) {
188
+ const n = this.getStoreUrl(t, `/products/${e}`, s);
189
+ return this.getResponse(await this.client.request("GET", n));
185
190
  }
186
- async getProductVariantPrice(e, r, s, i) {
187
- const a = this.getStoreUrl(e, `/products/${r}/variants/${s}/price`);
188
- return this.getResponse(await this.client.request("POST", a, i));
191
+ async getProductVariantPrice(t, e, s, n) {
192
+ const i = this.getStoreUrl(t, `/products/${e}/variants/${s}/price`);
193
+ return this.getResponse(await this.client.request("POST", i, n));
189
194
  }
190
195
  }
191
- class O extends o {
192
- getOrderUrl(e, r, s, i) {
193
- const a = typeof r == "string" ? r : r.id, u = typeof r == "string" ? void 0 : r.token;
194
- return this.getStoreUrl(e, `/orders/${a}${s}${u ? "?token=" + u : ""}`, i);
196
+ class $ extends d {
197
+ getOrderUrl(t, e, s, n) {
198
+ const i = typeof e == "string" ? e : e.id, a = typeof e == "string" ? void 0 : e.token;
199
+ return this.getStoreUrl(t, `/orders/${i}${s}${a ? "?token=" + a : ""}`, n);
195
200
  }
196
- getApiToken(e) {
197
- if (!(typeof e == "string" || typeof e.api_token > "u"))
198
- return e.api_token;
201
+ getApiToken(t) {
202
+ if (!(typeof t == "string" || typeof t.api_token > "u"))
203
+ return t.api_token;
199
204
  }
200
- async getOrders(e, r, s) {
201
- const i = this.getStoreUrl(e, "/orders", r);
202
- return this.getPaginatedResponse(await this.client.request("GET", i, void 0, s));
205
+ async getOrders(t, e, s) {
206
+ const n = this.getStoreUrl(t, "/orders", e);
207
+ return this.getPaginatedResponse(await this.client.request("GET", n, void 0, s));
203
208
  }
204
- async createOrder(e, r, s) {
205
- const i = this.getStoreUrl(e, "/orders");
206
- return this.getResponse(await this.client.request("POST", i, r, s));
209
+ async createOrder(t, e, s) {
210
+ const n = this.getStoreUrl(t, "/orders");
211
+ return this.getResponse(await this.client.request("POST", n, e, s));
207
212
  }
208
- async getOrder(e, r, s) {
209
- const i = this.getOrderUrl(e, r, "", s);
213
+ async getOrder(t, e, s) {
214
+ const n = this.getOrderUrl(t, e, "", s);
210
215
  return this.getResponse(
211
- await this.client.request("GET", i, void 0, this.getApiToken(r))
216
+ await this.client.request("GET", n, void 0, this.getApiToken(e))
212
217
  );
213
218
  }
214
- async getOrderSettings(e, r) {
215
- const s = this.getOrderUrl(e, r, "/settings");
219
+ async getOrderSettings(t, e) {
220
+ const s = this.getOrderUrl(t, e, "/settings");
216
221
  return this.getResponse(
217
- await this.client.request("GET", s, void 0, this.getApiToken(r))
222
+ await this.client.request("GET", s, void 0, this.getApiToken(e))
218
223
  );
219
224
  }
220
- async addProductVariantToOrder(e, r, s) {
221
- const i = this.getOrderUrl(e, r, "/products");
225
+ async addProductVariantToOrder(t, e, s) {
226
+ const n = this.getOrderUrl(t, e, "/products");
222
227
  return this.getResponse(
223
- await this.client.request("POST", i, s, this.getApiToken(r))
228
+ await this.client.request("POST", n, s, this.getApiToken(e))
224
229
  );
225
230
  }
226
- async removeProductVariantFromOrder(e, r, s) {
227
- const i = this.getOrderUrl(e, r, "/products");
231
+ async removeProductVariantFromOrder(t, e, s) {
232
+ const n = this.getOrderUrl(t, e, "/products");
228
233
  return this.getResponse(
229
- await this.client.request("POST", i, s, this.getApiToken(r))
234
+ await this.client.request("POST", n, s, this.getApiToken(e))
230
235
  );
231
236
  }
232
- async checkProducts(e, r) {
233
- const s = this.getOrderUrl(e, r, "/products/check");
237
+ async checkProducts(t, e) {
238
+ const s = this.getOrderUrl(t, e, "/products/check");
234
239
  return this.getResponse(
235
- await this.client.request("POST", s, void 0, this.getApiToken(r))
240
+ await this.client.request("POST", s, void 0, this.getApiToken(e))
236
241
  );
237
242
  }
238
- async setOrderCustomer(e, r, s) {
239
- const i = this.getOrderUrl(e, r, "/checkout/customer");
240
- return await this.client.request("POST", i, s, this.getApiToken(r)), !0;
243
+ async getOrderCheckoutUrl(t, e, s) {
244
+ const n = this.getOrderUrl(t, e, "/checkout/url");
245
+ return this.getResponse(
246
+ await this.client.request("POST", n, { redirect_url: s }, this.getApiToken(e))
247
+ ).url;
248
+ }
249
+ async setOrderCustomer(t, e, s) {
250
+ const n = this.getOrderUrl(t, e, "/checkout/customer");
251
+ return await this.client.request("POST", n, s, this.getApiToken(e)), !0;
241
252
  }
242
- async setOrderDeliveryMethod(e, r, s) {
243
- const i = this.getOrderUrl(e, r, "/checkout/delivery");
253
+ async setOrderDeliveryMethod(t, e, s) {
254
+ const n = this.getOrderUrl(t, e, "/checkout/delivery");
244
255
  return this.getResponse(
245
- await this.client.request("POST", i, s, this.getApiToken(r))
256
+ await this.client.request("POST", n, s, this.getApiToken(e))
246
257
  );
247
258
  }
248
- async setOrderPayments(e, r, s) {
249
- const i = this.getOrderUrl(e, r, "/checkout/payments");
259
+ async setOrderPayments(t, e, s) {
260
+ const n = this.getOrderUrl(t, e, "/checkout/payments");
250
261
  return this.getResponse(
251
- await this.client.request("POST", i, s, this.getApiToken(r))
262
+ await this.client.request("POST", n, s, this.getApiToken(e))
252
263
  );
253
264
  }
254
- async getOrderBonusesPreview(e, r, s) {
255
- const i = this.getOrderUrl(e, r, "/checkout/payments/bonuses", { amount: s });
265
+ async getOrderBonusesPreview(t, e, s) {
266
+ const n = this.getOrderUrl(t, e, "/checkout/payments/bonuses", { amount: s });
256
267
  return this.getResponse(
257
- await this.client.request("GET", i, void 0, this.getApiToken(r))
268
+ await this.client.request("GET", n, void 0, this.getApiToken(e))
258
269
  );
259
270
  }
260
- async getOrderTotal(e, r) {
261
- const s = this.getOrderUrl(e, r, "/checkout/total");
271
+ async getOrderTotal(t, e) {
272
+ const s = this.getOrderUrl(t, e, "/checkout/total");
262
273
  return this.getResponse(
263
- await this.client.request("GET", s, void 0, this.getApiToken(r))
274
+ await this.client.request("GET", s, void 0, this.getApiToken(e))
264
275
  );
265
276
  }
266
- async checkoutOrder(e, r, s) {
267
- const i = this.getOrderUrl(e, r, "/checkout");
277
+ async checkoutOrder(t, e, s) {
278
+ const n = this.getOrderUrl(t, e, "/checkout");
268
279
  return this.getResponse(
269
- await this.client.request("POST", i, s, this.getApiToken(r))
280
+ await this.client.request("POST", n, s, this.getApiToken(e))
270
281
  );
271
282
  }
272
- async confirmOrder(e, r, s) {
273
- const i = this.getOrderUrl(e, r, "/confirm");
274
- return await this.client.request("POST", i, s, this.getApiToken(r)), !0;
283
+ async confirmOrder(t, e, s) {
284
+ const n = this.getOrderUrl(t, e, "/confirm");
285
+ return await this.client.request("POST", n, s, this.getApiToken(e)), !0;
275
286
  }
276
- async resendOrderConfirmationCode(e, r) {
277
- const s = this.getOrderUrl(e, r, "/confirm/resend");
278
- return await this.client.request("POST", s, void 0, this.getApiToken(r)), !0;
287
+ async resendOrderConfirmationCode(t, e) {
288
+ const s = this.getOrderUrl(t, e, "/confirm/resend");
289
+ return await this.client.request("POST", s, void 0, this.getApiToken(e)), !0;
279
290
  }
280
- async getOrderBonusesTransactions(e, r, s) {
281
- const i = this.getOrderUrl(e, r, "/loyalty/transactions", s);
291
+ async getOrderBonusesTransactions(t, e, s) {
292
+ const n = this.getOrderUrl(t, e, "/loyalty/transactions", s);
282
293
  return this.getPaginatedResponse(
283
- await this.client.request("GET", i, void 0, this.getApiToken(r))
294
+ await this.client.request("GET", n, void 0, this.getApiToken(e))
284
295
  );
285
296
  }
286
- async getOrderCashbackTransaction(e, r) {
287
- const s = this.getOrderUrl(e, r, "/loyalty/transactions/cashback");
297
+ async getOrderCashbackTransaction(t, e) {
298
+ const s = this.getOrderUrl(t, e, "/loyalty/transactions/cashback");
288
299
  return this.getResponse(
289
- await this.client.request("GET", s, void 0, this.getApiToken(r))
300
+ await this.client.request("GET", s, void 0, this.getApiToken(e))
290
301
  );
291
302
  }
292
- async dispatchPromotionsChecker(e, r) {
293
- const s = this.getOrderUrl(e, r, "/loyalty/promotions/check");
303
+ async dispatchPromotionsChecker(t, e) {
304
+ const s = this.getOrderUrl(t, e, "/loyalty/promotions/check");
294
305
  return this.getResponse(
295
- await this.client.request("POST", s, void 0, this.getApiToken(r))
306
+ await this.client.request("POST", s, void 0, this.getApiToken(e))
296
307
  ).dispatched;
297
308
  }
298
- async getOrderPromotionRewards(e, r) {
299
- const s = this.getOrderUrl(e, r, "/loyalty/promotions/rewards");
309
+ async getOrderPromotionRewards(t, e) {
310
+ const s = this.getOrderUrl(t, e, "/loyalty/promotions/rewards");
300
311
  return this.getResponse(
301
- await this.client.request("GET", s, void 0, this.getApiToken(r))
312
+ await this.client.request("GET", s, void 0, this.getApiToken(e))
302
313
  );
303
314
  }
304
- async getCloudpaymentsReceipt(e, r, s) {
305
- const i = this.getOrderUrl(e, r, `/payments/${s}/receipt`);
315
+ async getCloudpaymentsReceipt(t, e, s) {
316
+ const n = this.getOrderUrl(t, e, `/payments/${s}/receipt`);
306
317
  return this.getResponse(
307
- await this.client.request("GET", i, void 0, this.getApiToken(r))
318
+ await this.client.request("GET", n, void 0, this.getApiToken(e))
308
319
  );
309
320
  }
310
321
  }
311
- class f extends o {
312
- async getAddressSuggestions(e, r) {
313
- const s = this.getStoreUrl(e, "/suggestions/address");
314
- return this.getResponse(await this.client.request("POST", s, r));
322
+ class G extends d {
323
+ async getAddressSuggestions(t, e) {
324
+ const s = this.getStoreUrl(t, "/suggestions/address");
325
+ return this.getResponse(await this.client.request("POST", s, e));
315
326
  }
316
327
  }
317
- class S extends o {
318
- async getProfile(e, r, s) {
319
- const i = this.getStoreUrl(e, "/me", r);
320
- return this.getResponse(await this.client.request("GET", i, null, s));
328
+ class V extends d {
329
+ async getProfile(t, e, s) {
330
+ const n = this.getStoreUrl(t, "/me", e);
331
+ return this.getResponse(await this.client.request("GET", n, null, s));
321
332
  }
322
- async updateProfile(e, r, s) {
323
- const i = this.getStoreUrl(e, "/me");
324
- return this.getResponse(await this.client.request("PUT", i, r, s));
333
+ async updateProfile(t, e, s) {
334
+ const n = this.getStoreUrl(t, "/me");
335
+ return this.getResponse(await this.client.request("PUT", n, e, s));
325
336
  }
326
- async removeProfile(e, r, s) {
327
- const i = this.getStoreUrl(e, "/me");
328
- return await this.client.request("DELETE", i, r, s), !0;
337
+ async removeProfile(t, e, s) {
338
+ const n = this.getStoreUrl(t, "/me");
339
+ return await this.client.request("DELETE", n, e, s), !0;
329
340
  }
330
- async getSettings(e, r) {
331
- const s = this.getStoreUrl(e, "/me/settings");
332
- return this.getResponse(await this.client.request("GET", s, null, r));
341
+ async getSettings(t, e) {
342
+ const s = this.getStoreUrl(t, "/me/settings");
343
+ return this.getResponse(await this.client.request("GET", s, null, e));
333
344
  }
334
- async updateSettings(e, r, s) {
335
- const i = this.getStoreUrl(e, "/me/settings");
336
- return this.getResponse(await this.client.request("PUT", i, r, s));
345
+ async updateSettings(t, e, s) {
346
+ const n = this.getStoreUrl(t, "/me/settings");
347
+ return this.getResponse(await this.client.request("PUT", n, e, s));
337
348
  }
338
- async getAddresses(e, r, s) {
339
- const i = this.getStoreUrl(e, "/me/addresses", r);
340
- return this.getPaginatedResponse(await this.client.request("GET", i, null, s));
349
+ async getAddresses(t, e, s) {
350
+ const n = this.getStoreUrl(t, "/me/addresses", e);
351
+ return this.getPaginatedResponse(await this.client.request("GET", n, null, s));
341
352
  }
342
- async createAddress(e, r, s) {
343
- const i = this.getStoreUrl(e, "/me/addresses");
344
- return this.getResponse(await this.client.request("POST", i, r, s));
353
+ async createAddress(t, e, s) {
354
+ const n = this.getStoreUrl(t, "/me/addresses");
355
+ return this.getResponse(await this.client.request("POST", n, e, s));
345
356
  }
346
- async updateAddress(e, r, s, i) {
347
- const a = this.getStoreUrl(e, `/me/addresses/${r}`);
348
- return this.getResponse(await this.client.request("PUT", a, s, i));
357
+ async updateAddress(t, e, s, n) {
358
+ const i = this.getStoreUrl(t, `/me/addresses/${e}`);
359
+ return this.getResponse(await this.client.request("PUT", i, s, n));
349
360
  }
350
- async deleteAddress(e, r, s) {
351
- const i = this.getStoreUrl(e, `/me/addresses/${r}`);
352
- return await this.client.request("DELETE", i, null, s), !0;
361
+ async deleteAddress(t, e, s) {
362
+ const n = this.getStoreUrl(t, `/me/addresses/${e}`);
363
+ return await this.client.request("DELETE", n, null, s), !0;
353
364
  }
354
- async getPaymentMethods(e, r, s) {
355
- const i = this.getStoreUrl(e, "/me/payment-methods", r);
356
- return this.getPaginatedResponse(await this.client.request("GET", i, null, s));
365
+ async getPaymentMethods(t, e, s) {
366
+ const n = this.getStoreUrl(t, "/me/payment-methods", e);
367
+ return this.getPaginatedResponse(await this.client.request("GET", n, null, s));
357
368
  }
358
- async deletePaymentMethod(e, r, s) {
359
- const i = this.getStoreUrl(e, `/me/payment-methods/${r}`);
360
- return await this.client.request("DELETE", i, null, s), !0;
369
+ async deletePaymentMethod(t, e, s) {
370
+ const n = this.getStoreUrl(t, `/me/payment-methods/${e}`);
371
+ return await this.client.request("DELETE", n, null, s), !0;
361
372
  }
362
- async getBonusesTransactions(e, r, s) {
363
- const i = this.getStoreUrl(e, "/me/loyalty/transactions", r);
364
- return this.getPaginatedResponse(await this.client.request("GET", i, null, s));
373
+ async getBonusesTransactions(t, e, s) {
374
+ const n = this.getStoreUrl(t, "/me/loyalty/transactions", e);
375
+ return this.getPaginatedResponse(await this.client.request("GET", n, null, s));
365
376
  }
366
- async getBonusesBalance(e) {
367
- const r = this.getStoreUrl(e, "/me/loyalty/balance");
368
- return this.getResponse(await this.client.request("GET", r, null, null));
377
+ async getBonusesBalance(t) {
378
+ const e = this.getStoreUrl(t, "/me/loyalty/balance");
379
+ return this.getResponse(await this.client.request("GET", e, null, null));
369
380
  }
370
381
  }
371
- class P extends o {
372
- async checkPhone(e, r) {
373
- const s = this.getStoreUrl(e, "/auth/check");
374
- return this.getResponse(await this.client.request("POST", s, r));
375
- }
376
- async register(e, r) {
377
- const s = this.getStoreUrl(e, "/auth/register");
378
- return this.getResponse(await this.client.request("POST", s, r));
379
- }
380
- async confirmRegistration(e, r) {
381
- const s = this.getStoreUrl(e, "/auth/register/confirm");
382
- return this.getResponse(await this.client.request("POST", s, r));
383
- }
384
- async resendRegistrationConfirmation(e, r) {
385
- const s = this.getStoreUrl(e, "/auth/register/resend");
386
- return this.getResponse(await this.client.request("POST", s, r));
387
- }
388
- async login(e, r) {
389
- const s = this.getStoreUrl(e, "/auth/login");
390
- return this.getResponse(await this.client.request("POST", s, r));
391
- }
392
- async dispatchPasswordReset(e, r) {
393
- const s = this.getStoreUrl(e, "/auth/password/request");
394
- return this.getResponse(await this.client.request("POST", s, r));
382
+ /**
383
+ postmate - A powerful, simple, promise-based postMessage library
384
+ @version v1.5.2
385
+ @link https://github.com/dollarshaveclub/postmate
386
+ @author Jacob Kelley <jakie8@gmail.com>
387
+ @license MIT
388
+ **/
389
+ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
390
+ return ++I;
391
+ }, u = function() {
392
+ var t;
393
+ return g.debug ? (t = console).log.apply(t, arguments) : null;
394
+ }, L = function(t) {
395
+ var e = document.createElement("a");
396
+ e.href = t;
397
+ 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;
398
+ return e.origin || s + "//" + n;
399
+ }, M = {
400
+ handshake: 1,
401
+ "handshake-reply": 1,
402
+ call: 1,
403
+ emit: 1,
404
+ reply: 1,
405
+ request: 1
406
+ /**
407
+ * Ensures that a message is safe to interpret
408
+ * @param {Object} message The postmate message being sent
409
+ * @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
410
+ * @return {Boolean}
411
+ */
412
+ }, E = function(t, e) {
413
+ 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
+ }, z = function(t, e) {
415
+ var s = typeof t[e] == "function" ? t[e]() : t[e];
416
+ return g.Promise.resolve(s);
417
+ }, j = /* @__PURE__ */ function() {
418
+ function r(e) {
419
+ var s = this;
420
+ 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 (!E(n, s.childOrigin))
422
+ return !1;
423
+ var i = ((n || {}).data || {}).value || {}, a = i.data, o = i.name;
424
+ 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));
425
+ }, this.parent.addEventListener("message", this.listener, !1), process.env.NODE_ENV !== "production" && u("Parent: Awaiting event emissions from Child");
426
+ }
427
+ var t = r.prototype;
428
+ return t.get = function(s) {
429
+ var n = this;
430
+ return new g.Promise(function(i) {
431
+ var a = x(), o = function c(h) {
432
+ h.data.uid === a && h.data.postmate === "reply" && (n.parent.removeEventListener("message", c, !1), i(h.data.value));
433
+ };
434
+ n.parent.addEventListener("message", o, !1), n.child.postMessage({
435
+ postmate: "request",
436
+ type: p,
437
+ property: s,
438
+ uid: a
439
+ }, n.childOrigin);
440
+ });
441
+ }, t.call = function(s, n) {
442
+ this.child.postMessage({
443
+ postmate: "call",
444
+ type: p,
445
+ property: s,
446
+ data: n
447
+ }, this.childOrigin);
448
+ }, t.on = function(s, n) {
449
+ this.events[s] = n;
450
+ }, t.destroy = function() {
451
+ process.env.NODE_ENV !== "production" && u("Parent: Destroying Postmate instance"), window.removeEventListener("message", this.listener, !1), this.frame.parentNode.removeChild(this.frame);
452
+ }, r;
453
+ }(), H = /* @__PURE__ */ function() {
454
+ function r(e) {
455
+ var s = this;
456
+ 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 (E(n, s.parentOrigin)) {
458
+ process.env.NODE_ENV !== "production" && u("Child: Received request", n.data);
459
+ var i = n.data, a = i.property, o = i.uid, c = i.data;
460
+ if (n.data.postmate === "call") {
461
+ a in s.model && typeof s.model[a] == "function" && s.model[a](c);
462
+ return;
463
+ }
464
+ z(s.model, a).then(function(h) {
465
+ return n.source.postMessage({
466
+ property: a,
467
+ postmate: "reply",
468
+ type: p,
469
+ uid: o,
470
+ value: h
471
+ }, n.origin);
472
+ });
473
+ }
474
+ });
395
475
  }
396
- async resetPassword(e, r) {
397
- const s = this.getStoreUrl(e, "/auth/password/reset");
398
- return this.getResponse(await this.client.request("POST", s, r));
476
+ var t = r.prototype;
477
+ return t.emit = function(s, n) {
478
+ process.env.NODE_ENV !== "production" && u('Child: Emitting Event "' + s + '"', n), this.parent.postMessage({
479
+ postmate: "emit",
480
+ type: p,
481
+ value: {
482
+ name: s,
483
+ data: n
484
+ }
485
+ }, this.parentOrigin);
486
+ }, r;
487
+ }(), g = /* @__PURE__ */ function() {
488
+ function r(e) {
489
+ var s = e.container, n = s === void 0 ? typeof n < "u" ? n : document.body : s, i = e.model, a = e.url, o = e.name, c = e.classListArray, h = c === void 0 ? [] : c;
490
+ return this.parent = window, this.frame = document.createElement("iframe"), this.frame.name = o || "", this.frame.classList.add.apply(this.frame.classList, h), n.appendChild(this.frame), this.child = this.frame.contentWindow || this.frame.contentDocument.parentWindow, this.model = i || {}, this.sendHandshake(a);
491
+ }
492
+ var t = r.prototype;
493
+ return t.sendHandshake = function(s) {
494
+ var n = this, i = L(s), a = 0, o;
495
+ return new r.Promise(function(c, h) {
496
+ var m = function v(y) {
497
+ return E(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
+ };
499
+ n.parent.addEventListener("message", m, !1);
500
+ var f = function() {
501
+ a++, process.env.NODE_ENV !== "production" && u("Parent: Sending handshake attempt " + a, {
502
+ childOrigin: i
503
+ }), n.child.postMessage({
504
+ postmate: "handshake",
505
+ type: p,
506
+ model: n.model
507
+ }, i), a === D && clearInterval(o);
508
+ }, w = function() {
509
+ f(), o = setInterval(f, 500);
510
+ };
511
+ n.frame.attachEvent ? n.frame.attachEvent("onload", w) : n.frame.onload = w, process.env.NODE_ENV !== "production" && u("Parent: Loading frame", {
512
+ url: s
513
+ }), n.frame.src = s;
514
+ });
515
+ }, r;
516
+ }();
517
+ g.debug = !1;
518
+ g.Promise = function() {
519
+ try {
520
+ return window ? window.Promise : Promise;
521
+ } catch {
522
+ return null;
523
+ }
524
+ }();
525
+ g.Model = /* @__PURE__ */ function() {
526
+ function r(e) {
527
+ return this.child = window, this.model = e, this.parent = this.child.parent, this.sendHandshakeReply();
528
+ }
529
+ var t = r.prototype;
530
+ return t.sendHandshakeReply = function() {
531
+ var s = this;
532
+ return new g.Promise(function(n, i) {
533
+ var a = function o(c) {
534
+ if (c.data.postmate) {
535
+ if (c.data.postmate === "handshake") {
536
+ process.env.NODE_ENV !== "production" && u("Child: Received handshake from Parent"), s.child.removeEventListener("message", o, !1), process.env.NODE_ENV !== "production" && u("Child: Sending handshake reply to Parent"), c.source.postMessage({
537
+ postmate: "handshake-reply",
538
+ type: p
539
+ }, c.origin), s.parentOrigin = c.origin;
540
+ var h = c.data.model;
541
+ return h && (Object.keys(h).forEach(function(m) {
542
+ s.model[m] = h[m];
543
+ }), process.env.NODE_ENV !== "production" && u("Child: Inherited and extended model from Parent")), process.env.NODE_ENV !== "production" && u("Child: Saving Parent origin", s.parentOrigin), n(new H(s));
544
+ }
545
+ return i("Handshake Reply Failed");
546
+ }
547
+ };
548
+ s.child.addEventListener("message", a, !1);
549
+ });
550
+ }, r;
551
+ }();
552
+ class F extends d {
553
+ async checkPhone(t, e) {
554
+ const s = this.getStoreUrl(t, "/auth/check");
555
+ return this.getResponse(await this.client.request("POST", s, e));
556
+ }
557
+ async register(t, e) {
558
+ const s = this.getStoreUrl(t, "/auth/register");
559
+ return this.getResponse(await this.client.request("POST", s, e));
560
+ }
561
+ async confirmRegistration(t, e) {
562
+ const s = this.getStoreUrl(t, "/auth/register/confirm");
563
+ return this.getResponse(await this.client.request("POST", s, e));
564
+ }
565
+ async resendRegistrationConfirmation(t, e) {
566
+ const s = this.getStoreUrl(t, "/auth/register/resend");
567
+ return this.getResponse(await this.client.request("POST", s, e));
568
+ }
569
+ async login(t, e) {
570
+ const s = this.getStoreUrl(t, "/auth/login");
571
+ return this.getResponse(await this.client.request("POST", s, e));
572
+ }
573
+ async dispatchPasswordReset(t, e) {
574
+ const s = this.getStoreUrl(t, "/auth/password/request");
575
+ return this.getResponse(await this.client.request("POST", s, e));
576
+ }
577
+ async resetPassword(t, e) {
578
+ const s = this.getStoreUrl(t, "/auth/password/reset");
579
+ return this.getResponse(await this.client.request("POST", s, e));
580
+ }
581
+ useAuthenticationModal(t, e, s, n = {}) {
582
+ const i = `${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;
583
+ let a = null, o = null;
584
+ return {
585
+ initAuthenticationModal: async () => new Promise((m) => {
586
+ const f = typeof e == "string" ? document.querySelector(e) : e;
587
+ a = new g({
588
+ ...n,
589
+ container: f,
590
+ url: i
591
+ }), a.then((w) => {
592
+ o = w, o.on("zenky:auth:token", s), o.on("zenky:auth:resize", (v) => {
593
+ o.frame.style.height = `${v}px`;
594
+ }), m(!0);
595
+ });
596
+ }),
597
+ destroyAuthenticationModal: () => {
598
+ o && o.destroy();
599
+ }
600
+ };
399
601
  }
400
602
  }
401
- class te {
402
- constructor(e, r) {
403
- n(this, "client");
404
- n(this, "store");
405
- n(this, "auth");
406
- n(this, "customer");
407
- n(this, "categories");
408
- n(this, "products");
409
- n(this, "addresses");
410
- n(this, "orders");
411
- n(this, "collections");
412
- n(this, "offers");
413
- n(this, "articles");
414
- n(this, "feedback");
415
- const s = c.build(e, r);
416
- this.store = new R(s), this.auth = new P(s), this.customer = new S(s), this.categories = new k(s), this.products = new y(s), this.addresses = new f(s), this.orders = new O(s), this.collections = new U(s), this.offers = new q(s), this.articles = new w(s), this.feedback = new v(s), this.client = s;
417
- }
418
- setApiToken(e) {
419
- return this.client.setToken(e), this;
603
+ class ke {
604
+ constructor(t, e) {
605
+ l(this, "client");
606
+ l(this, "store");
607
+ l(this, "auth");
608
+ l(this, "customer");
609
+ l(this, "categories");
610
+ l(this, "products");
611
+ l(this, "addresses");
612
+ l(this, "orders");
613
+ l(this, "collections");
614
+ l(this, "offers");
615
+ l(this, "articles");
616
+ l(this, "feedback");
617
+ const s = k.build(t, e);
618
+ this.store = new b(s), this.auth = new F(s), this.customer = new V(s), this.categories = new S(s), this.products = new N(s), this.addresses = new G(s), this.orders = new $(s), this.collections = new _(s), this.offers = new T(s), this.articles = new q(s), this.feedback = new C(s), this.client = s;
619
+ }
620
+ setApiToken(t) {
621
+ return this.client.setToken(t), this;
420
622
  }
421
623
  }
422
- var b = /* @__PURE__ */ ((t) => (t.Female = "female", t.Male = "male", t.Other = "other", t))(b || {}), E = /* @__PURE__ */ ((t) => (t.CloudPayments = "cloudpayments", t))(E || {}), T = /* @__PURE__ */ ((t) => (t.Visa = "visa", t.MasterCard = "master-card", t.MIR = "mir", t.Maestro = "maestro", t.AmericanExpress = "american-express", t.DinersClub = "diners-club", t.Discover = "discover", t.JCB = "jcb", t.UnionPay = "union-pay", t))(T || {}), A = /* @__PURE__ */ ((t) => (t.Select = "select", t.MutipleSelect = "mutiple_select", t.Checkboxes = "checkboxes", t.Radios = "radios", t.Range = "range", t.Text = "text", t))(A || {}), G = /* @__PURE__ */ ((t) => (t.Integer = "integer", t.Float = "float", t))(G || {}), $ = /* @__PURE__ */ ((t) => (t.Increase = "increase", t.Decrease = "decrease", t))($ || {}), C = /* @__PURE__ */ ((t) => (t.Pending = "pending", t.Confirmed = "confirmed", t.Cancelled = "cancelled", t.Rejected = "rejected", t.Refunded = "refunded", t.PartiallyRefunded = "partially_refunded", t))(C || {}), _ = /* @__PURE__ */ ((t) => (t.Manual = "manual", t.Cashback = "cashback", t.ReferralReward = "referral_reward", t.RecruitReward = "recruit_reward", t.Payment = "payment", t.Cancellation = "cancellation", t.Refund = "refund", t.Adjustment = "adjustment", t.WelcomeBonuses = "welcome_bonuses", t.PromotionReward = "promotion_reward", t.External = "external", t))(_ || {}), x = /* @__PURE__ */ ((t) => (t.Delivery = "delivery", t.Pickup = "pickup", t.OnPremise = "on_premise", t))(x || {}), I = /* @__PURE__ */ ((t) => (t.Payment = "payment", t.Refund = "refund", t))(I || {}), z = /* @__PURE__ */ ((t) => (t.Cash = "cash", t.CreditCard = "credit-card", t.CloudPayments = "cloudpayments", t.CardToken = "card_token", t.Bonuses = "bonuses", t))(z || {}), V = /* @__PURE__ */ ((t) => (t.Pending = "pending", t.Confirmed = "confirmed", t.Cancelled = "cancelled", t.PendingRefund = "pending_refund", t.Refunding = "refunding", t.Refunded = "refunded", t))(V || {}), j = /* @__PURE__ */ ((t) => (t.Auth = "auth", t.Charge = "charge", t))(j || {}), D = /* @__PURE__ */ ((t) => (t.PersonsCount = "persons_count", t.DeliveryTime = "delivery_time", t.DeliveryIntervals = "delivery_intervals", t))(D || {}), F = /* @__PURE__ */ ((t) => (t.PriceMismatch = "price_mismatch", t.OutOfStock = "out_of_stock", t.Unavailable = "unavailable", t))(F || {}), L = /* @__PURE__ */ ((t) => (t.None = "none", t.Cleanup = "cleanup", t))(L || {}), M = /* @__PURE__ */ ((t) => (t.Piece = "piece", t.Gram = "gram", t.Kilogram = "kilogram", t.Meter = "meter", t))(M || {}), N = /* @__PURE__ */ ((t) => (t.Weight = "weight", t.Width = "width", t.Height = "height", t.Length = "length", t))(N || {}), W = /* @__PURE__ */ ((t) => (t.Netto = "netto", t.Brutto = "brutto", t))(W || {}), Z = /* @__PURE__ */ ((t) => (t.Color = "color", t))(Z || {}), J = /* @__PURE__ */ ((t) => (t.Category = "category", t.Group = "group", t.VariantOption = "variant_option", t.VariantOptionValue = "variant_option_value", t))(J || {}), X = /* @__PURE__ */ ((t) => (t.Amount = "amount", t.Percentage = "percentage", t))(X || {}), H = /* @__PURE__ */ ((t) => (t.Email = "email", t.Website = "website", t.Vk = "vk", t.Facebook = "facebook", t.Instagram = "instagram", t.Twitter = "twitter", t.Ok = "ok", t.Tiktok = "tiktok", t))(H || {}), Y = /* @__PURE__ */ ((t) => (t.Yes = "yes", t.No = "no", t.Both = "both", t))(Y || {}), Q = /* @__PURE__ */ ((t) => (t.Disabled = "disabled", t.Preauth = "preauth", t.Confirmation = "confirmation", t))(Q || {}), B = /* @__PURE__ */ ((t) => (t.Dadata = "dadata", t.Manual = "manual", t))(B || {}), K = /* @__PURE__ */ ((t) => (t.Registration = "registration", t.ResendRegistrationCode = "resend_registration_code", t.ResetPassword = "reset_password", t.OrderSubmission = "order_submission", t.FeedbackRequest = "feedback_request", t.CallbackRequest = "callback_request", t))(K || {});
624
+ var W = /* @__PURE__ */ ((r) => (r.Female = "female", r.Male = "male", r.Other = "other", r))(W || {}), Z = /* @__PURE__ */ ((r) => (r.CloudPayments = "cloudpayments", r))(Z || {}), J = /* @__PURE__ */ ((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))(J || {}), X = /* @__PURE__ */ ((r) => (r.Select = "select", r.MutipleSelect = "mutiple_select", r.Checkboxes = "checkboxes", r.Radios = "radios", r.Range = "range", r.Text = "text", r))(X || {}), B = /* @__PURE__ */ ((r) => (r.Integer = "integer", r.Float = "float", r))(B || {}), Y = /* @__PURE__ */ ((r) => (r.Increase = "increase", r.Decrease = "decrease", r))(Y || {}), Q = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Confirmed = "confirmed", r.Cancelled = "cancelled", r.Rejected = "rejected", r.Refunded = "refunded", r.PartiallyRefunded = "partially_refunded", r))(Q || {}), K = /* @__PURE__ */ ((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))(K || {}), ee = /* @__PURE__ */ ((r) => (r.Delivery = "delivery", r.Pickup = "pickup", r.OnPremise = "on_premise", r))(ee || {}), te = /* @__PURE__ */ ((r) => (r.Payment = "payment", r.Refund = "refund", r))(te || {}), re = /* @__PURE__ */ ((r) => (r.Cash = "cash", r.CreditCard = "credit-card", r.CloudPayments = "cloudpayments", r.CardToken = "card_token", r.Bonuses = "bonuses", r))(re || {}), se = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Confirmed = "confirmed", r.Cancelled = "cancelled", r.PendingRefund = "pending_refund", r.Refunding = "refunding", r.Refunded = "refunded", r))(se || {}), ne = /* @__PURE__ */ ((r) => (r.Auth = "auth", r.Charge = "charge", r))(ne || {}), ie = /* @__PURE__ */ ((r) => (r.PersonsCount = "persons_count", r.DeliveryTime = "delivery_time", r.DeliveryIntervals = "delivery_intervals", r))(ie || {}), ae = /* @__PURE__ */ ((r) => (r.PriceMismatch = "price_mismatch", r.OutOfStock = "out_of_stock", r.Unavailable = "unavailable", r))(ae || {}), oe = /* @__PURE__ */ ((r) => (r.None = "none", r.Cleanup = "cleanup", r))(oe || {}), le = /* @__PURE__ */ ((r) => (r.Piece = "piece", r.Gram = "gram", r.Kilogram = "kilogram", r.Meter = "meter", r))(le || {}), ue = /* @__PURE__ */ ((r) => (r.Weight = "weight", r.Width = "width", r.Height = "height", r.Length = "length", r))(ue || {}), ce = /* @__PURE__ */ ((r) => (r.Netto = "netto", r.Brutto = "brutto", r))(ce || {}), he = /* @__PURE__ */ ((r) => (r.Color = "color", r))(he || {}), de = /* @__PURE__ */ ((r) => (r.Category = "category", r.Group = "group", r.VariantOption = "variant_option", r.VariantOptionValue = "variant_option_value", r))(de || {}), ge = /* @__PURE__ */ ((r) => (r.Amount = "amount", r.Percentage = "percentage", r))(ge || {}), pe = /* @__PURE__ */ ((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))(pe || {}), me = /* @__PURE__ */ ((r) => (r.Yes = "yes", r.No = "no", r.Both = "both", r))(me || {}), ve = /* @__PURE__ */ ((r) => (r.Disabled = "disabled", r.Preauth = "preauth", r.Confirmation = "confirmation", r))(ve || {}), fe = /* @__PURE__ */ ((r) => (r.Dadata = "dadata", r.Manual = "manual", r))(fe || {}), we = /* @__PURE__ */ ((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))(we || {});
423
625
  export {
424
- E as AcquiringType,
425
- p as AddressSuggestionsProvider,
426
- B as AddressesProvider,
427
- w as ArticlesResource,
428
- _ as BonusesTransactionReason,
429
- C as BonusesTransactionStatus,
430
- $ as BonusesTransactionType,
431
- k as CategoriesResource,
432
- j as CloudpaymentsChargeType,
433
- U as CollectionsResource,
434
- H as ContactType,
435
- x as DeliveryMethod,
436
- N as Dimension,
437
- W as DimensionType,
438
- X as DiscountType,
439
- G as FeatureRange,
440
- A as FeatureType,
441
- v as FeedbackResource,
442
- b as Gender,
443
- q as OffersResource,
444
- Q as OrderAuthenticationMethod,
445
- L as OrderCartCheckerResultAction,
446
- F as OrderCartCheckerResultReason,
447
- D as OrderOptionKind,
448
- V as OrderPaymentTransactionStatus,
449
- I as OrderPaymentTransactionType,
450
- O as OrdersResource,
451
- z as PaymentMethod,
452
- T as PaymentSystemType,
453
- J as ProductContextType,
454
- y as ProductsResource,
455
- K as RecaptchaAction,
456
- R as StoreResource,
457
- Y as TernaryFilter,
458
- M as UnitType,
459
- Z as VariantOptionType,
460
- h as ZenkyError,
461
- m as ZenkyErrorBuilder,
462
- te as ZenkyStorefront
626
+ Z as AcquiringType,
627
+ U as AddressSuggestionsProvider,
628
+ fe as AddressesProvider,
629
+ q as ArticlesResource,
630
+ K as BonusesTransactionReason,
631
+ Q as BonusesTransactionStatus,
632
+ Y as BonusesTransactionType,
633
+ S as CategoriesResource,
634
+ ne as CloudpaymentsChargeType,
635
+ _ as CollectionsResource,
636
+ pe as ContactType,
637
+ ee as DeliveryMethod,
638
+ ue as Dimension,
639
+ ce as DimensionType,
640
+ ge as DiscountType,
641
+ B as FeatureRange,
642
+ X as FeatureType,
643
+ C as FeedbackResource,
644
+ W as Gender,
645
+ T as OffersResource,
646
+ ve as OrderAuthenticationMethod,
647
+ oe as OrderCartCheckerResultAction,
648
+ ae as OrderCartCheckerResultReason,
649
+ ie as OrderOptionKind,
650
+ se as OrderPaymentTransactionStatus,
651
+ te as OrderPaymentTransactionType,
652
+ $ as OrdersResource,
653
+ re as PaymentMethod,
654
+ J as PaymentSystemType,
655
+ de as ProductContextType,
656
+ N as ProductsResource,
657
+ we as RecaptchaAction,
658
+ b as StoreResource,
659
+ me as TernaryFilter,
660
+ le as UnitType,
661
+ he as VariantOptionType,
662
+ O as ZenkyError,
663
+ A as ZenkyErrorBuilder,
664
+ ke as ZenkyStorefront
463
665
  };
@@ -1 +1,7 @@
1
- (function(n,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(n=typeof globalThis<"u"?globalThis:n||self,c(n.zenkyStorefrontApi={}))})(this,function(n){"use strict";var ee=Object.defineProperty;var te=(n,c,o)=>c in n?ee(n,c,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[c]=o;var a=(n,c,o)=>(te(n,typeof c!="symbol"?c+"":c,o),o);var c=(e=>(e.DADATA="dadata",e))(c||{});class o{constructor(t){this.client=t}getStoreUrl(t,r,s={}){return this.getUrl(`/store/${t}${r}`,s)}getUrl(t,r={}){if(!Object.keys(r).length)return t;const s=[];Object.keys(r).forEach(u=>{s.push(`${u}=${r[u]}`)});const i=t.includes("?")?"&":"?";return`${t}${i}${s.join("&")}`}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const r=t.data,s=t.meta.pagination;return{items:r,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class w extends o{async getArticleCategories(t){const r=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",r))}async getArticleCategory(t,r){const s=this.getStoreUrl(t,`/articles/categories/${r}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,r){const s=this.getStoreUrl(t,"/articles",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,r,s){const i=this.getStoreUrl(t,`/articles/${r}`,s);return this.getResponse(await this.client.request("GET",i))}}class p extends o{async getCategories(t,r){const s=this.getStoreUrl(t,"/categories",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,r){const s=this.getStoreUrl(t,"/categories/tree",r);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,r,s){const i=this.getStoreUrl(t,`/categories/${r}`,s);return this.getResponse(await this.client.request("GET",i))}async getFeaturesGroups(t,r){const s=this.getStoreUrl(t,`/categories/${r}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,r){const s=this.getStoreUrl(t,`/categories/${r}/features`);return this.getResponse(await this.client.request("GET",s))}}class g extends Error{constructor(r,s){super(r);a(this,"err");this.err=s}}class y{static async build(t){const r=await t.json();switch(t.status){case 401:return new g((r==null?void 0:r.message)??"Unauthenticated.",null);default:return new g(r==null?void 0:r.message,(r==null?void 0:r.error)||null)}}}class d{constructor(t,r,s,i,u,l){a(this,"baseUrl");a(this,"token");a(this,"client");a(this,"timezone");a(this,"fetchFunction");a(this,"fetchOptions");this.baseUrl=t,this.token=r,this.client=s,this.timezone=i,this.fetchFunction=typeof u=="function"?u:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,r){return new d((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",r,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}async request(t,r,s,i){const u={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};i?u.Authorization=`Bearer ${i}`:this.token&&(u.Authorization=`Bearer ${this.token}`);const l={method:t,mode:"cors",...this.fetchOptions};s&&(u["Content-Type"]="application/json",l.body=JSON.stringify(s)),l.headers=u;const h=await this.fetchFunction.call(null,`${this.baseUrl}${r}`,l);if(h.ok)return h.status===204?!0:h.json();throw await y.build(h)}}class k extends o{async getStore(t){const r=this.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",r))}async getStoreByBundleId(t){const r=this.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",r))}}class R extends o{async getCollections(t,r){const s=this.getStoreUrl(t,"/collections",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,r){const s=this.getStoreUrl(t,`/collections/${r}`);return this.getResponse(await this.client.request("GET",s))}}class m extends o{async getOffers(t,r){const s=this.getStoreUrl(t,"/offers",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,r,s){const i=this.getStoreUrl(t,`/offers/${r}`,s);return this.getResponse(await this.client.request("GET",i))}}class f extends o{async createFeedback(t,r){const s=this.getStoreUrl(t,"/feedback",r);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,r){const s=this.getStoreUrl(t,"/callback",r);return await this.client.request("POST",s),!0}}class U extends o{async getProducts(t,r){const s=this.getStoreUrl(t,"/products",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,r,s){const i=this.getStoreUrl(t,`/products/${r}`,s);return this.getResponse(await this.client.request("GET",i))}async getProductVariantPrice(t,r,s,i){const u=this.getStoreUrl(t,`/products/${r}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",u,i))}}class O extends o{getOrderUrl(t,r,s,i){const u=typeof r=="string"?r:r.id,l=typeof r=="string"?void 0:r.token;return this.getStoreUrl(t,`/orders/${u}${s}${l?"?token="+l:""}`,i)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,r,s){const i=this.getStoreUrl(t,"/orders",r);return this.getPaginatedResponse(await this.client.request("GET",i,void 0,s))}async createOrder(t,r,s){const i=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",i,r,s))}async getOrder(t,r,s){const i=this.getOrderUrl(t,r,"",s);return this.getResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}async getOrderSettings(t,r){const s=this.getOrderUrl(t,r,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async addProductVariantToOrder(t,r,s){const i=this.getOrderUrl(t,r,"/products");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async removeProductVariantFromOrder(t,r,s){const i=this.getOrderUrl(t,r,"/products");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async checkProducts(t,r){const s=this.getOrderUrl(t,r,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(r)))}async setOrderCustomer(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/customer");return await this.client.request("POST",i,s,this.getApiToken(r)),!0}async setOrderDeliveryMethod(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/delivery");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async setOrderPayments(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/payments");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async getOrderBonusesPreview(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/payments/bonuses",{amount:s});return this.getResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}async getOrderTotal(t,r){const s=this.getOrderUrl(t,r,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async checkoutOrder(t,r,s){const i=this.getOrderUrl(t,r,"/checkout");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async confirmOrder(t,r,s){const i=this.getOrderUrl(t,r,"/confirm");return await this.client.request("POST",i,s,this.getApiToken(r)),!0}async resendOrderConfirmationCode(t,r){const s=this.getOrderUrl(t,r,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(r)),!0}async getOrderBonusesTransactions(t,r,s){const i=this.getOrderUrl(t,r,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}async getOrderCashbackTransaction(t,r){const s=this.getOrderUrl(t,r,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async dispatchPromotionsChecker(t,r){const s=this.getOrderUrl(t,r,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(r))).dispatched}async getOrderPromotionRewards(t,r){const s=this.getOrderUrl(t,r,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async getCloudpaymentsReceipt(t,r,s){const i=this.getOrderUrl(t,r,`/payments/${s}/receipt`);return this.getResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}}class Y extends o{async getAddressSuggestions(t,r){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,r))}}class K extends o{async getProfile(t,r,s){const i=this.getStoreUrl(t,"/me",r);return this.getResponse(await this.client.request("GET",i,null,s))}async updateProfile(t,r,s){const i=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",i,r,s))}async removeProfile(t,r,s){const i=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",i,r,s),!0}async getSettings(t,r){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,r))}async updateSettings(t,r,s){const i=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",i,r,s))}async getAddresses(t,r,s){const i=this.getStoreUrl(t,"/me/addresses",r);return this.getPaginatedResponse(await this.client.request("GET",i,null,s))}async createAddress(t,r,s){const i=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",i,r,s))}async updateAddress(t,r,s,i){const u=this.getStoreUrl(t,`/me/addresses/${r}`);return this.getResponse(await this.client.request("PUT",u,s,i))}async deleteAddress(t,r,s){const i=this.getStoreUrl(t,`/me/addresses/${r}`);return await this.client.request("DELETE",i,null,s),!0}async getPaymentMethods(t,r,s){const i=this.getStoreUrl(t,"/me/payment-methods",r);return this.getPaginatedResponse(await this.client.request("GET",i,null,s))}async deletePaymentMethod(t,r,s){const i=this.getStoreUrl(t,`/me/payment-methods/${r}`);return await this.client.request("DELETE",i,null,s),!0}async getBonusesTransactions(t,r,s){const i=this.getStoreUrl(t,"/me/loyalty/transactions",r);return this.getPaginatedResponse(await this.client.request("GET",i,null,s))}async getBonusesBalance(t){const r=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",r,null,null))}}class Q extends o{async checkPhone(t,r){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,r))}async register(t,r){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,r))}async confirmRegistration(t,r){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,r))}async resendRegistrationConfirmation(t,r){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,r))}async login(t,r){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,r))}async dispatchPasswordReset(t,r){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,r))}async resetPassword(t,r){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,r))}}class x{constructor(t,r){a(this,"client");a(this,"store");a(this,"auth");a(this,"customer");a(this,"categories");a(this,"products");a(this,"addresses");a(this,"orders");a(this,"collections");a(this,"offers");a(this,"articles");a(this,"feedback");const s=d.build(t,r);this.store=new k(s),this.auth=new Q(s),this.customer=new K(s),this.categories=new p(s),this.products=new U(s),this.addresses=new Y(s),this.orders=new O(s),this.collections=new R(s),this.offers=new m(s),this.articles=new w(s),this.feedback=new f(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var S=(e=>(e.Female="female",e.Male="male",e.Other="other",e))(S||{}),v=(e=>(e.CloudPayments="cloudpayments",e))(v||{}),q=(e=>(e.Visa="visa",e.MasterCard="master-card",e.MIR="mir",e.Maestro="maestro",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.JCB="jcb",e.UnionPay="union-pay",e))(q||{}),P=(e=>(e.Select="select",e.MutipleSelect="mutiple_select",e.Checkboxes="checkboxes",e.Radios="radios",e.Range="range",e.Text="text",e))(P||{}),T=(e=>(e.Integer="integer",e.Float="float",e))(T||{}),b=(e=>(e.Increase="increase",e.Decrease="decrease",e))(b||{}),E=(e=>(e.Pending="pending",e.Confirmed="confirmed",e.Cancelled="cancelled",e.Rejected="rejected",e.Refunded="refunded",e.PartiallyRefunded="partially_refunded",e))(E||{}),A=(e=>(e.Manual="manual",e.Cashback="cashback",e.ReferralReward="referral_reward",e.RecruitReward="recruit_reward",e.Payment="payment",e.Cancellation="cancellation",e.Refund="refund",e.Adjustment="adjustment",e.WelcomeBonuses="welcome_bonuses",e.PromotionReward="promotion_reward",e.External="external",e))(A||{}),C=(e=>(e.Delivery="delivery",e.Pickup="pickup",e.OnPremise="on_premise",e))(C||{}),G=(e=>(e.Payment="payment",e.Refund="refund",e))(G||{}),$=(e=>(e.Cash="cash",e.CreditCard="credit-card",e.CloudPayments="cloudpayments",e.CardToken="card_token",e.Bonuses="bonuses",e))($||{}),_=(e=>(e.Pending="pending",e.Confirmed="confirmed",e.Cancelled="cancelled",e.PendingRefund="pending_refund",e.Refunding="refunding",e.Refunded="refunded",e))(_||{}),D=(e=>(e.Auth="auth",e.Charge="charge",e))(D||{}),j=(e=>(e.PersonsCount="persons_count",e.DeliveryTime="delivery_time",e.DeliveryIntervals="delivery_intervals",e))(j||{}),z=(e=>(e.PriceMismatch="price_mismatch",e.OutOfStock="out_of_stock",e.Unavailable="unavailable",e))(z||{}),I=(e=>(e.None="none",e.Cleanup="cleanup",e))(I||{}),V=(e=>(e.Piece="piece",e.Gram="gram",e.Kilogram="kilogram",e.Meter="meter",e))(V||{}),F=(e=>(e.Weight="weight",e.Width="width",e.Height="height",e.Length="length",e))(F||{}),M=(e=>(e.Netto="netto",e.Brutto="brutto",e))(M||{}),Z=(e=>(e.Color="color",e))(Z||{}),L=(e=>(e.Category="category",e.Group="group",e.VariantOption="variant_option",e.VariantOptionValue="variant_option_value",e))(L||{}),N=(e=>(e.Amount="amount",e.Percentage="percentage",e))(N||{}),W=(e=>(e.Email="email",e.Website="website",e.Vk="vk",e.Facebook="facebook",e.Instagram="instagram",e.Twitter="twitter",e.Ok="ok",e.Tiktok="tiktok",e))(W||{}),B=(e=>(e.Yes="yes",e.No="no",e.Both="both",e))(B||{}),J=(e=>(e.Disabled="disabled",e.Preauth="preauth",e.Confirmation="confirmation",e))(J||{}),X=(e=>(e.Dadata="dadata",e.Manual="manual",e))(X||{}),H=(e=>(e.Registration="registration",e.ResendRegistrationCode="resend_registration_code",e.ResetPassword="reset_password",e.OrderSubmission="order_submission",e.FeedbackRequest="feedback_request",e.CallbackRequest="callback_request",e))(H||{});n.AcquiringType=v,n.AddressSuggestionsProvider=c,n.AddressesProvider=X,n.ArticlesResource=w,n.BonusesTransactionReason=A,n.BonusesTransactionStatus=E,n.BonusesTransactionType=b,n.CategoriesResource=p,n.CloudpaymentsChargeType=D,n.CollectionsResource=R,n.ContactType=W,n.DeliveryMethod=C,n.Dimension=F,n.DimensionType=M,n.DiscountType=N,n.FeatureRange=T,n.FeatureType=P,n.FeedbackResource=f,n.Gender=S,n.OffersResource=m,n.OrderAuthenticationMethod=J,n.OrderCartCheckerResultAction=I,n.OrderCartCheckerResultReason=z,n.OrderOptionKind=j,n.OrderPaymentTransactionStatus=_,n.OrderPaymentTransactionType=G,n.OrdersResource=O,n.PaymentMethod=$,n.PaymentSystemType=q,n.ProductContextType=L,n.ProductsResource=U,n.RecaptchaAction=H,n.StoreResource=k,n.TernaryFilter=B,n.UnitType=V,n.VariantOptionType=Z,n.ZenkyError=g,n.ZenkyErrorBuilder=y,n.ZenkyStorefront=x,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
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))}}/**
2
+ postmate - A powerful, simple, promise-based postMessage library
3
+ @version v1.5.2
4
+ @link https://github.com/dollarshaveclub/postmate
5
+ @author Jacob Kelley <jakie8@gmail.com>
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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenky/storefront-api",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "Zenky Storefront API SDK",
5
5
  "author": "Timur Zurbaev <hello@zurbaev.ru>",
6
6
  "license": "MIT",
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^18.8.0",
31
+ "@types/postmate": "^1.5.3",
31
32
  "cross-fetch": "^3.1.6",
32
33
  "dts-bundle-generator": "^8.0.1",
33
34
  "typescript": "^5.0.2",
@@ -35,5 +36,8 @@
35
36
  "vite-plugin-dts": "^2.3.0",
36
37
  "vitest": "^0.32.0",
37
38
  "vitest-fetch-mock": "^0.2.2"
39
+ },
40
+ "dependencies": {
41
+ "postmate": "^1.5.2"
38
42
  }
39
43
  }