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