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