Skip to content

Commit

Permalink
Fix Package.swift, Add Kraken support.
Browse files Browse the repository at this point in the history
  • Loading branch information
trsathya committed Jan 12, 2018
1 parent 7894f17 commit 36b4260
Show file tree
Hide file tree
Showing 10 changed files with 389 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

.DS_Store
.build

Package.resolved
13 changes: 7 additions & 6 deletions Common/ExchangeDataStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ public class ExchangeDataStore<T: TickerType, U: BalanceType> {
}
}

public func getTotalBalance() -> NSDecimalNumber {
var totalBalance = NSDecimalNumber.zero
balances.forEach { totalBalance = totalBalance.adding(balanceInPreferredCurrency(balance: $0)) }
return totalBalance
}

public func displayablePrice(ticker: T) -> String {
guard ticker.symbol.price != accountingCurrency else { return "" }
return ticker.price.stringValue + " " + ticker.symbol.price.code
Expand Down Expand Up @@ -135,6 +129,13 @@ extension ExchangeDataStore: TickerTableViewDataSource {
}

extension ExchangeDataStore: BalanceTableViewDataSource {

public func getTotalBalance() -> NSDecimalNumber {
var totalBalance = NSDecimalNumber.zero
balances.forEach { totalBalance = totalBalance.adding(balanceInPreferredCurrency(balance: $0)) }
return totalBalance
}

public func balanceCount() -> Int {
return balances.count
}
Expand Down
8 changes: 8 additions & 0 deletions Common/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public extension Int {

public extension Locale {
static let enUS = Locale(identifier: "en-US")
static let enIN = Locale(identifier: "en-IN")
}

public extension TimeInterval {
Expand Down Expand Up @@ -47,6 +48,13 @@ public extension NumberFormatter {
formatter.numberStyle = .currency
return formatter
}

static var inr: NumberFormatter {
let formatter = NumberFormatter()
formatter.locale = .enIN
formatter.numberStyle = .currency
return formatter
}
}

public extension DateFormatter {
Expand Down
6 changes: 3 additions & 3 deletions Common/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ open class Network {

let httpUrlResponse = urlResponse as? HTTPURLResponse
api.print("\(httpUrlResponse?.statusCode ?? 0) \(httpUrlResponse?.url?.absoluteString ?? "")", content: .url)
api.print("Response Headers: \(httpUrlResponse)", content: .responseHeaders)
api.print("Response Headers: \(String(describing: httpUrlResponse))", content: .responseHeaders)

guard let data = data else {
print("No Data for request: \(httpUrlResponse?.url?.absoluteString)")
print("No Data for request: \(String(describing: httpUrlResponse?.url?.absoluteString))")
return
}

guard let responseDataString = data.string else { return }

guard let json = try? JSONSerialization.jsonObject(with: data, options: []) else {
print("Data is not a json for request: \(httpUrlResponse?.url?.absoluteString)")
print("Data is not a json for request: \(String(describing: httpUrlResponse?.url?.absoluteString))")
//api.print(responseDataString, content: .response)
completion?(responseDataString, httpUrlResponse, error)
return
Expand Down
1 change: 1 addition & 0 deletions Common/Ticker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public protocol TickerTableViewDataSource {
}

public protocol BalanceTableViewDataSource {
func getTotalBalance() -> NSDecimalNumber
func balanceCount() -> Int
func displayableBalance(row: Int) -> DisplayableBalanceType
}
5 changes: 5 additions & 0 deletions Cryptex.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Pod::Spec.new do |s|
ss.dependency 'Cryptex/BitGrail'
ss.dependency 'Cryptex/CoinExchange'
ss.dependency 'Cryptex/Bitfinex'
ss.dependency 'Cryptex/Kraken'
end
s.subspec "Common" do |ss|
ss.source_files = "Common/**/*.swift"
Expand Down Expand Up @@ -71,4 +72,8 @@ Pod::Spec.new do |s|
ss.source_files = "Bitfinex/**/*.swift"
ss.dependency 'Cryptex/Common'
end
s.subspec "Kraken" do |ss|
ss.source_files = "Kraken/**/*.swift"
ss.dependency 'Cryptex/Common'
end
end
Loading

0 comments on commit 36b4260

Please sign in to comment.