request-cnpj 0.1.0 → 0.1.2

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: 27d42d12ac65fda77337f9a6f5fddf10f17a7f9c7fbfe7e72f5a8d0222122c3e
4
+ data.tar.gz: 4af1a855108175c9e30a2367d00d728d0319d36f3fa0030e8d447bb189933c15
5
5
  SHA512:
6
- metadata.gz: 1e06229aa3c680ca81c4bd9ac786519a65408cf2666679a0c4ae3b28c29777151e848f171c93baf6170df246399882cfdf56d5a3f818562825eefbcc481ea131
7
- data.tar.gz: 3d2114d93c14947943c26e6f04c94a72e58f7ca9498f445e02316da05b7616d05f4d84d0b8fa8c8b28385d2b7f12fca6890290d789606cd7e8998083f1fbdc05
6
+ metadata.gz: 52346216291b627f72b8ec32812e703f8c770896981b691ffc47e4b473e450ab02255566504e5d37d20c3cc6fddeedcb1aaa56d98c2936538c3e4bf6982816f9
7
+ data.tar.gz: aacf22d7a4e249017a03f1b6ef22bdda465ec7afd2510daf8d07fbbc53da88e4e426d8bdd27fa882cd6085219a7ec6727cf6ceb0b5c7d10563660c05653608d4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2026-07-31
4
+
5
+ - Rename `application_client.rb` and related cleanup
6
+
3
7
  ## [0.1.0] - 2026-05-05
4
8
 
5
9
  - Initial release
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Request
4
+ module Cnpj
5
+ # Base class for CNPJ request clients, providing shared execution logic.
6
+ class ApplicationClient
7
+ protected
8
+
9
+ def get(path = nil, headers: { accept: 'application/json' }, url: url(path, **params.to_h))
10
+ execute(method: :get, url:, headers:)
11
+ end
12
+
13
+ def execute(**)
14
+ response = rest_client.execute(**)
15
+
16
+ return yield response if block_given?
17
+
18
+ response.body
19
+ end
20
+
21
+ def url(path)
22
+ URI('https://api.opencnpj.org').tap { |uri| uri.path += path }.to_s
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,12 +3,12 @@
3
3
  module Request
4
4
  module Cnpj
5
5
  # Client for fetching CNPJ data from the OpenCNPJ API.
6
- class Client < BaseClient
7
- attr_reader :url, :executor
6
+ class Client < ApplicationClient
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.2'
6
6
  end
7
7
  end
data/lib/request/cnpj.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'json'
4
4
  require 'rest-client'
5
5
  require_relative 'cnpj/version'
6
- require_relative 'cnpj/base_client'
6
+ require_relative 'cnpj/application_client'
7
7
  require_relative 'cnpj/client'
8
8
 
9
9
  module Request
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moisés Ribeiro
@@ -17,14 +17,13 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".claude/settings.json"
21
20
  - CHANGELOG.md
22
21
  - CODE_OF_CONDUCT.md
23
22
  - README.md
24
23
  - README.pt-BR.md
25
24
  - Rakefile
26
25
  - lib/request/cnpj.rb
27
- - lib/request/cnpj/base_client.rb
26
+ - lib/request/cnpj/application_client.rb
28
27
  - lib/request/cnpj/client.rb
29
28
  - lib/request/cnpj/version.rb
30
29
  - sig/request/cnpj.rbs
@@ -1,11 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(bundle install *)",
5
- "Bash(curl -s -o /dev/null -w \"%{http_code}\\\\n\" --max-time 5 https://api.opencnpj.org/00000000000191)",
6
- "Bash(curl -s --max-time 5 https://api.opencnpj.org/00000000000191)",
7
- "Bash(curl -s -o /dev/null -w \"%{http_code}\\\\n\" --max-time 5 https://api.opencnpj.org/11111111111111)",
8
- "Bash(gem build *)"
9
- ]
10
- }
11
- }
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Request
4
- module Cnpj
5
- # Base class for CNPJ request clients, providing shared execution logic.
6
- class BaseClient
7
- protected
8
-
9
- def get(path = nil, params: nil, headers: default_headers, url: url_for(path, **params.to_h), &)
10
- execute(method: :get, url:, headers:, &)
11
- end
12
-
13
- def execute(**)
14
- response = executor.execute(**default_execute_options, **)
15
-
16
- return yield response if block_given?
17
-
18
- response.body
19
- end
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
36
- end
37
- end
38
- end
39
- end