circuit-api 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/circuit_api/resources/base.rb +7 -0
- data/lib/circuit_api/resources/message.rb +3 -0
- data/lib/circuit_api/utils/errors.rb +19 -0
- data/lib/circuit_api/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8056c72f9a8086f8d564e353277a63aa87df7c3a79f6b21d4fe707cbb6e8fdfd
|
4
|
+
data.tar.gz: a441bdf32a0ef464a65624cda0d379465beaa2ccf8b3e4706c7cf12af42c6c45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d107fbc0f528eb44a55e9a61c61a92d1954ba4e47130321a94f8bf891093c03e9faeb93da3b720450161f874a4ee3b0f886560726220dcb60ed8b9fdce9e61
|
7
|
+
data.tar.gz: be1b3588ee087f8861e20503376c6549193495e16f2a127854fe80d6e775a6041fe559c2f9ce38215f611349b65750e3d6a46f38998e470cf47eca6aa0b250e6
|
@@ -68,6 +68,13 @@ module CircuitApi
|
|
68
68
|
#binding.pry
|
69
69
|
CircuitApi::Resource.new('foo', attributes)
|
70
70
|
end
|
71
|
+
|
72
|
+
def handle_validation_errors(bad_request_error)
|
73
|
+
errors = bad_request_error.json_message['validationErrors']
|
74
|
+
raise unless errors
|
75
|
+
|
76
|
+
raise CircuitApi::ValidationError.new(errors, bad_request_error.uri)
|
77
|
+
end
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module CircuitApi
|
2
|
+
# Network Errors
|
2
3
|
class HttpError < StandardError
|
3
4
|
attr_reader :error_code, :error_body, :uri
|
4
5
|
|
@@ -11,10 +12,28 @@ module CircuitApi
|
|
11
12
|
def message
|
12
13
|
"HTTP #{error_code} - URI: #{uri}.\n Error: #{error_body}"
|
13
14
|
end
|
15
|
+
|
16
|
+
def json_message
|
17
|
+
JSON.parse(error_body)
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
class BadRequest < HttpError; end;
|
17
22
|
class Unauthorized < HttpError; end;
|
18
23
|
class InternalServerError < HttpError; end;
|
19
24
|
class ServiceUnavailable < HttpError; end;
|
25
|
+
|
26
|
+
# Data errors
|
27
|
+
class ValidationError < StandardError
|
28
|
+
attr_reader :errors, :uri
|
29
|
+
|
30
|
+
def initialize(errors, uri)
|
31
|
+
@errors = errors
|
32
|
+
@uri = uri
|
33
|
+
end
|
34
|
+
|
35
|
+
def message
|
36
|
+
"URI: #{uri}.\n Errors: #{errors}"
|
37
|
+
end
|
38
|
+
end
|
20
39
|
end
|
data/lib/circuit_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circuit-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Pochet
|
@@ -39,47 +39,47 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 11.1.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 11.1.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.10.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.10.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sinatra
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.1.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.1.0
|
83
83
|
description: Wrapper of the Circuit Rest API
|
84
84
|
email: vincent@elqano.com
|
85
85
|
executables: []
|
@@ -103,7 +103,7 @@ files:
|
|
103
103
|
- lib/circuit_api/utils/errors.rb
|
104
104
|
- lib/circuit_api/utils/object.rb
|
105
105
|
- lib/circuit_api/version.rb
|
106
|
-
homepage:
|
106
|
+
homepage: https://github.com/Elqanoteam/circuit-rest-client
|
107
107
|
licenses:
|
108
108
|
- MIT
|
109
109
|
metadata: {}
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.0.3
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Circuit Rest API client
|