currency-rate 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/currency-rate.gemspec +4 -6
- data/lib/adapter.rb +36 -4
- data/lib/btc_adapters/average_rate_adapter.rb +2 -0
- data/lib/btc_adapters/bitfinex_adapter.rb +9 -0
- data/lib/btc_adapters/bitpay_adapter.rb +9 -2
- data/lib/btc_adapters/bitstamp_adapter.rb +9 -1
- data/lib/btc_adapters/btcchina_adapter.rb +5 -1
- data/lib/btc_adapters/btce_adapter.rb +9 -1
- data/lib/btc_adapters/coinbase_adapter.rb +9 -0
- data/lib/btc_adapters/huobi_adapter.rb +9 -0
- data/lib/btc_adapters/kraken_adapter.rb +9 -0
- data/lib/btc_adapters/localbitcoins_adapter.rb +9 -0
- data/lib/btc_adapters/okcoin_adapter.rb +9 -0
- data/lib/currency_rate.rb +6 -1
- data/lib/fiat_adapters/fixer_adapter.rb +11 -0
- data/lib/fiat_adapters/yahoo_adapter.rb +8 -0
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/average_rate_adapter.yml +307 -281
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/bitfinex_adapter.yml +46 -50
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/bitpay_adapter.yml +272 -0
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/btcchina_adapter.yml +9 -8
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/btce_adapter.yml +30 -30
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/coinbase_adapter.yml +36 -16
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/huobi_adapter.yml +20 -20
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/kraken_adapter.yml +12 -12
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/localbitcoins_adapter.yml +88 -83
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/okcoin_adapter.yml +52 -36
- data/spec/fixtures/vcr/exchange_rate_adapters/fiat_adapters/fixer_adapter.yml +16 -12
- data/spec/fixtures/vcr/exchange_rate_adapters/fiat_adapters/yahoo_adapter.yml +9 -11
- data/spec/lib/btc_adapter_spec.rb +12 -1
- data/spec/lib/btc_adapters/average_rate_adapter_spec.rb +1 -6
- data/spec/lib/btc_adapters/bitfinex_adapter_spec.rb +6 -6
- data/spec/lib/btc_adapters/bitpay_adapter_spec.rb +5 -5
- data/spec/lib/btc_adapters/bitstamp_adapter_spec.rb +9 -9
- data/spec/lib/btc_adapters/btcchina_adapter_spec.rb +4 -4
- data/spec/lib/btc_adapters/btce_adapter_spec.rb +10 -10
- data/spec/lib/btc_adapters/coinbase_adapter_spec.rb +4 -4
- data/spec/lib/btc_adapters/huobi_adapter_spec.rb +6 -6
- data/spec/lib/btc_adapters/kraken_adapter_spec.rb +6 -6
- data/spec/lib/btc_adapters/localbitcoins_adapter_spec.rb +4 -4
- data/spec/lib/btc_adapters/okcoin_adapter_spec.rb +11 -11
- data/spec/lib/fiat_adapters/fixer_adapter_spec.rb +5 -5
- data/spec/lib/fiat_adapters/yahoo_adapter_spec.rb +5 -5
- metadata +3 -4
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/bitpay_adapter_yml.yml +0 -272
- data/spec/fixtures/vcr/exchange_rate_adapters/btc_adapters/bitstamp_adapter.yml +0 -153
@@ -19,7 +19,7 @@ http_interactions:
|
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
21
|
Date:
|
22
|
-
-
|
22
|
+
- Mon, 06 Feb 2017 05:25:06 GMT
|
23
23
|
Content-Type:
|
24
24
|
- text/html;charset=UTF-8
|
25
25
|
Transfer-Encoding:
|
@@ -27,11 +27,11 @@ http_interactions:
|
|
27
27
|
Connection:
|
28
28
|
- keep-alive
|
29
29
|
Set-Cookie:
|
30
|
-
- __cfduid=
|
31
|
-
|
32
|
-
- coin_session_id_o=
|
30
|
+
- __cfduid=dcd408d8dd74dabec10b946cf9b7f32f21486358706; expires=Tue, 06-Feb-18
|
31
|
+
05:25:06 GMT; path=/; domain=.okcoin.com; HttpOnly
|
32
|
+
- coin_session_id_o=68dac424-1704-4903-80be-8c305ec61336qOsg; Domain=okcoin.com;
|
33
33
|
Path=/; Secure; HttpOnly
|
34
|
-
- language=
|
34
|
+
- language=0; Expires=Mon, 13-Feb-2017 05:25:06 GMT; Path=/
|
35
35
|
Cache-Control:
|
36
36
|
- no-store
|
37
37
|
Expires:
|
@@ -47,12 +47,12 @@ http_interactions:
|
|
47
47
|
Server:
|
48
48
|
- cloudflare-nginx
|
49
49
|
Cf-Ray:
|
50
|
-
-
|
50
|
+
- 32cc2dfb8a2b311a-SIN
|
51
51
|
body:
|
52
52
|
encoding: ASCII-8BIT
|
53
|
-
string: '{"date":"
|
53
|
+
string: '{"date":"1486358706","ticker":{"buy":"3.96","high":"4.077","last":"3.987","low":"3.93","sell":"3.976","vol":"28472.362"}}'
|
54
54
|
http_version:
|
55
|
-
recorded_at:
|
55
|
+
recorded_at: Mon, 06 Feb 2017 05:25:06 GMT
|
56
56
|
- request:
|
57
57
|
method: get
|
58
58
|
uri: https://www.okcoin.com/api/v1/ticker.do?symbol=btc_usd
|
@@ -72,7 +72,7 @@ http_interactions:
|
|
72
72
|
message: OK
|
73
73
|
headers:
|
74
74
|
Date:
|
75
|
-
-
|
75
|
+
- Mon, 06 Feb 2017 05:25:07 GMT
|
76
76
|
Content-Type:
|
77
77
|
- text/html;charset=UTF-8
|
78
78
|
Transfer-Encoding:
|
@@ -80,11 +80,11 @@ http_interactions:
|
|
80
80
|
Connection:
|
81
81
|
- keep-alive
|
82
82
|
Set-Cookie:
|
83
|
-
- __cfduid=
|
84
|
-
|
85
|
-
- coin_session_id_o=
|
83
|
+
- __cfduid=dc9a2ad3f9bbd6c665d8087a781f7d0831486358707; expires=Tue, 06-Feb-18
|
84
|
+
05:25:07 GMT; path=/; domain=.okcoin.com; HttpOnly
|
85
|
+
- coin_session_id_o=ec68edca-aa27-41a6-83f8-905eb19b1c2eqMwU; Domain=okcoin.com;
|
86
86
|
Path=/; Secure; HttpOnly
|
87
|
-
- language=0; Expires=
|
87
|
+
- language=0; Expires=Mon, 13-Feb-2017 05:25:07 GMT; Path=/
|
88
88
|
Cache-Control:
|
89
89
|
- no-store
|
90
90
|
Expires:
|
@@ -100,15 +100,15 @@ http_interactions:
|
|
100
100
|
Server:
|
101
101
|
- cloudflare-nginx
|
102
102
|
Cf-Ray:
|
103
|
-
-
|
103
|
+
- 32cc2dff1a350817-SIN
|
104
104
|
body:
|
105
105
|
encoding: ASCII-8BIT
|
106
|
-
string: '{"date":"
|
106
|
+
string: '{"date":"1486358707","ticker":{"buy":"1021.1","high":"1034.5","last":"1021.09","low":"1008.53","sell":"1022.49","vol":"1220.093"}}'
|
107
107
|
http_version:
|
108
|
-
recorded_at:
|
108
|
+
recorded_at: Mon, 06 Feb 2017 05:25:07 GMT
|
109
109
|
- request:
|
110
110
|
method: get
|
111
|
-
uri: https://www.okcoin.cn/api/ticker.do?symbol=
|
111
|
+
uri: https://www.okcoin.cn/api/ticker.do?symbol=ltc_cny
|
112
112
|
body:
|
113
113
|
encoding: US-ASCII
|
114
114
|
string: ''
|
@@ -124,40 +124,48 @@ http_interactions:
|
|
124
124
|
code: 200
|
125
125
|
message: OK
|
126
126
|
headers:
|
127
|
-
Server:
|
128
|
-
- nginx
|
129
|
-
Date:
|
130
|
-
- Sat, 18 Jun 2016 17:13:26 GMT
|
131
127
|
Content-Type:
|
132
128
|
- text/html;charset=UTF-8
|
133
129
|
Content-Length:
|
134
|
-
- '
|
130
|
+
- '137'
|
135
131
|
Connection:
|
136
132
|
- keep-alive
|
133
|
+
Server:
|
134
|
+
- nginx
|
135
|
+
Date:
|
136
|
+
- Mon, 06 Feb 2017 05:17:50 GMT
|
137
137
|
Set-Cookie:
|
138
|
-
- coin_session_id_o=
|
138
|
+
- coin_session_id_o=19deb5f4-42b3-44db-bf93-bdc34ca3fce5JdXY; Domain=okcoin.cn;
|
139
139
|
Path=/; Secure; HttpOnly
|
140
|
-
- language=0; Expires=
|
140
|
+
- language=0; Expires=Mon, 13-Feb-2017 05:25:11 GMT; Path=/
|
141
141
|
Cache-Control:
|
142
142
|
- no-store
|
143
143
|
Expires:
|
144
144
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
145
145
|
Pragma:
|
146
146
|
- no-cache
|
147
|
+
Vary:
|
148
|
+
- Accept-Encoding, User-Agent
|
147
149
|
X-Frame-Options:
|
148
150
|
- SAMEORIGIN
|
149
151
|
Access-Control-Allow-Credentials:
|
150
152
|
- 'true'
|
151
153
|
Access-Control-Allow-Origin:
|
152
154
|
- https://img.okcoin.cn
|
155
|
+
X-Cache:
|
156
|
+
- Miss from cloudfront
|
157
|
+
Via:
|
158
|
+
- 1.1 f7b7c91216531cea229d3692df41a83f.cloudfront.net (CloudFront)
|
159
|
+
X-Amz-Cf-Id:
|
160
|
+
- lw6KX9NKKZUUqQfWhBOC4iYcsz76x5LCHSRG1Y3Dd4lUHPG_7mlavQ==
|
153
161
|
body:
|
154
162
|
encoding: UTF-8
|
155
|
-
string: '{"date":"
|
163
|
+
string: '{"date":"1486358711","ticker":{"buy":"27.97","change":-0.0018,"high":"28.14","last":"28.0","low":"27.78","sell":"28.0","vol":"372709.5"}}'
|
156
164
|
http_version:
|
157
|
-
recorded_at:
|
165
|
+
recorded_at: Mon, 06 Feb 2017 05:25:11 GMT
|
158
166
|
- request:
|
159
167
|
method: get
|
160
|
-
uri: https://www.okcoin.cn/api/ticker.do?symbol=
|
168
|
+
uri: https://www.okcoin.cn/api/ticker.do?symbol=btc_cny
|
161
169
|
body:
|
162
170
|
encoding: US-ASCII
|
163
171
|
string: ''
|
@@ -173,35 +181,43 @@ http_interactions:
|
|
173
181
|
code: 200
|
174
182
|
message: OK
|
175
183
|
headers:
|
176
|
-
Server:
|
177
|
-
- nginx
|
178
|
-
Date:
|
179
|
-
- Sat, 18 Jun 2016 17:13:27 GMT
|
180
184
|
Content-Type:
|
181
185
|
- text/html;charset=UTF-8
|
182
186
|
Content-Length:
|
183
|
-
- '
|
187
|
+
- '145'
|
184
188
|
Connection:
|
185
189
|
- keep-alive
|
190
|
+
Server:
|
191
|
+
- nginx
|
192
|
+
Date:
|
193
|
+
- Mon, 06 Feb 2017 05:17:51 GMT
|
186
194
|
Set-Cookie:
|
187
|
-
- coin_session_id_o=
|
195
|
+
- coin_session_id_o=e074cb43-2205-4007-9c48-c19c5874ca69GlaR; Domain=okcoin.cn;
|
188
196
|
Path=/; Secure; HttpOnly
|
189
|
-
- language=0; Expires=
|
197
|
+
- language=0; Expires=Mon, 13-Feb-2017 05:25:12 GMT; Path=/
|
190
198
|
Cache-Control:
|
191
199
|
- no-store
|
192
200
|
Expires:
|
193
201
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
194
202
|
Pragma:
|
195
203
|
- no-cache
|
204
|
+
Vary:
|
205
|
+
- Accept-Encoding, User-Agent
|
196
206
|
X-Frame-Options:
|
197
207
|
- SAMEORIGIN
|
198
208
|
Access-Control-Allow-Credentials:
|
199
209
|
- 'true'
|
200
210
|
Access-Control-Allow-Origin:
|
201
211
|
- https://img.okcoin.cn
|
212
|
+
X-Cache:
|
213
|
+
- Miss from cloudfront
|
214
|
+
Via:
|
215
|
+
- 1.1 fdf852f8150530112aa9b7977369878b.cloudfront.net (CloudFront)
|
216
|
+
X-Amz-Cf-Id:
|
217
|
+
- OpXRqfGeg8Sit7eP430SY_mRdMPQlzB-Wv11Mu6HBmMxGS3qJXCFfQ==
|
202
218
|
body:
|
203
219
|
encoding: UTF-8
|
204
|
-
string: '{"date":"
|
220
|
+
string: '{"date":"1486358712","ticker":{"buy":"7204.0","change":-0.0035,"high":"7299.0","last":"7203.0","low":"7110.0","sell":"7209.0","vol":"12382.117"}}'
|
205
221
|
http_version:
|
206
|
-
recorded_at:
|
222
|
+
recorded_at: Mon, 06 Feb 2017 05:25:13 GMT
|
207
223
|
recorded_with: VCR 3.0.3
|
@@ -19,26 +19,28 @@ http_interactions:
|
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
21
|
Server:
|
22
|
-
- nginx/1.11.
|
22
|
+
- nginx/1.11.8
|
23
23
|
Date:
|
24
|
-
-
|
24
|
+
- Mon, 06 Feb 2017 05:25:14 GMT
|
25
25
|
Content-Type:
|
26
26
|
- application/json
|
27
27
|
Content-Length:
|
28
|
-
- '
|
28
|
+
- '447'
|
29
29
|
Connection:
|
30
30
|
- keep-alive
|
31
|
+
Cache-Control:
|
32
|
+
- public, must-revalidate, max-age=900
|
31
33
|
Last-Modified:
|
32
|
-
- Fri,
|
34
|
+
- Fri, 03 Feb 2017 00:00:00 GMT
|
33
35
|
Vary:
|
34
36
|
- Origin
|
35
37
|
X-Content-Type-Options:
|
36
38
|
- nosniff
|
37
39
|
body:
|
38
40
|
encoding: UTF-8
|
39
|
-
string: '{"base":"EUR","date":"
|
41
|
+
string: '{"base":"EUR","date":"2017-02-03","rates":{"AUD":1.4057,"BGN":1.9558,"BRL":3.3641,"CAD":1.4023,"CHF":1.0695,"CNY":7.3776,"CZK":27.021,"DKK":7.4376,"GBP":0.86013,"HKD":8.3343,"HRK":7.4331,"HUF":309.46,"IDR":14334.0,"ILS":4.0323,"INR":72.31,"JPY":121.49,"KRW":1232.2,"MXN":22.016,"MYR":4.7561,"NOK":8.8568,"NZD":1.4781,"PHP":53.461,"PLN":4.2972,"RON":4.5158,"RUB":63.611,"SEK":9.442,"SGD":1.5186,"THB":37.653,"TRY":4.0118,"USD":1.0741,"ZAR":14.421}}'
|
40
42
|
http_version:
|
41
|
-
recorded_at:
|
43
|
+
recorded_at: Mon, 06 Feb 2017 05:25:14 GMT
|
42
44
|
- request:
|
43
45
|
method: get
|
44
46
|
uri: http://api.fixer.io/latest?base=usd
|
@@ -58,24 +60,26 @@ http_interactions:
|
|
58
60
|
message: OK
|
59
61
|
headers:
|
60
62
|
Server:
|
61
|
-
- nginx/1.11.
|
63
|
+
- nginx/1.11.8
|
62
64
|
Date:
|
63
|
-
-
|
65
|
+
- Mon, 06 Feb 2017 05:25:14 GMT
|
64
66
|
Content-Type:
|
65
67
|
- application/json
|
66
68
|
Content-Length:
|
67
|
-
- '
|
69
|
+
- '448'
|
68
70
|
Connection:
|
69
71
|
- keep-alive
|
72
|
+
Cache-Control:
|
73
|
+
- public, must-revalidate, max-age=900
|
70
74
|
Last-Modified:
|
71
|
-
- Fri,
|
75
|
+
- Fri, 03 Feb 2017 00:00:00 GMT
|
72
76
|
Vary:
|
73
77
|
- Origin
|
74
78
|
X-Content-Type-Options:
|
75
79
|
- nosniff
|
76
80
|
body:
|
77
81
|
encoding: UTF-8
|
78
|
-
string: '{"base":"USD","date":"
|
82
|
+
string: '{"base":"USD","date":"2017-02-03","rates":{"AUD":1.3087,"BGN":1.8209,"BRL":3.132,"CAD":1.3056,"CHF":0.99572,"CNY":6.8686,"CZK":25.157,"DKK":6.9245,"GBP":0.80079,"HKD":7.7593,"HRK":6.9203,"HUF":288.11,"IDR":13345.0,"ILS":3.7541,"INR":67.321,"JPY":113.11,"KRW":1147.2,"MXN":20.497,"MYR":4.428,"NOK":8.2458,"NZD":1.3761,"PHP":49.773,"PLN":4.0007,"RON":4.2043,"RUB":59.223,"SEK":8.7906,"SGD":1.4138,"THB":35.055,"TRY":3.735,"ZAR":13.426,"EUR":0.93101}}'
|
79
83
|
http_version:
|
80
|
-
recorded_at:
|
84
|
+
recorded_at: Mon, 06 Feb 2017 05:25:14 GMT
|
81
85
|
recorded_with: VCR 3.0.3
|
@@ -19,32 +19,30 @@ http_interactions:
|
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
21
|
X-Yql-Host:
|
22
|
-
-
|
22
|
+
- prod_bf1_1;paas.yql;queryyahooapiscomproductionbf1;d587643e-e9f8-11e6-a255-d4ae52974c31
|
23
23
|
X-Content-Type-Options:
|
24
24
|
- nosniff
|
25
25
|
Access-Control-Allow-Origin:
|
26
26
|
- "*"
|
27
27
|
Content-Type:
|
28
|
-
- application/json;
|
28
|
+
- application/json;charset=utf-8
|
29
29
|
Cache-Control:
|
30
30
|
- no-cache
|
31
31
|
Date:
|
32
|
-
-
|
32
|
+
- Mon, 06 Feb 2017 05:25:15 GMT
|
33
33
|
Age:
|
34
34
|
- '0'
|
35
|
-
Server:
|
36
|
-
- ATS
|
37
|
-
Via:
|
38
|
-
- http/1.1 a14.ue.bf1.yahoo.net (ApacheTrafficServer [cMsSf ])
|
39
|
-
Y-Trace:
|
40
|
-
- BAEAQAAAAAC2YQNA_AaEuAAAAAAAAAAAZOzi9VN5UAwAAAAAAAAAAAAFNZxJY.NpAAU1nElkwG5.Cp0MAAAAAA--
|
41
35
|
Transfer-Encoding:
|
42
36
|
- chunked
|
43
37
|
Connection:
|
44
38
|
- keep-alive
|
39
|
+
Via:
|
40
|
+
- http/1.1 a32.ue.bf1.yahoo.net (ApacheTrafficServer [cMsSf ])
|
41
|
+
Server:
|
42
|
+
- ATS
|
45
43
|
body:
|
46
44
|
encoding: UTF-8
|
47
|
-
string: '{"query":{"count":32,"created":"
|
45
|
+
string: '{"query":{"count":32,"created":"2017-02-06T05:25:15Z","lang":"en-US","results":{"rate":[{"id":"USDAUD","Name":"USD/AUD","Rate":"1.3030","Date":"2/6/2017","Time":"1:22am","Ask":"1.3034","Bid":"1.3030"},{"id":"USDBGN","Name":"USD/BGN","Rate":"1.8209","Date":"2/3/2017","Time":"3:15pm","Ask":"N/A","Bid":"1.8209"},{"id":"USDBRL","Name":"USD/BRL","Rate":"3.1172","Date":"2/6/2017","Time":"2:30am","Ask":"3.1192","Bid":"3.1172"},{"id":"USDCAD","Name":"USD/CAD","Rate":"1.3020","Date":"2/6/2017","Time":"1:48am","Ask":"1.3020","Bid":"1.3020"},{"id":"USDCHF","Name":"USD/CHF","Rate":"0.9922","Date":"2/6/2017","Time":"2:31am","Ask":"0.9923","Bid":"0.9922"},{"id":"USDCNY","Name":"USD/CNY","Rate":"6.8577","Date":"2/6/2017","Time":"3:33am","Ask":"6.8587","Bid":"6.8577"},{"id":"USDCZK","Name":"USD/CZK","Rate":"25.0595","Date":"2/5/2017","Time":"11:44pm","Ask":"25.0663","Bid":"25.0595"},{"id":"USDDKK","Name":"USD/DKK","Rate":"6.8977","Date":"2/6/2017","Time":"2:49am","Ask":"6.8988","Bid":"6.8977"},{"id":"USDGBP","Name":"USD/GBP","Rate":"0.8009","Date":"2/6/2017","Time":"0:29am","Ask":"0.8010","Bid":"0.8009"},{"id":"USDHKD","Name":"USD/HKD","Rate":"7.7577","Date":"2/6/2017","Time":"3:33am","Ask":"7.7578","Bid":"7.7577"},{"id":"USDHRK","Name":"USD/HRK","Rate":"6.8568","Date":"2/6/2017","Time":"3:40am","Ask":"6.9317","Bid":"6.8568"},{"id":"USDHUF","Name":"USD/HUF","Rate":"287.1700","Date":"2/6/2017","Time":"3:50am","Ask":"287.3700","Bid":"287.1700"},{"id":"USDIDR","Name":"USD/IDR","Rate":"13325.0000","Date":"2/6/2017","Time":"3:34am","Ask":"13335.0000","Bid":"13325.0000"},{"id":"USDILS","Name":"USD/ILS","Rate":"3.7405","Date":"2/6/2017","Time":"3:31am","Ask":"3.7505","Bid":"3.7405"},{"id":"USDINR","Name":"USD/INR","Rate":"67.1750","Date":"2/6/2017","Time":"2:30am","Ask":"67.2250","Bid":"67.1750"},{"id":"USDJPY","Name":"USD/JPY","Rate":"112.4610","Date":"2/6/2017","Time":"2:49am","Ask":"112.4740","Bid":"112.4610"},{"id":"USDKRW","Name":"USD/KRW","Rate":"1135.5000","Date":"2/6/2017","Time":"3:52am","Ask":"1136.5000","Bid":"1135.5000"},{"id":"USDMXN","Name":"USD/MXN","Rate":"20.3983","Date":"2/6/2017","Time":"1:22am","Ask":"20.4025","Bid":"20.3983"},{"id":"USDMYR","Name":"USD/MYR","Rate":"4.4250","Date":"2/6/2017","Time":"3:32am","Ask":"4.4255","Bid":"4.4250"},{"id":"USDNOK","Name":"USD/NOK","Rate":"8.2099","Date":"2/6/2017","Time":"0:30am","Ask":"8.2124","Bid":"8.2099"},{"id":"USDNZD","Name":"USD/NZD","Rate":"1.3654","Date":"2/6/2017","Time":"3:50am","Ask":"1.3664","Bid":"1.3654"},{"id":"USDPHP","Name":"USD/PHP","Rate":"49.7200","Date":"2/6/2017","Time":"3:32am","Ask":"49.7300","Bid":"49.7200"},{"id":"USDPLN","Name":"USD/PLN","Rate":"3.9914","Date":"2/6/2017","Time":"3:34am","Ask":"3.9936","Bid":"3.9914"},{"id":"USDRON","Name":"USD/RON","Rate":"4.1763","Date":"2/6/2017","Time":"1:23am","Ask":"4.2037","Bid":"4.1763"},{"id":"USDRUB","Name":"USD/RUB","Rate":"59.5127","Date":"2/5/2017","Time":"11:43pm","Ask":"59.5477","Bid":"59.5127"},{"id":"USDSEK","Name":"USD/SEK","Rate":"8.7621","Date":"2/6/2017","Time":"3:49am","Ask":"8.7645","Bid":"8.7621"},{"id":"USDSGD","Name":"USD/SGD","Rate":"1.4076","Date":"2/6/2017","Time":"3:50am","Ask":"1.4077","Bid":"1.4076"},{"id":"USDTHB","Name":"USD/THB","Rate":"35.0100","Date":"2/5/2017","Time":"11:50pm","Ask":"35.0600","Bid":"35.0100"},{"id":"USDTRY","Name":"USD/TRY","Rate":"3.6997","Date":"2/6/2017","Time":"2:32am","Ask":"3.7007","Bid":"3.6997"},{"id":"USDUSD","Name":"USD/USD","Rate":"1.0000","Date":"N/A","Time":"N/A","Ask":"1.0000","Bid":"1.0000"},{"id":"USDZAR","Name":"USD/ZAR","Rate":"13.2577","Date":"2/5/2017","Time":"11:50pm","Ask":"13.2847","Bid":"13.2577"},{"id":"USDEUR","Name":"USD/EUR","Rate":"0.9272","Date":"2/6/2017","Time":"3:49am","Ask":"0.9277","Bid":"0.9272"}]}}}'
|
48
46
|
http_version:
|
49
|
-
recorded_at:
|
47
|
+
recorded_at: Mon, 06 Feb 2017 05:25:15 GMT
|
50
48
|
recorded_with: VCR 3.0.3
|
@@ -3,7 +3,8 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe CurrencyRate::BtcAdapter do
|
4
4
|
|
5
5
|
class CurrencyRate::Adapter
|
6
|
-
FETCH_URL
|
6
|
+
FETCH_URL = ''
|
7
|
+
DEFAULT_CURRENCIES = { from: "BTC", to: "USD" }
|
7
8
|
end
|
8
9
|
|
9
10
|
class SomeExchangeAdapter < CurrencyRate::BtcAdapter
|
@@ -12,6 +13,10 @@ RSpec.describe CurrencyRate::BtcAdapter do
|
|
12
13
|
rate = rate_to_f(750)
|
13
14
|
invert_rate(from,to,rate)
|
14
15
|
end
|
16
|
+
|
17
|
+
def supported_currency_pairs
|
18
|
+
["USD/BTC"]
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
before(:each) do
|
@@ -29,6 +34,7 @@ RSpec.describe CurrencyRate::BtcAdapter do
|
|
29
34
|
uri_mock = double('uri mock')
|
30
35
|
expect(URI).to receive(:parse).and_return(uri_mock).once
|
31
36
|
expect(uri_mock).to receive(:read).and_return('{ "USD": 534.4343 }').once
|
37
|
+
allow(@exchange_adapter).to receive(:supported_currency_pairs).and_return(["USD/BTC"])
|
32
38
|
@exchange_adapter.rate_for('USD', 'BTC')
|
33
39
|
@exchange_adapter.rate_for('USD', 'BTC') # not calling fetch_rates! because we've just checked
|
34
40
|
@exchange_adapter.instance_variable_set(:@rates_updated_at, Time.now-1900)
|
@@ -40,4 +46,9 @@ RSpec.describe CurrencyRate::BtcAdapter do
|
|
40
46
|
expect( -> { @exchange_adapter.rate_to_f(rate) }).to raise_error(CurrencyRate::Adapter::CurrencyNotSupported)
|
41
47
|
end
|
42
48
|
|
49
|
+
it "raises exception if target currency is not in supported currencies" do
|
50
|
+
@exchange_adapter = SomeExchangeAdapter.instance
|
51
|
+
expect( -> { @exchange_adapter.rate_for("BTC", "CNY") }).to raise_error(CurrencyRate::Adapter::CurrencyNotSupported)
|
52
|
+
end
|
53
|
+
|
43
54
|
end
|
@@ -18,12 +18,7 @@ RSpec.describe CurrencyRate::AverageRateAdapter do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "calculates average rate" do
|
21
|
-
|
22
|
-
json_response_bitpay = '[{"code":"USD","name":"US Dollar","rate":200},{"code":"EUR","name":"Eurozone Euro","rate":197.179544}]'
|
23
|
-
uri_mock = double('uri mock')
|
24
|
-
allow(uri_mock).to receive(:read).with(read_timeout: 4).and_return(json_response_bistamp, json_response_bitpay)
|
25
|
-
allow(URI).to receive(:parse).and_return(uri_mock)
|
26
|
-
expect(@average_rates_adapter.rate_for('BTC', 'USD')).to eq 150
|
21
|
+
expect(@average_rates_adapter.rate_for('BTC', 'USD')).to eq 1016.38
|
27
22
|
end
|
28
23
|
|
29
24
|
it "fetches rates for all adapters" do
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe CurrencyRate::BitfinexAdapter do
|
4
4
|
|
5
|
-
before :
|
5
|
+
before :each do
|
6
6
|
VCR.insert_cassette 'exchange_rate_adapters/btc_adapters/bitfinex_adapter'
|
7
7
|
end
|
8
8
|
|
9
|
-
after :
|
9
|
+
after :each do
|
10
10
|
VCR.eject_cassette
|
11
11
|
end
|
12
12
|
|
@@ -15,10 +15,10 @@ RSpec.describe CurrencyRate::BitfinexAdapter do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "finds the rate for currency code" do
|
18
|
-
expect(@exchange_adapter.rate_for('BTC', 'USD')).to eq(
|
19
|
-
expect(@exchange_adapter.rate_for('USD', 'BTC')).to eq(0.
|
20
|
-
expect(@exchange_adapter.rate_for('LTC', 'USD')).to eq(
|
21
|
-
expect(@exchange_adapter.rate_for('USD', 'LTC')).to eq(0.
|
18
|
+
expect(@exchange_adapter.rate_for('BTC', 'USD')).to eq(1016.9)
|
19
|
+
expect(@exchange_adapter.rate_for('USD', 'BTC')).to eq(0.000983381)
|
20
|
+
expect(@exchange_adapter.rate_for('LTC', 'USD')).to eq(3.9526)
|
21
|
+
expect(@exchange_adapter.rate_for('USD', 'LTC')).to eq(0.252998027)
|
22
22
|
expect( -> { @exchange_adapter.rate_for('FEDcoin', 'USD') }).to raise_error(CurrencyRate::Adapter::CurrencyNotSupported)
|
23
23
|
end
|
24
24
|
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe CurrencyRate::BitpayAdapter do
|
4
4
|
|
5
|
-
before :
|
6
|
-
VCR.insert_cassette 'exchange_rate_adapters/btc_adapters/
|
5
|
+
before :each do
|
6
|
+
VCR.insert_cassette 'exchange_rate_adapters/btc_adapters/average_rate_adapter' # contains request to Bitpay
|
7
7
|
end
|
8
8
|
|
9
|
-
after :
|
9
|
+
after :each do
|
10
10
|
VCR.eject_cassette
|
11
11
|
end
|
12
12
|
|
@@ -15,9 +15,9 @@ RSpec.describe CurrencyRate::BitpayAdapter do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "finds the rate for currency code" do
|
18
|
-
expect(@exchange_adapter.rate_for('BTC', 'USD')).to eq(
|
18
|
+
expect(@exchange_adapter.rate_for('BTC', 'USD')).to eq(1015.59)
|
19
19
|
expect(@exchange_adapter.rate_for('BTC', 'BTC')).to eq(1)
|
20
|
-
expect(@exchange_adapter.rate_for('BTC', 'EUR')).to eq(
|
20
|
+
expect(@exchange_adapter.rate_for('BTC', 'EUR')).to eq(941.895743)
|
21
21
|
expect(@exchange_adapter.rate_for('EUR', 'BTC')).to eq(1)
|
22
22
|
expect( -> { @exchange_adapter.rate_for('USD', 'EUR') }).to raise_exception(CurrencyRate::Adapter::CurrencyNotSupported)
|
23
23
|
expect( -> { @exchange_adapter.rate_for('EUR', 'USD') }).to raise_exception(CurrencyRate::Adapter::CurrencyNotSupported)
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe CurrencyRate::BitstampAdapter do
|
4
4
|
|
5
|
-
before :
|
6
|
-
VCR.insert_cassette 'exchange_rate_adapters/btc_adapters/
|
5
|
+
before :each do
|
6
|
+
VCR.insert_cassette 'exchange_rate_adapters/btc_adapters/average_rate_adapter' # contains request to Bistamp
|
7
7
|
end
|
8
8
|
|
9
|
-
after :
|
9
|
+
after :each do
|
10
10
|
VCR.eject_cassette
|
11
11
|
end
|
12
12
|
|
@@ -15,12 +15,12 @@ RSpec.describe CurrencyRate::BitstampAdapter do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "finds the rate for currency code" do
|
18
|
-
expect(@exchange_adapter.rate_for('BTC', 'USD')).to eq(
|
19
|
-
expect(@exchange_adapter.rate_for('USD', 'BTC')).to eq(0.
|
20
|
-
expect(@exchange_adapter.rate_for('BTC', 'EUR')).to eq(
|
21
|
-
expect(@exchange_adapter.rate_for('EUR', 'BTC')).to eq(0.
|
22
|
-
expect(@exchange_adapter.rate_for('USD', 'EUR')).to eq(0.
|
23
|
-
expect(@exchange_adapter.rate_for('EUR', 'USD')).to eq(1.
|
18
|
+
expect(@exchange_adapter.rate_for('BTC', 'USD')).to eq(1017.17)
|
19
|
+
expect(@exchange_adapter.rate_for('USD', 'BTC').to_f).to eq(0.00098312)
|
20
|
+
expect(@exchange_adapter.rate_for('BTC', 'EUR')).to eq(946.0)
|
21
|
+
expect(@exchange_adapter.rate_for('EUR', 'BTC').to_f).to eq(0.001057082)
|
22
|
+
expect(@exchange_adapter.rate_for('USD', 'EUR').to_f).to eq(0.933619643)
|
23
|
+
expect(@exchange_adapter.rate_for('EUR', 'USD')).to eq(1.0711)
|
24
24
|
expect( -> { @exchange_adapter.rate_for('FEDcoin', 'USD') }).to raise_error(CurrencyRate::Adapter::CurrencyNotSupported)
|
25
25
|
end
|
26
26
|
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe CurrencyRate::BTCChinaAdapter do
|
4
4
|
|
5
|
-
before :
|
5
|
+
before :each do
|
6
6
|
VCR.insert_cassette 'exchange_rate_adapters/btc_adapters/btcchina_adapter'
|
7
7
|
end
|
8
8
|
|
9
|
-
after :
|
9
|
+
after :each do
|
10
10
|
VCR.eject_cassette
|
11
11
|
end
|
12
12
|
|
@@ -15,8 +15,8 @@ RSpec.describe CurrencyRate::BTCChinaAdapter do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "finds the rate for currency code" do
|
18
|
-
expect(@exchange_adapter.rate_for('BTC', 'CNY')).to eq(
|
19
|
-
expect(@exchange_adapter.rate_for('CNY', 'BTC')).to eq(0.
|
18
|
+
expect(@exchange_adapter.rate_for('BTC', 'CNY')).to eq(7243.99)
|
19
|
+
expect(@exchange_adapter.rate_for('CNY', 'BTC').to_f).to eq(0.000138045)
|
20
20
|
expect( -> { @exchange_adapter.rate_for('FEDcoin', 'USD') }).to raise_error(CurrencyRate::Adapter::CurrencyNotSupported)
|
21
21
|
end
|
22
22
|
|