api-blueprint 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/lib/api-blueprint.rb +1 -0
- data/lib/api-blueprint/blueprint.rb +2 -0
- data/lib/api-blueprint/version.rb +1 -1
- 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: 25a22374a6b02d3b5e55d5efc2d1392d8e335a7f
|
4
|
+
data.tar.gz: 6ff27e1836f991f44f76aafc902306c96ca37c9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8b66d7598ce288c0a792caf45a93f977134c154a7728d1bd9dca890f873a50feb81ba2176571f568833915b63c59a56e357e17aabe92d6d772ebb4f918fccfe
|
7
|
+
data.tar.gz: 367c4b024d79733587c6f26b78b03563a3265aa39850e34b40aec36683aeaa03e646e005849cb09aefd63e9f7b521a7b99e74f46ddf99e0e70f19388c92b34d6
|
data/README.md
CHANGED
@@ -126,7 +126,7 @@ end
|
|
126
126
|
### Config.builder
|
127
127
|
|
128
128
|
When running a blueprint, after the response is returned and parsed, the result is passed to a builder, which is responsible for initializing objects from the response. The default [ApiBlueprint::Builder](https://github.com/iZettle/api-blueprint/blob/master/lib/api-blueprint/builder.rb)
|
129
|
-
|
129
|
+
will pass the attributes from the response into the initializer for the class the blueprint was defined in.
|
130
130
|
|
131
131
|
If you want to change the behavior of the builder, or have a complex response which needs manipulation before it should be passed to the initializer, you can define a custom builder. Custom builders must inherit from the default builder, and can override any combination of the core methods which are used to build responses; `build`, `prepare_item`, and `build_item`. Refer to the [default builder](https://github.com/iZettle/api-blueprint/blob/master/lib/api-blueprint/builder.rb) to see what those methods do.
|
132
132
|
|
@@ -171,15 +171,15 @@ If an API response includes an `errors` object, ApiBlueprint uses it to assign `
|
|
171
171
|
|
172
172
|
Certain response statuses will also cause ApiBlueprint to behave in different ways:
|
173
173
|
|
174
|
-
| HTTP Status range | Behavior
|
175
|
-
| ----------------- |
|
176
|
-
| 200 - 400
|
177
|
-
| 401
|
178
|
-
| 404
|
179
|
-
| 402 - 499
|
180
|
-
| 500 - 599
|
174
|
+
| HTTP Status range | Behavior |
|
175
|
+
| ----------------- | -------------------------------------------- |
|
176
|
+
| 200 - 400 | Objects are built normally, no errors raised |
|
177
|
+
| 401 | raises `ApiBlueprint::UnauthenticatedError` |
|
178
|
+
| 404 | raises `ApiBlueprint::NotFoundError` |
|
179
|
+
| 402 - 499 | raises `ApiBlueprint::ClientError` |
|
180
|
+
| 500 - 599 | raises `ApiBlueprint::ServerError` |
|
181
181
|
|
182
|
-
Additionally, if the request
|
182
|
+
Additionally, if the request has an error which prevents the request from ever receiving a response, an `ApiBlueprint::ConnectionFailed` error will be raised. If a request times out, an `ApiBlueprint::TimeoutError` error will be raised.
|
183
183
|
|
184
184
|
## Access to response headers and status codes
|
185
185
|
|
data/lib/api-blueprint.rb
CHANGED
@@ -39,6 +39,7 @@ module ApiBlueprint
|
|
39
39
|
class DefinitionError < StandardError; end
|
40
40
|
class BuilderError < StandardError; end
|
41
41
|
class ConnectionFailed < StandardError; end
|
42
|
+
class TimeoutError < StandardError; end
|
42
43
|
class ServerError < ResponseError; end
|
43
44
|
class UnauthenticatedError < ResponseError; end
|
44
45
|
class ClientError < ResponseError; end
|
@@ -40,6 +40,8 @@ module ApiBlueprint
|
|
40
40
|
after_build.present? ? after_build.call(runner, created) : created
|
41
41
|
rescue Faraday::ConnectionFailed
|
42
42
|
raise ApiBlueprint::ConnectionFailed
|
43
|
+
rescue Faraday::TimeoutError
|
44
|
+
raise ApiBlueprint::TimeoutError
|
43
45
|
end
|
44
46
|
|
45
47
|
def connection
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-blueprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damien Timewell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|