currency_quote 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +8 -0
- data/lib/currency_quote.rb +2 -0
- data/lib/currency_quote/invertir_online.rb +46 -0
- data/lib/currency_quote/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf88a3fc8a7d35ce9f4cba45330f8e59c9bf2efbb731adc1e0570367ef7bbaa
|
4
|
+
data.tar.gz: ade76e76c90775f8c7f6b58f9d6eb79aea43ca451f7b3522813d8f73222c1113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e231b50836f599f20f107c63108dd142b52a8cfe2092f0563401515d2a1dc377b4fc457d6f7d43186e80b9d8f502599bba0b2f07e94ec4910547627def5d97
|
7
|
+
data.tar.gz: 47446653b727e1ff5b78c3136e5f13f486c005edfbf4fff36fb88b0e66ec50c3f9561c7418e8bae832640a20713ca805425030c38b4fbfe2d8af04e435339c54
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -11,7 +11,14 @@ GEM
|
|
11
11
|
addressable (2.7.0)
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
13
13
|
diff-lcs (1.4.4)
|
14
|
+
httparty (0.18.1)
|
15
|
+
mime-types (~> 3.0)
|
16
|
+
multi_xml (>= 0.5.2)
|
17
|
+
mime-types (3.3.1)
|
18
|
+
mime-types-data (~> 3.2015)
|
19
|
+
mime-types-data (3.2020.1104)
|
14
20
|
mini_portile2 (2.4.0)
|
21
|
+
multi_xml (0.6.0)
|
15
22
|
nokogiri (1.10.10)
|
16
23
|
mini_portile2 (~> 2.4.0)
|
17
24
|
public_suffix (4.0.6)
|
@@ -36,6 +43,7 @@ PLATFORMS
|
|
36
43
|
DEPENDENCIES
|
37
44
|
addressable (~> 2.7)
|
38
45
|
currency_quote!
|
46
|
+
httparty (~> 0.18.1)
|
39
47
|
nokogiri (~> 1.10)
|
40
48
|
rake (~> 12.0)
|
41
49
|
rspec (~> 3.0)
|
data/lib/currency_quote.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative "currency_quote/version"
|
2
2
|
require_relative "currency_quote/dolar"
|
3
3
|
require_relative "currency_quote/currency"
|
4
|
+
require_relative "currency_quote/invertir_online"
|
4
5
|
|
5
6
|
module CurrencyQuote
|
6
7
|
class Error < StandardError; end
|
@@ -11,6 +12,7 @@ module CurrencyQuote
|
|
11
12
|
|
12
13
|
autoload :Dolar, "currency_quote/dolar"
|
13
14
|
autoload :Currency, "currency_quote/currency"
|
15
|
+
autoload :InvertirOnline, "currency_quote/invertir_online"
|
14
16
|
|
15
17
|
CURRENCIES = [
|
16
18
|
"Bolívar Venezolano",
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class CurrencyQuote::InvertirOnline
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
attr_accessor :username, :password, :access_token
|
5
|
+
|
6
|
+
BASE_URL = "https://api.invertironline.com"
|
7
|
+
|
8
|
+
def initialize(username:, password:)
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
get_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_quote(simbol:, mercado: 'bCBA', plazo: 't1')
|
15
|
+
url = BASE_URL + "/api/v2/#{mercado}/Titulos/#{currency.upcase}/Cotizacion"
|
16
|
+
HTTParty.get(url,
|
17
|
+
body: {
|
18
|
+
'mercado' => mercado,
|
19
|
+
'simbol' => currency.upcase,
|
20
|
+
'model.mercado' => mercado,
|
21
|
+
'model.plazo' => plazo
|
22
|
+
},
|
23
|
+
headers: {
|
24
|
+
'Authorization' => "Bearer #{@access_token}",
|
25
|
+
'Accept' => 'application/json'
|
26
|
+
}
|
27
|
+
).parsed_response
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def get_token
|
33
|
+
url = BASE_URL + "/token"
|
34
|
+
@access_token = HTTParty.post(url,
|
35
|
+
body: {
|
36
|
+
username: username,
|
37
|
+
password: password,
|
38
|
+
grant_type: 'password'
|
39
|
+
},
|
40
|
+
headers:{
|
41
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
42
|
+
'Accept' => 'application/json'
|
43
|
+
}
|
44
|
+
)['access_token']
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currency_quote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo A. Díaz Martínez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/currency_quote.rb
|
62
62
|
- lib/currency_quote/currency.rb
|
63
63
|
- lib/currency_quote/dolar.rb
|
64
|
+
- lib/currency_quote/invertir_online.rb
|
64
65
|
- lib/currency_quote/version.rb
|
65
66
|
homepage: https://www.sesocio.com
|
66
67
|
licenses:
|