@betterstore/sdk 0.3.46 → 0.3.47
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +74 -64
- package/dist/index.mjs +74 -64
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -251,6 +251,7 @@ declare class Customer {
|
|
|
251
251
|
declare class Helpers {
|
|
252
252
|
proxy?: string;
|
|
253
253
|
constructor(proxy?: string);
|
|
254
|
+
formatCurrency(currency: string): string;
|
|
254
255
|
formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
|
|
255
256
|
getExchangeRate(baseCurrency: string, targetCurrency: string): Promise<number>;
|
|
256
257
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -251,6 +251,7 @@ declare class Customer {
|
|
|
251
251
|
declare class Helpers {
|
|
252
252
|
proxy?: string;
|
|
253
253
|
constructor(proxy?: string);
|
|
254
|
+
formatCurrency(currency: string): string;
|
|
254
255
|
formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
|
|
255
256
|
getExchangeRate(baseCurrency: string, targetCurrency: string): Promise<number>;
|
|
256
257
|
}
|
package/dist/index.js
CHANGED
|
@@ -336,78 +336,88 @@ var Customer = class {
|
|
|
336
336
|
var customer_default = Customer;
|
|
337
337
|
|
|
338
338
|
// src/helpers/index.ts
|
|
339
|
+
var currencyLocales = {
|
|
340
|
+
CZK: "cs-CZ",
|
|
341
|
+
// Czech Koruna
|
|
342
|
+
USD: "en-US",
|
|
343
|
+
// US Dollar
|
|
344
|
+
EUR: "de-DE",
|
|
345
|
+
// Euro (Germany locale)
|
|
346
|
+
GBP: "en-GB",
|
|
347
|
+
// British Pound
|
|
348
|
+
JPY: "ja-JP",
|
|
349
|
+
// Japanese Yen
|
|
350
|
+
AUD: "en-AU",
|
|
351
|
+
// Australian Dollar
|
|
352
|
+
CAD: "en-CA",
|
|
353
|
+
// Canadian Dollar
|
|
354
|
+
NZD: "en-NZ",
|
|
355
|
+
// New Zealand Dollar
|
|
356
|
+
SEK: "sv-SE",
|
|
357
|
+
// Swedish Krona
|
|
358
|
+
NOK: "nb-NO",
|
|
359
|
+
// Norwegian Krone
|
|
360
|
+
DKK: "da-DK",
|
|
361
|
+
// Danish Krone
|
|
362
|
+
CHF: "de-CH",
|
|
363
|
+
// Swiss Franc (German Switzerland)
|
|
364
|
+
HUF: "hu-HU",
|
|
365
|
+
// Hungarian Forint
|
|
366
|
+
PLN: "pl-PL",
|
|
367
|
+
// Polish Zloty
|
|
368
|
+
BGN: "bg-BG",
|
|
369
|
+
// Bulgarian Lev
|
|
370
|
+
RON: "ro-RO",
|
|
371
|
+
// Romanian Leu
|
|
372
|
+
RUB: "ru-RU",
|
|
373
|
+
// Russian Ruble
|
|
374
|
+
CNY: "zh-CN",
|
|
375
|
+
// Chinese Yuan
|
|
376
|
+
INR: "en-IN",
|
|
377
|
+
// Indian Rupee
|
|
378
|
+
BRL: "pt-BR",
|
|
379
|
+
// Brazilian Real
|
|
380
|
+
MXN: "es-MX",
|
|
381
|
+
// Mexican Peso
|
|
382
|
+
ZAR: "en-ZA",
|
|
383
|
+
// South African Rand
|
|
384
|
+
KRW: "ko-KR",
|
|
385
|
+
// South Korean Won
|
|
386
|
+
MYR: "ms-MY",
|
|
387
|
+
// Malaysian Ringgit
|
|
388
|
+
SGD: "en-SG",
|
|
389
|
+
// Singapore Dollar
|
|
390
|
+
TWD: "zh-TW",
|
|
391
|
+
// Taiwanese Dollar
|
|
392
|
+
THB: "th-TH",
|
|
393
|
+
// Thai Baht
|
|
394
|
+
IDR: "id-ID",
|
|
395
|
+
// Indonesian Rupiah
|
|
396
|
+
AED: "ar-AE",
|
|
397
|
+
// UAE Dirham
|
|
398
|
+
SAR: "ar-SA",
|
|
399
|
+
// Saudi Riyal
|
|
400
|
+
TRY: "tr-TR"
|
|
401
|
+
// Turkish Lira
|
|
402
|
+
};
|
|
339
403
|
var Helpers = class {
|
|
340
404
|
constructor(proxy) {
|
|
341
405
|
this.proxy = proxy;
|
|
342
406
|
}
|
|
407
|
+
formatCurrency(currency) {
|
|
408
|
+
var _a;
|
|
409
|
+
const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
|
|
410
|
+
const formattedCurrency = new Intl.NumberFormat(locale, {
|
|
411
|
+
style: "currency",
|
|
412
|
+
currency,
|
|
413
|
+
currencyDisplay: "symbol"
|
|
414
|
+
});
|
|
415
|
+
return formattedCurrency.format(0).replace(/[\d.,\s]/g, "").trim();
|
|
416
|
+
}
|
|
343
417
|
formatPrice(priceInCents, currency, exchangeRate) {
|
|
344
418
|
var _a;
|
|
345
419
|
const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
|
|
346
420
|
const isWhole = amount % 1 === 0;
|
|
347
|
-
const currencyLocales = {
|
|
348
|
-
CZK: "cs-CZ",
|
|
349
|
-
// Czech Koruna
|
|
350
|
-
USD: "en-US",
|
|
351
|
-
// US Dollar
|
|
352
|
-
EUR: "de-DE",
|
|
353
|
-
// Euro (Germany locale)
|
|
354
|
-
GBP: "en-GB",
|
|
355
|
-
// British Pound
|
|
356
|
-
JPY: "ja-JP",
|
|
357
|
-
// Japanese Yen
|
|
358
|
-
AUD: "en-AU",
|
|
359
|
-
// Australian Dollar
|
|
360
|
-
CAD: "en-CA",
|
|
361
|
-
// Canadian Dollar
|
|
362
|
-
NZD: "en-NZ",
|
|
363
|
-
// New Zealand Dollar
|
|
364
|
-
SEK: "sv-SE",
|
|
365
|
-
// Swedish Krona
|
|
366
|
-
NOK: "nb-NO",
|
|
367
|
-
// Norwegian Krone
|
|
368
|
-
DKK: "da-DK",
|
|
369
|
-
// Danish Krone
|
|
370
|
-
CHF: "de-CH",
|
|
371
|
-
// Swiss Franc (German Switzerland)
|
|
372
|
-
HUF: "hu-HU",
|
|
373
|
-
// Hungarian Forint
|
|
374
|
-
PLN: "pl-PL",
|
|
375
|
-
// Polish Zloty
|
|
376
|
-
BGN: "bg-BG",
|
|
377
|
-
// Bulgarian Lev
|
|
378
|
-
RON: "ro-RO",
|
|
379
|
-
// Romanian Leu
|
|
380
|
-
RUB: "ru-RU",
|
|
381
|
-
// Russian Ruble
|
|
382
|
-
CNY: "zh-CN",
|
|
383
|
-
// Chinese Yuan
|
|
384
|
-
INR: "en-IN",
|
|
385
|
-
// Indian Rupee
|
|
386
|
-
BRL: "pt-BR",
|
|
387
|
-
// Brazilian Real
|
|
388
|
-
MXN: "es-MX",
|
|
389
|
-
// Mexican Peso
|
|
390
|
-
ZAR: "en-ZA",
|
|
391
|
-
// South African Rand
|
|
392
|
-
KRW: "ko-KR",
|
|
393
|
-
// South Korean Won
|
|
394
|
-
MYR: "ms-MY",
|
|
395
|
-
// Malaysian Ringgit
|
|
396
|
-
SGD: "en-SG",
|
|
397
|
-
// Singapore Dollar
|
|
398
|
-
TWD: "zh-TW",
|
|
399
|
-
// Taiwanese Dollar
|
|
400
|
-
THB: "th-TH",
|
|
401
|
-
// Thai Baht
|
|
402
|
-
IDR: "id-ID",
|
|
403
|
-
// Indonesian Rupiah
|
|
404
|
-
AED: "ar-AE",
|
|
405
|
-
// UAE Dirham
|
|
406
|
-
SAR: "ar-SA",
|
|
407
|
-
// Saudi Riyal
|
|
408
|
-
TRY: "tr-TR"
|
|
409
|
-
// Turkish Lira
|
|
410
|
-
};
|
|
411
421
|
const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
|
|
412
422
|
const formattedPrice = new Intl.NumberFormat(locale, {
|
|
413
423
|
style: "currency",
|
package/dist/index.mjs
CHANGED
|
@@ -300,78 +300,88 @@ var Customer = class {
|
|
|
300
300
|
var customer_default = Customer;
|
|
301
301
|
|
|
302
302
|
// src/helpers/index.ts
|
|
303
|
+
var currencyLocales = {
|
|
304
|
+
CZK: "cs-CZ",
|
|
305
|
+
// Czech Koruna
|
|
306
|
+
USD: "en-US",
|
|
307
|
+
// US Dollar
|
|
308
|
+
EUR: "de-DE",
|
|
309
|
+
// Euro (Germany locale)
|
|
310
|
+
GBP: "en-GB",
|
|
311
|
+
// British Pound
|
|
312
|
+
JPY: "ja-JP",
|
|
313
|
+
// Japanese Yen
|
|
314
|
+
AUD: "en-AU",
|
|
315
|
+
// Australian Dollar
|
|
316
|
+
CAD: "en-CA",
|
|
317
|
+
// Canadian Dollar
|
|
318
|
+
NZD: "en-NZ",
|
|
319
|
+
// New Zealand Dollar
|
|
320
|
+
SEK: "sv-SE",
|
|
321
|
+
// Swedish Krona
|
|
322
|
+
NOK: "nb-NO",
|
|
323
|
+
// Norwegian Krone
|
|
324
|
+
DKK: "da-DK",
|
|
325
|
+
// Danish Krone
|
|
326
|
+
CHF: "de-CH",
|
|
327
|
+
// Swiss Franc (German Switzerland)
|
|
328
|
+
HUF: "hu-HU",
|
|
329
|
+
// Hungarian Forint
|
|
330
|
+
PLN: "pl-PL",
|
|
331
|
+
// Polish Zloty
|
|
332
|
+
BGN: "bg-BG",
|
|
333
|
+
// Bulgarian Lev
|
|
334
|
+
RON: "ro-RO",
|
|
335
|
+
// Romanian Leu
|
|
336
|
+
RUB: "ru-RU",
|
|
337
|
+
// Russian Ruble
|
|
338
|
+
CNY: "zh-CN",
|
|
339
|
+
// Chinese Yuan
|
|
340
|
+
INR: "en-IN",
|
|
341
|
+
// Indian Rupee
|
|
342
|
+
BRL: "pt-BR",
|
|
343
|
+
// Brazilian Real
|
|
344
|
+
MXN: "es-MX",
|
|
345
|
+
// Mexican Peso
|
|
346
|
+
ZAR: "en-ZA",
|
|
347
|
+
// South African Rand
|
|
348
|
+
KRW: "ko-KR",
|
|
349
|
+
// South Korean Won
|
|
350
|
+
MYR: "ms-MY",
|
|
351
|
+
// Malaysian Ringgit
|
|
352
|
+
SGD: "en-SG",
|
|
353
|
+
// Singapore Dollar
|
|
354
|
+
TWD: "zh-TW",
|
|
355
|
+
// Taiwanese Dollar
|
|
356
|
+
THB: "th-TH",
|
|
357
|
+
// Thai Baht
|
|
358
|
+
IDR: "id-ID",
|
|
359
|
+
// Indonesian Rupiah
|
|
360
|
+
AED: "ar-AE",
|
|
361
|
+
// UAE Dirham
|
|
362
|
+
SAR: "ar-SA",
|
|
363
|
+
// Saudi Riyal
|
|
364
|
+
TRY: "tr-TR"
|
|
365
|
+
// Turkish Lira
|
|
366
|
+
};
|
|
303
367
|
var Helpers = class {
|
|
304
368
|
constructor(proxy) {
|
|
305
369
|
this.proxy = proxy;
|
|
306
370
|
}
|
|
371
|
+
formatCurrency(currency) {
|
|
372
|
+
var _a;
|
|
373
|
+
const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
|
|
374
|
+
const formattedCurrency = new Intl.NumberFormat(locale, {
|
|
375
|
+
style: "currency",
|
|
376
|
+
currency,
|
|
377
|
+
currencyDisplay: "symbol"
|
|
378
|
+
});
|
|
379
|
+
return formattedCurrency.format(0).replace(/[\d.,\s]/g, "").trim();
|
|
380
|
+
}
|
|
307
381
|
formatPrice(priceInCents, currency, exchangeRate) {
|
|
308
382
|
var _a;
|
|
309
383
|
const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
|
|
310
384
|
const isWhole = amount % 1 === 0;
|
|
311
|
-
const currencyLocales = {
|
|
312
|
-
CZK: "cs-CZ",
|
|
313
|
-
// Czech Koruna
|
|
314
|
-
USD: "en-US",
|
|
315
|
-
// US Dollar
|
|
316
|
-
EUR: "de-DE",
|
|
317
|
-
// Euro (Germany locale)
|
|
318
|
-
GBP: "en-GB",
|
|
319
|
-
// British Pound
|
|
320
|
-
JPY: "ja-JP",
|
|
321
|
-
// Japanese Yen
|
|
322
|
-
AUD: "en-AU",
|
|
323
|
-
// Australian Dollar
|
|
324
|
-
CAD: "en-CA",
|
|
325
|
-
// Canadian Dollar
|
|
326
|
-
NZD: "en-NZ",
|
|
327
|
-
// New Zealand Dollar
|
|
328
|
-
SEK: "sv-SE",
|
|
329
|
-
// Swedish Krona
|
|
330
|
-
NOK: "nb-NO",
|
|
331
|
-
// Norwegian Krone
|
|
332
|
-
DKK: "da-DK",
|
|
333
|
-
// Danish Krone
|
|
334
|
-
CHF: "de-CH",
|
|
335
|
-
// Swiss Franc (German Switzerland)
|
|
336
|
-
HUF: "hu-HU",
|
|
337
|
-
// Hungarian Forint
|
|
338
|
-
PLN: "pl-PL",
|
|
339
|
-
// Polish Zloty
|
|
340
|
-
BGN: "bg-BG",
|
|
341
|
-
// Bulgarian Lev
|
|
342
|
-
RON: "ro-RO",
|
|
343
|
-
// Romanian Leu
|
|
344
|
-
RUB: "ru-RU",
|
|
345
|
-
// Russian Ruble
|
|
346
|
-
CNY: "zh-CN",
|
|
347
|
-
// Chinese Yuan
|
|
348
|
-
INR: "en-IN",
|
|
349
|
-
// Indian Rupee
|
|
350
|
-
BRL: "pt-BR",
|
|
351
|
-
// Brazilian Real
|
|
352
|
-
MXN: "es-MX",
|
|
353
|
-
// Mexican Peso
|
|
354
|
-
ZAR: "en-ZA",
|
|
355
|
-
// South African Rand
|
|
356
|
-
KRW: "ko-KR",
|
|
357
|
-
// South Korean Won
|
|
358
|
-
MYR: "ms-MY",
|
|
359
|
-
// Malaysian Ringgit
|
|
360
|
-
SGD: "en-SG",
|
|
361
|
-
// Singapore Dollar
|
|
362
|
-
TWD: "zh-TW",
|
|
363
|
-
// Taiwanese Dollar
|
|
364
|
-
THB: "th-TH",
|
|
365
|
-
// Thai Baht
|
|
366
|
-
IDR: "id-ID",
|
|
367
|
-
// Indonesian Rupiah
|
|
368
|
-
AED: "ar-AE",
|
|
369
|
-
// UAE Dirham
|
|
370
|
-
SAR: "ar-SA",
|
|
371
|
-
// Saudi Riyal
|
|
372
|
-
TRY: "tr-TR"
|
|
373
|
-
// Turkish Lira
|
|
374
|
-
};
|
|
375
385
|
const locale = (_a = currencyLocales[currency.toUpperCase()]) != null ? _a : void 0;
|
|
376
386
|
const formattedPrice = new Intl.NumberFormat(locale, {
|
|
377
387
|
style: "currency",
|