secured_cloud_api_client 0.0.3 → 0.0.4
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/secured_cloud_api_client/http_client.rb +38 -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: 18f67b7501fc4643d86bac1db9fbce0bdcf0d9f7
|
4
|
+
data.tar.gz: 0cbfbb255c553911d3797514d79f1129dff3f05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 289a3fa97a09f3a60d08d7c51f4a22c5bd0449768dfabe151817055abe131bf5e45f63567a7e7e0837940cb604c9e8beb7624f1d443a283142c1e0b8be09dd4d
|
7
|
+
data.tar.gz: b5c26511f522ffce53e3926d964a040038144e16a8c65f191ebaff79550f0ad839ebac986db30ccff98f58eb777b94e3570911a42ed2f2ace4b983cf63161dd3
|
@@ -15,6 +15,31 @@ class HttpClient
|
|
15
15
|
|
16
16
|
APP_CONTENT_TYPE = "application/vnd.securedcloud.v7.0+json"
|
17
17
|
AUTH_SCHEME = "SC "
|
18
|
+
|
19
|
+
|
20
|
+
#Raise error if response is not successful.
|
21
|
+
def self.handleResponseError(response)
|
22
|
+
|
23
|
+
if ((response.code != "202") && (response.code != "200")) then
|
24
|
+
|
25
|
+
errorMsg = ""
|
26
|
+
|
27
|
+
if ((response['X-Application-Error-Reference'] != nil) && (response['X-Application-Error-Reference'] != "")) then
|
28
|
+
errorMsg = response['X-Application-Error-Reference']
|
29
|
+
end
|
30
|
+
if ((response['X-Application-Error-Description'] != nil) && (response['X-Application-Error-Description'] != "")) then
|
31
|
+
errorMsg = response['X-Application-Error-Description']
|
32
|
+
end
|
33
|
+
|
34
|
+
if (errorMsg == "") then
|
35
|
+
errorMsg = "Error " + response.code.to_str() + " " + response.body()
|
36
|
+
else
|
37
|
+
errorMsg = "Error " + response.code.to_str() + " " + errorMsg
|
38
|
+
end
|
39
|
+
|
40
|
+
raise errorMsg
|
41
|
+
end
|
42
|
+
end
|
18
43
|
|
19
44
|
|
20
45
|
#Sends an HTTP GET request and returns response.
|
@@ -32,7 +57,10 @@ class HttpClient
|
|
32
57
|
|
33
58
|
#Execute request.
|
34
59
|
res = Net::HTTP.start(@url.host, @url.port,:use_ssl => @url.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|http.request(req)} # Net::HTTPResponse object
|
35
|
-
|
60
|
+
|
61
|
+
#Raise error if response is not successful.
|
62
|
+
self.handleResponseError(res)
|
63
|
+
|
36
64
|
#Return response.
|
37
65
|
return res
|
38
66
|
end
|
@@ -55,6 +83,9 @@ class HttpClient
|
|
55
83
|
|
56
84
|
#Execute request.
|
57
85
|
res = Net::HTTP.start(@url.host, @url.port,:use_ssl => @url.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|http.request(req)} # Net::HTTPResponse object
|
86
|
+
|
87
|
+
#Raise error if response is not successful.
|
88
|
+
self.handleResponseError(res)
|
58
89
|
|
59
90
|
#Return response.
|
60
91
|
return res
|
@@ -88,6 +119,9 @@ class HttpClient
|
|
88
119
|
|
89
120
|
#Execute request.
|
90
121
|
res = Net::HTTP.start(@url.host, @url.port,:use_ssl => @url.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|http.request(req)} # Net::HTTPResponse object
|
122
|
+
|
123
|
+
#Raise error if response is not successful.
|
124
|
+
self.handleResponseError(res)
|
91
125
|
|
92
126
|
#Return response.
|
93
127
|
return res
|
@@ -121,6 +155,9 @@ class HttpClient
|
|
121
155
|
|
122
156
|
#Execute request.
|
123
157
|
res = Net::HTTP.start(@url.host, @url.port,:use_ssl => @url.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|http.request(req)} # Net::HTTPResponse object
|
158
|
+
|
159
|
+
#Raise error if response is not successful.
|
160
|
+
self.handleResponseError(res)
|
124
161
|
|
125
162
|
#Return response.
|
126
163
|
return res
|