brasilapi 0.4.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea46d9028ee79406566abf23b22f13aa2bbdc39627514285d8b37aaefb800155
4
- data.tar.gz: bf450026f52e66133949d096bab1c0f928d99ba8470113b605b35a224f5ad024
3
+ metadata.gz: 90984c3c65874f8182c32cf0117ecbec0b6c93595885323a7d8d23597788941f
4
+ data.tar.gz: f708ddf656929596da3ff1c8c44a30abedd6cdff120222edd6b007b0b878ca40
5
5
  SHA512:
6
- metadata.gz: 270117e9836151ac6c82a96846c79d50e2aa6934e65262a0dd1114695d38a1cc79a4c84fa06c268919855716d174d02c970a0b565a711ee411b9f141ce0f38a4
7
- data.tar.gz: 210966b126a31f9761ffed838e89b3e612e43d2706fa5bf547de48fb3b197d6fb12297ad7ff3b8f730865cec7eb20fe659397e2453a679eaff93ab323a080dc0
6
+ metadata.gz: cb1831e4435f2a28c0b6e5df7b822c5c65a84f65866096231742a98c87696c31c0058f06837a7b6b7860eb50874f4cdfb8a0f900727d7f32844990c5b9e966cd
7
+ data.tar.gz: 20193f1e912ca81e215760aa9bc7daaf5fefc9adbf82101da8889c21e6bca7365d79bd95f94d1b4aed8074902fa1b76363bb1a086935e1fd91eb26cd5991af5a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] - 2024-02-25
4
+
5
+ - Integração da API do IBGE
6
+
7
+ ## [0.5.1] - 2023-12-01
8
+
9
+ - Corrigindo versão publicada no RubyGems
10
+
11
+ ## [0.5.0] - 2023-12-01
12
+
13
+ - Integração da API de Corretoras ativas listadas na CVM
14
+
3
15
  ## [0.4.0] - 2023-10-30
4
16
 
5
17
  - Integração da API de Feriados Nacionais
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brasilapi (0.4.0)
4
+ brasilapi (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -9,12 +9,12 @@ Dependency-less Brasil API lookup gem for brazilian data with an easy-to-use API
9
9
  - [x] **Bank**
10
10
  - [x] **CEP (Zip code)**
11
11
  - [x] **CNPJ**
12
- - [ ] **Corretoras**
12
+ - [x] **Corretoras**
13
13
  - [ ] **CPTEC**
14
14
  - [x] **DDD**
15
15
  - [x] **Feriados Nacionais**
16
16
  - [ ] **FIPE**
17
- - [ ] **IBGE**
17
+ - [x] **IBGE**
18
18
  - [ ] **ISBN**
19
19
  - [ ] **NCM**
20
20
  - [ ] **PIX**
@@ -50,9 +50,9 @@ BrasilAPI::Bank.find_by_code(77)
50
50
  # find company by cnpj
51
51
  BrasilAPI::Company.find_by_cnpj("60316817000103")
52
52
  =>
53
- {"uf"=>"SP",
54
- "cep"=>"04543907",
55
- "qsa"=>
53
+ {"uf"=>"SP",
54
+ "cep"=>"04543907",
55
+ "qsa"=>
56
56
  [{"pais"=>"ESTADOS UNIDOS",
57
57
  ...}
58
58
 
@@ -71,12 +71,26 @@ BrasilAPI::Address.find_by_zip_code('80060000', location: true)
71
71
  # get state and cities by area code
72
72
  BrasilAPI::Address.state_and_cities_by_area_code('89')
73
73
  =>
74
- {"state"=>"PI",
75
- "cities"=>
76
- ["MASSÂPE DO PIAUÍ",
77
- ...,
78
- "ACAUÃ"
79
- ]}
74
+ {"state"=>"PI",
75
+ "cities"=>
76
+ ["MASSÂPE DO PIAUÍ",
77
+ ...,
78
+ "ACAUÃ"
79
+ ]}
80
+
81
+ # get all CVM brokers
82
+ BrasilAPI::CVM.all
83
+ =>
84
+ [{"cnpj"=>"76621457000185",
85
+ "type"=>"CORRETORAS",
86
+ ...]
87
+
88
+ # find bank by code
89
+ BrasilAPI::CVM.find_by_cnpj('74014747000135')
90
+ =>
91
+ {"cnpj"=>"74014747000135",
92
+ "type"=>"CORRETORAS",
93
+ ...}
80
94
 
81
95
  # get brazilian national holidays by year
82
96
  BrasilAPI::Holiday.by_year(2024)
@@ -84,8 +98,46 @@ BrasilAPI::Holiday.by_year(2024)
84
98
  [{"date"=>"2024-01-01", "name"=>"Confraternização mundial", "type"=>"national"},
85
99
  ...
86
100
  {"date"=>"2024-12-25", "name"=>"Natal", "type"=>"national"}]
101
+
102
+ # get states from ibge
103
+ BrasilAPI::IBGE.states
104
+ =>
105
+ [{"id"=>11,
106
+ "sigla"=>"RO"
107
+ "nome"=>"Rondônia",
108
+ "regiao"=>{"id"=>1, "sigla"=>"N", "nome"=>"Norte"}},
109
+ ...
110
+ {"id"=>53,
111
+ "sigla"=>"DF",
112
+ "nome"=>"Distrito Federal",
113
+ "regiao"=>{"id"=>5, "sigla"=>"CO", "nome"=>"Centro-Oeste"}}]
114
+
115
+ # find state by abbreviation from ibge
116
+ BrasilAPI::IBGE.find_state_by_code('PI')
117
+ =>
118
+ {"id"=>22,
119
+ "sigla"=>"PI",
120
+ "nome"=>"Piauí",
121
+ "regiao"=>{"id"=>2, "sigla"=>"NE", "nome"=>"Nordeste"}}
122
+
123
+ # find state by code from ibge
124
+ BrasilAPI::IBGE.find_state_by_code(53)
125
+ =>
126
+ {"id"=>53,
127
+ "sigla"=>"DF",
128
+ "nome"=>"Distrito Federal",
129
+ "regiao"=>{"id"=>5, "sigla"=>"CO", "nome"=>"Centro-Oeste"}}
130
+
131
+ # get cities by state abbreviation from ibge
132
+ BrasilAPI::IBGE.cities_by_state('CE')
133
+ =>
134
+ [{"nome"=>"ABAIARA", "codigo_ibge"=>"2300101"},
135
+ ...
136
+ {"nome"=>"VÁRZEA ALEGRE", "codigo_ibge"=>"2314003"},
137
+ {"nome"=>"VIÇOSA DO CEARÁ", "codigo_ibge"=>"2314102"}]
87
138
  ```
88
139
 
140
+
89
141
  # License
90
142
  [MIT](./LICENSE)
91
143
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class CVM < Base
5
+ class << self
6
+ def all
7
+ get("/cvm/corretoras/v1")
8
+ end
9
+
10
+ def find_by_cnpj(cnpj)
11
+ get("/cvm/corretoras/v1/#{cnpj}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class IBGE < Base
5
+ class << self
6
+ def states
7
+ get("/ibge/uf/v1")
8
+ end
9
+
10
+ def find_state_by_code(code)
11
+ get("/ibge/uf/v1/#{code}")
12
+ end
13
+
14
+ def cities_by_state(state_abbr, providers: [])
15
+ return get("/ibge/municipios/v1/#{state_abbr}") if providers.empty?
16
+
17
+ providers_query = providers.join(",")
18
+ get("/ibge/municipios/v1/#{state_abbr}?providers=#{providers_query}")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrasilAPI
4
- VERSION = "0.4.0"
4
+ VERSION = "0.6.0"
5
5
  end
data/lib/brasil_api.rb CHANGED
@@ -5,7 +5,9 @@ require_relative "brasil_api/base"
5
5
  require_relative "brasil_api/address"
6
6
  require_relative "brasil_api/bank"
7
7
  require_relative "brasil_api/company"
8
+ require_relative "brasil_api/cvm"
8
9
  require_relative "brasil_api/holiday"
10
+ require_relative "brasil_api/ibge"
9
11
 
10
12
  module BrasilAPI
11
13
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brasilapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dayvid Emerson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-30 00:00:00.000000000 Z
11
+ date: 2024-02-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Acesso programático de informações é algo fundamental na comunicação
14
14
  entre sistemas, mas, para nossa surpresa, uma informação tão útil e pública quanto
@@ -40,7 +40,9 @@ files:
40
40
  - lib/brasil_api/bank.rb
41
41
  - lib/brasil_api/base.rb
42
42
  - lib/brasil_api/company.rb
43
+ - lib/brasil_api/cvm.rb
43
44
  - lib/brasil_api/holiday.rb
45
+ - lib/brasil_api/ibge.rb
44
46
  - lib/brasil_api/version.rb
45
47
  - lib/brasilapi.rb
46
48
  homepage: https://brasilapi.com.br