Skip to content
This repository was archived by the owner on Jul 2, 2018. It is now read-only.

Commit eb5d0a8

Browse files
committed
Merge branch 'release/1.5.0'
2 parents 4675ae7 + 12bc978 commit eb5d0a8

26 files changed

+16
-2096
lines changed

.jazzy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
author_name: Daniel Thorpe
22
author_url: http://danthorpe.me
33
module_name: Money
4-
module_version: 1.4.0
4+
module_version: 1.5.0
55
github_url: https://github.com/danthorpe/Money
66
readme: README.md
77
podspec: Money.podspec

Cartfile

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
github "danthorpe/ValueCoding"
2-
github "antitypical/Result" >= 1.0
3-
github "SwiftyJSON/SwiftyJSON"

Cartfile.private

-1
This file was deleted.

Cartfile.resolved

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
github "venmo/DVR" "v0.2.0"
2-
github "antitypical/Result" "1.0.1"
3-
github "SwiftyJSON/SwiftyJSON" "2.3.3"
4-
github "danthorpe/ValueCoding" "1.1.1"
1+
github "danthorpe/ValueCoding" "1.2.0"

Money.podspec

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Money"
3-
s.version = "1.4.2"
3+
s.version = "1.5.0"
44
s.summary = "Swift types for working with Money."
55
s.description = <<-DESC
66
@@ -34,7 +34,6 @@ Pod::Spec.new do |s|
3434
s.tvos.exclude_files = [ 'Money/iOS' ]
3535

3636
s.dependency 'ValueCoding'
37-
s.dependency 'Result'
38-
s.dependency 'SwiftyJSON'
37+
3938
end
4039

Money.xcodeproj/project.pbxproj

+5-153
Large diffs are not rendered by default.

Money.xcodeproj/xcshareddata/xcschemes/Money-OSX.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Money.xcodeproj/xcshareddata/xcschemes/Money-iOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Money.xcodeproj/xcshareddata/xcschemes/Money-tvOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Money.xcodeproj/xcshareddata/xcschemes/Money-watchOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Money/Shared/FX/Bitcoin.swift

-142
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
// SOFTWARE.
2626

2727
import Foundation
28-
import Result
29-
import SwiftyJSON
3028

3129

3230
// MARK: - Bitcoin Currency
@@ -90,143 +88,3 @@ public typealias XBT = _Money<Currency.XBT>
9088
public typealias BTC = _Money<Currency.BTC>
9189

9290

93-
// MARK - cex.io FX
94-
95-
/**
96-
CEX.io Supported fiat currencies
97-
98-
CEX only supports USD, EUR and RUB.
99-
100-
- see: https://cex.io
101-
*/
102-
public protocol CEXSupportedFiatCurrencyType: ISOCurrencyType {
103-
104-
/**
105-
CEX.io charge a percentage based commission with FX transactions.
106-
- returns: a BankersDecimal representing the % commission.
107-
*/
108-
static var cex_commissionPercentage: BankersDecimal { get }
109-
}
110-
111-
extension Currency.USD: CEXSupportedFiatCurrencyType {
112-
113-
/// - returns: the commission charged for USD transactions, a BankersDecimal
114-
public static let cex_commissionPercentage: BankersDecimal = 0.2
115-
}
116-
117-
extension Currency.EUR: CEXSupportedFiatCurrencyType {
118-
119-
/// - returns: the commission charged for EUR transactions, a BankersDecimal
120-
public static let cex_commissionPercentage: BankersDecimal = 0.2
121-
}
122-
123-
extension Currency.RUB: CEXSupportedFiatCurrencyType {
124-
125-
/// - returns: the commission charged for RUB transactions, a BankersDecimal
126-
public static let cex_commissionPercentage: BankersDecimal = 0
127-
}
128-
129-
struct _CEXBuy<Base: MoneyType where Base.Currency: CEXSupportedFiatCurrencyType>: CryptoCurrencyMarketTransactionType {
130-
typealias BaseMoney = Base
131-
typealias CounterMoney = BTC
132-
typealias FiatCurrency = Base.Currency
133-
static var transactionKind: CurrencyMarketTransactionKind { return .Buy }
134-
}
135-
136-
struct _CEXSell<Counter: MoneyType where Counter.Currency: CEXSupportedFiatCurrencyType>: CryptoCurrencyMarketTransactionType {
137-
typealias BaseMoney = BTC
138-
typealias CounterMoney = Counter
139-
typealias FiatCurrency = Counter.Currency
140-
static var transactionKind: CurrencyMarketTransactionKind { return .Sell }
141-
}
142-
143-
class _CEX<T: CryptoCurrencyMarketTransactionType where T.FiatCurrency: CEXSupportedFiatCurrencyType>: FXRemoteProvider<T.BaseMoney, T.CounterMoney>, FXRemoteProviderType {
144-
145-
static func name() -> String {
146-
return "CEX.IO \(BaseMoney.Currency.code)\(CounterMoney.Currency.code)"
147-
}
148-
149-
static func request() -> NSURLRequest {
150-
let url = NSURL(string: "https://cex.io/api/convert/\(BTC.Currency.code)/\(T.FiatCurrency.code)")
151-
let request = NSMutableURLRequest(URL: url!)
152-
request.HTTPMethod = "POST"
153-
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
154-
let data = try! JSON(["amnt": Double(1.0)]).rawData()
155-
request.HTTPBody = data
156-
return request
157-
}
158-
159-
static func quoteFromNetworkResult(result: Result<(NSData?, NSURLResponse?), NSError>) -> Result<FXQuote, FXError> {
160-
return result.analysis(
161-
162-
ifSuccess: { data, response in
163-
164-
guard let data = data else {
165-
return Result(error: .NoData)
166-
}
167-
168-
let json = JSON(data: data)
169-
170-
if json.isEmpty {
171-
return Result(error: .InvalidData(data))
172-
}
173-
174-
guard let rateLiteral = json["amnt"].double else {
175-
return Result(error: .RateNotFound(name()))
176-
}
177-
178-
let rate: BankersDecimal
179-
180-
switch T.transactionKind {
181-
case .Buy:
182-
rate = BankersDecimal(floatLiteral: rateLiteral).reciprocal
183-
case .Sell:
184-
rate = BankersDecimal(floatLiteral: rateLiteral)
185-
}
186-
187-
return Result(value: FXQuote(rate: rate, percentage: T.FiatCurrency.cex_commissionPercentage))
188-
},
189-
190-
ifFailure: { error in
191-
return Result(error: .NetworkError(error))
192-
}
193-
)
194-
}
195-
}
196-
197-
/**
198-
Represents the purchase of bitcoin using CEX.io.
199-
200-
Usage is entirely type based - there is nothing to initialize. It is
201-
generic over USD, EUR or RUB, no other currency types. For example.
202-
203-
```swift
204-
CEXBuy<USD>.quote(1_000) { transaction in
205-
// etc.
206-
}
207-
```
208-
209-
The above sample represents buying US$1,000 worth of BTC using CEX.io.
210-
*/
211-
public final class CEXBuy<Base: MoneyType where Base.Currency: CEXSupportedFiatCurrencyType>: _CEX<_CEXBuy<Base>> { }
212-
213-
/**
214-
Represents the sale of bitcoin using CEX.io.
215-
216-
Usage is entirely type based - there is nothing to initialize. It is
217-
generic over USD, EUR or RUB, no other currency types. For example.
218-
219-
```swift
220-
CEXBuy<EUR>.quote(10) { transaction in
221-
// etc.
222-
}
223-
```
224-
225-
The above sample represents selling 10 bitcoins for euros using CEX.io.
226-
*/
227-
public final class CEXSell<Counter: MoneyType where Counter.Currency: CEXSupportedFiatCurrencyType>: _CEX<_CEXSell<Counter>> { }
228-
229-
230-
231-
232-

0 commit comments

Comments
 (0)