service_client 0.1.9 → 0.1.11

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: 3f2fa6e4467eeebb62c415fe9bc02200a756b2120a5a81bb5b5a02bd1334830b
4
- data.tar.gz: 87edd53292d35452425c96b48d90fe9fecce793b94631e45931332f82dbb7256
3
+ metadata.gz: 7d785d79f17da59bcbc444fc44744620c695b33d9a8c659ab6dd60bf804775ae
4
+ data.tar.gz: 941d815ff71420eeab33d24a99feaf822830d99f73152850f82892b5516e365d
5
5
  SHA512:
6
- metadata.gz: e64c653c4cb28ba78520a03a888a576e85755655a186f99d147ee96754b7be9612c628f4d28b5914958fff8b0e03571cf7362ae1c0baf6b4fe0bfed91bc4aa17
7
- data.tar.gz: 3bbcfb5be8fac7a4412e93e09fba5f063640867d829b4512b367d8c007511bcf6edc36c05c666621aa38004662f395c78f8d0206c99e31a9270bb39d935c655c
6
+ metadata.gz: f9388925c566cef3738b13209a1f72f81578b460c56d238d2f62434d0e6abf7987cfecfc8f0e9b9ffdf2bc8f4ed37d446a475fdc7d7d7862ebdd8362a4114f98
7
+ data.tar.gz: 4bc5b7a97d1d7406764a5ee1bbd2cb30625787c63f4f6d752feffc3ca850e2a1bac021c52c85af9d41d0dea7be06dc45b0098a320527ff163f013aa866c3cf49
data/Gemfile CHANGED
@@ -1,11 +1,13 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in service_client.gemspec
4
6
  gemspec
5
7
 
6
- ruby "2.7.1"
8
+ ruby '2.7.1'
7
9
 
8
- gem "rake", "~> 12.0"
9
- gem "rspec", "~> 3.0"
10
- gem "httparty", "~> 0.18.0"
11
- gem "rack", "~> 2.2.3"
10
+ gem 'httparty', '~> 0.21.0'
11
+ gem 'rack', '~> 2.2.3'
12
+ gem 'rake', '~> 12.0'
13
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,19 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- service_client (0.1.8)
5
- httparty (~> 0.18.0)
4
+ service_client (0.1.10)
5
+ httparty (~> 0.21.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.5.0)
11
- httparty (0.18.1)
12
- mime-types (~> 3.0)
11
+ httparty (0.21.0)
12
+ mini_mime (>= 1.0.0)
13
13
  multi_xml (>= 0.5.2)
14
- mime-types (3.4.1)
15
- mime-types-data (~> 3.2015)
16
- mime-types-data (3.2022.0105)
14
+ mini_mime (1.1.2)
17
15
  multi_xml (0.6.0)
18
16
  rack (2.2.6.2)
19
17
  rake (12.3.3)
@@ -36,7 +34,7 @@ PLATFORMS
36
34
 
37
35
  DEPENDENCIES
38
36
  bundler (= 2.1.4)
39
- httparty (~> 0.18.0)
37
+ httparty (~> 0.21.0)
40
38
  rack (~> 2.2.3)
41
39
  rake (~> 12.0)
42
40
  rspec (~> 3.0)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ServiceClient
1
+ *# ServiceClient
2
2
 
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/service_client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
@@ -26,9 +26,8 @@ gem install service_client
26
26
 
27
27
  Basic usage example:
28
28
 
29
- <pre>
30
- <code>
31
- class CustomerClientServiceClient::Base
29
+ ```ruby
30
+ class CustomerClient < ServiceClient::Base
32
31
  base_url 'https://api.com'
33
32
  default_headers content_type: 'application/json'
34
33
 
@@ -53,13 +52,11 @@ class CustomerClientServiceClient::Base
53
52
  puts e.message
54
53
  end
55
54
  end
56
- </code>
57
- </pre>
55
+ ```
58
56
 
59
57
  ## Methods of class
60
58
 
61
- <pre>
62
- <code>
59
+ ```ruby
63
60
  # GET
64
61
  ServiceClient::Base.get(url, headers:)
65
62
 
@@ -71,13 +68,11 @@ ServiceClient::Base.put(url, headers:, body:)
71
68
 
72
69
  # DELETE
73
70
  ServiceClient::Base.delete(url, headers:, body:)
74
- </code>
75
- </pre>
71
+ ```
76
72
 
77
73
  ## Classes of errors
78
74
 
79
- <pre>
80
- <code>
75
+ ```ruby
81
76
  # 400 – Bad Request
82
77
  ServiceClient::Errors::BadRequestError
83
78
  # 401 – Unauthorized
@@ -166,8 +161,7 @@ ServiceClient::Base.delete(url, headers:, body:)
166
161
  ServiceClient::Errors::NetworkReadTimeoutError
167
162
  # 599 – Network Connect Timeout Error
168
163
  ServiceClient::Errors::NetworkConnectTimeoutError
169
- </code>
170
- </pre>
164
+ ```
171
165
 
172
166
  ## Development
173
167
 
@@ -177,7 +171,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
177
171
 
178
172
  ## Contributing
179
173
 
180
- Bug reports and pull requests are welcome on GitHub at https://github.com/nemuba/service_client.
174
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/nemuba/service_client>.
181
175
 
182
176
  ## License
183
177
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "service_client"
4
+ require 'bundler/setup'
5
+ require 'service_client'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "service_client"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -9,6 +9,7 @@ module ServiceClient
9
9
  # @example Raise an error if any of the required params are nil.
10
10
  # raise ParamsRequired, "Params: #{params_required(params)} are required" if params_nil?(params)
11
11
  class ParamsRequired < StandardError; end
12
+
12
13
  # This class provides a lightweight and flexible way to make HTTP requests
13
14
  # in Ruby projects.
14
15
  #
@@ -96,7 +97,7 @@ module ServiceClient
96
97
  end
97
98
 
98
99
  # Raises an error if any of the required params are nil.
99
- #
100
+ #
100
101
  # @param params [Hash] the params to check for nil values
101
102
  # @raise [ParamsRequired] if any of the params are nil
102
103
  # @return [nil] if all params are not nil
@@ -155,7 +155,7 @@ module ServiceClient
155
155
  '510': NotExtendedError,
156
156
  '511': NetworkAuthenticationRequiredError,
157
157
  '598': NetworkReadTimeoutError,
158
- '599': NetworkConnectTimeoutError,
158
+ '599': NetworkConnectTimeoutError
159
159
  }.freeze
160
160
 
161
161
  # Raises an error based on the given HTTP response.
@@ -165,6 +165,8 @@ module ServiceClient
165
165
  # raise [BaseError] The error that corresponds to the given HTTP response code.
166
166
  # @return [void]
167
167
  def raise_error(code, response)
168
+ raise BaseError.new('Unknown error', response) if [code, response].any?(&:nil?)
169
+
168
170
  raise ERRORS[code.to_sym].new(ERRORS[code.to_sym].class.name, response)
169
171
  end
170
172
  end
@@ -40,7 +40,8 @@ module ServiceClient
40
40
  #
41
41
  # @param response [HTTParty::Response] The HTTP response object.
42
42
  # @return [ServiceClient::Response] Returns itself if the response was successful.
43
- # @raise [ServiceClient::Error] Raises an error with the response code and object if the response was unsuccessful.
43
+ # @raise [ServiceClient::Error] Raises an error with the response code
44
+ # and object if the response was unsuccessful.
44
45
  def call(response)
45
46
  new(response).call
46
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ServiceClient
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alef Ojeda de Oliveira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-25 00:00:00.000000000 Z
11
+ date: 2024-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.18.0
33
+ version: 0.21.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.18.0
40
+ version: 0.21.0
41
41
  description: Service client
42
42
  email:
43
43
  - alef.oliveira@dimensa.com.br
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.4.7
149
+ rubygems_version: 3.1.2
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Service client