service_client 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 346614efbcf2a797ae8cb217ab590cbeaa35b6d2c8b75c808b437411bec9cd5f
4
- data.tar.gz: 9e8957a321ced64da1f0f8ceae671f2005b28eed236f74f2fcdfaf0e7c87dc35
3
+ metadata.gz: 6b08c3ae1cd289404a362c7a57e3caafa43b0c5cb59cb3af1baeb9391dc8c59b
4
+ data.tar.gz: 6b3a8b21aba11b9cf2213f88a8f16c8df35bac58611791dde035738195a26b72
5
5
  SHA512:
6
- metadata.gz: edb896efd67024f3480f34cef5a589aaba511e05a08906c7def7f2c696bdf5fe7a4d6e323f49d1c4b634369b6a2cfe5b4eabb9f7515f684c11689f1a9845cc53
7
- data.tar.gz: d4c7f8a8564fb4a7b36715732a88dd2ba7f73819d75692e94c7d3f68cc288d704e242e6e90e27c3a652dc8e2845a55ba8fc93319c6a4401f4b4cc8686a1daa22
6
+ metadata.gz: bc58261c84dd5f89c3f88ba70d92cd74ddd6223effbc3784d5a436f0303e5d17000fc038d224266561e0adde28eac729e7f53d4888b393b6fb70f52b4bf0aae9
7
+ data.tar.gz: 85006dfbf928d9b63e34fc456bfa33a3556e9706cd4d9fc932eed424e4216846936b32bcddcd37422d5405e6e75e59a398afc9ec11c62f6db4b6caa5996836a2
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ ruby "2.7.1"
8
8
  gem "rake", "~> 12.0"
9
9
  gem "rspec", "~> 3.0"
10
10
  gem "httparty", "~> 0.18.0"
11
+ gem "rack", "~> 2.2.3"
data/Gemfile.lock CHANGED
@@ -7,6 +7,7 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ byebug (11.1.3)
10
11
  diff-lcs (1.5.0)
11
12
  httparty (0.18.1)
12
13
  mime-types (~> 3.0)
@@ -15,6 +16,7 @@ GEM
15
16
  mime-types-data (~> 3.2015)
16
17
  mime-types-data (3.2022.0105)
17
18
  multi_xml (0.6.0)
19
+ rack (2.2.6.2)
18
20
  rake (12.3.3)
19
21
  rspec (3.12.0)
20
22
  rspec-core (~> 3.12.0)
@@ -35,7 +37,9 @@ PLATFORMS
35
37
 
36
38
  DEPENDENCIES
37
39
  bundler (= 2.1.4)
40
+ byebug
38
41
  httparty (~> 0.18.0)
42
+ rack (~> 2.2.3)
39
43
  rake (~> 12.0)
40
44
  rspec (~> 3.0)
41
45
  service_client!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Alef ojeda de Oliveira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -22,7 +22,142 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Basic usage example:
26
+
27
+ ```ruby
28
+ class Request < ServiceClient::Call
29
+ def customer(id)
30
+ response = get("https://api.com/customers/#{id}")
31
+
32
+ response.data
33
+ rescue ServiceClient::Errors::NoDataFoundError => e
34
+ puts e.response.code # 404
35
+ puts e.response.headers
36
+ puts e.response.data
37
+ rescue ServiceClient::Errors::InternalServerError => e
38
+ puts e.response.code # 500
39
+ puts e.response.headers
40
+ puts e.response.data
41
+ # All errors of HTTP status code
42
+ end
43
+
44
+ def customers
45
+ get(nil)
46
+ rescue ServiceClient::ParamsRequired => e
47
+ puts e.message
48
+ end
49
+ end
50
+
51
+ ```
52
+
53
+ # Methods of class
54
+
55
+ ```ruby
56
+ # GET
57
+ ServiceClient::Call.get(url, headers:)
58
+
59
+ # POST
60
+ ServiceClient::Call.post(url, headers:, body:)
61
+
62
+ # PUT
63
+ ServiceClient::Call.put(url, headers:, body:)
64
+
65
+ # DELETE
66
+ ServiceClient::Call.delete(url, headers:, body:)
67
+ ```
68
+
69
+ # Classes of errors
70
+
71
+ ```ruby
72
+ # 400 – Bad Request
73
+ ServiceClient::Errors::BadRequestError
74
+ # 401 – Unauthorized
75
+ ServiceClient::Errors::UnauthorizedError
76
+ # 402 – Payment Required
77
+ ServiceClient::Errors::PaymentRequiredError
78
+ # 403 – Forbidden
79
+ ServiceClient::Errors::ForbiddenError
80
+ # 404 – Not Found
81
+ ServiceClient::Errors::NotFoundError
82
+ # 405 – Method Not Allowed
83
+ ServiceClient::Errors::MethodNotAllowedError
84
+ # 406 – Not Acceptable
85
+ ServiceClient::Errors::NotAcceptableError
86
+ # 407 – Proxy Authentication Required
87
+ ServiceClient::Errors::ProxyAuthenticationRequiredError
88
+ # 408 – Request Timeout
89
+ ServiceClient::Errors::RequestTimeoutError
90
+ # 409 – Conflict
91
+ ServiceClient::Errors::ConflictError
92
+ # 410 – Gone
93
+ ServiceClient::Errors::GoneError
94
+ # 411 – Length Required
95
+ ServiceClient::Errors::LengthRequiredError
96
+ # 412 – Precondition Failed
97
+ ServiceClient::Errors::PreconditionFailedError
98
+ # 413 – Request Entity Too Large
99
+ ServiceClient::Errors::RequestEntityTooLargeError
100
+ # 414 – Request-URI Too Long
101
+ ServiceClient::Errors::RequestURITooLongError
102
+ # 415 – Unsupported Media Type
103
+ ServiceClient::Errors::UnsupportedMediaTypeError
104
+ # 416 – Requested Range Not Satisfiable
105
+ ServiceClient::Errors::RequestedRangeNotSatisfiableError
106
+ # 417 – Expectation Failed
107
+ ServiceClient::Errors::ExpectationFailedError
108
+ # 420 – Enhance Your Calm
109
+ ServiceClient::Errors::EnhanceYourCalmError
110
+ # 422 – Unprocessable Entity
111
+ ServiceClient::Errors::UnprocessableEntityError
112
+ # 423 – Locked
113
+ ServiceClient::Errors::LockedError
114
+ # 424 – Failed Dependency
115
+ ServiceClient::Errors::FailedDependencyError
116
+ # 426 – Upgrade Required
117
+ ServiceClient::Errors::UpgradeRequiredError
118
+ # 428 – Precondition Required
119
+ ServiceClient::Errors::PreconditionRequiredError
120
+ # 429 – Too Many Requests
121
+ ServiceClient::Errors::TooManyRequestsError
122
+ # 431 – Request Header Fields Too Large
123
+ ServiceClient::Errors::RequestHeaderFieldsTooLargeError
124
+ # 444 – No Response
125
+ ServiceClient::Errors::NoResponseError
126
+ # 449 – Retry With
127
+ ServiceClient::Errors::RetryWithError
128
+ # 450 – Bllocked by Windows Parental Controls
129
+ ServiceClient::Errors::BlockedByWindowsParentalControlsError
130
+ # 451 – Unavailable For Legal Reasons
131
+ ServiceClient::Errors::UnavailableForLegalReasonsError
132
+ # 499 – Client Closed Request
133
+ ServiceClient::Errors::ClientClosedRequestError
134
+ # 500 – Internal Server Error
135
+ ServiceClient::Errors::InternalServerError
136
+ # 501 – Not Implemented
137
+ ServiceClient::Errors::NotImplementedError
138
+ # 502 – Bad Gateway
139
+ ServiceClient::Errors::BadGatewayError
140
+ # 503 – Service Unavailable
141
+ ServiceClient::Errors::ServiceUnavailableError
142
+ # 504 – Gateway Timeout
143
+ ServiceClient::Errors::GatewayTimeoutError
144
+ # 505 – HTTP Version Not Supported
145
+ ServiceClient::Errors::HTTPVersionNotSupportedError
146
+ # 506 – Variant Also Negotiates
147
+ ServiceClient::Errors::VariantAlsoNegotiatesError
148
+ # 507 – Insufficient Storage
149
+ ServiceClient::Errors::InsufficientStorageError
150
+ # 508 – Loop Detected
151
+ ServiceClient::Errors::LoopDetectedError
152
+ # 510 – Not Extended
153
+ ServiceClient::Errors::NotExtendedError
154
+ # 511 – Network Authentication Required
155
+ ServiceClient::Errors::NetworkAuthenticationRequiredError
156
+ # 598 – Network Read Timeout Error
157
+ ServiceClient::Errors::NetworkReadTimeoutError
158
+ # 599 – Network Connect Timeout Error
159
+ ServiceClient::Errors::NetworkConnectTimeoutError
160
+ ```
26
161
 
27
162
  ## Development
28
163
 
@@ -34,7 +169,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
169
 
35
170
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/service_client.
36
171
 
37
-
38
172
  ## License
39
173
 
40
174
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module ServiceClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -3,6 +3,7 @@ require_relative 'service_client/version'
3
3
  require_relative 'service_client/response'
4
4
  require_relative 'service_client/errors'
5
5
  require 'httparty'
6
+ require 'rack/utils'
6
7
 
7
8
  # Service Client
8
9
  module ServiceClient
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.0
4
+ version: 0.1.1
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-05 00:00:00.000000000 Z
11
+ date: 2023-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - Gemfile
49
49
  - Gemfile.lock
50
+ - LICENSE
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile