api_client 0.5.9 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/api_client/connection/basic.rb +10 -8
- data/lib/api_client/errors.rb +1 -0
- data/lib/api_client/version.rb +1 -1
- data/spec/api_client/connection/basic_spec.rb +19 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa72f20faca901deb66fb6f1b73599829a0ef633
|
4
|
+
data.tar.gz: 38f72c8e3f27ec6c708bba8aa6cc22a2729f0e40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9414f6a69354c668012ce321773f83d45e845cf109dbe0a3e4b77146ba986bac7b866ba13cd187dc4c3bac3b05d4c4f6dd8a2939562cf31a4a93f1ca13f6de
|
7
|
+
data.tar.gz: e4195081871e961a05ec586042de5b9aad01c0e92143a5abc4b5c5298e8842a2d8759976c96d46c53a21ecebbda92c47031203837b03c7a90ccf7bf36118d532
|
data/CHANGELOG.md
CHANGED
@@ -83,26 +83,28 @@ module ApiClient
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def handle_response(request, response)
|
86
|
-
raise ApiClient::Errors::ConnectionFailed.new(request, response) unless response
|
86
|
+
raise ApiClient::Errors::ConnectionFailed.new(nil, request, response) unless response
|
87
87
|
case response.status
|
88
88
|
when 401
|
89
|
-
raise ApiClient::Errors::Unauthorized.new(request, response)
|
89
|
+
raise ApiClient::Errors::Unauthorized.new(nil, request, response)
|
90
90
|
when 403
|
91
|
-
raise ApiClient::Errors::Forbidden.new(request, response)
|
91
|
+
raise ApiClient::Errors::Forbidden.new(nil, request, response)
|
92
92
|
when 404
|
93
|
-
raise ApiClient::Errors::NotFound.new(request, response)
|
93
|
+
raise ApiClient::Errors::NotFound.new(nil, request, response)
|
94
94
|
when 400
|
95
|
-
raise ApiClient::Errors::BadRequest.new(request, response)
|
95
|
+
raise ApiClient::Errors::BadRequest.new(nil, request, response)
|
96
96
|
when 406
|
97
|
-
raise ApiClient::Errors::Unsupported.new(request, response)
|
97
|
+
raise ApiClient::Errors::Unsupported.new(nil, request, response)
|
98
98
|
when 409
|
99
|
-
raise ApiClient::Errors::Conflict.new(request, response)
|
99
|
+
raise ApiClient::Errors::Conflict.new(nil, request, response)
|
100
100
|
when 422
|
101
101
|
raise ApiClient::Errors::UnprocessableEntity.new(response.body, request, response)
|
102
|
+
when 429
|
103
|
+
raise ApiClient::Errors::TooManyRequests.new(response.body, request, response)
|
102
104
|
when 300..399
|
103
105
|
raise ApiClient::Errors::Redirect.new(response['Location'], request, response)
|
104
106
|
when 500..599
|
105
|
-
raise ApiClient::Errors::ServerError.new(request, response)
|
107
|
+
raise ApiClient::Errors::ServerError.new(nil, request, response)
|
106
108
|
else
|
107
109
|
response
|
108
110
|
end
|
data/lib/api_client/errors.rb
CHANGED
data/lib/api_client/version.rb
CHANGED
@@ -89,71 +89,79 @@ describe ApiClient::Connection::Basic do
|
|
89
89
|
it "raises an ApiClient::Errors::ConnectionFailed if there is no response" do
|
90
90
|
lambda {
|
91
91
|
@instance.send :handle_response, request, nil
|
92
|
-
}.should raise_error(ApiClient::Errors::ConnectionFailed)
|
92
|
+
}.should raise_error(ApiClient::Errors::ConnectionFailed, "ApiClient::Errors::ConnectionFailed")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "raises an ApiClient::Errors::Unauthorized if status is 401" do
|
96
96
|
@response.env[:status] = 401
|
97
97
|
lambda {
|
98
98
|
@instance.send :handle_response, request, @response
|
99
|
-
}.should raise_error(ApiClient::Errors::Unauthorized)
|
99
|
+
}.should raise_error(ApiClient::Errors::Unauthorized, "ApiClient::Errors::Unauthorized")
|
100
100
|
end
|
101
101
|
|
102
102
|
it "raises an ApiClient::Errors::Forbidden if status is 403" do
|
103
103
|
@response.env[:status] = 403
|
104
104
|
lambda {
|
105
105
|
@instance.send :handle_response, request, @response
|
106
|
-
}.should raise_error(ApiClient::Errors::Forbidden)
|
106
|
+
}.should raise_error(ApiClient::Errors::Forbidden, "ApiClient::Errors::Forbidden")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "raises an ApiClient::Errors::NotFound if status is 404" do
|
110
110
|
@response.env[:status] = 404
|
111
111
|
lambda {
|
112
112
|
@instance.send :handle_response, request, @response
|
113
|
-
}.should raise_error(ApiClient::Errors::NotFound)
|
113
|
+
}.should raise_error(ApiClient::Errors::NotFound, "ApiClient::Errors::NotFound")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "raises an ApiClient::Errors::BadRequest if status is 400" do
|
117
117
|
@response.env[:status] = 400
|
118
118
|
lambda {
|
119
119
|
@instance.send :handle_response, request, @response
|
120
|
-
}.should raise_error(ApiClient::Errors::BadRequest)
|
120
|
+
}.should raise_error(ApiClient::Errors::BadRequest, "ApiClient::Errors::BadRequest")
|
121
121
|
end
|
122
122
|
|
123
123
|
it "raises an ApiClient::Errors::Unsupported if status is 406" do
|
124
124
|
@response.env[:status] = 406
|
125
125
|
lambda {
|
126
126
|
@instance.send :handle_response, request, @response
|
127
|
-
}.should raise_error(ApiClient::Errors::Unsupported)
|
127
|
+
}.should raise_error(ApiClient::Errors::Unsupported, "ApiClient::Errors::Unsupported")
|
128
128
|
end
|
129
129
|
|
130
130
|
it "raises an ApiClient::Errors::Conflict if status is 409" do
|
131
131
|
@response.env[:status] = 409
|
132
132
|
lambda {
|
133
133
|
@instance.send :handle_response, request, @response
|
134
|
-
}.should raise_error(ApiClient::Errors::Conflict)
|
134
|
+
}.should raise_error(ApiClient::Errors::Conflict, "ApiClient::Errors::Conflict")
|
135
135
|
end
|
136
136
|
|
137
137
|
it "raises an ApiClient::Errors::Unsupported if status is 422" do
|
138
138
|
@response.env[:status] = 422
|
139
139
|
lambda {
|
140
140
|
@instance.send :handle_response, request, @response
|
141
|
-
}.should raise_error(ApiClient::Errors::UnprocessableEntity)
|
141
|
+
}.should raise_error(ApiClient::Errors::UnprocessableEntity, @response.body)
|
142
|
+
end
|
143
|
+
|
144
|
+
it "raises an ApiClient::Errors::TooManyRequests if status is 429" do
|
145
|
+
@response.env[:status] = 429
|
146
|
+
lambda {
|
147
|
+
@instance.send :handle_response, request, @response
|
148
|
+
}.should raise_error(ApiClient::Errors::TooManyRequests, @response.body)
|
142
149
|
end
|
143
150
|
|
144
151
|
it "raises an ApiClient::Errors::Unsupported if status is 300..399" do
|
152
|
+
location = "https://google.com"
|
145
153
|
@response.env[:status] = 302
|
146
|
-
@response.env[:response_headers] = { 'Location' =>
|
154
|
+
@response.env[:response_headers] = { 'Location' => location }
|
147
155
|
lambda {
|
148
156
|
@instance.send :handle_response, request, @response
|
149
|
-
}.should raise_error(ApiClient::Errors::Redirect)
|
157
|
+
}.should raise_error(ApiClient::Errors::Redirect, location)
|
150
158
|
end
|
151
159
|
|
152
160
|
it "raises an ApiClient::Errors::ServerError if status is 500..599" do
|
153
161
|
@response.env[:status] = 502
|
154
162
|
lambda {
|
155
163
|
@instance.send :handle_response, request, @response
|
156
|
-
}.should raise_error(ApiClient::Errors::ServerError)
|
164
|
+
}.should raise_error(ApiClient::Errors::ServerError, "ApiClient::Errors::ServerError")
|
157
165
|
end
|
158
166
|
|
159
167
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Bunsch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|