Code Monkey home page Code Monkey logo

hmrc-fx's Introduction

HMRC FX Rate

This package provide currency conversion via UK HMRC rate

Swift

Example

Please reference HMRC's XML for possible values of the "CurrencyCode".

import Foundation
import HMRCExchangeRate

// Get exchange rate by `Date`
let rates = try? await RateSource.directHMRC.rate(of: "TWD", at: Date())
if let rate = rates?.first {
    print("Current rate - \(rate)")
}

// Get exchange rate of a certain month
let rates = try? await RateSource.directHMRC.rate(of: "TWD", in: Month(.sep, in: 2020))
if let rate = rates?.first {
    print("Rate of Sept 2020 - \(rate)")
}

Setup as a dependency

This is a Swift Package, and hence you could use it in a way like this

// swift-tools-version:5.5

import PackageDescription

let package = Package(
    name: "fx-example",
    platforms: [
        .macOS(.v12),
    ],
    dependencies: [
        .package(url: "https://github.com/sodastsai/hmrc-fx.git", from: "0.5.0"),
    ],
    targets: [
        .target(
            name: "fx-example",
            dependencies: [
                .product(name: "HMRCExchangeRate", package: "hmrc-fx"),
            ]
        ),
    ]
)

hmrc-fx's People

Contributors

sodastsai avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hmrc-fx's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.