@zenky/storefront-api 0.0.35 → 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 +22 -1
- package/dist/zenky-storefront-api.es.js +239 -215
- 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>>;
|
|
@@ -1121,6 +1130,7 @@ export interface Order {
|
|
|
1121
1130
|
statuses?: OrderStatus[];
|
|
1122
1131
|
progress?: OrderStatusProgress[];
|
|
1123
1132
|
payments?: OrderPaymentTransaction[];
|
|
1133
|
+
promocode?: OrderPromocode | null;
|
|
1124
1134
|
}
|
|
1125
1135
|
export interface OrderPaymentMethod {
|
|
1126
1136
|
id: PaymentMethod;
|
|
@@ -1238,6 +1248,9 @@ export interface OrderPaymentMethodRequest {
|
|
|
1238
1248
|
export interface SetOrderPaymentsRequest {
|
|
1239
1249
|
payments: OrderPaymentMethodRequest[];
|
|
1240
1250
|
}
|
|
1251
|
+
export interface SetOrderPromocodeRequest {
|
|
1252
|
+
promocode: string;
|
|
1253
|
+
}
|
|
1241
1254
|
export interface OrderCheckoutBonusesPreview {
|
|
1242
1255
|
bonuses: number;
|
|
1243
1256
|
unpaid: number;
|
|
@@ -1297,6 +1310,11 @@ export interface OrderPromotionReward {
|
|
|
1297
1310
|
total_amount: number | null;
|
|
1298
1311
|
count: number;
|
|
1299
1312
|
}
|
|
1313
|
+
export interface OrderPromocode {
|
|
1314
|
+
type: "plain";
|
|
1315
|
+
promocode: string;
|
|
1316
|
+
message: string;
|
|
1317
|
+
}
|
|
1300
1318
|
export declare class OrdersResource extends AbstractResource {
|
|
1301
1319
|
protected getOrderUrl(storeId: string, credentials: OrderCredentials, path: string, request?: any): string;
|
|
1302
1320
|
protected getApiToken(credentials: OrderCredentials): undefined | string;
|
|
@@ -1311,6 +1329,9 @@ export declare class OrdersResource extends AbstractResource {
|
|
|
1311
1329
|
setOrderCustomer(storeId: string, credentials: OrderCredentials, request: SetOrderCustomerRequest): Promise<boolean>;
|
|
1312
1330
|
setOrderDeliveryMethod(storeId: string, credentials: OrderCredentials, request: SetOrderDeliveryRequest): Promise<Order>;
|
|
1313
1331
|
setOrderPayments(storeId: string, credentials: OrderCredentials, request: SetOrderPaymentsRequest): Promise<Order>;
|
|
1332
|
+
getOrderPromocode(storeId: string, credentials: OrderCredentials, request: SetOrderPromocodeRequest): Promise<OrderPromocode | null>;
|
|
1333
|
+
setOrderPromocode(storeId: string, credentials: OrderCredentials, request: SetOrderPromocodeRequest): Promise<OrderPromocode>;
|
|
1334
|
+
removeOrderPromocode(storeId: string, credentials: OrderCredentials): Promise<boolean>;
|
|
1314
1335
|
getOrderBonusesPreview(storeId: string, credentials: OrderCredentials, amount: number | string): Promise<OrderCheckoutBonusesPreview>;
|
|
1315
1336
|
getOrderTotal(storeId: string, credentials: OrderCredentials): Promise<OrderCheckoutTotal>;
|
|
1316
1337
|
checkoutOrder(storeId: string, credentials: OrderCredentials, request: OrderCheckoutRequest): Promise<OrderCheckoutResult>;
|
|
@@ -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) {
|
|
@@ -24,57 +24,65 @@ class d {
|
|
|
24
24
|
return t.data;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class q extends d {
|
|
28
28
|
async getArticleCategories(t) {
|
|
29
29
|
const e = this.getStoreUrl(t, "/articles/categories");
|
|
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
|
-
class
|
|
46
|
-
async getCatalog(t) {
|
|
47
|
-
const
|
|
48
|
-
return this.getResponse(await this.client.request("GET",
|
|
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
|
+
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
|
-
class
|
|
74
|
-
constructor(e,
|
|
81
|
+
class E extends Error {
|
|
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 {
|
|
@@ -82,14 +90,14 @@ class b {
|
|
|
82
90
|
const e = await t.json();
|
|
83
91
|
switch (t.status) {
|
|
84
92
|
case 401:
|
|
85
|
-
return new
|
|
93
|
+
return new E((e == null ? void 0 : e.message) ?? "Unauthenticated.", null);
|
|
86
94
|
default:
|
|
87
|
-
return new
|
|
95
|
+
return new E(e == null ? void 0 : e.message, (e == null ? void 0 : e.error) || null);
|
|
88
96
|
}
|
|
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,14 +149,14 @@ 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();
|
|
148
156
|
throw await b.build(o);
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
|
-
class
|
|
159
|
+
class T extends d {
|
|
152
160
|
async getStore(t) {
|
|
153
161
|
const e = this.client.getUrl(`/store/${t}`);
|
|
154
162
|
return this.getResponse(await this.client.request("GET", e));
|
|
@@ -158,238 +166,254 @@ class _ extends d {
|
|
|
158
166
|
return this.getResponse(await this.client.request("GET", e));
|
|
159
167
|
}
|
|
160
168
|
}
|
|
161
|
-
class
|
|
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
|
|
275
|
-
const n = this.getOrderUrl(t, e, "/checkout/
|
|
282
|
+
async getOrderPromocode(t, e, r) {
|
|
283
|
+
const n = this.getOrderUrl(t, e, "/checkout/promocode");
|
|
284
|
+
return this.getResponse(
|
|
285
|
+
await this.client.request("GET", n, r, this.getApiToken(e))
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
async setOrderPromocode(t, e, r) {
|
|
289
|
+
const n = this.getOrderUrl(t, e, "/checkout/promocode");
|
|
290
|
+
return this.getResponse(
|
|
291
|
+
await this.client.request("POST", n, r, this.getApiToken(e))
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
async removeOrderPromocode(t, e) {
|
|
295
|
+
const r = this.getOrderUrl(t, e, "/checkout/promocode");
|
|
296
|
+
return await this.client.request("DELETE", r, null, this.getApiToken(e)), !0;
|
|
297
|
+
}
|
|
298
|
+
async getOrderBonusesPreview(t, e, r) {
|
|
299
|
+
const n = this.getOrderUrl(t, e, "/checkout/payments/bonuses", { amount: r });
|
|
276
300
|
return this.getResponse(
|
|
277
301
|
await this.client.request("GET", n, void 0, this.getApiToken(e))
|
|
278
302
|
);
|
|
279
303
|
}
|
|
280
304
|
async getOrderTotal(t, e) {
|
|
281
|
-
const
|
|
305
|
+
const r = this.getOrderUrl(t, e, "/checkout/total");
|
|
282
306
|
return this.getResponse(
|
|
283
|
-
await this.client.request("GET",
|
|
307
|
+
await this.client.request("GET", r, void 0, this.getApiToken(e))
|
|
284
308
|
);
|
|
285
309
|
}
|
|
286
|
-
async checkoutOrder(t, e,
|
|
310
|
+
async checkoutOrder(t, e, r) {
|
|
287
311
|
const n = this.getOrderUrl(t, e, "/checkout");
|
|
288
312
|
return this.getResponse(
|
|
289
|
-
await this.client.request("POST", n,
|
|
313
|
+
await this.client.request("POST", n, r, this.getApiToken(e))
|
|
290
314
|
);
|
|
291
315
|
}
|
|
292
|
-
async confirmOrder(t, e,
|
|
316
|
+
async confirmOrder(t, e, r) {
|
|
293
317
|
const n = this.getOrderUrl(t, e, "/confirm");
|
|
294
|
-
return await this.client.request("POST", n,
|
|
318
|
+
return await this.client.request("POST", n, r, this.getApiToken(e)), !0;
|
|
295
319
|
}
|
|
296
320
|
async resendOrderConfirmationCode(t, e) {
|
|
297
|
-
const
|
|
298
|
-
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;
|
|
299
323
|
}
|
|
300
|
-
async getOrderBonusesTransactions(t, e,
|
|
301
|
-
const n = this.getOrderUrl(t, e, "/loyalty/transactions",
|
|
324
|
+
async getOrderBonusesTransactions(t, e, r) {
|
|
325
|
+
const n = this.getOrderUrl(t, e, "/loyalty/transactions", r);
|
|
302
326
|
return this.getPaginatedResponse(
|
|
303
327
|
await this.client.request("GET", n, void 0, this.getApiToken(e))
|
|
304
328
|
);
|
|
305
329
|
}
|
|
306
330
|
async getOrderCashbackTransaction(t, e) {
|
|
307
|
-
const
|
|
331
|
+
const r = this.getOrderUrl(t, e, "/loyalty/transactions/cashback");
|
|
308
332
|
return this.getResponse(
|
|
309
|
-
await this.client.request("GET",
|
|
333
|
+
await this.client.request("GET", r, void 0, this.getApiToken(e))
|
|
310
334
|
);
|
|
311
335
|
}
|
|
312
336
|
async dispatchPromotionsChecker(t, e) {
|
|
313
|
-
const
|
|
337
|
+
const r = this.getOrderUrl(t, e, "/loyalty/promotions/check");
|
|
314
338
|
return this.getResponse(
|
|
315
|
-
await this.client.request("POST",
|
|
339
|
+
await this.client.request("POST", r, void 0, this.getApiToken(e))
|
|
316
340
|
).dispatched;
|
|
317
341
|
}
|
|
318
342
|
async getOrderPromotionRewards(t, e) {
|
|
319
|
-
const
|
|
343
|
+
const r = this.getOrderUrl(t, e, "/loyalty/promotions/rewards");
|
|
320
344
|
return this.getResponse(
|
|
321
|
-
await this.client.request("GET",
|
|
345
|
+
await this.client.request("GET", r, void 0, this.getApiToken(e))
|
|
322
346
|
);
|
|
323
347
|
}
|
|
324
|
-
async getCloudpaymentsReceipt(t, e,
|
|
325
|
-
const n = this.getOrderUrl(t, e, `/payments/${
|
|
348
|
+
async getCloudpaymentsReceipt(t, e, r) {
|
|
349
|
+
const n = this.getOrderUrl(t, e, `/payments/${r}/receipt`);
|
|
326
350
|
return this.getResponse(
|
|
327
351
|
await this.client.request("GET", n, void 0, this.getApiToken(e))
|
|
328
352
|
);
|
|
329
353
|
}
|
|
330
354
|
}
|
|
331
|
-
class
|
|
355
|
+
class D extends d {
|
|
332
356
|
async getAddressSuggestions(t, e) {
|
|
333
|
-
const
|
|
334
|
-
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));
|
|
335
359
|
}
|
|
336
360
|
}
|
|
337
|
-
class
|
|
338
|
-
async getProfile(t, e,
|
|
361
|
+
class V extends d {
|
|
362
|
+
async getProfile(t, e, r) {
|
|
339
363
|
const n = this.getStoreUrl(t, "/me", e);
|
|
340
|
-
return this.getResponse(await this.client.request("GET", n, null,
|
|
364
|
+
return this.getResponse(await this.client.request("GET", n, null, r));
|
|
341
365
|
}
|
|
342
|
-
async updateProfile(t, e,
|
|
366
|
+
async updateProfile(t, e, r) {
|
|
343
367
|
const n = this.getStoreUrl(t, "/me");
|
|
344
|
-
return this.getResponse(await this.client.request("PUT", n, e,
|
|
368
|
+
return this.getResponse(await this.client.request("PUT", n, e, r));
|
|
345
369
|
}
|
|
346
|
-
async removeProfile(t, e,
|
|
370
|
+
async removeProfile(t, e, r) {
|
|
347
371
|
const n = this.getStoreUrl(t, "/me");
|
|
348
|
-
return await this.client.request("DELETE", n, e,
|
|
372
|
+
return await this.client.request("DELETE", n, e, r), !0;
|
|
349
373
|
}
|
|
350
374
|
async getSettings(t, e) {
|
|
351
|
-
const
|
|
352
|
-
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));
|
|
353
377
|
}
|
|
354
|
-
async updateSettings(t, e,
|
|
378
|
+
async updateSettings(t, e, r) {
|
|
355
379
|
const n = this.getStoreUrl(t, "/me/settings");
|
|
356
|
-
return this.getResponse(await this.client.request("PUT", n, e,
|
|
380
|
+
return this.getResponse(await this.client.request("PUT", n, e, r));
|
|
357
381
|
}
|
|
358
|
-
async getAddresses(t, e,
|
|
382
|
+
async getAddresses(t, e, r) {
|
|
359
383
|
const n = this.getStoreUrl(t, "/me/addresses", e);
|
|
360
|
-
return this.getPaginatedResponse(await this.client.request("GET", n, null,
|
|
384
|
+
return this.getPaginatedResponse(await this.client.request("GET", n, null, r));
|
|
361
385
|
}
|
|
362
|
-
async createAddress(t, e,
|
|
386
|
+
async createAddress(t, e, r) {
|
|
363
387
|
const n = this.getStoreUrl(t, "/me/addresses");
|
|
364
|
-
return this.getResponse(await this.client.request("POST", n, e,
|
|
388
|
+
return this.getResponse(await this.client.request("POST", n, e, r));
|
|
365
389
|
}
|
|
366
|
-
async updateAddress(t, e,
|
|
390
|
+
async updateAddress(t, e, r, n) {
|
|
367
391
|
const i = this.getStoreUrl(t, `/me/addresses/${e}`);
|
|
368
|
-
return this.getResponse(await this.client.request("PUT", i,
|
|
392
|
+
return this.getResponse(await this.client.request("PUT", i, r, n));
|
|
369
393
|
}
|
|
370
|
-
async deleteAddress(t, e,
|
|
394
|
+
async deleteAddress(t, e, r) {
|
|
371
395
|
const n = this.getStoreUrl(t, `/me/addresses/${e}`);
|
|
372
|
-
return await this.client.request("DELETE", n, null,
|
|
396
|
+
return await this.client.request("DELETE", n, null, r), !0;
|
|
373
397
|
}
|
|
374
|
-
async getPaymentMethods(t, e,
|
|
398
|
+
async getPaymentMethods(t, e, r) {
|
|
375
399
|
const n = this.getStoreUrl(t, "/me/payment-methods", e);
|
|
376
|
-
return this.getPaginatedResponse(await this.client.request("GET", n, null,
|
|
400
|
+
return this.getPaginatedResponse(await this.client.request("GET", n, null, r));
|
|
377
401
|
}
|
|
378
|
-
async deletePaymentMethod(t, e,
|
|
402
|
+
async deletePaymentMethod(t, e, r) {
|
|
379
403
|
const n = this.getStoreUrl(t, `/me/payment-methods/${e}`);
|
|
380
|
-
return await this.client.request("DELETE", n, null,
|
|
404
|
+
return await this.client.request("DELETE", n, null, r), !0;
|
|
381
405
|
}
|
|
382
|
-
async getBonusesTransactions(t, e,
|
|
406
|
+
async getBonusesTransactions(t, e, r) {
|
|
383
407
|
const n = this.getStoreUrl(t, "/me/loyalty/transactions", e);
|
|
384
|
-
return this.getPaginatedResponse(await this.client.request("GET", n, null,
|
|
408
|
+
return this.getPaginatedResponse(await this.client.request("GET", n, null, r));
|
|
385
409
|
}
|
|
386
410
|
async getBonusesBalance(t, e) {
|
|
387
|
-
const
|
|
388
|
-
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));
|
|
389
413
|
}
|
|
390
414
|
async revokeToken(t, e) {
|
|
391
|
-
const
|
|
392
|
-
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;
|
|
393
417
|
}
|
|
394
418
|
}
|
|
395
419
|
/**
|
|
@@ -407,8 +431,8 @@ var p = "application/x-postmate-v1+json", x = 5, I = 0, L = function() {
|
|
|
407
431
|
}, M = function(t) {
|
|
408
432
|
var e = document.createElement("a");
|
|
409
433
|
e.href = t;
|
|
410
|
-
var
|
|
411
|
-
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;
|
|
412
436
|
}, z = {
|
|
413
437
|
handshake: 1,
|
|
414
438
|
"handshake-reply": 1,
|
|
@@ -422,23 +446,23 @@ var p = "application/x-postmate-v1+json", x = 5, I = 0, L = function() {
|
|
|
422
446
|
* @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
|
|
423
447
|
* @return {Boolean}
|
|
424
448
|
*/
|
|
425
|
-
},
|
|
449
|
+
}, O = function(t, e) {
|
|
426
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]);
|
|
427
451
|
}, j = function(t, e) {
|
|
428
|
-
var
|
|
429
|
-
return g.Promise.resolve(
|
|
452
|
+
var r = typeof t[e] == "function" ? t[e]() : t[e];
|
|
453
|
+
return g.Promise.resolve(r);
|
|
430
454
|
}, H = /* @__PURE__ */ function() {
|
|
431
|
-
function
|
|
432
|
-
var
|
|
455
|
+
function s(e) {
|
|
456
|
+
var r = this;
|
|
433
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) {
|
|
434
|
-
if (!
|
|
458
|
+
if (!O(n, r.childOrigin))
|
|
435
459
|
return !1;
|
|
436
460
|
var i = ((n || {}).data || {}).value || {}, a = i.data, o = i.name;
|
|
437
|
-
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));
|
|
438
462
|
}, this.parent.addEventListener("message", this.listener, !1), process.env.NODE_ENV !== "production" && c("Parent: Awaiting event emissions from Child");
|
|
439
463
|
}
|
|
440
|
-
var t =
|
|
441
|
-
return t.get = function(
|
|
464
|
+
var t = s.prototype;
|
|
465
|
+
return t.get = function(r) {
|
|
442
466
|
var n = this;
|
|
443
467
|
return new g.Promise(function(i) {
|
|
444
468
|
var a = L(), o = function u(h) {
|
|
@@ -447,34 +471,34 @@ var p = "application/x-postmate-v1+json", x = 5, I = 0, L = function() {
|
|
|
447
471
|
n.parent.addEventListener("message", o, !1), n.child.postMessage({
|
|
448
472
|
postmate: "request",
|
|
449
473
|
type: p,
|
|
450
|
-
property:
|
|
474
|
+
property: r,
|
|
451
475
|
uid: a
|
|
452
476
|
}, n.childOrigin);
|
|
453
477
|
});
|
|
454
|
-
}, t.call = function(
|
|
478
|
+
}, t.call = function(r, n) {
|
|
455
479
|
this.child.postMessage({
|
|
456
480
|
postmate: "call",
|
|
457
481
|
type: p,
|
|
458
|
-
property:
|
|
482
|
+
property: r,
|
|
459
483
|
data: n
|
|
460
484
|
}, this.childOrigin);
|
|
461
|
-
}, t.on = function(
|
|
462
|
-
this.events[
|
|
485
|
+
}, t.on = function(r, n) {
|
|
486
|
+
this.events[r] = n;
|
|
463
487
|
}, t.destroy = function() {
|
|
464
488
|
process.env.NODE_ENV !== "production" && c("Parent: Destroying Postmate instance"), window.removeEventListener("message", this.listener, !1), this.frame.parentNode.removeChild(this.frame);
|
|
465
|
-
},
|
|
489
|
+
}, s;
|
|
466
490
|
}(), F = /* @__PURE__ */ function() {
|
|
467
|
-
function
|
|
468
|
-
var
|
|
491
|
+
function s(e) {
|
|
492
|
+
var r = this;
|
|
469
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) {
|
|
470
|
-
if (
|
|
494
|
+
if (O(n, r.parentOrigin)) {
|
|
471
495
|
process.env.NODE_ENV !== "production" && c("Child: Received request", n.data);
|
|
472
496
|
var i = n.data, a = i.property, o = i.uid, u = i.data;
|
|
473
497
|
if (n.data.postmate === "call") {
|
|
474
|
-
a in
|
|
498
|
+
a in r.model && typeof r.model[a] == "function" && r.model[a](u);
|
|
475
499
|
return;
|
|
476
500
|
}
|
|
477
|
-
j(
|
|
501
|
+
j(r.model, a).then(function(h) {
|
|
478
502
|
return n.source.postMessage({
|
|
479
503
|
property: a,
|
|
480
504
|
postmate: "reply",
|
|
@@ -486,28 +510,28 @@ var p = "application/x-postmate-v1+json", x = 5, I = 0, L = function() {
|
|
|
486
510
|
}
|
|
487
511
|
});
|
|
488
512
|
}
|
|
489
|
-
var t =
|
|
490
|
-
return t.emit = function(
|
|
491
|
-
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({
|
|
492
516
|
postmate: "emit",
|
|
493
517
|
type: p,
|
|
494
518
|
value: {
|
|
495
|
-
name:
|
|
519
|
+
name: r,
|
|
496
520
|
data: n
|
|
497
521
|
}
|
|
498
522
|
}, this.parentOrigin);
|
|
499
|
-
},
|
|
523
|
+
}, s;
|
|
500
524
|
}(), g = /* @__PURE__ */ function() {
|
|
501
|
-
function
|
|
502
|
-
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;
|
|
503
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);
|
|
504
528
|
}
|
|
505
|
-
var t =
|
|
506
|
-
return t.sendHandshake = function(
|
|
507
|
-
var n = this, i = M(
|
|
508
|
-
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) {
|
|
509
533
|
var m = function v(y) {
|
|
510
|
-
return
|
|
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;
|
|
511
535
|
};
|
|
512
536
|
n.parent.addEventListener("message", m, !1);
|
|
513
537
|
var f = function() {
|
|
@@ -522,10 +546,10 @@ var p = "application/x-postmate-v1+json", x = 5, I = 0, L = function() {
|
|
|
522
546
|
f(), o = setInterval(f, 500);
|
|
523
547
|
};
|
|
524
548
|
n.frame.attachEvent ? n.frame.attachEvent("onload", w) : n.frame.onload = w, process.env.NODE_ENV !== "production" && c("Parent: Loading frame", {
|
|
525
|
-
url:
|
|
526
|
-
}), n.frame.src =
|
|
549
|
+
url: r
|
|
550
|
+
}), n.frame.src = r;
|
|
527
551
|
});
|
|
528
|
-
},
|
|
552
|
+
}, s;
|
|
529
553
|
}();
|
|
530
554
|
g.debug = !1;
|
|
531
555
|
g.Promise = function() {
|
|
@@ -536,62 +560,62 @@ g.Promise = function() {
|
|
|
536
560
|
}
|
|
537
561
|
}();
|
|
538
562
|
g.Model = /* @__PURE__ */ function() {
|
|
539
|
-
function
|
|
563
|
+
function s(e) {
|
|
540
564
|
return this.child = window, this.model = e, this.parent = this.child.parent, this.sendHandshakeReply();
|
|
541
565
|
}
|
|
542
|
-
var t =
|
|
566
|
+
var t = s.prototype;
|
|
543
567
|
return t.sendHandshakeReply = function() {
|
|
544
|
-
var
|
|
568
|
+
var r = this;
|
|
545
569
|
return new g.Promise(function(n, i) {
|
|
546
570
|
var a = function o(u) {
|
|
547
571
|
if (u.data.postmate) {
|
|
548
572
|
if (u.data.postmate === "handshake") {
|
|
549
|
-
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({
|
|
550
574
|
postmate: "handshake-reply",
|
|
551
575
|
type: p
|
|
552
|
-
}, u.origin),
|
|
576
|
+
}, u.origin), r.parentOrigin = u.origin;
|
|
553
577
|
var h = u.data.model;
|
|
554
578
|
return h && (Object.keys(h).forEach(function(m) {
|
|
555
|
-
|
|
556
|
-
}), 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));
|
|
557
581
|
}
|
|
558
582
|
return i("Handshake Reply Failed");
|
|
559
583
|
}
|
|
560
584
|
};
|
|
561
|
-
|
|
585
|
+
r.child.addEventListener("message", a, !1);
|
|
562
586
|
});
|
|
563
|
-
},
|
|
587
|
+
}, s;
|
|
564
588
|
}();
|
|
565
589
|
class W extends d {
|
|
566
590
|
async checkPhone(t, e) {
|
|
567
|
-
const
|
|
568
|
-
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));
|
|
569
593
|
}
|
|
570
594
|
async register(t, e) {
|
|
571
|
-
const
|
|
572
|
-
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));
|
|
573
597
|
}
|
|
574
598
|
async confirmRegistration(t, e) {
|
|
575
|
-
const
|
|
576
|
-
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));
|
|
577
601
|
}
|
|
578
602
|
async resendRegistrationConfirmation(t, e) {
|
|
579
|
-
const
|
|
580
|
-
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));
|
|
581
605
|
}
|
|
582
606
|
async login(t, e) {
|
|
583
|
-
const
|
|
584
|
-
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));
|
|
585
609
|
}
|
|
586
610
|
async dispatchPasswordReset(t, e) {
|
|
587
|
-
const
|
|
588
|
-
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));
|
|
589
613
|
}
|
|
590
614
|
async resetPassword(t, e) {
|
|
591
|
-
const
|
|
592
|
-
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));
|
|
593
617
|
}
|
|
594
|
-
useAuthenticationModal(t, e,
|
|
618
|
+
useAuthenticationModal(t, e, r, n = {}) {
|
|
595
619
|
const i = `${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;
|
|
596
620
|
let a = null, o = null;
|
|
597
621
|
return {
|
|
@@ -602,7 +626,7 @@ class W extends d {
|
|
|
602
626
|
container: f,
|
|
603
627
|
url: i
|
|
604
628
|
}), a.then((w) => {
|
|
605
|
-
o = w, o.on("zenky:auth:token",
|
|
629
|
+
o = w, o.on("zenky:auth:token", r), o.on("zenky:auth:resize", (v) => {
|
|
606
630
|
o.frame.style.height = `${v}px`;
|
|
607
631
|
}), m(!0);
|
|
608
632
|
});
|
|
@@ -613,7 +637,7 @@ class W extends d {
|
|
|
613
637
|
};
|
|
614
638
|
}
|
|
615
639
|
}
|
|
616
|
-
class
|
|
640
|
+
class Oe {
|
|
617
641
|
constructor(t, e) {
|
|
618
642
|
l(this, "client");
|
|
619
643
|
l(this, "store");
|
|
@@ -628,26 +652,26 @@ class Ee {
|
|
|
628
652
|
l(this, "offers");
|
|
629
653
|
l(this, "articles");
|
|
630
654
|
l(this, "feedback");
|
|
631
|
-
const
|
|
632
|
-
this.store = new
|
|
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;
|
|
633
657
|
}
|
|
634
658
|
setApiToken(t) {
|
|
635
659
|
return this.client.setToken(t), this;
|
|
636
660
|
}
|
|
637
661
|
}
|
|
638
|
-
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 || {});
|
|
639
663
|
export {
|
|
640
664
|
J as AcquiringType,
|
|
641
665
|
U as AddressSuggestionsProvider,
|
|
642
666
|
we as AddressesProvider,
|
|
643
|
-
|
|
667
|
+
q as ArticlesResource,
|
|
644
668
|
ee as BonusesTransactionReason,
|
|
645
669
|
K as BonusesTransactionStatus,
|
|
646
670
|
Q as BonusesTransactionType,
|
|
647
|
-
|
|
671
|
+
S as CatalogResource,
|
|
648
672
|
A as CategoriesResource,
|
|
649
673
|
ie as CloudpaymentsChargeType,
|
|
650
|
-
|
|
674
|
+
_ as CollectionsResource,
|
|
651
675
|
me as ContactType,
|
|
652
676
|
te as DeliveryMethod,
|
|
653
677
|
ue as Dimension,
|
|
@@ -664,17 +688,17 @@ export {
|
|
|
664
688
|
ae as OrderOptionKind,
|
|
665
689
|
ne as OrderPaymentTransactionStatus,
|
|
666
690
|
re as OrderPaymentTransactionType,
|
|
667
|
-
|
|
691
|
+
$ as OrdersResource,
|
|
668
692
|
se as PaymentMethod,
|
|
669
693
|
X as PaymentSystemType,
|
|
670
694
|
ge as ProductContextType,
|
|
671
|
-
|
|
695
|
+
G as ProductsResource,
|
|
672
696
|
ye as RecaptchaAction,
|
|
673
|
-
|
|
697
|
+
T as StoreResource,
|
|
674
698
|
ve as TernaryFilter,
|
|
675
699
|
ce as UnitType,
|
|
676
700
|
de as VariantOptionType,
|
|
677
|
-
|
|
701
|
+
E as ZenkyError,
|
|
678
702
|
b as ZenkyErrorBuilder,
|
|
679
|
-
|
|
703
|
+
Oe as ZenkyStorefront
|
|
680
704
|
};
|
|
@@ -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=(r=>(r.DADATA="dadata",r))(g||{});class u{constructor(t){this.client=t}getStoreUrl(t,e,s={}){return this.client.getStoreUrl(t,e,s)}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const e=t.data,s=t.meta.pagination;return{items:e,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class U extends 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 s=this.getStoreUrl(t,`/articles/categories/${e}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,e){const s=this.getStoreUrl(t,"/articles",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,e,s){const n=this.getStoreUrl(t,`/articles/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class S extends 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 s=this.getStoreUrl(t,"/categories",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,e){const s=this.getStoreUrl(t,"/categories/tree",e);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,e,s){const n=this.getStoreUrl(t,`/categories/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getFeaturesGroups(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features`);return this.getResponse(await this.client.request("GET",s))}}class O extends Error{constructor(e,s){super(e);c(this,"err");this.err=s}}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,s,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=s,this.client=n,this.timezone=a,this.fetchFunction=typeof o=="function"?o:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,e){return new R((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.baseAuthUrl)||"https://auth.zenky.io/",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",e,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}getBaseAuthUrl(){return this.baseAuthUrl}getStoreUrl(t,e,s={}){return this.getUrl(`/store/${t}${e}`,s)}getUrl(t,e={}){if(!Object.keys(e).length)return t;const s=[];Object.keys(e).forEach(a=>{s.push(`${a}=${e[a]}`)});const n=t.includes("?")?"&":"?";return`${t}${n}${s.join("&")}`}async request(t,e,s,n){const a={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};n?a.Authorization=`Bearer ${n}`:this.token&&(a.Authorization=`Bearer ${this.token}`);const o={method:t,mode:"cors",...this.fetchOptions};s&&(a["Content-Type"]="application/json",o.body=JSON.stringify(s)),o.headers=a;const l=await this.fetchFunction.call(null,`${this.baseUrl}${e}`,o);if(l.ok)return l.status===204?!0:l.json();throw await 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 s=this.getStoreUrl(t,"/collections",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,e){const s=this.getStoreUrl(t,`/collections/${e}`);return this.getResponse(await this.client.request("GET",s))}}class _ extends u{async getOffers(t,e){const s=this.getStoreUrl(t,"/offers",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,e,s){const n=this.getStoreUrl(t,`/offers/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class C extends u{async createFeedback(t,e){const s=this.getStoreUrl(t,"/feedback",e);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,e){const s=this.getStoreUrl(t,"/callback",e);return await this.client.request("POST",s),!0}}class N extends u{async getProducts(t,e){const s=this.getStoreUrl(t,"/products",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,e,s){const n=this.getStoreUrl(t,`/products/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getProductVariantPrice(t,e,s,n){const a=this.getStoreUrl(t,`/products/${e}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",a,n))}}class $ extends u{getOrderUrl(t,e,s,n){const a=typeof e=="string"?e:e.id,o=typeof e=="string"?void 0:e.token;return this.getStoreUrl(t,`/orders/${a}${s}${o?"?token="+o:""}`,n)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,e,s){const n=this.getStoreUrl(t,"/orders",e);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,s))}async createOrder(t,e,s){const n=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",n,e,s))}async getOrder(t,e,s){const n=this.getOrderUrl(t,e,"",s);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderSettings(t,e){const s=this.getOrderUrl(t,e,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async addProductVariantToOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async removeProductVariantFromOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products/remove");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async checkProducts(t,e){const s=this.getOrderUrl(t,e,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e)))}async getOrderCheckoutUrl(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/url");return this.getResponse(await this.client.request("POST",n,{redirect_url:s},this.getApiToken(e))).url}async setOrderCustomer(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/customer");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async setOrderDeliveryMethod(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/delivery");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async setOrderPayments(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async getOrderBonusesPreview(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments/bonuses",{amount:s});return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderTotal(t,e){const s=this.getOrderUrl(t,e,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async checkoutOrder(t,e,s){const n=this.getOrderUrl(t,e,"/checkout");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async confirmOrder(t,e,s){const n=this.getOrderUrl(t,e,"/confirm");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async resendOrderConfirmationCode(t,e){const s=this.getOrderUrl(t,e,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(e)),!0}async getOrderBonusesTransactions(t,e,s){const n=this.getOrderUrl(t,e,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderCashbackTransaction(t,e){const s=this.getOrderUrl(t,e,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async dispatchPromotionsChecker(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e))).dispatched}async getOrderPromotionRewards(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async getCloudpaymentsReceipt(t,e,s){const n=this.getOrderUrl(t,e,`/payments/${s}/receipt`);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}}class le extends u{async getAddressSuggestions(t,e){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,e))}}class ce extends u{async getProfile(t,e,s){const n=this.getStoreUrl(t,"/me",e);return this.getResponse(await this.client.request("GET",n,null,s))}async updateProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",n,e,s))}async removeProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",n,e,s),!0}async getSettings(t,e){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,e))}async updateSettings(t,e,s){const n=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",n,e,s))}async getAddresses(t,e,s){const n=this.getStoreUrl(t,"/me/addresses",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async createAddress(t,e,s){const n=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",n,e,s))}async updateAddress(t,e,s,n){const a=this.getStoreUrl(t,`/me/addresses/${e}`);return this.getResponse(await this.client.request("PUT",a,s,n))}async deleteAddress(t,e,s){const n=this.getStoreUrl(t,`/me/addresses/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getPaymentMethods(t,e,s){const n=this.getStoreUrl(t,"/me/payment-methods",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async deletePaymentMethod(t,e,s){const n=this.getStoreUrl(t,`/me/payment-methods/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getBonusesTransactions(t,e,s){const n=this.getStoreUrl(t,"/me/loyalty/transactions",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async getBonusesBalance(t,e){const s=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",s,null,e))}async revokeToken(t,e){const s=this.getStoreUrl(t,"/me/logout");return await this.client.request("POST",s,null,e),!0}}/**
|
|
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 s=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||s+"//"+n},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 s=typeof t[e]=="function"?t[e]():t[e];return m.Promise.resolve(s)},fe=function(){function r(e){var s=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},process.env.NODE_ENV!=="production"&&(h("Parent: Registering API"),h("Parent: Awaiting messages...")),this.listener=function(n){if(!E(n,s.childOrigin))return!1;var a=((n||{}).data||{}).value||{},o=a.data,l=a.name;n.data.postmate==="emit"&&(process.env.NODE_ENV!=="production"&&h("Parent: Received event emission: "+l),l in s.events&&s.events[l].call(s,o))},this.parent.addEventListener("message",this.listener,!1),process.env.NODE_ENV!=="production"&&h("Parent: Awaiting event emissions from Child")}var t=r.prototype;return t.get=function(s){var n=this;return new m.Promise(function(a){var o=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:s,uid:o},n.childOrigin)})},t.call=function(s,n){this.child.postMessage({postmate:"call",type:f,property:s,data:n},this.childOrigin)},t.on=function(s,n){this.events[s]=n},t.destroy=function(){process.env.NODE_ENV!=="production"&&h("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},r}(),ve=function(){function r(e){var s=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,process.env.NODE_ENV!=="production"&&(h("Child: Registering API"),h("Child: Awaiting messages...")),this.child.addEventListener("message",function(n){if(E(n,s.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 s.model&&typeof s.model[o]=="function"&&s.model[o](d);return}me(s.model,o).then(function(p){return n.source.postMessage({property:o,postmate:"reply",type:f,uid:l,value:p},n.origin)})}})}var t=r.prototype;return t.emit=function(s,n){process.env.NODE_ENV!=="production"&&h('Child: Emitting Event "'+s+'"',n),this.parent.postMessage({postmate:"emit",type:f,value:{name:s,data:n}},this.parentOrigin)},r}(),m=function(){function r(e){var s=e.container,n=s===void 0?typeof n<"u"?n:document.body:s,a=e.model,o=e.url,l=e.name,d=e.classListArray,p=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=l||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(o)}var t=r.prototype;return t.sendHandshake=function(s){var n=this,a=ge(s),o=0,l;return new r.Promise(function(d,p){var v=function y(P){return E(P,a)?P.data.postmate==="handshake-reply"?(clearInterval(l),process.env.NODE_ENV!=="production"&&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:s}),n.frame.src=s})},r}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),m.Model=function(){function r(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=r.prototype;return t.sendHandshakeReply=function(){var s=this;return new m.Promise(function(n,a){var o=function l(d){if(d.data.postmate){if(d.data.postmate==="handshake"){process.env.NODE_ENV!=="production"&&h("Child: Received handshake from Parent"),s.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),s.parentOrigin=d.origin;var p=d.data.model;return p&&(Object.keys(p).forEach(function(v){s.model[v]=p[v]}),process.env.NODE_ENV!=="production"&&h("Child: Inherited and extended model from Parent")),process.env.NODE_ENV!=="production"&&h("Child: Saving Parent origin",s.parentOrigin),n(new ve(s))}return a("Handshake Reply Failed")}};s.child.addEventListener("message",o,!1)})},r}();class ye extends u{async checkPhone(t,e){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,e))}async register(t,e){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,e))}async confirmRegistration(t,e){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,e))}async resendRegistrationConfirmation(t,e){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,e))}async login(t,e){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,e))}async dispatchPasswordReset(t,e){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,e))}async resetPassword(t,e){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,e))}useAuthenticationModal(t,e,s,n={}){const a=`${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;let o=null,l=null;return{initAuthenticationModal:async()=>new Promise(v=>{const w=typeof e=="string"?document.querySelector(e):e;o=new m({...n,container:w,url:a}),o.then(k=>{l=k,l.on("zenky:auth:token",s),l.on("zenky:auth:resize",y=>{l.frame.style.height=`${y}px`}),v(!0)})}),destroyAuthenticationModal:()=>{l&&l.destroy()}}}}class 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 s=R.build(t,e);this.store=new A(s),this.auth=new ye(s),this.customer=new ce(s),this.catalog=new S(s),this.categories=new q(s),this.products=new N(s),this.addresses=new le(s),this.orders=new $(s),this.collections=new b(s),this.offers=new _(s),this.articles=new U(s),this.feedback=new C(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var G=(r=>(r.Female="female",r.Male="male",r.Other="other",r))(G||{}),D=(r=>(r.CloudPayments="cloudpayments",r))(D||{}),V=(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))(V||{}),I=(r=>(r.Select="select",r.MutipleSelect="mutiple_select",r.Checkboxes="checkboxes",r.Radios="radios",r.Range="range",r.Text="text",r))(I||{}),M=(r=>(r.Integer="integer",r.Float="float",r))(M||{}),L=(r=>(r.Increase="increase",r.Decrease="decrease",r))(L||{}),z=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.Rejected="rejected",r.Refunded="refunded",r.PartiallyRefunded="partially_refunded",r))(z||{}),j=(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))(j||{}),F=(r=>(r.Delivery="delivery",r.Pickup="pickup",r.OnPremise="on_premise",r))(F||{}),H=(r=>(r.Payment="payment",r.Refund="refund",r))(H||{}),Z=(r=>(r.Cash="cash",r.CreditCard="credit-card",r.CloudPayments="cloudpayments",r.CardToken="card_token",r.Bonuses="bonuses",r))(Z||{}),W=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.PendingRefund="pending_refund",r.Refunding="refunding",r.Refunded="refunded",r))(W||{}),B=(r=>(r.Auth="auth",r.Charge="charge",r))(B||{}),J=(r=>(r.PersonsCount="persons_count",r.DeliveryTime="delivery_time",r.DeliveryIntervals="delivery_intervals",r))(J||{}),X=(r=>(r.PriceMismatch="price_mismatch",r.OutOfStock="out_of_stock",r.Unavailable="unavailable",r))(X||{}),Y=(r=>(r.None="none",r.Cleanup="cleanup",r))(Y||{}),K=(r=>(r.Piece="piece",r.Gram="gram",r.Kilogram="kilogram",r.Meter="meter",r))(K||{}),Q=(r=>(r.Weight="weight",r.Width="width",r.Height="height",r.Length="length",r))(Q||{}),x=(r=>(r.Netto="netto",r.Brutto="brutto",r))(x||{}),ee=(r=>(r.Color="color",r))(ee||{}),te=(r=>(r.Category="category",r.Group="group",r.VariantOption="variant_option",r.VariantOptionValue="variant_option_value",r))(te||{}),re=(r=>(r.Amount="amount",r.Percentage="percentage",r))(re||{}),se=(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))(se||{}),ne=(r=>(r.Yes="yes",r.No="no",r.Both="both",r))(ne||{}),ie=(r=>(r.Disabled="disabled",r.Preauth="preauth",r.Confirmation="confirmation",r))(ie||{}),ae=(r=>(r.Dadata="dadata",r.Manual="manual",r))(ae||{}),oe=(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))(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=G,i.OffersResource=_,i.OrderAuthenticationMethod=ie,i.OrderCartCheckerResultAction=Y,i.OrderCartCheckerResultReason=X,i.OrderOptionKind=J,i.OrderPaymentTransactionStatus=W,i.OrderPaymentTransactionType=H,i.OrdersResource=$,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"})});
|