brasilapi 0.6.0 → 0.7.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: 90984c3c65874f8182c32cf0117ecbec0b6c93595885323a7d8d23597788941f
4
- data.tar.gz: f708ddf656929596da3ff1c8c44a30abedd6cdff120222edd6b007b0b878ca40
3
+ metadata.gz: 2d4feae01c7e83e53c8f30fe32b71bb335e64d17a05874b0e465abc695ba518a
4
+ data.tar.gz: 8d36f60325e36d611da49f21a513fbe6e8551fea5f44446e7b9106c6d16ae221
5
5
  SHA512:
6
- metadata.gz: cb1831e4435f2a28c0b6e5df7b822c5c65a84f65866096231742a98c87696c31c0058f06837a7b6b7860eb50874f4cdfb8a0f900727d7f32844990c5b9e966cd
7
- data.tar.gz: 20193f1e912ca81e215760aa9bc7daaf5fefc9adbf82101da8889c21e6bca7365d79bd95f94d1b4aed8074902fa1b76363bb1a086935e1fd91eb26cd5991af5a
6
+ metadata.gz: df32ff8fb00d74216638a81b683e1ca95abd42be4f0404deff5ada20ec1b52d411711a854aed8c4650e93b76d81ac587dab67db54c08abfa36907fbf9c987de8
7
+ data.tar.gz: 005a4a9b91af86ad408f2f8fb5293d5285b2a974b4720d9b884c2e657f84286add533d0ed6a2d3cea75105c3ed4583ea89738fa44396b4e94430c421ba011b39
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.0] - 2025-04-21
4
+
5
+ - Integração da API do CPTEC
6
+ - Integração da API da Tabela FIPE
7
+ - Integração da API de ISBN
8
+ - Integração da API de NCM
9
+ - Integração da API de PIX
10
+ - Integração da API de Registros BR
11
+ - Integração da API de Taxas
12
+
3
13
  ## [0.6.0] - 2024-02-25
4
14
 
5
15
  - Integração da API do IBGE
data/Gemfile CHANGED
@@ -9,6 +9,6 @@ group :development do
9
9
  gem "rspec", "~> 3.0"
10
10
  gem "rubocop", "~> 1.21"
11
11
  gem "rubocop-rspec", "~> 2.24"
12
- gem "vcr", "~> 6.2"
13
- gem "webmock", "~> 3.19"
12
+ gem "vcr", "~> 6.3"
13
+ gem "webmock", "~> 3.25"
14
14
  end
data/Gemfile.lock CHANGED
@@ -1,31 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brasilapi (0.6.0)
4
+ brasilapi (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- addressable (2.8.5)
10
- public_suffix (>= 2.0.2, < 6.0)
9
+ addressable (2.8.7)
10
+ public_suffix (>= 2.0.2, < 7.0)
11
11
  ast (2.4.2)
12
12
  base64 (0.1.1)
13
- crack (0.4.5)
13
+ bigdecimal (3.1.9)
14
+ crack (1.0.0)
15
+ bigdecimal
14
16
  rexml
15
17
  diff-lcs (1.5.0)
16
- hashdiff (1.0.1)
18
+ hashdiff (1.1.2)
17
19
  json (2.6.3)
18
20
  language_server-protocol (3.17.0.3)
19
21
  parallel (1.23.0)
20
22
  parser (3.2.2.4)
21
23
  ast (~> 2.4.1)
22
24
  racc
23
- public_suffix (5.0.3)
25
+ public_suffix (6.0.1)
24
26
  racc (1.7.1)
25
27
  rainbow (3.1.1)
26
28
  rake (13.0.6)
27
29
  regexp_parser (2.8.2)
28
- rexml (3.2.6)
30
+ rexml (3.4.1)
29
31
  rspec (3.12.0)
30
32
  rspec-core (~> 3.12.0)
31
33
  rspec-expectations (~> 3.12.0)
@@ -63,8 +65,9 @@ GEM
63
65
  rubocop-factory_bot (~> 2.22)
64
66
  ruby-progressbar (1.13.0)
65
67
  unicode-display_width (2.5.0)
66
- vcr (6.2.0)
67
- webmock (3.19.1)
68
+ vcr (6.3.1)
69
+ base64
70
+ webmock (3.25.1)
68
71
  addressable (>= 2.8.0)
69
72
  crack (>= 0.3.2)
70
73
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -78,8 +81,8 @@ DEPENDENCIES
78
81
  rspec (~> 3.0)
79
82
  rubocop (~> 1.21)
80
83
  rubocop-rspec (~> 2.24)
81
- vcr (~> 6.2)
82
- webmock (~> 3.19)
84
+ vcr (~> 6.3)
85
+ webmock (~> 3.25)
83
86
 
84
87
  BUNDLED WITH
85
88
  2.4.10
data/README.md CHANGED
@@ -10,16 +10,16 @@ Dependency-less Brasil API lookup gem for brazilian data with an easy-to-use API
10
10
  - [x] **CEP (Zip code)**
11
11
  - [x] **CNPJ**
12
12
  - [x] **Corretoras**
13
- - [ ] **CPTEC**
13
+ - [x] **CPTEC**
14
14
  - [x] **DDD**
15
15
  - [x] **Feriados Nacionais**
16
- - [ ] **FIPE**
16
+ - [x] **FIPE**
17
17
  - [x] **IBGE**
18
- - [ ] **ISBN**
19
- - [ ] **NCM**
20
- - [ ] **PIX**
21
- - [ ] **Registros BR**
22
- - [ ] **Taxas**
18
+ - [x] **ISBN**
19
+ - [x] **NCM**
20
+ - [x] **PIX**
21
+ - [x] **Registros BR**
22
+ - [x] **Taxas**
23
23
 
24
24
  ## Installation
25
25
 
@@ -6,11 +6,17 @@ require "net/http"
6
6
  module BrasilAPI
7
7
  class Base
8
8
  BASE_URL = "https://brasilapi.com.br/api"
9
-
10
9
  class << self
11
- def get(path)
10
+ def get(path, params = {})
12
11
  uri = URI("#{BASE_URL}#{path}")
12
+ uri.query = URI.encode_www_form(params) if params.any?
13
+
14
+ request_data(uri)
15
+ end
13
16
 
17
+ protected
18
+
19
+ def request_data(uri)
14
20
  response = Net::HTTP.get_response(uri)
15
21
 
16
22
  case status_for(response)
@@ -23,8 +29,6 @@ module BrasilAPI
23
29
  end
24
30
  end
25
31
 
26
- protected
27
-
28
32
  def status_for(response)
29
33
  status = {
30
34
  Net::HTTPOK => 200,
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class CPTEC < Base
5
+ class << self
6
+ def all
7
+ get("/cptec/v1/cidade")
8
+ end
9
+
10
+ def search_location(city_name)
11
+ get("/cptec/v1/cidade/#{city_name}")
12
+ end
13
+
14
+ def capital_weather
15
+ get("/cptec/v1/clima/capital")
16
+ end
17
+
18
+ def airport_weather(code)
19
+ get("/cptec/v1/clima/aeroporto/#{code}")
20
+ end
21
+
22
+ def city_weather(city_code, days = nil)
23
+ if days
24
+ get("/cptec/v1/clima/previsao/#{city_code}/#{days}")
25
+ else
26
+ get("/cptec/v1/clima/previsao/#{city_code}")
27
+ end
28
+ end
29
+
30
+ def ocean_forecast(city_code, days = nil)
31
+ if days
32
+ get("/cptec/v1/ondas/#{city_code}/#{days}")
33
+ else
34
+ get("/cptec/v1/ondas/#{city_code}")
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class FIPE < Base
5
+ class << self
6
+ # https://brasilapi.com.br/api/fipe/marcas/v1/{tipoVeiculo}
7
+ def vehicle_brands(vehicle_type, reference_table = nil)
8
+ get("/fipe/marcas/v1/#{vehicle_type}", { tabela_referencia: reference_table })
9
+ end
10
+
11
+ # https://brasilapi.com.br/api/fipe/preco/v1/{codigoFipe}
12
+ def vehicle_price(vehicle_code, reference_table = nil)
13
+ get("/fipe/preco/v1/#{vehicle_code}", { tabela_referencia: reference_table })
14
+ end
15
+
16
+ # https://brasilapi.com.br/api/fipe/tabelas/v1
17
+ def fipe_tables
18
+ get("/fipe/tabelas/v1")
19
+ end
20
+
21
+ # https://brasilapi.com.br/api/fipe/veiculos/v1/{tipoVeiculo}/{codigoMarca}
22
+ def list_vehicles(vehicle_type, brand_code, reference_table = nil)
23
+ get("/fipe/veiculos/v1/#{vehicle_type}/#{brand_code}", { tabela_referencia: reference_table })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -14,8 +14,7 @@ module BrasilAPI
14
14
  def cities_by_state(state_abbr, providers: [])
15
15
  return get("/ibge/municipios/v1/#{state_abbr}") if providers.empty?
16
16
 
17
- providers_query = providers.join(",")
18
- get("/ibge/municipios/v1/#{state_abbr}?providers=#{providers_query}")
17
+ get("/ibge/municipios/v1/#{state_abbr}", providers: providers.join(","))
19
18
  end
20
19
  end
21
20
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class ISBN < Base
5
+ class << self
6
+ def search(code, providers: [])
7
+ return get("/isbn/v1/#{code}") if providers.empty?
8
+
9
+ get("/isbn/v1/#{code}", providers: providers.join(","))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class NCM < Base
5
+ class << self
6
+ def all
7
+ get("/ncm/v1")
8
+ end
9
+
10
+ def search(code)
11
+ get("/ncm/v1", { search: code })
12
+ end
13
+
14
+ def find_by_code(code)
15
+ get("/ncm/v1/#{code}")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class PIX < Base
5
+ class << self
6
+ def all
7
+ get("/pix/v1/participants")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class RegistroBR < Base
5
+ class << self
6
+ def whois(domain)
7
+ get("/registrobr/v1/#{domain}")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrasilAPI
4
+ class Taxas < Base
5
+ class << self
6
+ def all
7
+ get("/taxas/v1")
8
+ end
9
+
10
+ def find_by_name(name)
11
+ get("/taxas/v1/#{name}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrasilAPI
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/brasil_api.rb CHANGED
@@ -8,6 +8,13 @@ require_relative "brasil_api/company"
8
8
  require_relative "brasil_api/cvm"
9
9
  require_relative "brasil_api/holiday"
10
10
  require_relative "brasil_api/ibge"
11
+ require_relative "brasil_api/cptec"
12
+ require_relative "brasil_api/fipe"
13
+ require_relative "brasil_api/isbn"
14
+ require_relative "brasil_api/ncm"
15
+ require_relative "brasil_api/pix"
16
+ require_relative "brasil_api/registrobr"
17
+ require_relative "brasil_api/taxas"
11
18
 
12
19
  module BrasilAPI
13
20
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brasilapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dayvid Emerson
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-02-25 00:00:00.000000000 Z
10
+ date: 2025-04-21 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Acesso programático de informações é algo fundamental na comunicação
14
13
  entre sistemas, mas, para nossa surpresa, uma informação tão útil e pública quanto
@@ -40,9 +39,16 @@ files:
40
39
  - lib/brasil_api/bank.rb
41
40
  - lib/brasil_api/base.rb
42
41
  - lib/brasil_api/company.rb
42
+ - lib/brasil_api/cptec.rb
43
43
  - lib/brasil_api/cvm.rb
44
+ - lib/brasil_api/fipe.rb
44
45
  - lib/brasil_api/holiday.rb
45
46
  - lib/brasil_api/ibge.rb
47
+ - lib/brasil_api/isbn.rb
48
+ - lib/brasil_api/ncm.rb
49
+ - lib/brasil_api/pix.rb
50
+ - lib/brasil_api/registrobr.rb
51
+ - lib/brasil_api/taxas.rb
46
52
  - lib/brasil_api/version.rb
47
53
  - lib/brasilapi.rb
48
54
  homepage: https://brasilapi.com.br
@@ -53,7 +59,6 @@ metadata:
53
59
  source_code_uri: https://github.com/dayvidemerson/brasilapi-rb
54
60
  changelog_uri: https://github.com/dayvidemerson/brasilapi-rb/blob/main/CHANGELOG.md
55
61
  rubygems_mfa_required: 'true'
56
- post_install_message:
57
62
  rdoc_options: []
58
63
  require_paths:
59
64
  - lib
@@ -68,8 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
73
  - !ruby/object:Gem::Version
69
74
  version: '0'
70
75
  requirements: []
71
- rubygems_version: 3.4.10
72
- signing_key:
76
+ rubygems_version: 3.6.2
73
77
  specification_version: 4
74
78
  summary: Cliente desenvolvido em Ruby para o consumo da Brasil API que permite buscar
75
79
  informações públicas referentes ao Brasil de modo eficiente e simplificado.