-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JSON framework, add QR reader framework and add statics API
- Loading branch information
1 parent
18571d1
commit 1edf375
Showing
12 changed files
with
224 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
github "iCepa/Tor.framework" "master" | ||
github "hackiftekhar/IQKeyboardManager" "v6.1.1" | ||
github "aschuch/QRCode" "master" | ||
github "SwiftyJSON/SwiftyJSON" ~> 4.0 | ||
github "hyperoslo/BarcodeScanner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
github "SwiftyJSON/SwiftyJSON" "4.1.0" | ||
github "aschuch/QRCode" "601af09fa394da662753a1d0bdfeb7d11e54e7e7" | ||
github "hackiftekhar/IQKeyboardManager" "v6.1.1" | ||
github "hyperoslo/BarcodeScanner" "4.1.3" | ||
github "iCepa/Tor.framework" "479e3770a1f6bd56ac25927e2626047e048683c3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// StatisicsAPIClient.swift | ||
// VergeiOS | ||
// | ||
// Created by Swen van Zanten on 07-08-18. | ||
// Copyright © 2018 Verge Currency. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftyJSON | ||
|
||
class StatisicsAPIClient { | ||
|
||
static let shared = StatisicsAPIClient() | ||
|
||
let endpoint: String = "https://min-api.cryptocompare.com/data/" | ||
|
||
func infoBy(currency: String, completion: @escaping (_ data: XvgInfo?) -> Void) { | ||
let url = URL(string: "\(endpoint)pricemultifull?fsyms=XVG&tsyms=\(currency)") | ||
|
||
let task = tor().dataTask(with: url!) { (data, resonse, error) in | ||
if let data = data { | ||
do { | ||
let json = try JSON(data: data) | ||
let raw = try JSONDecoder().decode(XvgInfoRaw.self, from: try json["RAW"]["XVG"][currency].rawData()) | ||
let display = try JSONDecoder().decode(XvgInfoDisplay.self, from: try json["DISPLAY"]["XVG"][currency].rawData()) | ||
|
||
completion(XvgInfo(raw: raw, display: display)) | ||
} catch { | ||
print("Error info: \(error)") | ||
completion(nil) | ||
} | ||
} else if let _ = error { | ||
completion(nil) | ||
} | ||
} | ||
|
||
task.resume() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// | ||
// XvgInfo.swift | ||
// VergeiOS | ||
// | ||
// Created by Swen van Zanten on 07-08-18. | ||
// Copyright © 2018 Verge Currency. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct XvgInfo: Decodable { | ||
public let raw: XvgInfoRaw | ||
public let display: XvgInfoDisplay | ||
} | ||
|
||
public struct XvgInfoRaw: Decodable { | ||
public let price: Double | ||
public let openday: Double | ||
public let highday: Double | ||
public let lowday: Double | ||
public let open24Hour: Double | ||
public let high24Hour: Double | ||
public let low24Hour: Double | ||
public let change24Hour: Double | ||
public let changepct24Hour: Double | ||
public let changeday: Double | ||
public let changepctday: Double | ||
public let supply: Double | ||
public let mktcap: Double | ||
public let totalvolume24H: Double | ||
public let totalvolume24Hto: Double | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case price = "PRICE" | ||
case openday = "OPENDAY" | ||
case highday = "HIGHDAY" | ||
case lowday = "LOWDAY" | ||
case open24Hour = "OPEN24HOUR" | ||
case high24Hour = "HIGH24HOUR" | ||
case low24Hour = "LOW24HOUR" | ||
case change24Hour = "CHANGE24HOUR" | ||
case changepct24Hour = "CHANGEPCT24HOUR" | ||
case changeday = "CHANGEDAY" | ||
case changepctday = "CHANGEPCTDAY" | ||
case supply = "SUPPLY" | ||
case mktcap = "MKTCAP" | ||
case totalvolume24H = "TOTALVOLUME24H" | ||
case totalvolume24Hto = "TOTALVOLUME24HTO" | ||
} | ||
} | ||
|
||
public struct XvgInfoDisplay: Decodable { | ||
public let price: String | ||
public let openday: String | ||
public let highday: String | ||
public let lowday: String | ||
public let open24Hour: String | ||
public let high24Hour: String | ||
public let low24Hour: String | ||
public let change24Hour: String | ||
public let changepct24Hour: String | ||
public let changeday: String | ||
public let changepctday: String | ||
public let supply: String | ||
public let mktcap: String | ||
public let totalvolume24H: String | ||
public let totalvolume24Hto: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case price = "PRICE" | ||
case openday = "OPENDAY" | ||
case highday = "HIGHDAY" | ||
case lowday = "LOWDAY" | ||
case open24Hour = "OPEN24HOUR" | ||
case high24Hour = "HIGH24HOUR" | ||
case low24Hour = "LOW24HOUR" | ||
case change24Hour = "CHANGE24HOUR" | ||
case changepct24Hour = "CHANGEPCT24HOUR" | ||
case changeday = "CHANGEDAY" | ||
case changepctday = "CHANGEPCTDAY" | ||
case supply = "SUPPLY" | ||
case mktcap = "MKTCAP" | ||
case totalvolume24H = "TOTALVOLUME24H" | ||
case totalvolume24Hto = "TOTALVOLUME24HTO" | ||
} | ||
} |
Oops, something went wrong.