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