fixer-rb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -2
- data/lib/fixer.rb +2 -0
- data/lib/fixer/request.rb +10 -0
- data/lib/fixer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f71d6fcdbe0db8212b251cc4e2bae06f155999f
|
4
|
+
data.tar.gz: 325efc74ed133115b6335e1c1b1e040e0f191352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 990d428765fecf8dba42e9532593afc4bd3d47b25c06f302d1431288bb958e7d701c56eab155105c6c780603d3ecaa869d56070167cce0c6eb67dc1b95178c8a
|
7
|
+
data.tar.gz: a0f611cd42928b3feb9213598c163b0cbb6418e3822cf76e1930abbc88ee10c15b195deb2e5692b521dc7bf00c8cda19a7d73dd9390fa78fc83af5ffd01d1a40
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Fixer
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/gaotongfei/fixer.svg?branch=master)](https://travis-ci.org/gaotongfei/fixer)
|
4
|
+
|
3
5
|
Fixer is a simple API wrapper of [http://fixer.io/](http://fixer.io/) to provide a clean way of converting currency
|
4
6
|
|
5
7
|
# Install
|
@@ -16,12 +18,51 @@ To convert Chinese Yuan to US Dollars, simply do this
|
|
16
18
|
require 'fixer'
|
17
19
|
|
18
20
|
fixer = Fixer::Request.new 'CNY'
|
19
|
-
params = {target: 'USD', ammount:
|
21
|
+
params = {target: 'USD', ammount: 1000}
|
20
22
|
|
21
23
|
fixer.transfer(params)
|
24
|
+
$ 149.75
|
22
25
|
```
|
23
26
|
|
24
27
|
```
|
25
|
-
|
28
|
+
fixer.get_rate do |rate|
|
29
|
+
rate.USD
|
30
|
+
end
|
31
|
+
|
32
|
+
$ 0.14975
|
26
33
|
```
|
27
34
|
|
35
|
+
# Supported Currencies
|
36
|
+
|
37
|
+
* CNY
|
38
|
+
* AUD
|
39
|
+
* BGN
|
40
|
+
* BRL
|
41
|
+
* CAD
|
42
|
+
* CHF
|
43
|
+
* CZK
|
44
|
+
* DKK
|
45
|
+
* GBP
|
46
|
+
* HKD
|
47
|
+
* HRK
|
48
|
+
* HUF
|
49
|
+
* IDR
|
50
|
+
* ILS
|
51
|
+
* INR
|
52
|
+
* JPY
|
53
|
+
* KRW
|
54
|
+
* MXN
|
55
|
+
* MYR
|
56
|
+
* NOK
|
57
|
+
* NZD
|
58
|
+
* PHP
|
59
|
+
* PLN
|
60
|
+
* RON
|
61
|
+
* RUB
|
62
|
+
* SEK
|
63
|
+
* SGD
|
64
|
+
* THB
|
65
|
+
* TRY
|
66
|
+
* USD
|
67
|
+
* ZAR
|
68
|
+
* EUR
|
data/lib/fixer.rb
CHANGED
data/lib/fixer/request.rb
CHANGED
@@ -2,6 +2,7 @@ module Fixer
|
|
2
2
|
class Request
|
3
3
|
attr_reader :response
|
4
4
|
def initialize(base = Fixer.base)
|
5
|
+
@base = base
|
5
6
|
base_host = "https://api.fixer.io/latest?base=#{base}"
|
6
7
|
@response = HTTParty.get(base_host)
|
7
8
|
end
|
@@ -22,6 +23,15 @@ module Fixer
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
26
|
+
def get_rate
|
27
|
+
result = JSON.parse @response.body, symbolize_names: true
|
28
|
+
base = {base: @base}
|
29
|
+
rates = result[:rates]
|
30
|
+
currencies = base.merge(rates)
|
31
|
+
r_obj = OpenStruct.new currencies
|
32
|
+
yield r_obj
|
33
|
+
end
|
34
|
+
|
25
35
|
private
|
26
36
|
def valid_currency?(currency)
|
27
37
|
valid_currencies = ["EUR", "AUD", "BGN", "BRL", "CAD", "CHF", "CNY",
|
data/lib/fixer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixer-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taff Gao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|