jsonrates_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/jsonrates_client.gemspec +27 -0
- data/lib/jsonrates_client.rb +30 -0
- data/lib/jsonrates_client/version.rb +3 -0
- data/spec/cassettes/Jsonrates_Client/_historical/params_keys_setup/replaces_date_start_and_date_end_with_dateStart_and_dateEnd.yml +32 -0
- data/spec/cassettes/Jsonrates_Client/_historical/successful_request/requests_historical_using_arguments_as_query_parameters.yml +32 -0
- data/spec/cassettes/Jsonrates_Client/_historical/successful_request/returns_a_hash_of_rates.yml +32 -0
- data/spec/jsonrates_client_spec.rb +31 -0
- data/spec/spec_helper.rb +23 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b58247cf7b96871e045c12470c009b5e9a070fb
|
4
|
+
data.tar.gz: 89855b532db96fbb823cebbf0c0dfd3b93bf079a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c14aa7e9c1cec2b4526ccf808df947201cc09965a4a8b80f50c377c2f45f194448a17498b6de36bd81fc3a70231d274df6fc8ca388513bf15663848d3314207
|
7
|
+
data.tar.gz: e9bdab5f2052c4abb8d328559ac388d84d071bc3388ffcb15dfa9ff93aeacccbdcaaef5807dabe9d2db59fab6bda51fa46e43ac8e9874bae9dc1a503e6fb77d0
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jsonrates-client
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Roberto Soares
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# JsonratesClient
|
2
|
+
|
3
|
+
Client for [jsonrates.com](http://jsonrates.com/) written in Ruby.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Jsonrates::Client.historical(from: "USD", to: "BRL", date: "2014-06-23")
|
8
|
+
# {"2014-06-23"=>{"utctime"=>"2014-06-23T23:50:03+02:00", "rate"=>"2.22120000"}}
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'jsonrates_client'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install jsonrates_client
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
1. Fork it ( https://github.com/roberto/jsonrates_client/fork )
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jsonrates_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jsonrates_client"
|
8
|
+
spec.version = JsonratesClient::VERSION
|
9
|
+
spec.authors = ["Roberto Soares"]
|
10
|
+
spec.email = ["roberto.tech@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby client for jsonrates.com}
|
12
|
+
spec.homepage = "http://github.com/roberto/jsonrates_client/"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "httparty"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "vcr"
|
26
|
+
spec.add_development_dependency "webmock"
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "jsonrates_client/version"
|
2
|
+
require "httparty"
|
3
|
+
|
4
|
+
module Jsonrates
|
5
|
+
class Client
|
6
|
+
include HTTParty
|
7
|
+
base_uri "jsonrates.com"
|
8
|
+
|
9
|
+
REPLACE_KEYS = {
|
10
|
+
date_start: :dateStart,
|
11
|
+
date_end: :dateEnd
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.historical(options)
|
15
|
+
prepare_params(options)
|
16
|
+
response = JSON.parse(get("/historical", query: options))
|
17
|
+
response["rates"]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def self.prepare_params(options)
|
23
|
+
REPLACE_KEYS.each_key do |key|
|
24
|
+
if options.has_key?(key)
|
25
|
+
options[REPLACE_KEYS[key]] = options.delete(key)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://jsonrates.com/historical?base=USD&dateEnd=2014-06-25&dateStart=2014-06-23
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/1.4.6 (Ubuntu)
|
17
|
+
Date:
|
18
|
+
- Fri, 26 Sep 2014 01:18:29 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.5.9-1ubuntu4.3
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"base":"USD","rates":{"2014-06-23":{"utctime":"2014-06-23T23:50:03+02:00","AED":"3.67320000","AFN":"56.72000100","ALL":"103.04000100","AMD":"409.00000000","ANG":"1.79000000","AOA":"97.65000200","ARS":"8.13265000","AUD":"1.06100800","AWG":"1.79000000","AZN":"0.78430000","BAM":"1.44085000","BBD":"2.00000000","BDT":"77.44999700","BGN":"1.44350000","BHD":"0.37710000","BIF":"1535.00000000","BMD":"1.00000000","BND":"1.24865000","BOB":"6.91000000","BRL":"2.22120000","BSD":"1.00000000","BTN":"60.19500000","BWP":"8.81830000","BYR":"10190.00000000","BZD":"1.99500000","CAD":"1.07294500","CDF":"923.00000000","CHF":"0.89421500","CLF":"0.02300000","CLP":"552.42999300","CNH":"6.22360000","CNY":"6.22550000","COP":"1881.50000000","CRC":"547.54998800","CUP":"1.00000000","CVE":"80.12999700","CZK":"20.18420000","DJF":"182.00000000","DKK":"5.47994500","DOP":"43.48500100","DZD":"80.19999700","EGP":"7.14935000","ERN":"15.10000000","ETB":"19.62785000","EUR":"0.73508300","FJD":"1.85130000","FKP":"0.58730000","GBP":"0.58725800","GEL":"1.76780000","GHS":"3.03650000","GIP":"0.58725000","GMD":"39.79999900","GNF":"7030.00000000","GTQ":"7.80550000","GYD":"205.64999400","HKD":"7.75110000","HNL":"20.95000100","HRK":"5.56900000","HTG":"45.34830100","HUF":"224.37500000","IDR":"12035.00000000","IEP":"0.57892100","ILS":"3.44275000","INR":"60.16050000","IQD":"1164.50000000","IRR":"25633.00000000","ISK":"113.69999700","JMD":"111.55000300","JOD":"0.70860000","JPY":"101.92649800","KES":"87.55000300","KGS":"52.11169800","KHR":"4011.00000000","KMF":"361.63464400","KPW":"900.00000000","KRW":"1018.50000000","KWD":"0.28195500","KYD":"0.82000000","KZT":"183.50000000","LAK":"8053.50000000","LBP":"1508.62500000","LKR":"130.29499800","LRD":"89.50000000","LSL":"10.59000000","LTL":"2.54250000","LVL":"0.50950000","LYD":"1.21050000","MAD":"8.24995000","MDL":"14.00000000","MGA":"2428.00000000","MKD":"45.36500200","MMK":"977.00000000","MNT":"1826.50000000","MOP":"7.98365000","MRO":"289.50000000","MUR":"30.65000000","MVR":"15.41000000","MWK":"393.00000000","MXN":"13.02790000","MXV":"2.54030500","MYR":"3.21950000","MZN":"31.40000000","NAD":"10.60700000","NGN":"162.63000500","NIO":"26.00499900","NOK":"6.10953000","NPR":"96.98000300","NZD":"1.14675600","OMR":"0.38510000","PAB":"1.00000000","PEN":"2.80700000","PGK":"2.42800000","PHP":"43.84000000","PKR":"98.34999800","PLN":"3.05990000","PYG":"4395.66503900","QAR":"3.64100000","RON":"3.22905000","RSD":"84.89550000","RUB":"34.09600100","RWF":"680.00000000","SAR":"3.75080000","SBD":"7.22088400","SCR":"12.36000000","SDG":"5.69250000","SEK":"6.69490000","SGD":"1.24858000","SHP":"0.58725000","SLL":"4340.00000000","SOS":"953.00000000","SRD":"3.27500000","STD":"18045.00000000","SVC":"8.74700000","SYP":"149.35000600","SZL":"10.61500000","THB":"32.44500000","TJS":"4.92490000","TMT":"2.85000000","TND":"1.68015000","TOP":"1.85166800","TRY":"2.13670000","TTD":"6.43450000","TWD":"30.04200000","TZS":"1681.50000000","UAH":"11.88320000","UGX":"2610.00000000","USD":"1.00000000","UYU":"22.99000000","UZS":"2296.42993200","VEF":"6.29250000","VND":"21310.00000000","VUV":"93.40000200","WST":"2.30286100","XAF":"482.17950400","XAG":"0.04782600","XAU":"0.00075900","XBT":"0.00170765","XCD":"2.70000000","XCP":"0.31791400","XDR":"0.64805000","XOF":"483.20001200","XPD":"0.00121400","XPF":"88.30000300","XPT":"0.00068600","YER":"214.85499600","ZAR":"10.58960000","ZMW":"6.09000000","ZWL":"322.35501100"},"2014-06-24":{"utctime":"2014-06-24T23:50:02+02:00","AED":"3.67320000","AFN":"56.83000200","ALL":"103.02500200","AMD":"408.45001200","ANG":"1.79000000","AOA":"97.66100300","ARS":"8.13305000","AUD":"1.06749800","AWG":"1.79000000","AZN":"0.78430000","BAM":"1.44065000","BBD":"2.00000000","BDT":"77.66000400","BGN":"1.44120000","BHD":"0.37710000","BIF":"1549.00000000","BMD":"1.00000000","BND":"1.24920000","BOB":"6.91000000","BRL":"2.22100000","BSD":"1.00000000","BTN":"60.09999800","BWP":"8.78730000","BYR":"10190.00000000","BZD":"1.99500000","CAD":"1.07445000","CDF":"922.00000000","CHF":"0.89395000","CLF":"0.02299000","CLP":"552.14001500","CNH":"6.23225000","CNY":"6.23250000","COP":"1890.50000000","CRC":"547.50000000","CUP":"1.00000000","CVE":"80.12999700","CZK":"20.16750000","DJF":"181.19999700","DKK":"5.47938000","DOP":"43.48000000","DZD":"79.37000300","EGP":"7.15250000","ERN":"15.10000000","ETB":"19.62785000","EUR":"0.73500800","FJD":"1.84060000","FKP":"0.58880000","GBP":"0.58874600","GEL":"1.76480000","GHS":"3.00580000","GIP":"0.58875000","GMD":"39.90000200","GNF":"7030.00000000","GTQ":"7.79650000","GYD":"208.44999700","HKD":"7.75160000","HNL":"20.95000100","HRK":"5.56950000","HTG":"45.34830100","HUF":"224.92500300","IDR":"12035.00000000","IEP":"0.57880400","ILS":"3.43760000","INR":"60.16050000","IQD":"1164.50000000","IRR":"25633.00000000","ISK":"113.94999700","JMD":"110.90000200","JOD":"0.70860000","JPY":"101.95349900","KES":"87.48000300","KGS":"52.29499800","KHR":"4045.00000000","KMF":"361.56814600","KPW":"900.00000000","KRW":"1018.50000000","KWD":"0.28195000","KYD":"0.82000000","KZT":"183.61000100","LAK":"8052.50000000","LBP":"1508.62500000","LKR":"130.28999300","LRD":"90.50000000","LSL":"10.63500000","LTL":"2.53795000","LVL":"0.50950000","LYD":"1.21050000","MAD":"8.25720000","MDL":"13.97500000","MGA":"2365.00000000","MKD":"45.31000100","MMK":"975.00000000","MNT":"1827.50000000","MOP":"7.98415000","MRO":"290.50000000","MUR":"30.65000000","MVR":"15.41000000","MWK":"395.00000000","MXN":"13.06390000","MXV":"2.54687800","MYR":"3.21350000","MZN":"31.45000100","NAD":"10.61800000","NGN":"162.69999700","NIO":"26.00499900","NOK":"6.11340000","NPR":"96.50000000","NZD":"1.15317700","OMR":"0.38495000","PAB":"1.00000000","PEN":"2.80600000","PGK":"2.42800000","PHP":"43.86999900","PKR":"98.59999800","PLN":"3.05330000","PYG":"4397.72509800","QAR":"3.64070000","RON":"3.22840000","RSD":"85.01049800","RUB":"33.80950200","RWF":"678.00000000","SAR":"3.75080000","SBD":"7.22088400","SCR":"12.36000000","SDG":"5.69250000","SEK":"6.72620000","SGD":"1.24906500","SHP":"0.58875000","SLL":"4338.00000000","SOS":"952.00000000","SRD":"3.27500000","STD":"18015.00000000","SVC":"8.74700000","SYP":"149.50000000","SZL":"10.54700000","THB":"32.45000100","TJS":"4.93240000","TMT":"2.85030000","TND":"1.68350000","TOP":"1.84858700","TRY":"2.14410000","TTD":"6.43450000","TWD":"29.99200100","TZS":"1681.50000000","UAH":"11.89700000","UGX":"2613.00000000","USD":"1.00000000","UYU":"22.95000100","UZS":"2296.42993200","VEF":"6.29250000","VND":"21285.00000000","VUV":"93.65000200","WST":"2.28236000","XAF":"482.09094200","XAG":"0.04753300","XAU":"0.00075900","XBT":"0.00171262","XCD":"2.70000000","XCP":"0.31781300","XDR":"0.64815000","XOF":"483.29998800","XPD":"0.00120200","XPF":"87.75000000","XPT":"0.00067800","YER":"214.80499300","ZAR":"10.64655000","ZMW":"6.08000000","ZWL":"322.35501100"},"2014-06-25":{"utctime":"2014-06-25T23:50:01+02:00","AED":"3.67300000","AFN":"56.73000000","ALL":"102.77500200","AMD":"407.89001500","ANG":"1.79000000","AOA":"97.65850100","ARS":"8.13225000","AUD":"1.06350200","AWG":"1.78000000","AZN":"0.78430000","BAM":"1.43805000","BBD":"2.00000000","BDT":"77.72000100","BGN":"1.44150000","BHD":"0.37709000","BIF":"1535.00000000","BMD":"1.00000000","BND":"1.24995000","BOB":"6.91000000","BRL":"2.20450000","BSD":"1.00000000","BTN":"60.17499900","BWP":"8.82610000","BYR":"10195.00000000","BZD":"1.99500000","CAD":"1.07215000","CDF":"922.00000000","CHF":"0.89265000","CLF":"0.02291000","CLP":"550.35998500","CNH":"6.22800000","CNY":"6.23550000","COP":"1891.90002400","CRC":"547.50000000","CUP":"1.00000000","CVE":"79.77999900","CZK":"20.12299900","DJF":"182.00000000","DKK":"5.46930000","DOP":"43.47499800","DZD":"79.71299700","EGP":"7.15045000","ERN":"15.10000000","ETB":"19.62785000","EUR":"0.73364900","FJD":"1.84600000","FKP":"0.58890000","GBP":"0.58890200","GEL":"1.76480000","GHS":"3.00500000","GIP":"0.58895000","GMD":"39.91000000","GNF":"7030.00000000","GTQ":"7.79250000","GYD":"205.69999700","HKD":"7.75165000","HNL":"20.95000100","HRK":"5.55915000","HTG":"45.33359900","HUF":"225.11500500","IDR":"12135.00000000","IEP":"0.57785100","ILS":"3.43280000","INR":"60.08549900","IQD":"1164.50000000","IRR":"25633.00000000","ISK":"113.80000300","JMD":"111.65000200","JOD":"0.70850000","JPY":"101.84100300","KES":"87.75000000","KGS":"52.11980100","KHR":"4049.00000000","KMF":"360.97131300","KPW":"900.00000000","KRW":"1019.90002400","KWD":"0.28205000","KYD":"0.82000000","KZT":"183.50999500","LAK":"8051.50000000","LBP":"1508.62500000","LKR":"130.32499700","LRD":"90.50000000","LSL":"10.59500000","LTL":"2.53325000","LVL":"0.50950000","LYD":"1.23500000","MAD":"8.23895000","MDL":"13.97500000","MGA":"2427.00000000","MKD":"45.17499900","MMK":"976.00000000","MNT":"1827.50000000","MOP":"7.98430000","MRO":"290.50000000","MUR":"30.65000000","MVR":"15.42000000","MWK":"392.50000000","MXN":"13.00245000","MXV":"2.53473400","MYR":"3.22425000","MZN":"31.45000100","NAD":"10.57200000","NGN":"162.72000100","NIO":"26.01499900","NOK":"6.13570000","NPR":"96.98000300","NZD":"1.14496400","OMR":"0.38495000","PAB":"1.00000000","PEN":"2.80700000","PGK":"2.42800000","PHP":"43.91500100","PKR":"98.75000000","PLN":"3.03580000","PYG":"4393.89990200","QAR":"3.64080000","RON":"3.21875000","RSD":"84.81050100","RUB":"33.76699800","RWF":"678.00000000","SAR":"3.75100000","SBD":"7.22088400","SCR":"12.35000000","SDG":"5.68250000","SEK":"6.73510000","SGD":"1.24980000","SHP":"0.58895000","SLL":"4340.00000000","SOS":"952.00000000","SRD":"3.27500000","STD":"17985.00000000","SVC":"8.74700000","SYP":"149.50000000","SZL":"10.55600000","THB":"32.45000100","TJS":"4.92670000","TMT":"2.85030000","TND":"1.68395000","TOP":"1.84858700","TRY":"2.13160000","TTD":"6.43450000","TWD":"30.00000000","TZS":"1673.50000000","UAH":"11.88690000","UGX":"2603.00000000","USD":"1.00000000","UYU":"22.91000000","UZS":"2296.42993200","VEF":"6.29250000","VND":"21305.00000000","VUV":"93.34999800","WST":"2.29915400","XAF":"481.29504400","XAG":"0.04736900","XAU":"0.00075800","XBT":"0.00177161","XCD":"2.70000000","XCP":"0.31640600","XDR":"0.64775000","XOF":"481.04998800","XPD":"0.00119900","XPF":"87.59999800","XPT":"0.00067800","YER":"214.90499900","ZAR":"10.58670000","ZMW":"6.07000000","ZWL":"322.35501100"}}}'
|
30
|
+
http_version:
|
31
|
+
recorded_at: Fri, 26 Sep 2014 01:18:30 GMT
|
32
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://jsonrates.com/historical?date=2014-06-23&from=USD&to=BRL
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/1.4.6 (Ubuntu)
|
17
|
+
Date:
|
18
|
+
- Thu, 25 Sep 2014 03:42:19 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.5.9-1ubuntu4.3
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"from":"USD","to":"BRL","rates":{"2014-06-23":{"utctime":"2014-06-23T23:50:03+02:00","rate":"2.22120000"}}}'
|
30
|
+
http_version:
|
31
|
+
recorded_at: Thu, 25 Sep 2014 03:42:19 GMT
|
32
|
+
recorded_with: VCR 2.9.3
|
data/spec/cassettes/Jsonrates_Client/_historical/successful_request/returns_a_hash_of_rates.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://jsonrates.com/historical?date=2014-06-23&from=USD&to=BRL
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/1.4.6 (Ubuntu)
|
17
|
+
Date:
|
18
|
+
- Thu, 25 Sep 2014 03:42:20 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.5.9-1ubuntu4.3
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"from":"USD","to":"BRL","rates":{"2014-06-23":{"utctime":"2014-06-23T23:50:03+02:00","rate":"2.22120000"}}}'
|
30
|
+
http_version:
|
31
|
+
recorded_at: Thu, 25 Sep 2014 03:42:20 GMT
|
32
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RSpec.describe Jsonrates::Client do
|
2
|
+
subject do
|
3
|
+
Jsonrates::Client
|
4
|
+
end
|
5
|
+
|
6
|
+
describe ".historical", :vcr do
|
7
|
+
context "successful request" do
|
8
|
+
let!(:historical) do
|
9
|
+
subject.historical(from: "USD", to: "BRL", date: "2014-06-23")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "requests historical using arguments as query parameters" do
|
13
|
+
expect(a_request(:get, "http://jsonrates.com/historical?from=USD&to=BRL&date=2014-06-23")).to have_been_made
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns a hash of rates", :vcr do
|
17
|
+
expect(historical).to eq({"2014-06-23"=>{"utctime"=>"2014-06-23T23:50:03+02:00", "rate"=>"2.22120000"}})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "params keys setup" do
|
22
|
+
let!(:historical) do
|
23
|
+
subject.historical(base: "USD", date_start: "2014-06-23", date_end: "2014-06-25")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "replaces date_start and date_end with dateStart and dateEnd" do
|
27
|
+
expect(a_request(:get, "http://jsonrates.com/historical").with(query: {base: "USD", dateStart: "2014-06-23", dateEnd: "2014-06-25"})).to have_been_made
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "jsonrates_client"
|
2
|
+
require "vcr"
|
3
|
+
require "webmock/rspec"
|
4
|
+
|
5
|
+
VCR.configure do |c|
|
6
|
+
c.cassette_library_dir = 'spec/cassettes'
|
7
|
+
c.hook_into :webmock
|
8
|
+
c.configure_rspec_metadata!
|
9
|
+
end
|
10
|
+
|
11
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.expect_with :rspec do |expectations|
|
14
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.mock_with :rspec do |mocks|
|
18
|
+
mocks.verify_partial_doubles = true
|
19
|
+
end
|
20
|
+
|
21
|
+
config.disable_monkey_patching!
|
22
|
+
config.warnings = true
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsonrates_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roberto Soares
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- roberto.tech@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".ruby-gemset"
|
107
|
+
- ".ruby-version"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- jsonrates_client.gemspec
|
113
|
+
- lib/jsonrates_client.rb
|
114
|
+
- lib/jsonrates_client/version.rb
|
115
|
+
- spec/cassettes/Jsonrates_Client/_historical/params_keys_setup/replaces_date_start_and_date_end_with_dateStart_and_dateEnd.yml
|
116
|
+
- spec/cassettes/Jsonrates_Client/_historical/successful_request/requests_historical_using_arguments_as_query_parameters.yml
|
117
|
+
- spec/cassettes/Jsonrates_Client/_historical/successful_request/returns_a_hash_of_rates.yml
|
118
|
+
- spec/jsonrates_client_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: http://github.com/roberto/jsonrates_client/
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.2.2
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Ruby client for jsonrates.com
|
144
|
+
test_files:
|
145
|
+
- spec/cassettes/Jsonrates_Client/_historical/params_keys_setup/replaces_date_start_and_date_end_with_dateStart_and_dateEnd.yml
|
146
|
+
- spec/cassettes/Jsonrates_Client/_historical/successful_request/requests_historical_using_arguments_as_query_parameters.yml
|
147
|
+
- spec/cassettes/Jsonrates_Client/_historical/successful_request/returns_a_hash_of_rates.yml
|
148
|
+
- spec/jsonrates_client_spec.rb
|
149
|
+
- spec/spec_helper.rb
|