bovesparb 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c7e4794b8b3cc8f512977b5e1086c9eedb72748783b803c1c37832cf7d2c5bc
4
- data.tar.gz: c79950b522f110793d6c51258f8500c15c72219934e8b17343756616e96592ab
3
+ metadata.gz: 6eec17b1f7d3bceb581182be9f9ca0e93b5703b9717dc7ed2aa2c93714aee982
4
+ data.tar.gz: d689b70c2483eaeac81f20c17dc38c8aa865ad95a523cbd035a1d4f4db168186
5
5
  SHA512:
6
- metadata.gz: 6c997bc2976171233e6515837a4757fbcae9a1cc858c476c8cc0bba0f8ef801bd1fce7fb9910dbdbdbce88d0a42541143f8dd6cbd4270910f496ec63e4764861
7
- data.tar.gz: 27481e7f9ede1f0f696361a92283116ef5390e74ac2a42750d31d886b7825c6c4d81ea51fd63e646e04c82e27e38ad24862d24146471f2fe1753d9de60f5334e
6
+ metadata.gz: b8e830a4b3d171ec9fdc480ca1b94317b7f80a9f6cc49a39d33cd4d05463dbb22814f802827717ca444e170b1889aaa199b59268c9cf9e3468244813d2247af2
7
+ data.tar.gz: 378356dbe2a2db9c78b27f587863f2cf7268922a78d0371570a5f129064d9a66838bc95f228e5a9c24d746591f2754264dc950b00e4e9c9677ea7acc1165ac9b
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "bovesparb"
8
8
  spec.version = Bovesparb::VERSION
9
9
  spec.authors = ["Hugo Lyra"]
10
- spec.email = ["hugo.lyra@apple.com"]
10
+ spec.email = ["me@hugolyra.com"]
11
11
 
12
12
  spec.summary = %q{BovespaRB}
13
13
  spec.description = %q{A Ruby library to query the bovespa stocks.}
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.require_paths = ["lib"]
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.17"
29
+ spec.add_development_dependency "bundler", "> 1.17"
30
30
  spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
32
 
@@ -1,15 +1,34 @@
1
1
  module Bovesparb
2
2
  class Client
3
- API_ENDPOINT = 'http://bvmf.bmfbovespa.com.br'.freeze
3
+ API_ENDPOINT = "http://bvmf.bmfbovespa.com.br".freeze
4
+ DICTIONARY = {
5
+ Codigo: :ticket,
6
+ Nome: :name,
7
+ Data: :date,
8
+ Abertura: :open,
9
+ Minimo: :low,
10
+ Maximo: :high,
11
+ Medio: :average,
12
+ Ultimo: :close,
13
+ Oscilacao: :variation,
14
+ }
4
15
 
5
16
  def quotes(stocks)
6
- request params: { strListaCodigos: stocks }
17
+ response = request(params: { strListaCodigos: stocks })
18
+ parser(response)
7
19
  end
8
20
 
9
21
  private
10
22
 
23
+ def parser(response)
24
+ tickets = response[:ComportamentoPapeis][:Papel].flatten
25
+ tickets.collect do |ticket|
26
+ ticket.transform_keys { |key| DICTIONARY[key] || key }
27
+ end
28
+ end
29
+
11
30
  def client
12
- @_client ||= Faraday.new(API_ENDPOINT) do |client|
31
+ @_client ||= Faraday.new(API_ENDPOINT, request: { open_timeout: 3, timeout: 5 }) do |client|
13
32
  client.request :url_encoded
14
33
  client.adapter Faraday.default_adapter
15
34
  end
@@ -1,3 +1,3 @@
1
1
  module Bovesparb
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bovesparb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugo Lyra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-24 00:00:00.000000000 Z
11
+ date: 2020-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.17'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.17'
27
27
  - !ruby/object:Gem::Dependency
@@ -94,7 +94,7 @@ dependencies:
94
94
  version: '2.11'
95
95
  description: A Ruby library to query the bovespa stocks.
96
96
  email:
97
- - hugo.lyra@apple.com
97
+ - me@hugolyra.com
98
98
  executables: []
99
99
  extensions: []
100
100
  extra_rdoc_files: []