Skip to content

Commit

Permalink
Add JSON framework, add QR reader framework and add statics API
Browse files Browse the repository at this point in the history
  • Loading branch information
SwenVanZanten committed Aug 8, 2018
1 parent 18571d1 commit 1edf375
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 73 deletions.
2 changes: 2 additions & 0 deletions Cartfile
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"
2 changes: 2 additions & 0 deletions Cartfile.resolved
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"
22 changes: 21 additions & 1 deletion VergeiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
A32566582115AEE8006FB08A /* FiatBalanceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A32566572115AEE8006FB08A /* FiatBalanceView.swift */; };
A325665A2115B0DF006FB08A /* BalanceSlide.swift in Sources */ = {isa = PBXBuildFile; fileRef = A32566592115B0DF006FB08A /* BalanceSlide.swift */; };
A325665D2116EF71006FB08A /* BlendedNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A325665C2116EF71006FB08A /* BlendedNavigationBar.swift */; };
A325665F211A2219006FB08A /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A325665E211A2219006FB08A /* SwiftyJSON.framework */; };
A3256661211A22C4006FB08A /* BarcodeScanner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3256660211A22C4006FB08A /* BarcodeScanner.framework */; };
A3256663211A39A2006FB08A /* StatisicsAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3256662211A39A2006FB08A /* StatisicsAPIClient.swift */; };
A3256665211A3B61006FB08A /* XvgInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3256664211A3B61006FB08A /* XvgInfo.swift */; };
A338E695210CF60B000D44EE /* Setup.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A338E694210CF60B000D44EE /* Setup.storyboard */; };
A338E698210CF725000D44EE /* LoadingTorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A338E697210CF725000D44EE /* LoadingTorViewController.swift */; };
A338E69A210D1FC4000D44EE /* PaperKeyWordsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A338E699210D1FC4000D44EE /* PaperKeyWordsViewController.swift */; };
Expand Down Expand Up @@ -146,6 +150,10 @@
A32566572115AEE8006FB08A /* FiatBalanceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FiatBalanceView.swift; sourceTree = "<group>"; };
A32566592115B0DF006FB08A /* BalanceSlide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceSlide.swift; sourceTree = "<group>"; };
A325665C2116EF71006FB08A /* BlendedNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlendedNavigationBar.swift; sourceTree = "<group>"; };
A325665E211A2219006FB08A /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = Carthage/Build/iOS/SwiftyJSON.framework; sourceTree = "<group>"; };
A3256660211A22C4006FB08A /* BarcodeScanner.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BarcodeScanner.framework; path = Carthage/Build/iOS/BarcodeScanner.framework; sourceTree = "<group>"; };
A3256662211A39A2006FB08A /* StatisicsAPIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatisicsAPIClient.swift; sourceTree = "<group>"; };
A3256664211A3B61006FB08A /* XvgInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XvgInfo.swift; sourceTree = "<group>"; };
A338E694210CF60B000D44EE /* Setup.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Setup.storyboard; sourceTree = "<group>"; };
A338E697210CF725000D44EE /* LoadingTorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingTorViewController.swift; sourceTree = "<group>"; };
A338E699210D1FC4000D44EE /* PaperKeyWordsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaperKeyWordsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -203,6 +211,8 @@
A338E6A0210DC037000D44EE /* IQKeyboardManagerSwift.framework in Frameworks */,
A338E6CE21110A0A000D44EE /* QRCode.framework in Frameworks */,
A376411D2108F7B500E04521 /* Tor.framework in Frameworks */,
A3256661211A22C4006FB08A /* BarcodeScanner.framework in Frameworks */,
A325665F211A2219006FB08A /* SwiftyJSON.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -226,8 +236,8 @@
07B9F44B2107C69D00871990 /* Model */ = {
isa = PBXGroup;
children = (
07B9F44C2107C6C500871990 /* InsightAPIClient.swift */,
07B9F4532107C9EB00871990 /* BlockchainInfo.swift */,
A3256664211A3B61006FB08A /* XvgInfo.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -521,6 +531,8 @@
A37641112108E79800E04521 /* Frameworks */ = {
isa = PBXGroup;
children = (
A3256660211A22C4006FB08A /* BarcodeScanner.framework */,
A325665E211A2219006FB08A /* SwiftyJSON.framework */,
A338E6CD21110A09000D44EE /* QRCode.framework */,
A338E69F210DC037000D44EE /* IQKeyboardManagerSwift.framework */,
A376411C2108F7B500E04521 /* Tor.framework */,
Expand All @@ -534,6 +546,8 @@
children = (
07C88D69210D047D00094EA1 /* URLSession.swift */,
A37641202108FC1F00E04521 /* TorClient.swift */,
07B9F44C2107C6C500871990 /* InsightAPIClient.swift */,
A3256662211A39A2006FB08A /* StatisicsAPIClient.swift */,
);
path = Http;
sourceTree = "<group>";
Expand Down Expand Up @@ -704,11 +718,15 @@
"$(SRCROOT)/Carthage/Build/iOS/Tor.framework",
"$(SRCROOT)/Carthage/Build/iOS/IQKeyboardManagerSwift.framework",
"$(SRCROOT)/Carthage/Build/iOS/QRCode.framework",
"$(SRCROOT)/Carthage/Build/iOS/SwiftyJSON.framework",
"$(SRCROOT)/Carthage/Build/iOS/BarcodeScanner.framework",
);
outputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Tor.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/IQKeyboardManagerSwift.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/QRCode.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SwiftyJSON.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/BarcodeScanner.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -732,6 +750,7 @@
07938407210DB46C00C3C799 /* RestoreWalletController.swift in Sources */,
A32566582115AEE8006FB08A /* FiatBalanceView.swift in Sources */,
A33F6A7820EEE485001492C2 /* VergeiOS.xcdatamodeld in Sources */,
A3256663211A39A2006FB08A /* StatisicsAPIClient.swift in Sources */,
A325665D2116EF71006FB08A /* BlendedNavigationBar.swift in Sources */,
A37641212108FC1F00E04521 /* TorClient.swift in Sources */,
A305DDBF2107C82200911B64 /* EmptyKey.swift in Sources */,
Expand Down Expand Up @@ -763,6 +782,7 @@
A305DDA32106917400911B64 /* RoundedButton.swift in Sources */,
07938410210DD73900C3C799 /* FinalRecoveryController.swift in Sources */,
07B9F4542107C9EB00871990 /* BlockchainInfo.swift in Sources */,
A3256665211A3B61006FB08A /* XvgInfo.swift in Sources */,
A338E698210CF725000D44EE /* LoadingTorViewController.swift in Sources */,
A338E6A8210E2B92000D44EE /* AbstractRestoreViewController.swift in Sources */,
0793840C210DC8A000C3C799 /* EnterRecoveryKeyController.swift in Sources */,
Expand Down
File renamed without changes.
40 changes: 40 additions & 0 deletions VergeiOS/Http/StatisicsAPIClient.swift
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()
}
}
6 changes: 4 additions & 2 deletions VergeiOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<string>0.2</string>
<key>CFBundleVersion</key>
<string>0.1</string>
<string>0.2.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand All @@ -35,6 +35,8 @@
</dict>
</dict>
</dict>
<key>NSCameraUsageDescription</key>
<string>This app uses the camera for scanning QR codes when sending XVG to another wallet</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
86 changes: 86 additions & 0 deletions VergeiOS/Model/XvgInfo.swift
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"
}
}
Loading

0 comments on commit 1edf375

Please sign in to comment.