Swiftpack.co - paylike/swift-currencies as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by paylike.
paylike/swift-currencies 0.4.0
Swift implementation of currencies
⭐️ 1
🕓 1 year ago
.package(url: "https://github.com/paylike/swift-currencies.git", from: "0.4.0")

PaylikeCurrencies

This package is used to provide a handy interfaces for handling internal currencies supported by the Paylike ecosystem

This library is a clone of the JS version

List of currencies supported by Paylike for transactions and accounts.

Read more:

Account currencies

These are the currencies you can use as a base for your account. Also known as account, settlement and funding currency.

Global

  • EUR (Euro)
  • USD (United States dollar)
  • GBP (British pound sterling)

Nordic

  • DKK (Danish krone)
  • NOK (Norwegian krone)
  • SEK (Swedish krona)

Other EU

  • CHF (Swiss franc)
  • HUF (Hungarian forint)
  • PLN (Polish złoty)
  • RON (Romanian leu)
  • CZK (Czech koruna)
  • BGN (Bulgarian lev)
  • HRK (Croatian kuna)

Install

SPM:

// dependencies: 
.package(url: "[email protected]:paylike/swift-currencies.git", .upToNextMajor(from: "0.4.0")

// target:
.product(name: "PaylikeCurrencies", package: "swift-currencies")

Cocoapods: https://cocoapods.org/pods/PaylikeCurrencies

pod 'PaylikeCurrencies'

Usage

Within the Paylike ecosystem you should use the CurrencyCode enum to refer to a currency.

let eur = PaylikeCurrencies.byCode(code: CurrencyCode.EUR);

// lookup by code
PaylikeCurrencies.byCode(code: CurrencyCode.AED);
// { code: 'AED', currency: 'United Arab Emirates dirham', numeric: '784' }

// lookup CurrencyCode
PaylikeCurrencies.getCurrencyCode("EUR");
// CurrencyCode.EUR

// get List<PaylikeCurrency>
PaylikeCurrencies.list();

// Convert between minor and major respecting the exponent
PaylikeCurrencies.toMinor(CurrencyCode.DKK, 100.00);
// 10000

PaylikeCurrencies.toMajor(CurrencyCode.DKK, 10000);
// 100.00

Running code generation

The library is able to regenerate CurrencyCode and PaylikeCurrencyCollection, by using the small Node.JS script provided in tools directory.

To regenerate files run:

yarn && yarn start

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics