CryptoApiLib 0.4.6

CryptoApiLib 0.4.6

pixelplex incVladimir LebedevichVladimir Sharaev 维护。



  • mobile team @ pixelplex inc

CryptoApiLib

CryptoAPI 是 Swift API 包装框架。设计用于接收有关事务、余额的信息并发送交易。

安装

此框架可以通过 CocoaPods 获取

pod 'CryptoApiLib'

设置

要设置框架,请使用以下简单代码

let settings = Settings(authorizationToken: "Your token")
let api = CryptoAPI(settings: settings)

// Or you can use custom configuration
let settings = Settings(authorizationToken: "Your token") { configurator in
    configurator.workingQueue = DispatchQueue.global()
    configurator.timeoutIntervalForRequest = 30
    configurator.timeoutIntervalForResource = 30
    configurator.sessionConfiguration = URLSessionConfiguration()
    configurator.networkType = NetworkType.testnet
    configurator.debugEnabled = true
}
let api = CryptoAPI(settings: settings)

使用

网络

CryptoAPI 支持 mainnettestnet 链。在设置框架时,可以通过设置 networkType 属性选择链类型。您可以在 NetworkType 枚举中找到所有可用的网络类型。

let settings = Settings(authorizationToken: "Your token") { configurator in
    configurator.networkType = NetworkType.testnet
}
let api = CryptoAPI(settings: settings)

服务

CryptoAPI包含4个主要服务。 ETHServiceBTCServiceBCHService 具有对应货币的功能。公共功能实现在 CommonService 中,它与特定货币无关。

let common = api.common
let eth = api.eth
let btc = api.btc
let bch = api.bch

错误处理

每个请求都包含包含 Swift.Resultcompletion。结果返回期望的响应类型或 CryptoApiError

api.common.coins { result in
    switch result {
    case let .success(coins):
        // Process result
    case let .failure(error):
        // Process error
    }
    expectation.fulfill()
}

示例

我们准备了一些比特币以太坊示例,以了解CryptoAPI如何与其他流行库一起工作。

许可协议

MIT许可协议(MIT)

版权所有(c)2019 PixelPlex Inc. https://pixelplex.io

本许可协议免费授予任何获得本软件及其相关文档副本(以下简称“软件”)的人以自由使用本软件的权利,包括但不限于使用的权利、复制的权利、修改的权利、合并的权利、出版的权利、发行的权利、再许可的权利,以及允许本软件提供人使用本软件的权利,前提是遵守以下条件

上述版权声明和本许可协议应当包含在本软件所有副本或主要部分中。

本软件按“原样”提供,不提供任何形式的保证,无论是明示的、隐含的,还是关于适销性、特定用途和侵权性的。在任何情况下,作者或版权持有者不应对任何主张、损害或任何其他责任承担任何责任,即使是在契约行为、侵权行为或其他情况下,从本软件或本软件的使用或其他交易中产生。