@zenky/storefront-api 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -71,8 +71,11 @@ export declare class ZenkyError extends Error {
71
71
  export declare class ZenkyStorefront {
72
72
  protected readonly client: Client;
73
73
  readonly store: StoreResource;
74
+ readonly auth: AuthenticationResource;
75
+ readonly customer: CustomersResource;
74
76
  readonly categories: CategoriesResource;
75
77
  readonly products: ProductsResource;
78
+ readonly addresses: AddressesResource;
76
79
  readonly orders: OrdersResource;
77
80
  readonly collections: CollectionsResource;
78
81
  readonly offers: OffersResource;
@@ -385,6 +388,14 @@ export declare enum Gender {
385
388
  Male = "male",
386
389
  Other = "other"
387
390
  }
391
+ export interface CustomerSettings {
392
+ onesignal_id: string | null;
393
+ device_id: string | null;
394
+ device_token: string | null;
395
+ device_os: string | null;
396
+ barcode: string | null;
397
+ qrcode: string | null;
398
+ }
388
399
  export interface CustomerLoyaltyProfile {
389
400
  referral_program: {
390
401
  code: string;
@@ -394,6 +405,8 @@ export interface CustomerLoyaltyProfile {
394
405
  balance: number;
395
406
  bonuses_level: BonusesLevel | null;
396
407
  rates: LoyaltyRates | null;
408
+ settings?: CustomerSettings;
409
+ avatar?: Media | null;
397
410
  }
398
411
  export interface Customer {
399
412
  id: string;
@@ -406,6 +419,99 @@ export interface Customer {
406
419
  registered_at: string;
407
420
  loyalty: CustomerLoyaltyProfile | null;
408
421
  }
422
+
423
+ export interface UpdateCustomerProfileRequest {
424
+ first_name?: string;
425
+ last_name?: string;
426
+ gender?: Gender;
427
+ birth_date?: string;
428
+ password?: string;
429
+ current_password?: string;
430
+ }
431
+
432
+ export interface RemoveCustomerProfileRequest {
433
+ password: string;
434
+ }
435
+
436
+ export interface UpdateCustomerSettingsRequest {
437
+ onesignal_id?: string;
438
+ device_id?: string;
439
+ device_token?: string;
440
+ device_os?: string;
441
+ barcode?: string;
442
+ qrcode?: string;
443
+ }
444
+
445
+ export interface DeliveryAddressRequest {
446
+ delivery_address: DadataDeliveryAddressRequest | ManualDeliveryAddressRequest;
447
+ }
448
+
449
+ export enum AcquiringType {
450
+ CloudPayments = 'cloudpayments',
451
+ }
452
+
453
+ export enum PaymentSystemType {
454
+ Visa = 'visa',
455
+ MasterCard = 'master-card',
456
+ MIR = 'mir',
457
+ Maestro = 'maestro',
458
+ AmericanExpress = 'american-express',
459
+ DinersClub = 'diners-club',
460
+ Discover = 'discover',
461
+ JCB = 'jcb',
462
+ UnionPay = 'union-pay',
463
+ }
464
+
465
+ export interface PaymentSystem {
466
+ id: PaymentSystemType;
467
+ name: string;
468
+ logos: {
469
+ black: string | null;
470
+ white: string | null;
471
+ colored: string | null;
472
+ };
473
+ }
474
+
475
+ export interface BankInfo {
476
+ id: string;
477
+ name: string;
478
+ url: string;
479
+ background_colors: string[];
480
+ primary_background_color: string;
481
+ background_style: 'dark' | 'white';
482
+ logo_style: 'dark' | 'white';
483
+ text_color: string;
484
+ logos: {
485
+ png: string | null;
486
+ svg: string | null;
487
+ };
488
+ payment_system: PaymentSystem;
489
+ }
490
+
491
+ export interface CustomerPaymentMethod {
492
+ id: string;
493
+ acquiring_type: AcquiringType;
494
+ card_type: PaymentSystemType;
495
+ card_first_six: string;
496
+ card_last_four: string;
497
+ name: string;
498
+ bank: BankInfo | null;
499
+ }
500
+
501
+ export declare class CustomersResource extends AbstractResource {
502
+ getProfile(storeId: string, request?: InclusionRequest, apiToken?: string): Promise<Customer>;
503
+ updateProfile(storeId: string, request: UpdateCustomerProfileRequest, apiToken?: string): Promise<Customer>;
504
+ removeProfile(storeId: string, request: RemoveCustomerProfileRequest, apiToken?: string): Promise<boolean>;
505
+ getSettings(storeId: string, apiToken?: string): Promise<CustomerSettings>;
506
+ updateSettings(storeId: string, request: UpdateCustomerSettingsRequest, apiToken?: string): Promise<CustomerSettings>;
507
+ getAddresses(storeId: string, request?: ListRequest, apiToken?: string): Promise<PaginatedResponse<DeliveryAddress>>;
508
+ createAddress(storeId: string, request: DeliveryAddressRequest, apiToken?: string): Promise<DeliveryAddress>;
509
+ updateAddress(storeId: string, addressId: string, request: DeliveryAddressRequest, apiToken?: string): Promise<DeliveryAddress>;
510
+ deleteAddress(storeId: string, addressId: string, apiToken?: string): Promise<boolean>;
511
+ getPaymentMethods(storeId: string, request?: PaginationRequest, apiToken?: string): Promise<PaginatedResponse<CustomerPaymentMethod>>;
512
+ deletePaymentMethod(storeId: string, paymentMethodId: string, apiToken?: string): Promise<boolean>;
513
+ getBonusesTransactions(storeId: string, request?: ListCustomerBonusesTransactionsRequest, apiToken?: string): Promise<PaginatedResponse<BonusesTransaction>>;
514
+ }
409
515
  export interface Feedback {
410
516
  id: string;
411
517
  name: string | null;
@@ -966,14 +1072,14 @@ export interface OrderCheckoutRequest {
966
1072
  notes?: string;
967
1073
  persons_count?: string | number;
968
1074
  }
969
- export declare enum OrderConfirmationMethod {
1075
+ export declare enum ConfirmationMethod {
970
1076
  Sms = "sms",
971
1077
  Call = "call"
972
1078
  }
973
1079
  export interface OrderCheckoutResult {
974
1080
  confirmation: {
975
1081
  required: boolean;
976
- method: OrderConfirmationMethod | null;
1082
+ method: ConfirmationMethod | null;
977
1083
  phone: Phone | null;
978
1084
  };
979
1085
  online_payment: {
@@ -1017,3 +1123,178 @@ export declare class OrdersResource extends AbstractResource {
1017
1123
  dispatchPromotionsChecker(storeId: string, credentials: OrderCredentials): Promise<boolean>;
1018
1124
  getOrderPromotionRewards(storeId: string, credentials: OrderCredentials): Promise<OrderPromotionReward>;
1019
1125
  }
1126
+ export enum AddressSuggestionsProvider {
1127
+ DADATA = 'dadata',
1128
+ }
1129
+ export interface DadataAddressSuggestion {
1130
+ value: string | null;
1131
+ unrestricted_value: string | null;
1132
+ data: {
1133
+ postal_code: string | null;
1134
+ country: string | null;
1135
+ country_code: string | null;
1136
+ federal_district: string | null;
1137
+ region_fias_id: string | null;
1138
+ region_kladr_id: string | null;
1139
+ region_iso_code: string | null;
1140
+ region_with_type: string | null;
1141
+ region_type: string | null;
1142
+ region_type_full: string | null;
1143
+ region: string | null;
1144
+ area_fias_id: string | null;
1145
+ area_kladr_id: string | null;
1146
+ area_with_type: string | null;
1147
+ area_type: string | null;
1148
+ area_type_full: string | null;
1149
+ area: string | null;
1150
+ city_fias_id: string | null;
1151
+ city_kladr_id: string | null;
1152
+ city_with_type: string | null;
1153
+ city_type: string | null;
1154
+ city_type_full: string | null;
1155
+ city: string | null;
1156
+ city_area: string | null;
1157
+ city_district_fias_id: string | null;
1158
+ city_district_with_type: string | null;
1159
+ city_district_type: string | null;
1160
+ city_district_type_full: string | null;
1161
+ city_district: string | null;
1162
+ settlement_fias_id: string | null;
1163
+ settlement_kladr_id: string | null;
1164
+ settlement_with_type: string | null;
1165
+ settlement_type: string | null;
1166
+ settlement_type_full: string | null;
1167
+ settlement: string | null;
1168
+ street_fias_id: string | null;
1169
+ street_kladr_id: string | null;
1170
+ street_with_type: string | null;
1171
+ street_type: string | null;
1172
+ street_type_full: string | null;
1173
+ street: string | null;
1174
+ stead_fias_id: string | null;
1175
+ stead_cadnum: string | null;
1176
+ stead_type: string | null;
1177
+ stead_type_full: string | null;
1178
+ stead: string | null;
1179
+ house_fias_id: string | null;
1180
+ house_kladr_id: string | null;
1181
+ house_cadnum: string | null;
1182
+ house_type: string | null;
1183
+ house_type_full: string | null;
1184
+ house: string | null;
1185
+ block_type: string | null;
1186
+ block_type_full: string | null;
1187
+ block: string | null;
1188
+ flat_fias_id: string | null;
1189
+ flat_cadnum: string | null;
1190
+ flat_type: string | null;
1191
+ flat_type_full: string | null;
1192
+ flat: string | null;
1193
+ flat_area: string | null;
1194
+ square_meter_price: string | null;
1195
+ flat_price: string | null;
1196
+ room_fias_id: string | null;
1197
+ room_cadnum: string | null;
1198
+ room_type: string | null;
1199
+ room_type_full: string | null;
1200
+ postal_box: string | null;
1201
+ fias_id: string | null;
1202
+ fias_level: string | null;
1203
+ fias_actuality_state: string | null;
1204
+ kladr_id: string | null;
1205
+ geoname_id: string | null;
1206
+ capital_marker: string | null;
1207
+ okato: string | null;
1208
+ oktmo: string | null;
1209
+ tax_office: string | null;
1210
+ tax_office_legal: string | null;
1211
+ timezone: string | null;
1212
+ geo_lat: string | null;
1213
+ geo_lon: string | null;
1214
+ qc_geo: string | null;
1215
+ beltway_hit: string | null;
1216
+ beltway_distance: string | null;
1217
+ metro?: {
1218
+ name: string | null;
1219
+ line: string | null;
1220
+ distance: string | null;
1221
+ }[] | null;
1222
+ };
1223
+ }
1224
+ export interface AddressSuggestions {
1225
+ provider: AddressSuggestionsProvider;
1226
+ suggestions: DadataAddressSuggestion[];
1227
+ }
1228
+ export interface AddressSuggestionsRequest {
1229
+ query: string;
1230
+ city_id?: string;
1231
+ count?: number;
1232
+ }
1233
+ export declare class AddressesResource extends AbstractResource {
1234
+ getAddressSuggestions(storeId: string, request: AddressSuggestionsRequest): Promise<AddressSuggestions>;
1235
+ }
1236
+ export interface AbstractRegistrationRequest {
1237
+ phone: PhoneRequest;
1238
+ password?: string;
1239
+ first_name?: string;
1240
+ last_name?: string;
1241
+ gender?: Gender;
1242
+ birth_date?: string;
1243
+ }
1244
+
1245
+ export interface RegistrationRequest extends AbstractRegistrationRequest {
1246
+ referrer_code?: string;
1247
+ referrer_id?: string;
1248
+ }
1249
+
1250
+ export interface ConfirmRegistrationRequest extends AbstractRegistrationRequest {
1251
+ code: string | number;
1252
+ }
1253
+
1254
+ export interface AuthConfirmationStatus {
1255
+ confirmation_required: boolean;
1256
+ queued_to: string;
1257
+ method: ConfirmationMethod;
1258
+ }
1259
+
1260
+ export interface AuthResult {
1261
+ token: string;
1262
+ }
1263
+
1264
+ export interface ResendAuthConfirmationRequest {
1265
+ phone: PhoneRequest;
1266
+ }
1267
+
1268
+ export interface DispatchPasswordResetRequest {
1269
+ phone: PhoneRequest;
1270
+ }
1271
+
1272
+ export interface ResetPasswordRequest {
1273
+ phone: PhoneRequest;
1274
+ code: string | number;
1275
+ password: string;
1276
+ }
1277
+
1278
+ export interface LoginRequest {
1279
+ phone: PhoneRequest;
1280
+ password: string;
1281
+ }
1282
+
1283
+ export interface CheckPhoneRequest {
1284
+ phone: PhoneRequest;
1285
+ }
1286
+
1287
+ export interface PhoneCheckResult {
1288
+ registered: boolean;
1289
+ confirmed: boolean;
1290
+ }
1291
+
1292
+ export declare class AuthenticationResource extends AbstractResource {
1293
+ checkPhone(storeId: string, request: CheckPhoneRequest): Promise<PhoneCheckResult>;
1294
+ register(storeId: string, request: RegistrationRequest): Promise<AuthConfirmationStatus>;
1295
+ confirmRegistration(storeId: string, request: ConfirmRegistrationRequest): Promise<AuthResult>;
1296
+ resendRegistrationConfirmation(storeId: string, request: ResendAuthConfirmationRequest): Promise<AuthConfirmationStatus>;
1297
+ login(storeId: string, request: LoginRequest): Promise<AuthResult>;
1298
+ dispatchPasswordReset(storeId: string, request: DispatchPasswordResetRequest): Promise<AuthConfirmationStatus>;
1299
+ resetPassword(storeId: string, request: ResetPasswordRequest): Promise<AuthResult>;
1300
+ }
@@ -1,7 +1,8 @@
1
1
  var g = Object.defineProperty;
2
2
  var d = (e, t, r) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var n = (e, t, r) => (d(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- class l {
4
+ var p = /* @__PURE__ */ ((e) => (e.DADATA = "dadata", e))(p || {});
5
+ class o {
5
6
  constructor(t) {
6
7
  this.client = t;
7
8
  }
@@ -12,8 +13,8 @@ class l {
12
13
  if (!Object.keys(r).length)
13
14
  return t;
14
15
  const s = [];
15
- Object.keys(r).forEach((o) => {
16
- s.push(`${o}=${r[o]}`);
16
+ Object.keys(r).forEach((a) => {
17
+ s.push(`${a}=${r[a]}`);
17
18
  });
18
19
  const i = t.includes("?") ? "&" : "?";
19
20
  return `${t}${i}${s.join("&")}`;
@@ -33,7 +34,7 @@ class l {
33
34
  return t.data;
34
35
  }
35
36
  }
36
- class p extends l {
37
+ class w extends o {
37
38
  async getArticleCategories(t) {
38
39
  const r = this.getStoreUrl(t, "/articles/categories");
39
40
  return this.getPaginatedResponse(await this.client.request("GET", r));
@@ -51,7 +52,7 @@ class p extends l {
51
52
  return this.getResponse(await this.client.request("GET", i));
52
53
  }
53
54
  }
54
- class k extends l {
55
+ class k extends o {
55
56
  async getCategories(t, r) {
56
57
  const s = this.getStoreUrl(t, "/categories", r);
57
58
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -80,7 +81,7 @@ class h extends Error {
80
81
  this.err = s;
81
82
  }
82
83
  }
83
- class w {
84
+ class R {
84
85
  static async build(t) {
85
86
  const r = await t.json();
86
87
  switch (t.status) {
@@ -91,18 +92,18 @@ class w {
91
92
  }
92
93
  }
93
94
  }
94
- class u {
95
- constructor(t, r, s, i, o, a) {
95
+ class c {
96
+ constructor(t, r, s, i, a, u) {
96
97
  n(this, "baseUrl");
97
98
  n(this, "token");
98
99
  n(this, "client");
99
100
  n(this, "timezone");
100
101
  n(this, "fetchFunction");
101
102
  n(this, "fetchOptions");
102
- this.baseUrl = t, this.token = r, this.client = s, this.timezone = i, this.fetchFunction = typeof o == "function" ? o : fetch, this.fetchOptions = typeof a < "u" ? a : {};
103
+ this.baseUrl = t, this.token = r, this.client = s, this.timezone = i, this.fetchFunction = typeof a == "function" ? a : fetch, this.fetchOptions = typeof u < "u" ? u : {};
103
104
  }
104
105
  static build(t, r) {
105
- return new u(
106
+ return new c(
106
107
  (t == null ? void 0 : t.baseUrl) || "https://storefront.zenky.io/v1",
107
108
  (t == null ? void 0 : t.token) || null,
108
109
  (t == null ? void 0 : t.client) || "web",
@@ -115,25 +116,25 @@ class u {
115
116
  return this.token = t, this;
116
117
  }
117
118
  async request(t, r, s, i) {
118
- const o = {
119
+ const a = {
119
120
  Accept: "application/json",
120
121
  "X-Zenky-Client": this.client,
121
122
  "X-Timezone": this.timezone
122
123
  };
123
- i ? o.Authorization = `Bearer ${i}` : this.token && (o.Authorization = `Bearer ${this.token}`);
124
- const a = {
124
+ i ? a.Authorization = `Bearer ${i}` : this.token && (a.Authorization = `Bearer ${this.token}`);
125
+ const u = {
125
126
  method: t,
126
127
  mode: "cors",
127
128
  ...this.fetchOptions
128
129
  };
129
- s && (o["Content-Type"] = "application/json", a.body = JSON.stringify(s)), a.headers = o;
130
- const c = await this.fetchFunction.call(null, `${this.baseUrl}${r}`, a);
131
- if (c.ok)
132
- return c.json();
133
- throw await w.build(c);
130
+ s && (a["Content-Type"] = "application/json", u.body = JSON.stringify(s)), u.headers = a;
131
+ const l = await this.fetchFunction.call(null, `${this.baseUrl}${r}`, u);
132
+ if (l.ok)
133
+ return l.json();
134
+ throw await R.build(l);
134
135
  }
135
136
  }
136
- class m extends l {
137
+ class m extends o {
137
138
  async getStore(t) {
138
139
  const r = this.getUrl(`/store/${t}`);
139
140
  return this.getResponse(await this.client.request("GET", r));
@@ -143,7 +144,7 @@ class m extends l {
143
144
  return this.getResponse(await this.client.request("GET", r));
144
145
  }
145
146
  }
146
- class v extends l {
147
+ class U extends o {
147
148
  async getCollections(t, r) {
148
149
  const s = this.getStoreUrl(t, "/collections", r);
149
150
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -153,7 +154,7 @@ class v extends l {
153
154
  return this.getResponse(await this.client.request("GET", s));
154
155
  }
155
156
  }
156
- class f extends l {
157
+ class q extends o {
157
158
  async getOffers(t, r) {
158
159
  const s = this.getStoreUrl(t, "/offers", r);
159
160
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -163,7 +164,7 @@ class f extends l {
163
164
  return this.getResponse(await this.client.request("GET", i));
164
165
  }
165
166
  }
166
- class O extends l {
167
+ class O extends o {
167
168
  async createFeedback(t, r) {
168
169
  const s = this.getStoreUrl(t, "/feedback", r);
169
170
  return this.getResponse(await this.client.request("POST", s));
@@ -173,7 +174,7 @@ class O extends l {
173
174
  return await this.client.request("POST", s), !0;
174
175
  }
175
176
  }
176
- class R extends l {
177
+ class f extends o {
177
178
  async getProducts(t, r) {
178
179
  const s = this.getStoreUrl(t, "/products", r);
179
180
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -183,14 +184,14 @@ class R extends l {
183
184
  return this.getResponse(await this.client.request("GET", i));
184
185
  }
185
186
  async getProductVariantPrice(t, r, s, i) {
186
- const o = this.getStoreUrl(t, `/products/${r}/variants/${s}/price`);
187
- return this.getResponse(await this.client.request("POST", o, i));
187
+ const a = this.getStoreUrl(t, `/products/${r}/variants/${s}/price`);
188
+ return this.getResponse(await this.client.request("POST", a, i));
188
189
  }
189
190
  }
190
- class y extends l {
191
+ class v extends o {
191
192
  getOrderUrl(t, r, s, i) {
192
- const o = typeof r == "string" ? r : r.id, a = typeof r == "string" ? void 0 : r.token;
193
- return this.getStoreUrl(t, `/orders/${o}${s}${a ? "?token=" + a : ""}`, i);
193
+ const a = typeof r == "string" ? r : r.id, u = typeof r == "string" ? void 0 : r.token;
194
+ return this.getStoreUrl(t, `/orders/${a}${s}${u ? "?token=" + u : ""}`, i);
194
195
  }
195
196
  getApiToken(t) {
196
197
  if (!(typeof t == "string" || typeof t.api_token > "u"))
@@ -301,61 +302,152 @@ class y extends l {
301
302
  );
302
303
  }
303
304
  }
304
- class Q {
305
+ class S extends o {
306
+ async getAddressSuggestions(t, r) {
307
+ const s = this.getStoreUrl(t, "/suggestions/address");
308
+ return this.getResponse(await this.client.request("POST", s, r));
309
+ }
310
+ }
311
+ class P extends o {
312
+ async getProfile(t, r, s) {
313
+ const i = this.getStoreUrl(t, "/me", r);
314
+ return this.getResponse(await this.client.request("GET", i, null, s));
315
+ }
316
+ async updateProfile(t, r, s) {
317
+ const i = this.getStoreUrl(t, "/me");
318
+ return this.getResponse(await this.client.request("PUT", i, r, s));
319
+ }
320
+ async removeProfile(t, r, s) {
321
+ const i = this.getStoreUrl(t, "/me");
322
+ return await this.client.request("DELETE", i, r, s), !0;
323
+ }
324
+ async getSettings(t, r) {
325
+ const s = this.getStoreUrl(t, "/me/settings");
326
+ return this.getResponse(await this.client.request("GET", s, null, r));
327
+ }
328
+ async updateSettings(t, r, s) {
329
+ const i = this.getStoreUrl(t, "/me/settings");
330
+ return this.getResponse(await this.client.request("PUT", i, r, s));
331
+ }
332
+ async getAddresses(t, r, s) {
333
+ const i = this.getStoreUrl(t, "/me/addresses", r);
334
+ return this.getPaginatedResponse(await this.client.request("GET", i, null, s));
335
+ }
336
+ async createAddress(t, r, s) {
337
+ const i = this.getStoreUrl(t, "/me/addresses");
338
+ return this.getResponse(await this.client.request("POST", i, r, s));
339
+ }
340
+ async updateAddress(t, r, s, i) {
341
+ const a = this.getStoreUrl(t, `/me/addresses/${r}`);
342
+ return this.getResponse(await this.client.request("PUT", a, s, i));
343
+ }
344
+ async deleteAddress(t, r, s) {
345
+ const i = this.getStoreUrl(t, `/me/addresses/${r}`);
346
+ return await this.client.request("DELETE", i, null, s), !0;
347
+ }
348
+ async getPaymentMethods(t, r, s) {
349
+ const i = this.getStoreUrl(t, "/me/payment-methods", r);
350
+ return this.getPaginatedResponse(await this.client.request("GET", i, null, s));
351
+ }
352
+ async deletePaymentMethod(t, r, s) {
353
+ const i = this.getStoreUrl(t, `/me/payment-methods/${r}`);
354
+ return await this.client.request("DELETE", i, null, s), !0;
355
+ }
356
+ async getBonusesTransactions(t, r, s) {
357
+ const i = this.getStoreUrl(t, "/me/loyalty/transactions", r);
358
+ return this.getPaginatedResponse(await this.client.request("GET", i, null, s));
359
+ }
360
+ }
361
+ class y extends o {
362
+ async checkPhone(t, r) {
363
+ const s = this.getStoreUrl(t, "/auth/check");
364
+ return this.getResponse(await this.client.request("POST", s, r));
365
+ }
366
+ async register(t, r) {
367
+ const s = this.getStoreUrl(t, "/auth/register");
368
+ return this.getResponse(await this.client.request("POST", s, r));
369
+ }
370
+ async confirmRegistration(t, r) {
371
+ const s = this.getStoreUrl(t, "/auth/register/confirm");
372
+ return this.getResponse(await this.client.request("POST", s, r));
373
+ }
374
+ async resendRegistrationConfirmation(t, r) {
375
+ const s = this.getStoreUrl(t, "/auth/register/resend");
376
+ return this.getResponse(await this.client.request("POST", s, r));
377
+ }
378
+ async login(t, r) {
379
+ const s = this.getStoreUrl(t, "/auth/login");
380
+ return this.getResponse(await this.client.request("POST", s, r));
381
+ }
382
+ async dispatchPasswordReset(t, r) {
383
+ const s = this.getStoreUrl(t, "/auth/password/request");
384
+ return this.getResponse(await this.client.request("POST", s, r));
385
+ }
386
+ async resetPassword(t, r) {
387
+ const s = this.getStoreUrl(t, "/auth/password/reset");
388
+ return this.getResponse(await this.client.request("POST", s, r));
389
+ }
390
+ }
391
+ class te {
305
392
  constructor(t, r) {
306
393
  n(this, "client");
307
394
  n(this, "store");
395
+ n(this, "auth");
396
+ n(this, "customer");
308
397
  n(this, "categories");
309
398
  n(this, "products");
399
+ n(this, "addresses");
310
400
  n(this, "orders");
311
401
  n(this, "collections");
312
402
  n(this, "offers");
313
403
  n(this, "articles");
314
404
  n(this, "feedback");
315
- const s = u.build(t, r);
316
- this.store = new m(s), this.categories = new k(s), this.products = new R(s), this.orders = new y(s), this.collections = new v(s), this.offers = new f(s), this.articles = new p(s), this.feedback = new O(s), this.client = s;
405
+ const s = c.build(t, r);
406
+ this.store = new m(s), this.auth = new y(s), this.customer = new P(s), this.categories = new k(s), this.products = new f(s), this.addresses = new S(s), this.orders = new v(s), this.collections = new U(s), this.offers = new q(s), this.articles = new w(s), this.feedback = new O(s), this.client = s;
317
407
  }
318
408
  setApiToken(t) {
319
409
  return this.client.setToken(t), this;
320
410
  }
321
411
  }
322
- var U = /* @__PURE__ */ ((e) => (e.Female = "female", e.Male = "male", e.Other = "other", e))(U || {}), b = /* @__PURE__ */ ((e) => (e.Select = "select", e.MutipleSelect = "mutiple_select", e.Checkboxes = "checkboxes", e.Radios = "radios", e.Range = "range", e.Text = "text", e))(b || {}), q = /* @__PURE__ */ ((e) => (e.Integer = "integer", e.Float = "float", e))(q || {}), P = /* @__PURE__ */ ((e) => (e.Increase = "increase", e.Decrease = "decrease", e))(P || {}), S = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Confirmed = "confirmed", e.Cancelled = "cancelled", e.Rejected = "rejected", e.Refunded = "refunded", e.PartiallyRefunded = "partially_refunded", e))(S || {}), E = /* @__PURE__ */ ((e) => (e.Manual = "manual", e.Cashback = "cashback", e.ReferralReward = "referral_reward", e.RecruitReward = "recruit_reward", e.Payment = "payment", e.Cancellation = "cancellation", e.Refund = "refund", e.Adjustment = "adjustment", e.WelcomeBonuses = "welcome_bonuses", e.PromotionReward = "promotion_reward", e.External = "external", e))(E || {}), G = /* @__PURE__ */ ((e) => (e.Delivery = "delivery", e.Pickup = "pickup", e.OnPremise = "on_premise", e))(G || {}), T = /* @__PURE__ */ ((e) => (e.Payment = "payment", e.Refund = "refund", e))(T || {}), $ = /* @__PURE__ */ ((e) => (e.Cash = "cash", e.CreditCard = "credit-card", e.CloudPayments = "cloudpayments", e.CardToken = "card_token", e.Bonuses = "bonuses", e))($ || {}), A = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Confirmed = "confirmed", e.Cancelled = "cancelled", e.PendingRefund = "pending_refund", e.Refunding = "refunding", e.Refunded = "refunded", e))(A || {}), _ = /* @__PURE__ */ ((e) => (e.Auth = "auth", e.Charge = "charge", e))(_ || {}), C = /* @__PURE__ */ ((e) => (e.PersonsCount = "persons_count", e.DeliveryTime = "delivery_time", e))(C || {}), x = /* @__PURE__ */ ((e) => (e.PriceMismatch = "price_mismatch", e.OutOfStock = "out_of_stock", e.Unavailable = "unavailable", e))(x || {}), z = /* @__PURE__ */ ((e) => (e.None = "none", e.Cleanup = "cleanup", e))(z || {}), I = /* @__PURE__ */ ((e) => (e.Sms = "sms", e.Call = "call", e))(I || {}), V = /* @__PURE__ */ ((e) => (e.Piece = "piece", e.Gram = "gram", e.Kilogram = "kilogram", e.Meter = "meter", e))(V || {}), j = /* @__PURE__ */ ((e) => (e.Weight = "weight", e.Width = "width", e.Height = "height", e.Length = "length", e))(j || {}), F = /* @__PURE__ */ ((e) => (e.Netto = "netto", e.Brutto = "brutto", e))(F || {}), N = /* @__PURE__ */ ((e) => (e.Color = "color", e))(N || {}), W = /* @__PURE__ */ ((e) => (e.Category = "category", e.Group = "group", e.VariantOption = "variant_option", e.VariantOptionValue = "variant_option_value", e))(W || {}), Z = /* @__PURE__ */ ((e) => (e.Amount = "amount", e.Percentage = "percentage", e))(Z || {}), X = /* @__PURE__ */ ((e) => (e.Email = "email", e.Website = "website", e.Vk = "vk", e.Facebook = "facebook", e.Instagram = "instagram", e.Twitter = "twitter", e.Ok = "ok", e.Tiktok = "tiktok", e))(X || {}), H = /* @__PURE__ */ ((e) => (e.Yes = "yes", e.No = "no", e.Both = "both", e))(H || {}), J = /* @__PURE__ */ ((e) => (e.Disabled = "disabled", e.Preauth = "preauth", e.Confirmation = "confirmation", e))(J || {}), L = /* @__PURE__ */ ((e) => (e.Dadata = "dadata", e.Manual = "manual", e))(L || {}), Y = /* @__PURE__ */ ((e) => (e.Registration = "registration", e.ResendRegistrationCode = "resend_registration_code", e.ResetPassword = "reset_password", e.OrderSubmission = "order_submission", e.FeedbackRequest = "feedback_request", e.CallbackRequest = "callback_request", e))(Y || {});
412
+ var b = /* @__PURE__ */ ((e) => (e.Female = "female", e.Male = "male", e.Other = "other", e))(b || {}), E = /* @__PURE__ */ ((e) => (e.CloudPayments = "cloudpayments", e))(E || {}), T = /* @__PURE__ */ ((e) => (e.Visa = "visa", e.MasterCard = "master-card", e.MIR = "mir", e.Maestro = "maestro", e.AmericanExpress = "american-express", e.DinersClub = "diners-club", e.Discover = "discover", e.JCB = "jcb", e.UnionPay = "union-pay", e))(T || {}), A = /* @__PURE__ */ ((e) => (e.Select = "select", e.MutipleSelect = "mutiple_select", e.Checkboxes = "checkboxes", e.Radios = "radios", e.Range = "range", e.Text = "text", e))(A || {}), G = /* @__PURE__ */ ((e) => (e.Integer = "integer", e.Float = "float", e))(G || {}), $ = /* @__PURE__ */ ((e) => (e.Increase = "increase", e.Decrease = "decrease", e))($ || {}), C = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Confirmed = "confirmed", e.Cancelled = "cancelled", e.Rejected = "rejected", e.Refunded = "refunded", e.PartiallyRefunded = "partially_refunded", e))(C || {}), _ = /* @__PURE__ */ ((e) => (e.Manual = "manual", e.Cashback = "cashback", e.ReferralReward = "referral_reward", e.RecruitReward = "recruit_reward", e.Payment = "payment", e.Cancellation = "cancellation", e.Refund = "refund", e.Adjustment = "adjustment", e.WelcomeBonuses = "welcome_bonuses", e.PromotionReward = "promotion_reward", e.External = "external", e))(_ || {}), x = /* @__PURE__ */ ((e) => (e.Delivery = "delivery", e.Pickup = "pickup", e.OnPremise = "on_premise", e))(x || {}), z = /* @__PURE__ */ ((e) => (e.Payment = "payment", e.Refund = "refund", e))(z || {}), I = /* @__PURE__ */ ((e) => (e.Cash = "cash", e.CreditCard = "credit-card", e.CloudPayments = "cloudpayments", e.CardToken = "card_token", e.Bonuses = "bonuses", e))(I || {}), V = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Confirmed = "confirmed", e.Cancelled = "cancelled", e.PendingRefund = "pending_refund", e.Refunding = "refunding", e.Refunded = "refunded", e))(V || {}), j = /* @__PURE__ */ ((e) => (e.Auth = "auth", e.Charge = "charge", e))(j || {}), D = /* @__PURE__ */ ((e) => (e.PersonsCount = "persons_count", e.DeliveryTime = "delivery_time", e))(D || {}), F = /* @__PURE__ */ ((e) => (e.PriceMismatch = "price_mismatch", e.OutOfStock = "out_of_stock", e.Unavailable = "unavailable", e))(F || {}), L = /* @__PURE__ */ ((e) => (e.None = "none", e.Cleanup = "cleanup", e))(L || {}), M = /* @__PURE__ */ ((e) => (e.Piece = "piece", e.Gram = "gram", e.Kilogram = "kilogram", e.Meter = "meter", e))(M || {}), N = /* @__PURE__ */ ((e) => (e.Weight = "weight", e.Width = "width", e.Height = "height", e.Length = "length", e))(N || {}), W = /* @__PURE__ */ ((e) => (e.Netto = "netto", e.Brutto = "brutto", e))(W || {}), Z = /* @__PURE__ */ ((e) => (e.Color = "color", e))(Z || {}), J = /* @__PURE__ */ ((e) => (e.Category = "category", e.Group = "group", e.VariantOption = "variant_option", e.VariantOptionValue = "variant_option_value", e))(J || {}), X = /* @__PURE__ */ ((e) => (e.Amount = "amount", e.Percentage = "percentage", e))(X || {}), H = /* @__PURE__ */ ((e) => (e.Email = "email", e.Website = "website", e.Vk = "vk", e.Facebook = "facebook", e.Instagram = "instagram", e.Twitter = "twitter", e.Ok = "ok", e.Tiktok = "tiktok", e))(H || {}), Y = /* @__PURE__ */ ((e) => (e.Yes = "yes", e.No = "no", e.Both = "both", e))(Y || {}), K = /* @__PURE__ */ ((e) => (e.Disabled = "disabled", e.Preauth = "preauth", e.Confirmation = "confirmation", e))(K || {}), Q = /* @__PURE__ */ ((e) => (e.Dadata = "dadata", e.Manual = "manual", e))(Q || {}), B = /* @__PURE__ */ ((e) => (e.Registration = "registration", e.ResendRegistrationCode = "resend_registration_code", e.ResetPassword = "reset_password", e.OrderSubmission = "order_submission", e.FeedbackRequest = "feedback_request", e.CallbackRequest = "callback_request", e))(B || {});
323
413
  export {
324
- L as AddressesProvider,
325
- p as ArticlesResource,
326
- E as BonusesTransactionReason,
327
- S as BonusesTransactionStatus,
328
- P as BonusesTransactionType,
414
+ E as AcquiringType,
415
+ p as AddressSuggestionsProvider,
416
+ Q as AddressesProvider,
417
+ w as ArticlesResource,
418
+ _ as BonusesTransactionReason,
419
+ C as BonusesTransactionStatus,
420
+ $ as BonusesTransactionType,
329
421
  k as CategoriesResource,
330
- _ as CloudpaymentsChargeType,
331
- v as CollectionsResource,
332
- X as ContactType,
333
- G as DeliveryMethod,
334
- j as Dimension,
335
- F as DimensionType,
336
- Z as DiscountType,
337
- q as FeatureRange,
338
- b as FeatureType,
422
+ j as CloudpaymentsChargeType,
423
+ U as CollectionsResource,
424
+ H as ContactType,
425
+ x as DeliveryMethod,
426
+ N as Dimension,
427
+ W as DimensionType,
428
+ X as DiscountType,
429
+ G as FeatureRange,
430
+ A as FeatureType,
339
431
  O as FeedbackResource,
340
- U as Gender,
341
- f as OffersResource,
342
- J as OrderAuthenticationMethod,
343
- z as OrderCartCheckerResultAction,
344
- x as OrderCartCheckerResultReason,
345
- I as OrderConfirmationMethod,
346
- C as OrderOptionKind,
347
- A as OrderPaymentTransactionStatus,
348
- T as OrderPaymentTransactionType,
349
- y as OrdersResource,
350
- $ as PaymentMethod,
351
- W as ProductContextType,
352
- R as ProductsResource,
353
- Y as RecaptchaAction,
432
+ b as Gender,
433
+ q as OffersResource,
434
+ K as OrderAuthenticationMethod,
435
+ L as OrderCartCheckerResultAction,
436
+ F as OrderCartCheckerResultReason,
437
+ D as OrderOptionKind,
438
+ V as OrderPaymentTransactionStatus,
439
+ z as OrderPaymentTransactionType,
440
+ v as OrdersResource,
441
+ I as PaymentMethod,
442
+ T as PaymentSystemType,
443
+ J as ProductContextType,
444
+ f as ProductsResource,
445
+ B as RecaptchaAction,
354
446
  m as StoreResource,
355
- H as TernaryFilter,
356
- V as UnitType,
357
- N as VariantOptionType,
447
+ Y as TernaryFilter,
448
+ M as UnitType,
449
+ Z as VariantOptionType,
358
450
  h as ZenkyError,
359
- w as ZenkyErrorBuilder,
360
- Q as ZenkyStorefront
451
+ R as ZenkyErrorBuilder,
452
+ te as ZenkyStorefront
361
453
  };
@@ -1 +1 @@
1
- (function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.zenkyStorefrontApi={}))})(this,function(i){"use strict";var L=Object.defineProperty;var Y=(i,a,l)=>a in i?L(i,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[a]=l;var o=(i,a,l)=>(Y(i,typeof a!="symbol"?a+"":a,l),l);class a{constructor(t){this.client=t}getStoreUrl(t,r,s={}){return this.getUrl(`/store/${t}${r}`,s)}getUrl(t,r={}){if(!Object.keys(r).length)return t;const s=[];Object.keys(r).forEach(c=>{s.push(`${c}=${r[c]}`)});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 r=t.data,s=t.meta.pagination;return{items:r,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class l extends a{async getArticleCategories(t){const r=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",r))}async getArticleCategory(t,r){const s=this.getStoreUrl(t,`/articles/categories/${r}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,r){const s=this.getStoreUrl(t,"/articles",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,r,s){const n=this.getStoreUrl(t,`/articles/${r}`,s);return this.getResponse(await this.client.request("GET",n))}}class k extends a{async getCategories(t,r){const s=this.getStoreUrl(t,"/categories",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,r){const s=this.getStoreUrl(t,"/categories/tree",r);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,r,s){const n=this.getStoreUrl(t,`/categories/${r}`,s);return this.getResponse(await this.client.request("GET",n))}async getFeaturesGroups(t,r){const s=this.getStoreUrl(t,`/categories/${r}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,r){const s=this.getStoreUrl(t,`/categories/${r}/features`);return this.getResponse(await this.client.request("GET",s))}}class h extends Error{constructor(r,s){super(r);o(this,"err");this.err=s}}class w{static async build(t){const r=await t.json();switch(t.status){case 401:return new h((r==null?void 0:r.message)||"Unauthenticated.",null);default:return new h(r==null?void 0:r.message,(r==null?void 0:r.error)||null)}}}class d{constructor(t,r,s,n,c,u){o(this,"baseUrl");o(this,"token");o(this,"client");o(this,"timezone");o(this,"fetchFunction");o(this,"fetchOptions");this.baseUrl=t,this.token=r,this.client=s,this.timezone=n,this.fetchFunction=typeof c=="function"?c:fetch,this.fetchOptions=typeof u<"u"?u:{}}static build(t,r){return new d((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",r,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}async request(t,r,s,n){const c={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};n?c.Authorization=`Bearer ${n}`:this.token&&(c.Authorization=`Bearer ${this.token}`);const u={method:t,mode:"cors",...this.fetchOptions};s&&(c["Content-Type"]="application/json",u.body=JSON.stringify(s)),u.headers=c;const g=await this.fetchFunction.call(null,`${this.baseUrl}${r}`,u);if(g.ok)return g.json();throw await w.build(g)}}class p extends a{async getStore(t){const r=this.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",r))}async getStoreByBundleId(t){const r=this.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",r))}}class y extends a{async getCollections(t,r){const s=this.getStoreUrl(t,"/collections",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,r){const s=this.getStoreUrl(t,`/collections/${r}`);return this.getResponse(await this.client.request("GET",s))}}class f extends a{async getOffers(t,r){const s=this.getStoreUrl(t,"/offers",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,r,s){const n=this.getStoreUrl(t,`/offers/${r}`,s);return this.getResponse(await this.client.request("GET",n))}}class m extends a{async createFeedback(t,r){const s=this.getStoreUrl(t,"/feedback",r);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,r){const s=this.getStoreUrl(t,"/callback",r);return await this.client.request("POST",s),!0}}class O extends a{async getProducts(t,r){const s=this.getStoreUrl(t,"/products",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,r,s){const n=this.getStoreUrl(t,`/products/${r}`,s);return this.getResponse(await this.client.request("GET",n))}async getProductVariantPrice(t,r,s,n){const c=this.getStoreUrl(t,`/products/${r}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",c,n))}}class R extends a{getOrderUrl(t,r,s,n){const c=typeof r=="string"?r:r.id,u=typeof r=="string"?void 0:r.token;return this.getStoreUrl(t,`/orders/${c}${s}${u?"?token="+u:""}`,n)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,r,s){const n=this.getStoreUrl(t,"/orders",r);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,s))}async createOrder(t,r,s){const n=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",n,r,s))}async getOrder(t,r,s){const n=this.getOrderUrl(t,r,"",s);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(r)))}async getOrderSettings(t,r){const s=this.getOrderUrl(t,r,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async addProductVariantToOrder(t,r,s){const n=this.getOrderUrl(t,r,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(r)))}async removeProductVariantFromOrder(t,r,s){const n=this.getOrderUrl(t,r,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(r)))}async checkProducts(t,r){const s=this.getOrderUrl(t,r,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(r)))}async setOrderCustomer(t,r,s){const n=this.getOrderUrl(t,r,"/checkout/customer");return await this.client.request("POST",n,s,this.getApiToken(r)),!0}async setOrderDeliveryMethod(t,r,s){const n=this.getOrderUrl(t,r,"/checkout/delivery");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(r)))}async setOrderPayments(t,r,s){const n=this.getOrderUrl(t,r,"/checkout/payments");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(r)))}async getOrderBonusesPreview(t,r,s){const n=this.getOrderUrl(t,r,"/checkout/bonuses/preview",{amount:s});return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(r)))}async getOrderTotal(t,r){const s=this.getOrderUrl(t,r,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async checkoutOrder(t,r,s){const n=this.getOrderUrl(t,r,"/checkout");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(r)))}async confirmOrder(t,r,s){const n=this.getOrderUrl(t,r,"/confirm");return await this.client.request("POST",n,s,this.getApiToken(r)),!0}async resendOrderConfirmationCode(t,r){const s=this.getOrderUrl(t,r,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(r)),!0}async getOrderBonusesTransactions(t,r,s){const n=this.getOrderUrl(t,r,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,this.getApiToken(r)))}async getOrderCashbackTransaction(t,r){const s=this.getOrderUrl(t,r,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async dispatchPromotionsChecker(t,r){const s=this.getOrderUrl(t,r,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(r))).dispatched}async getOrderPromotionRewards(t,r){const s=this.getOrderUrl(t,r,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}}class K{constructor(t,r){o(this,"client");o(this,"store");o(this,"categories");o(this,"products");o(this,"orders");o(this,"collections");o(this,"offers");o(this,"articles");o(this,"feedback");const s=d.build(t,r);this.store=new p(s),this.categories=new k(s),this.products=new O(s),this.orders=new R(s),this.collections=new y(s),this.offers=new f(s),this.articles=new l(s),this.feedback=new m(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var v=(e=>(e.Female="female",e.Male="male",e.Other="other",e))(v||{}),b=(e=>(e.Select="select",e.MutipleSelect="mutiple_select",e.Checkboxes="checkboxes",e.Radios="radios",e.Range="range",e.Text="text",e))(b||{}),U=(e=>(e.Integer="integer",e.Float="float",e))(U||{}),P=(e=>(e.Increase="increase",e.Decrease="decrease",e))(P||{}),T=(e=>(e.Pending="pending",e.Confirmed="confirmed",e.Cancelled="cancelled",e.Rejected="rejected",e.Refunded="refunded",e.PartiallyRefunded="partially_refunded",e))(T||{}),S=(e=>(e.Manual="manual",e.Cashback="cashback",e.ReferralReward="referral_reward",e.RecruitReward="recruit_reward",e.Payment="payment",e.Cancellation="cancellation",e.Refund="refund",e.Adjustment="adjustment",e.WelcomeBonuses="welcome_bonuses",e.PromotionReward="promotion_reward",e.External="external",e))(S||{}),q=(e=>(e.Delivery="delivery",e.Pickup="pickup",e.OnPremise="on_premise",e))(q||{}),E=(e=>(e.Payment="payment",e.Refund="refund",e))(E||{}),C=(e=>(e.Cash="cash",e.CreditCard="credit-card",e.CloudPayments="cloudpayments",e.CardToken="card_token",e.Bonuses="bonuses",e))(C||{}),A=(e=>(e.Pending="pending",e.Confirmed="confirmed",e.Cancelled="cancelled",e.PendingRefund="pending_refund",e.Refunding="refunding",e.Refunded="refunded",e))(A||{}),G=(e=>(e.Auth="auth",e.Charge="charge",e))(G||{}),$=(e=>(e.PersonsCount="persons_count",e.DeliveryTime="delivery_time",e))($||{}),_=(e=>(e.PriceMismatch="price_mismatch",e.OutOfStock="out_of_stock",e.Unavailable="unavailable",e))(_||{}),z=(e=>(e.None="none",e.Cleanup="cleanup",e))(z||{}),j=(e=>(e.Sms="sms",e.Call="call",e))(j||{}),F=(e=>(e.Piece="piece",e.Gram="gram",e.Kilogram="kilogram",e.Meter="meter",e))(F||{}),V=(e=>(e.Weight="weight",e.Width="width",e.Height="height",e.Length="length",e))(V||{}),I=(e=>(e.Netto="netto",e.Brutto="brutto",e))(I||{}),Z=(e=>(e.Color="color",e))(Z||{}),N=(e=>(e.Category="category",e.Group="group",e.VariantOption="variant_option",e.VariantOptionValue="variant_option_value",e))(N||{}),W=(e=>(e.Amount="amount",e.Percentage="percentage",e))(W||{}),D=(e=>(e.Email="email",e.Website="website",e.Vk="vk",e.Facebook="facebook",e.Instagram="instagram",e.Twitter="twitter",e.Ok="ok",e.Tiktok="tiktok",e))(D||{}),M=(e=>(e.Yes="yes",e.No="no",e.Both="both",e))(M||{}),X=(e=>(e.Disabled="disabled",e.Preauth="preauth",e.Confirmation="confirmation",e))(X||{}),H=(e=>(e.Dadata="dadata",e.Manual="manual",e))(H||{}),J=(e=>(e.Registration="registration",e.ResendRegistrationCode="resend_registration_code",e.ResetPassword="reset_password",e.OrderSubmission="order_submission",e.FeedbackRequest="feedback_request",e.CallbackRequest="callback_request",e))(J||{});i.AddressesProvider=H,i.ArticlesResource=l,i.BonusesTransactionReason=S,i.BonusesTransactionStatus=T,i.BonusesTransactionType=P,i.CategoriesResource=k,i.CloudpaymentsChargeType=G,i.CollectionsResource=y,i.ContactType=D,i.DeliveryMethod=q,i.Dimension=V,i.DimensionType=I,i.DiscountType=W,i.FeatureRange=U,i.FeatureType=b,i.FeedbackResource=m,i.Gender=v,i.OffersResource=f,i.OrderAuthenticationMethod=X,i.OrderCartCheckerResultAction=z,i.OrderCartCheckerResultReason=_,i.OrderConfirmationMethod=j,i.OrderOptionKind=$,i.OrderPaymentTransactionStatus=A,i.OrderPaymentTransactionType=E,i.OrdersResource=R,i.PaymentMethod=C,i.ProductContextType=N,i.ProductsResource=O,i.RecaptchaAction=J,i.StoreResource=p,i.TernaryFilter=M,i.UnitType=F,i.VariantOptionType=Z,i.ZenkyError=h,i.ZenkyErrorBuilder=w,i.ZenkyStorefront=K,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(n=typeof globalThis<"u"?globalThis:n||self,c(n.zenkyStorefrontApi={}))})(this,function(n){"use strict";var ee=Object.defineProperty;var te=(n,c,o)=>c in n?ee(n,c,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[c]=o;var a=(n,c,o)=>(te(n,typeof c!="symbol"?c+"":c,o),o);var c=(e=>(e.DADATA="dadata",e))(c||{});class o{constructor(t){this.client=t}getStoreUrl(t,r,s={}){return this.getUrl(`/store/${t}${r}`,s)}getUrl(t,r={}){if(!Object.keys(r).length)return t;const s=[];Object.keys(r).forEach(u=>{s.push(`${u}=${r[u]}`)});const i=t.includes("?")?"&":"?";return`${t}${i}${s.join("&")}`}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const r=t.data,s=t.meta.pagination;return{items:r,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class w extends o{async getArticleCategories(t){const r=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",r))}async getArticleCategory(t,r){const s=this.getStoreUrl(t,`/articles/categories/${r}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,r){const s=this.getStoreUrl(t,"/articles",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,r,s){const i=this.getStoreUrl(t,`/articles/${r}`,s);return this.getResponse(await this.client.request("GET",i))}}class p extends o{async getCategories(t,r){const s=this.getStoreUrl(t,"/categories",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,r){const s=this.getStoreUrl(t,"/categories/tree",r);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,r,s){const i=this.getStoreUrl(t,`/categories/${r}`,s);return this.getResponse(await this.client.request("GET",i))}async getFeaturesGroups(t,r){const s=this.getStoreUrl(t,`/categories/${r}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,r){const s=this.getStoreUrl(t,`/categories/${r}/features`);return this.getResponse(await this.client.request("GET",s))}}class h extends Error{constructor(r,s){super(r);a(this,"err");this.err=s}}class k{static async build(t){const r=await t.json();switch(t.status){case 401:return new h((r==null?void 0:r.message)||"Unauthenticated.",null);default:return new h(r==null?void 0:r.message,(r==null?void 0:r.error)||null)}}}class d{constructor(t,r,s,i,u,l){a(this,"baseUrl");a(this,"token");a(this,"client");a(this,"timezone");a(this,"fetchFunction");a(this,"fetchOptions");this.baseUrl=t,this.token=r,this.client=s,this.timezone=i,this.fetchFunction=typeof u=="function"?u:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,r){return new d((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",r,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}async request(t,r,s,i){const u={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};i?u.Authorization=`Bearer ${i}`:this.token&&(u.Authorization=`Bearer ${this.token}`);const l={method:t,mode:"cors",...this.fetchOptions};s&&(u["Content-Type"]="application/json",l.body=JSON.stringify(s)),l.headers=u;const g=await this.fetchFunction.call(null,`${this.baseUrl}${r}`,l);if(g.ok)return g.json();throw await k.build(g)}}class R extends o{async getStore(t){const r=this.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",r))}async getStoreByBundleId(t){const r=this.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",r))}}class m extends o{async getCollections(t,r){const s=this.getStoreUrl(t,"/collections",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,r){const s=this.getStoreUrl(t,`/collections/${r}`);return this.getResponse(await this.client.request("GET",s))}}class y extends o{async getOffers(t,r){const s=this.getStoreUrl(t,"/offers",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,r,s){const i=this.getStoreUrl(t,`/offers/${r}`,s);return this.getResponse(await this.client.request("GET",i))}}class f extends o{async createFeedback(t,r){const s=this.getStoreUrl(t,"/feedback",r);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,r){const s=this.getStoreUrl(t,"/callback",r);return await this.client.request("POST",s),!0}}class O extends o{async getProducts(t,r){const s=this.getStoreUrl(t,"/products",r);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,r,s){const i=this.getStoreUrl(t,`/products/${r}`,s);return this.getResponse(await this.client.request("GET",i))}async getProductVariantPrice(t,r,s,i){const u=this.getStoreUrl(t,`/products/${r}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",u,i))}}class U extends o{getOrderUrl(t,r,s,i){const u=typeof r=="string"?r:r.id,l=typeof r=="string"?void 0:r.token;return this.getStoreUrl(t,`/orders/${u}${s}${l?"?token="+l:""}`,i)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,r,s){const i=this.getStoreUrl(t,"/orders",r);return this.getPaginatedResponse(await this.client.request("GET",i,void 0,s))}async createOrder(t,r,s){const i=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",i,r,s))}async getOrder(t,r,s){const i=this.getOrderUrl(t,r,"",s);return this.getResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}async getOrderSettings(t,r){const s=this.getOrderUrl(t,r,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async addProductVariantToOrder(t,r,s){const i=this.getOrderUrl(t,r,"/products");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async removeProductVariantFromOrder(t,r,s){const i=this.getOrderUrl(t,r,"/products");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async checkProducts(t,r){const s=this.getOrderUrl(t,r,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(r)))}async setOrderCustomer(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/customer");return await this.client.request("POST",i,s,this.getApiToken(r)),!0}async setOrderDeliveryMethod(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/delivery");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async setOrderPayments(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/payments");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async getOrderBonusesPreview(t,r,s){const i=this.getOrderUrl(t,r,"/checkout/bonuses/preview",{amount:s});return this.getResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}async getOrderTotal(t,r){const s=this.getOrderUrl(t,r,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async checkoutOrder(t,r,s){const i=this.getOrderUrl(t,r,"/checkout");return this.getResponse(await this.client.request("POST",i,s,this.getApiToken(r)))}async confirmOrder(t,r,s){const i=this.getOrderUrl(t,r,"/confirm");return await this.client.request("POST",i,s,this.getApiToken(r)),!0}async resendOrderConfirmationCode(t,r){const s=this.getOrderUrl(t,r,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(r)),!0}async getOrderBonusesTransactions(t,r,s){const i=this.getOrderUrl(t,r,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",i,void 0,this.getApiToken(r)))}async getOrderCashbackTransaction(t,r){const s=this.getOrderUrl(t,r,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}async dispatchPromotionsChecker(t,r){const s=this.getOrderUrl(t,r,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(r))).dispatched}async getOrderPromotionRewards(t,r){const s=this.getOrderUrl(t,r,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(r)))}}class K extends o{async getAddressSuggestions(t,r){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,r))}}class Y extends o{async getProfile(t,r,s){const i=this.getStoreUrl(t,"/me",r);return this.getResponse(await this.client.request("GET",i,null,s))}async updateProfile(t,r,s){const i=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",i,r,s))}async removeProfile(t,r,s){const i=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",i,r,s),!0}async getSettings(t,r){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,r))}async updateSettings(t,r,s){const i=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",i,r,s))}async getAddresses(t,r,s){const i=this.getStoreUrl(t,"/me/addresses",r);return this.getPaginatedResponse(await this.client.request("GET",i,null,s))}async createAddress(t,r,s){const i=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",i,r,s))}async updateAddress(t,r,s,i){const u=this.getStoreUrl(t,`/me/addresses/${r}`);return this.getResponse(await this.client.request("PUT",u,s,i))}async deleteAddress(t,r,s){const i=this.getStoreUrl(t,`/me/addresses/${r}`);return await this.client.request("DELETE",i,null,s),!0}async getPaymentMethods(t,r,s){const i=this.getStoreUrl(t,"/me/payment-methods",r);return this.getPaginatedResponse(await this.client.request("GET",i,null,s))}async deletePaymentMethod(t,r,s){const i=this.getStoreUrl(t,`/me/payment-methods/${r}`);return await this.client.request("DELETE",i,null,s),!0}async getBonusesTransactions(t,r,s){const i=this.getStoreUrl(t,"/me/loyalty/transactions",r);return this.getPaginatedResponse(await this.client.request("GET",i,null,s))}}class Q extends o{async checkPhone(t,r){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,r))}async register(t,r){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,r))}async confirmRegistration(t,r){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,r))}async resendRegistrationConfirmation(t,r){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,r))}async login(t,r){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,r))}async dispatchPasswordReset(t,r){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,r))}async resetPassword(t,r){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,r))}}class x{constructor(t,r){a(this,"client");a(this,"store");a(this,"auth");a(this,"customer");a(this,"categories");a(this,"products");a(this,"addresses");a(this,"orders");a(this,"collections");a(this,"offers");a(this,"articles");a(this,"feedback");const s=d.build(t,r);this.store=new R(s),this.auth=new Q(s),this.customer=new Y(s),this.categories=new p(s),this.products=new O(s),this.addresses=new K(s),this.orders=new U(s),this.collections=new m(s),this.offers=new y(s),this.articles=new w(s),this.feedback=new f(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var S=(e=>(e.Female="female",e.Male="male",e.Other="other",e))(S||{}),v=(e=>(e.CloudPayments="cloudpayments",e))(v||{}),q=(e=>(e.Visa="visa",e.MasterCard="master-card",e.MIR="mir",e.Maestro="maestro",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.JCB="jcb",e.UnionPay="union-pay",e))(q||{}),P=(e=>(e.Select="select",e.MutipleSelect="mutiple_select",e.Checkboxes="checkboxes",e.Radios="radios",e.Range="range",e.Text="text",e))(P||{}),T=(e=>(e.Integer="integer",e.Float="float",e))(T||{}),b=(e=>(e.Increase="increase",e.Decrease="decrease",e))(b||{}),E=(e=>(e.Pending="pending",e.Confirmed="confirmed",e.Cancelled="cancelled",e.Rejected="rejected",e.Refunded="refunded",e.PartiallyRefunded="partially_refunded",e))(E||{}),A=(e=>(e.Manual="manual",e.Cashback="cashback",e.ReferralReward="referral_reward",e.RecruitReward="recruit_reward",e.Payment="payment",e.Cancellation="cancellation",e.Refund="refund",e.Adjustment="adjustment",e.WelcomeBonuses="welcome_bonuses",e.PromotionReward="promotion_reward",e.External="external",e))(A||{}),C=(e=>(e.Delivery="delivery",e.Pickup="pickup",e.OnPremise="on_premise",e))(C||{}),G=(e=>(e.Payment="payment",e.Refund="refund",e))(G||{}),$=(e=>(e.Cash="cash",e.CreditCard="credit-card",e.CloudPayments="cloudpayments",e.CardToken="card_token",e.Bonuses="bonuses",e))($||{}),_=(e=>(e.Pending="pending",e.Confirmed="confirmed",e.Cancelled="cancelled",e.PendingRefund="pending_refund",e.Refunding="refunding",e.Refunded="refunded",e))(_||{}),D=(e=>(e.Auth="auth",e.Charge="charge",e))(D||{}),j=(e=>(e.PersonsCount="persons_count",e.DeliveryTime="delivery_time",e))(j||{}),z=(e=>(e.PriceMismatch="price_mismatch",e.OutOfStock="out_of_stock",e.Unavailable="unavailable",e))(z||{}),V=(e=>(e.None="none",e.Cleanup="cleanup",e))(V||{}),F=(e=>(e.Piece="piece",e.Gram="gram",e.Kilogram="kilogram",e.Meter="meter",e))(F||{}),I=(e=>(e.Weight="weight",e.Width="width",e.Height="height",e.Length="length",e))(I||{}),M=(e=>(e.Netto="netto",e.Brutto="brutto",e))(M||{}),Z=(e=>(e.Color="color",e))(Z||{}),L=(e=>(e.Category="category",e.Group="group",e.VariantOption="variant_option",e.VariantOptionValue="variant_option_value",e))(L||{}),N=(e=>(e.Amount="amount",e.Percentage="percentage",e))(N||{}),W=(e=>(e.Email="email",e.Website="website",e.Vk="vk",e.Facebook="facebook",e.Instagram="instagram",e.Twitter="twitter",e.Ok="ok",e.Tiktok="tiktok",e))(W||{}),J=(e=>(e.Yes="yes",e.No="no",e.Both="both",e))(J||{}),X=(e=>(e.Disabled="disabled",e.Preauth="preauth",e.Confirmation="confirmation",e))(X||{}),B=(e=>(e.Dadata="dadata",e.Manual="manual",e))(B||{}),H=(e=>(e.Registration="registration",e.ResendRegistrationCode="resend_registration_code",e.ResetPassword="reset_password",e.OrderSubmission="order_submission",e.FeedbackRequest="feedback_request",e.CallbackRequest="callback_request",e))(H||{});n.AcquiringType=v,n.AddressSuggestionsProvider=c,n.AddressesProvider=B,n.ArticlesResource=w,n.BonusesTransactionReason=A,n.BonusesTransactionStatus=E,n.BonusesTransactionType=b,n.CategoriesResource=p,n.CloudpaymentsChargeType=D,n.CollectionsResource=m,n.ContactType=W,n.DeliveryMethod=C,n.Dimension=I,n.DimensionType=M,n.DiscountType=N,n.FeatureRange=T,n.FeatureType=P,n.FeedbackResource=f,n.Gender=S,n.OffersResource=y,n.OrderAuthenticationMethod=X,n.OrderCartCheckerResultAction=V,n.OrderCartCheckerResultReason=z,n.OrderOptionKind=j,n.OrderPaymentTransactionStatus=_,n.OrderPaymentTransactionType=G,n.OrdersResource=U,n.PaymentMethod=$,n.PaymentSystemType=q,n.ProductContextType=L,n.ProductsResource=O,n.RecaptchaAction=H,n.StoreResource=R,n.TernaryFilter=J,n.UnitType=F,n.VariantOptionType=Z,n.ZenkyError=h,n.ZenkyErrorBuilder=k,n.ZenkyStorefront=x,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenky/storefront-api",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Zenky Storefront API SDK",
5
5
  "author": "Timur Zurbaev <hello@zurbaev.ru>",
6
6
  "license": "MIT",