🐋 WhaleAlert
示例
要运行示例项目,请克隆仓库,然后首先从示例目录中运行pod install
。
安装
WhaleAlert可通过CocoaPods获得。要安装它,只需将以下行添加到Podfile中
pod 'WhaleAlert'
使用
使用WhaleAlert API密钥初始化
// NOTE: Delegate is optional and can be left nil if you'd rather receive block-based responses
let whaleAlert: WhaleAlert = WhaleAlert(apiKey: "your-api-key", delegate: self)
获取网络/区块链状态
// Delegate based
whaleAlert.getStatus()
// WhaleAlertProtocol
func whaleAlertDidReceiveStatus(_ status: Status?, _ error: WhaleAlertError?) {
// Do something with `status` object.
}
// Block based
whaleAlert.getStatus { (status, error) in
// Do something with `status` object.
}
通过哈希和区块链获取交易
// Delegate based
whaleAlert.getTransaction(withHash: "some-hash", fromBlockchain: .bitcoin)
// WhaleAlertProtocol
func whaleAlertDidReceiveTransactions(_ transactions: [Transaction]?, _ error: WhaleAlertError?) {
// Do something with `transactions` object.
}
// Block based
whaleAlert.getTransaction(withHash: "some-hash", fromBlockchain: .bitcoin) { (transactions, error) in
// Do something with `transactions` object.
}
获取起始日期之后的所有交易
// Delegate based
let pastHour: Date = Date().addingTimeInterval(-3600)
whaleAlert.getAllTransactions(fromDate: pastHour)
// WhaleAlertProtocol
func whaleAlertDidReceiveTransactions(_ transactions: [Transaction]?, _ error: WhaleAlertError?) {
// Do something with `transactions` object.
}
// Block based (`fromDate` is required, all other parameters are optional.)
whaleAlert.getAllTransactions(fromDate: pastHour, toDate: nil, cursor: nil, minUSDValue: nil, limit: 100, currency: "usd") { (transactions, error) in
// Do something with `transactions` object.
}
作者
Ryan Cohen, [email protected]
许可协议
WhaleAlert遵循MIT许可协议。更多信息请参阅LICENSE文件。