vindi 0.0.1 → 0.0.2
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 +2 -2
- data/lib/vindi/error.rb +18 -18
- data/lib/vindi/response/raise_error.rb +3 -4
- data/lib/vindi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa9ad99820c63edef8c56003e328dd221ce994cd
|
4
|
+
data.tar.gz: 834423a9ffabfad33678cf29fae92cb371e4ede2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6d6f22cba50f50a2ca96eb6d99e78555c8699af0feafac40ab6eba87ca4bc2da665ee2bcd0d842df6a1ad6cd37dd0ed4c53cc7c3ba63c876f95db2412f05d8f
|
7
|
+
data.tar.gz: b59bbdcaa255677a7d964a0bc57f0b24c42606031b2ca7051587d29d7720a0ec8c6b0c553bda78f62cdfcf120f6958559b30b5d608b2a53b9ade55cd0022fa01
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Ruby toolkit para a [API de Recorrência][link-introducao-api] da [Vindi][link-v
|
|
7
7
|
## Instalação
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'vindi
|
10
|
+
gem 'vindi'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -16,7 +16,7 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install vindi
|
19
|
+
$ gem install vindi
|
20
20
|
|
21
21
|
## Uso
|
22
22
|
Os métodos da API estão disponíveis atraves dos métodos da instancia de um cliente
|
data/lib/vindi/error.rb
CHANGED
@@ -42,24 +42,24 @@ module Vindi
|
|
42
42
|
def from_response(response)
|
43
43
|
status = response.status.to_i
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
45
|
+
klass = case status
|
46
|
+
when 400 then Vindi::Error::BadRequest
|
47
|
+
when 401 then Vindi::Error::Unauthorized
|
48
|
+
when 403 then Vindi::Error::Forbidden
|
49
|
+
when 404 then Vindi::Error::NotFound
|
50
|
+
when 406 then Vindi::Error::NotAcceptable
|
51
|
+
when 415 then Vindi::Error::UnsupportedMediaType
|
52
|
+
when 422 then Vindi::Error::UnprocessableEntity
|
53
|
+
when 429 then Vindi::Error::TooManyRequests
|
54
|
+
when 400..499 then Vindi::Error::ClientError
|
55
|
+
when 500 then Vindi::Error::InternalServerError
|
56
|
+
when 502 then Vindi::Error::BadGateway
|
57
|
+
when 503 then Vindi::Error::ServiceUnavailable
|
58
|
+
when 504 then Vindi::Error::GatewayTimeout
|
59
|
+
when 500..599 then Vindi::Error::ServerError
|
60
|
+
end
|
61
|
+
|
62
|
+
klass.new(response) if klass
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -3,16 +3,15 @@ require 'vindi/error'
|
|
3
3
|
|
4
4
|
module Vindi
|
5
5
|
module Response
|
6
|
-
|
6
|
+
|
7
7
|
# This class raises exceptions based HTTP status codes retuned by the API
|
8
8
|
class RaiseError < Faraday::Response::Middleware
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def on_complete(response)
|
13
|
-
|
14
|
-
|
15
|
-
end
|
13
|
+
error = Vindi::Error.from_response(response)
|
14
|
+
raise error if error
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
data/lib/vindi/version.rb
CHANGED