exchange-nbkr 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/lib/exchange/external_api/valuta_kg.rb +29 -0
- data/lib/exchange/nbkr.rb +1 -0
- data/lib/exchange/nbkr/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecf1a3e8274c0b7f055faed5e9c25dbb4d217639
|
4
|
+
data.tar.gz: a1336b8aa93d293a4cbebd402609cdddc461919d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be4f9b7d345e5a429199a6e404e78d5333533a0619260224d913369f6eb0c881cb74a0a625f8c655a8f0f65ae8b8cc60e0cedbc4b0ba66e70ef257a7f02accfe
|
7
|
+
data.tar.gz: d0dca114e5541fcb9c5634e2858c972910a502750acb83c23844b8c2ee8ec0cbcbc926cf583a58acb50d95458b7efd0c5e67eae62893346ab57a20790f9adbed
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# [National Bank of Kyrgyzstan](http://nbkr.kg) API adapter for [exchange gem](https://github.com/beatrichartz/exchange)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
It also has [valuta.kg](http://valuta.kg) fallback adapter.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -26,7 +24,7 @@ Setup exchange to use NBKR(National Bank of Kyrgyzstan) currency rates provider.
|
|
26
24
|
|
27
25
|
```ruby
|
28
26
|
Exchange.configuration = Exchange::Configuration.new do |c|
|
29
|
-
c.api.subclass = :nbkr
|
27
|
+
c.api.subclass = :nbkr # or :valuta_kg
|
30
28
|
end
|
31
29
|
```
|
32
30
|
|
@@ -44,7 +42,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
44
42
|
|
45
43
|
## Contributing
|
46
44
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sharshenov/exchange-nbkr.
|
48
46
|
|
49
47
|
|
50
48
|
## License
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Exchange
|
2
|
+
module ExternalAPI
|
3
|
+
|
4
|
+
class ValutaKg < XML
|
5
|
+
|
6
|
+
API_URL = "http://m.valuta.kg/api/"
|
7
|
+
|
8
|
+
CURRENCIES = %I(kgs usd eur rub kzt uzs cny gbp)
|
9
|
+
|
10
|
+
def update opts={}
|
11
|
+
time = helper.assure_time(opts[:at], default: :now)
|
12
|
+
|
13
|
+
Call.new(API_URL, at: time, format: :xml) do |result|
|
14
|
+
@base = :kgs
|
15
|
+
|
16
|
+
@rates = result.search('currency').map do |c|
|
17
|
+
[
|
18
|
+
c.at("title_alias").text.downcase.to_sym,
|
19
|
+
(1 / BigDecimal.new(c.at('buy_rate').text.sub(',', '.')))
|
20
|
+
]
|
21
|
+
end.to_h.merge({ kgs: 1 })
|
22
|
+
|
23
|
+
@timestamp = Date.today.to_time.to_i
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/exchange/nbkr.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exchange-nbkr
|
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
|
- Rustam Sharshenov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: exchange
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- exchange-nbkr.gemspec
|
57
57
|
- lib/exchange-nbkr.rb
|
58
58
|
- lib/exchange/external_api/nbkr.rb
|
59
|
+
- lib/exchange/external_api/valuta_kg.rb
|
59
60
|
- lib/exchange/nbkr.rb
|
60
61
|
- lib/exchange/nbkr/version.rb
|
61
62
|
homepage: https://github.com/sharshenov/exchange-nbkr
|