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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40af8e101ebaefb3a05d6e4eb5bf756b6e0fb5feac9bd1b7df9d6aeeb920ee7e
4
- data.tar.gz: dd7b7cb583665180ef77b39e040a585b8746fc53a4ecfc1ec7821d19f01e26d3
3
+ metadata.gz: 90984c3c65874f8182c32cf0117ecbec0b6c93595885323a7d8d23597788941f
4
+ data.tar.gz: f708ddf656929596da3ff1c8c44a30abedd6cdff120222edd6b007b0b878ca40
5
5
  SHA512:
6
- metadata.gz: 0a2b7630a8d5eef7358231019feaeed5610969b09357e439128f138e1456d89fc0cdddc211fa4c1cd3bec363913b192bcab0639e9f034ff4121710a15c6e4f87
7
- data.tar.gz: 9841a7a7fc7df413fee19810872969b9290ec2dbb93a7519acea864a2953327dc80d0ce0bca028a8c6d042f368cdafad1774ac56b489d5cd7d1d1228127884c2
6
+ metadata.gz: cb1831e4435f2a28c0b6e5df7b822c5c65a84f65866096231742a98c87696c31c0058f06837a7b6b7860eb50874f4cdfb8a0f900727d7f32844990c5b9e966cd
7
+ data.tar.gz: 20193f1e912ca81e215760aa9bc7daaf5fefc9adbf82101da8889c21e6bca7365d79bd95f94d1b4aed8074902fa1b76363bb1a086935e1fd91eb26cd5991af5a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] - 2024-02-25
4
+
5
+ - Integração da API do IBGE
6
+
3
7
  ## [0.5.1] - 2023-12-01
4
8
 
5
9
  - Corrigindo versão publicada no RubyGems
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brasilapi (0.5.1)
4
+ brasilapi (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- - [ ] **IBGE**
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrasilAPI
4
- VERSION = "0.5.1"
4
+ VERSION = "0.6.0"
5
5
  end
data/lib/brasil_api.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "brasil_api/bank"
7
7
  require_relative "brasil_api/company"
8
8
  require_relative "brasil_api/cvm"
9
9
  require_relative "brasil_api/holiday"
10
+ require_relative "brasil_api/ibge"
10
11
 
11
12
  module BrasilAPI
12
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.5.1
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-12-01 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
@@ -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