request-cnpj 0.1.0 → 0.1.1

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: 8107226372f6afef3e83e5bf0ca7a44c5024492d02f22eee29cbe062f5dd3a8c
4
- data.tar.gz: 17404f2e1f66e641cceb063929548a2e3dbc10ad8fe14cb3a2999b97650e9b49
3
+ metadata.gz: f7046d31cec1b83a5860306f5a7aeade2e5608c07122dfa9cbfdae11861f952d
4
+ data.tar.gz: 2d641f7cf06adfbbbbf63c514ea476d5cf19a3e7e59473adfdf6ee54176f2f2b
5
5
  SHA512:
6
- metadata.gz: 1e06229aa3c680ca81c4bd9ac786519a65408cf2666679a0c4ae3b28c29777151e848f171c93baf6170df246399882cfdf56d5a3f818562825eefbcc481ea131
7
- data.tar.gz: 3d2114d93c14947943c26e6f04c94a72e58f7ca9498f445e02316da05b7616d05f4d84d0b8fa8c8b28385d2b7f12fca6890290d789606cd7e8998083f1fbdc05
6
+ metadata.gz: d78586fcf8fab9cca497b145a6db81fa001327c16cbea675a2123cc6f34aacebcfb2914e698dd6b3d4c48b45d45c76f0f40b8dc99d36e68c630e1313fc0543ba
7
+ data.tar.gz: e01fddea0fa4b45ddead7a0e4a2bed1b2632c83ac7624003f538eadad2c9a2f70abd0042ad8dda1d19173f19e97678c5e76e89c3d64100ba488323ed695c82cb
@@ -5,7 +5,29 @@
5
5
  "Bash(curl -s -o /dev/null -w \"%{http_code}\\\\n\" --max-time 5 https://api.opencnpj.org/00000000000191)",
6
6
  "Bash(curl -s --max-time 5 https://api.opencnpj.org/00000000000191)",
7
7
  "Bash(curl -s -o /dev/null -w \"%{http_code}\\\\n\" --max-time 5 https://api.opencnpj.org/11111111111111)",
8
- "Bash(gem build *)"
8
+ "Bash(gem build *)",
9
+ "Bash(curl -s https://rubygems.org/api/v1/gems/request-cnpj.json)",
10
+ "Bash(ls -la ~/.gem/credentials 2>/dev/null && echo \"arquivo existe\" || echo \"arquivo nao encontrado\")",
11
+ "Read(//Users/moisesribeiro/.gem/**)",
12
+ "Bash(gem list *)",
13
+ "Bash(gem which *)",
14
+ "Bash(gem env *)",
15
+ "Bash(find /Users/moisesribeiro -maxdepth 3 -iname \"Gemfile\" 2>/dev/null)",
16
+ "Read(//Users/moisesribeiro/**)",
17
+ "Bash(grep -l \"request-cnpj\\\\|request/cnpj\\\\|cnpj_client\" -r /Users/moisesribeiro/river /Users/moisesribeiro/rivers /Users/moisesribeiro/debanco 2>/dev/null | grep -v node_modules)",
18
+ "Read(//Users/moisesribeiro/river/**)",
19
+ "Read(//Users/moisesribeiro/debanco/app/models/**)",
20
+ "Read(//Users/moisesribeiro/debanco/**)",
21
+ "Bash(grep -n \"class CNPJ\\\\|module CNPJ\" \"/Users/moisesribeiro/.rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/cpf_cnpj-1.0.1/lib/cpf_cnpj.rb\")",
22
+ "Read(//Users/moisesribeiro/.rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/cpf_cnpj-1.0.1/lib/**)",
23
+ "Bash(grep -rn \"class CNPJ\\\\|module CNPJ\" \"/Users/moisesribeiro/.rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/cpf_cnpj-1.0.1/lib/\")",
24
+ "Bash(grep -n \"^gem \" /Users/moisesribeiro/debanco/Gemfile | head -20)",
25
+ "Bash(gem search *)",
26
+ "Bash(grep -E '\\\\.gem$|request-cnpj-0.1.0')",
27
+ "Bash(git rm *)"
28
+ ],
29
+ "additionalDirectories": [
30
+ "/Users/moisesribeiro/debanco"
9
31
  ]
10
32
  }
11
33
  }
@@ -6,33 +6,20 @@ module Request
6
6
  class BaseClient
7
7
  protected
8
8
 
9
- def get(path = nil, params: nil, headers: default_headers, url: url_for(path, **params.to_h), &)
9
+ def get(path = nil, params: nil, headers: { accept: 'application/json' }, url: url(path, **params.to_h), &)
10
10
  execute(method: :get, url:, headers:, &)
11
11
  end
12
12
 
13
13
  def execute(**)
14
- response = executor.execute(**default_execute_options, **)
14
+ response = rest_client.execute(**)
15
15
 
16
16
  return yield response if block_given?
17
17
 
18
18
  response.body
19
19
  end
20
20
 
21
- def default_headers
22
- {
23
- accept: 'application/json'
24
- }
25
- end
26
-
27
- def default_execute_options
28
- {}
29
- end
30
-
31
- def url_for(path, **params)
32
- URI('https://api.opencnpj.org').tap do |uri|
33
- uri.path += path
34
- uri.query = params.to_query if params.any?
35
- end.to_s
21
+ def url(path)
22
+ URI('https://api.opencnpj.org').tap { |uri| uri.path += path }.to_s
36
23
  end
37
24
  end
38
25
  end
@@ -4,11 +4,11 @@ module Request
4
4
  module Cnpj
5
5
  # Client for fetching CNPJ data from the OpenCNPJ API.
6
6
  class Client < BaseClient
7
- attr_reader :url, :executor
7
+ attr_reader :url, :rest_client
8
8
 
9
- def initialize(executor: RestClient::Request)
9
+ def initialize(rest_client: RestClient::Request)
10
10
  super()
11
- @executor = executor
11
+ @rest_client = rest_client
12
12
  end
13
13
 
14
14
  # Method to request CNPJ to API
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Request
4
4
  module Cnpj
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request-cnpj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moisés Ribeiro