service_client 0.1.10 → 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 +4 -4
- data/README.md +8 -14
- data/lib/service_client/errors.rb +2 -0
- data/lib/service_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d785d79f17da59bcbc444fc44744620c695b33d9a8c659ab6dd60bf804775ae
|
4
|
+
data.tar.gz: 941d815ff71420eeab33d24a99feaf822830d99f73152850f82892b5516e365d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9388925c566cef3738b13209a1f72f81578b460c56d238d2f62434d0e6abf7987cfecfc8f0e9b9ffdf2bc8f4ed37d446a475fdc7d7d7862ebdd8362a4114f98
|
7
|
+
data.tar.gz: 4bc5b7a97d1d7406764a5ee1bbd2cb30625787c63f4f6d752feffc3ca850e2a1bac021c52c85af9d41d0dea7be06dc45b0098a320527ff163f013aa866c3cf49
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
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,8 +26,7 @@ gem install service_client
|
|
26
26
|
|
27
27
|
Basic usage example:
|
28
28
|
|
29
|
-
|
30
|
-
<code class="code ruby">
|
29
|
+
```ruby
|
31
30
|
class CustomerClient < ServiceClient::Base
|
32
31
|
base_url 'https://api.com'
|
33
32
|
default_headers content_type: 'application/json'
|
@@ -53,13 +52,11 @@ class CustomerClient < ServiceClient::Base
|
|
53
52
|
puts e.message
|
54
53
|
end
|
55
54
|
end
|
56
|
-
|
57
|
-
</pre>
|
55
|
+
```
|
58
56
|
|
59
57
|
## Methods of class
|
60
58
|
|
61
|
-
|
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
|
-
|
75
|
-
</pre>
|
71
|
+
```
|
76
72
|
|
77
73
|
## Classes of errors
|
78
74
|
|
79
|
-
|
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
|
-
|
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
|
|
@@ -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
|
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.
|
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:
|
11
|
+
date: 2024-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|