brasilapi 0.5.1 → 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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +39 -1
- data/lib/brasil_api/ibge.rb +22 -0
- data/lib/brasil_api/version.rb +1 -1
- data/lib/brasil_api.rb +1 -0
- 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: 90984c3c65874f8182c32cf0117ecbec0b6c93595885323a7d8d23597788941f
|
4
|
+
data.tar.gz: f708ddf656929596da3ff1c8c44a30abedd6cdff120222edd6b007b0b878ca40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb1831e4435f2a28c0b6e5df7b822c5c65a84f65866096231742a98c87696c31c0058f06837a7b6b7860eb50874f4cdfb8a0f900727d7f32844990c5b9e966cd
|
7
|
+
data.tar.gz: 20193f1e912ca81e215760aa9bc7daaf5fefc9adbf82101da8889c21e6bca7365d79bd95f94d1b4aed8074902fa1b76363bb1a086935e1fd91eb26cd5991af5a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Dependency-less Brasil API lookup gem for brazilian data with an easy-to-use API
|
|
14
14
|
- [x] **DDD**
|
15
15
|
- [x] **Feriados Nacionais**
|
16
16
|
- [ ] **FIPE**
|
17
|
-
- [
|
17
|
+
- [x] **IBGE**
|
18
18
|
- [ ] **ISBN**
|
19
19
|
- [ ] **NCM**
|
20
20
|
- [ ] **PIX**
|
@@ -98,8 +98,46 @@ BrasilAPI::Holiday.by_year(2024)
|
|
98
98
|
[{"date"=>"2024-01-01", "name"=>"Confraternização mundial", "type"=>"national"},
|
99
99
|
...
|
100
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"}]
|
101
138
|
```
|
102
139
|
|
140
|
+
|
103
141
|
# License
|
104
142
|
[MIT](./LICENSE)
|
105
143
|
|
@@ -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
|
data/lib/brasil_api/version.rb
CHANGED
data/lib/brasil_api.rb
CHANGED
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
|
+
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:
|
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
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/brasil_api/company.rb
|
43
43
|
- lib/brasil_api/cvm.rb
|
44
44
|
- lib/brasil_api/holiday.rb
|
45
|
+
- lib/brasil_api/ibge.rb
|
45
46
|
- lib/brasil_api/version.rb
|
46
47
|
- lib/brasilapi.rb
|
47
48
|
homepage: https://brasilapi.com.br
|