naranya_ecm-sdk 0.0.18 → 0.0.19
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/lib/naranya_ecm-sdk/version.rb +1 -1
- data/lib/naranya_ecm/rest/client.rb +1 -1
- data/lib/naranya_ecm/rest/errors.rb +10 -3
- data/lib/naranya_ecm/rest/persistence.rb +2 -2
- 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: 6d0605e5198ba184c433cc674dd0831078453ef7
|
4
|
+
data.tar.gz: 5eba9f1fe373e4e52b809d1a8b5b27d5dd556cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a63a9a222ccf44282b57c9594ef7d1ead36fa1c159b0052f7b633887733f4860481cb49573ae543be9797530f123e5b689202434fb261093f9caeacee9ed89
|
7
|
+
data.tar.gz: e00196376879c815be17956650b49c391a7ae7ca1c3d7678a90292929e36d3acb923db34266c11c232690de4fe0ad75fb26db74f4664982ab0e7a1a810117351
|
@@ -30,7 +30,7 @@ module NaranyaEcm::Rest
|
|
30
30
|
options[:headers]['Authorization'] = authorization_header(true)
|
31
31
|
response = HTTParty.send method, url, options
|
32
32
|
end
|
33
|
-
::NaranyaEcm::Rest::RestError.
|
33
|
+
::NaranyaEcm::Rest::RestError.raise_by_failed_response(response) unless response.success?
|
34
34
|
|
35
35
|
response
|
36
36
|
end
|
@@ -4,15 +4,22 @@ module NaranyaEcm::Rest
|
|
4
4
|
# Generic REST exception class.
|
5
5
|
class RestError < StandardError
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
attr_reader :response
|
8
|
+
|
9
|
+
def initialize(given_response, msg = "")
|
10
|
+
@response = given_response
|
11
|
+
super(msg)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.raise_by_failed_response(response, message = "")
|
15
|
+
klass = case response.code
|
9
16
|
when 401 then AuthorizationRequired
|
10
17
|
when 403 then Forbidden
|
11
18
|
when 404 then ResourceNotFound
|
12
19
|
when 422 then UnprocessableEntity
|
13
20
|
else RemoteFailed
|
14
21
|
end
|
15
|
-
raise klass, "Server responded with code #{code}. Message: #{message}"
|
22
|
+
raise klass.new response, "Server responded with code #{response.code}. Message: #{message}"
|
16
23
|
end
|
17
24
|
|
18
25
|
end
|
@@ -74,8 +74,8 @@ module NaranyaEcm::Rest
|
|
74
74
|
response = Client.post create_path, persist_request_options(self.attributes)
|
75
75
|
self.load(response.to_hash)
|
76
76
|
true
|
77
|
-
rescue UnprocessableEntity
|
78
|
-
self.load_server_errors(response.to_hash)
|
77
|
+
rescue UnprocessableEntity => e
|
78
|
+
self.load_server_errors(e.response.to_hash)
|
79
79
|
false
|
80
80
|
end
|
81
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naranya_ecm-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|