arky-sdk 0.4.22 → 0.4.23
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.cjs +5 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -18
- package/dist/index.d.ts +3 -18
- package/dist/index.js +6 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1416,42 +1416,20 @@ var createPlatformApi = (apiConfig) => {
|
|
|
1416
1416
|
},
|
|
1417
1417
|
getConfigCache() {
|
|
1418
1418
|
return cachedConfig;
|
|
1419
|
+
},
|
|
1420
|
+
async getCurrencies(options) {
|
|
1421
|
+
return apiConfig.httpClient.get("/v1/platform/currencies", options);
|
|
1419
1422
|
}
|
|
1420
1423
|
};
|
|
1421
1424
|
};
|
|
1422
1425
|
|
|
1423
|
-
// src/utils/
|
|
1424
|
-
var cachedCurrencies = null;
|
|
1425
|
-
function setCurrenciesCache(currencies) {
|
|
1426
|
-
cachedCurrencies = currencies;
|
|
1427
|
-
}
|
|
1428
|
-
function getCurrenciesCache() {
|
|
1429
|
-
return cachedCurrencies;
|
|
1430
|
-
}
|
|
1426
|
+
// src/utils/price.ts
|
|
1431
1427
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
1432
1428
|
return new Intl.NumberFormat(locale, {
|
|
1433
1429
|
style: "currency",
|
|
1434
1430
|
currency: currencyCode.toUpperCase()
|
|
1435
1431
|
}).format(amount);
|
|
1436
1432
|
}
|
|
1437
|
-
function getCurrencySymbol(currencyCode) {
|
|
1438
|
-
const cached = cachedCurrencies?.find((c) => c.code === currencyCode.toLowerCase());
|
|
1439
|
-
if (cached) return cached.symbol;
|
|
1440
|
-
const parts = new Intl.NumberFormat("en", {
|
|
1441
|
-
style: "currency",
|
|
1442
|
-
currency: currencyCode.toUpperCase(),
|
|
1443
|
-
currencyDisplay: "narrowSymbol"
|
|
1444
|
-
}).formatToParts(0);
|
|
1445
|
-
return parts.find((p) => p.type === "currency")?.value || "";
|
|
1446
|
-
}
|
|
1447
|
-
function getCurrencyName(currencyCode) {
|
|
1448
|
-
const cached = cachedCurrencies?.find((c) => c.code === currencyCode.toLowerCase());
|
|
1449
|
-
if (cached) return cached.name;
|
|
1450
|
-
const displayNames = new Intl.DisplayNames(["en"], { type: "currency" });
|
|
1451
|
-
return displayNames.of(currencyCode.toUpperCase()) || "";
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
// src/utils/price.ts
|
|
1455
1433
|
function convertToMajor(minorAmount) {
|
|
1456
1434
|
return minorAmount / 100;
|
|
1457
1435
|
}
|
|
@@ -1663,7 +1641,7 @@ function track(eventName, params) {
|
|
|
1663
1641
|
}
|
|
1664
1642
|
|
|
1665
1643
|
// src/index.ts
|
|
1666
|
-
var SDK_VERSION = "0.4.
|
|
1644
|
+
var SDK_VERSION = "0.4.23";
|
|
1667
1645
|
var SUPPORTED_FRAMEWORKS = [
|
|
1668
1646
|
"astro",
|
|
1669
1647
|
"react",
|
|
@@ -1694,14 +1672,6 @@ async function createArkySDK(config) {
|
|
|
1694
1672
|
}
|
|
1695
1673
|
}).catch(() => {
|
|
1696
1674
|
});
|
|
1697
|
-
if (config.fetchFullConfig) {
|
|
1698
|
-
platformApi.getConfig({ params: { currencies: true } }).then((platformConfig) => {
|
|
1699
|
-
if (platformConfig.currencies) {
|
|
1700
|
-
setCurrenciesCache(platformConfig.currencies);
|
|
1701
|
-
}
|
|
1702
|
-
}).catch(() => {
|
|
1703
|
-
});
|
|
1704
|
-
}
|
|
1705
1675
|
}
|
|
1706
1676
|
const sdk = {
|
|
1707
1677
|
auth: authApi,
|
|
@@ -1753,10 +1723,6 @@ async function createArkySDK(config) {
|
|
|
1753
1723
|
getPriceAmount: (prices) => getPriceAmount(prices, apiConfig.market),
|
|
1754
1724
|
formatPayment,
|
|
1755
1725
|
formatMinor,
|
|
1756
|
-
formatCurrency,
|
|
1757
|
-
getCurrencySymbol,
|
|
1758
|
-
getCurrencyName,
|
|
1759
|
-
getCurrenciesCache,
|
|
1760
1726
|
validatePhoneNumber,
|
|
1761
1727
|
tzGroups,
|
|
1762
1728
|
findTimeZone,
|
|
@@ -1785,9 +1751,5 @@ exports.PaymentMethodType = PaymentMethodType;
|
|
|
1785
1751
|
exports.SDK_VERSION = SDK_VERSION;
|
|
1786
1752
|
exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
|
|
1787
1753
|
exports.createArkySDK = createArkySDK;
|
|
1788
|
-
exports.formatCurrency = formatCurrency;
|
|
1789
|
-
exports.getCurrenciesCache = getCurrenciesCache;
|
|
1790
|
-
exports.getCurrencyName = getCurrencyName;
|
|
1791
|
-
exports.getCurrencySymbol = getCurrencySymbol;
|
|
1792
1754
|
//# sourceMappingURL=index.cjs.map
|
|
1793
1755
|
//# sourceMappingURL=index.cjs.map
|