ocean-rails 3.7.0 → 3.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocean/api_remote_resource.rb +13 -4
- data/lib/ocean/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: ed162b3b5596e3d89355491f248cb6130bc2c740
|
4
|
+
data.tar.gz: de749dc4a656157f009b364b123391f7c2785294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e504ead775dac6f1a7bf8430fe638ee0aa11c567421c8f4939168b04ffe25551a9b39a5d2ce31d5ed79364550a1f20626b939d833a1e3d8d17306dfa5e92bf1d
|
7
|
+
data.tar.gz: 7eb4d41631be3c3f59619e5b6a55caa64778cd6f0fad529ddb06b1b35c00484bd9e59c478600e7c9b5e1e6b0291b269b87817761ae93b111a0f0491254c75488
|
@@ -13,6 +13,7 @@ class Api
|
|
13
13
|
# thing.resource_type => 'thing'
|
14
14
|
# thing.status => 200
|
15
15
|
# thing.status_message => "OK"
|
16
|
+
# thing.response => #<an Api::Response instance>
|
16
17
|
#
|
17
18
|
# The last raw body can be read:
|
18
19
|
#
|
@@ -52,7 +53,7 @@ class Api
|
|
52
53
|
# +thing.get+ does the same, but always returns the RemoteResource. The remote resource
|
53
54
|
# can be examined to see its status.
|
54
55
|
#
|
55
|
-
# Hyperlinks can be specified to avoid hardcoding API URIs.
|
56
|
+
# Hyperlinks can be specified to avoid hardcoding API URIs. Simply specify
|
56
57
|
# the hyperlink as the first parameter to the instance versions of the HTTP accessors:
|
57
58
|
#
|
58
59
|
# x = Api::RemoteResource.new("http://foo.com/x")
|
@@ -76,11 +77,15 @@ class Api
|
|
76
77
|
# x.get
|
77
78
|
# x.get(:self)
|
78
79
|
#
|
79
|
-
# #post, #post!, #put, #put!, #delete, and #delete! are also available
|
80
|
+
# #post, #post!, #put, #put!, #delete, and #delete! are also available and have the same
|
81
|
+
# hyperlink handling capabilities.
|
80
82
|
#
|
81
83
|
# Exceptions:
|
82
84
|
#
|
83
85
|
# GetFailed raised when the GET to obtain the remote resource has failed.
|
86
|
+
# PutFailed raised when a PUT on the remote resource has failed.
|
87
|
+
# PostFailed raised when a POST to the remote resource has failed.
|
88
|
+
# DeleteFailed raised when a DELETE of the remote resource has failed.
|
84
89
|
# UnparseableJson raised when the response body doesn't parse as JSON.
|
85
90
|
# JsonIsNoResource raised when the structure of the parsed JSON body is not a resource.
|
86
91
|
#
|
@@ -124,7 +129,7 @@ class Api
|
|
124
129
|
|
125
130
|
attr_reader :uri, :content_type, :retries, :backoff_time, :backoff_rate, :backoff_max
|
126
131
|
attr_reader :raw, :resource, :resource_type, :status, :headers, :credentials, :x_api_token
|
127
|
-
attr_reader :status_message
|
132
|
+
attr_reader :status_message, :response
|
128
133
|
|
129
134
|
def initialize(uri, type="application/json",
|
130
135
|
credentials: nil, x_api_token: nil,
|
@@ -272,7 +277,7 @@ class Api
|
|
272
277
|
private
|
273
278
|
|
274
279
|
attr_accessor :present
|
275
|
-
attr_writer :raw, :resource, :resource_type, :status, :headers, :status_message
|
280
|
+
attr_writer :raw, :resource, :resource_type, :status, :headers, :status_message, :response
|
276
281
|
|
277
282
|
|
278
283
|
def self._credentials(rr)
|
@@ -292,6 +297,7 @@ class Api
|
|
292
297
|
response = Api.request rr.uri, :get, headers: {}, credentials: credentials, x_api_token: token,
|
293
298
|
retries: rr.retries, backoff_time: rr.backoff_time, backoff_rate: rr.backoff_rate,
|
294
299
|
backoff_max: rr.backoff_max
|
300
|
+
rr.send :response=, response
|
295
301
|
rr.send :status=, response.status
|
296
302
|
rr.send :status_message=, response.message
|
297
303
|
rr.send :headers=, response.headers
|
@@ -311,6 +317,7 @@ class Api
|
|
311
317
|
type, resource = verify_resource body
|
312
318
|
self.resource = resource
|
313
319
|
self.resource_type = type
|
320
|
+
self.response = response
|
314
321
|
self.status = response.status
|
315
322
|
self.status_message = response.message
|
316
323
|
self.headers = response.headers
|
@@ -347,6 +354,7 @@ class Api
|
|
347
354
|
return if resource_type && type != resource_type
|
348
355
|
self.resource = resource
|
349
356
|
self.resource_type = type
|
357
|
+
self.response = response
|
350
358
|
self.status = response.status
|
351
359
|
self.status_message = response.message
|
352
360
|
self.headers = response.headers
|
@@ -379,6 +387,7 @@ class Api
|
|
379
387
|
credentials: credentials, x_api_token: token,
|
380
388
|
retries: retries, backoff_time: backoff_time, backoff_rate: backoff_rate,
|
381
389
|
backoff_max: backoff_max
|
390
|
+
self.response = response
|
382
391
|
self.status = response.status
|
383
392
|
self.status_message = response.message
|
384
393
|
self.headers = response.headers
|
data/lib/ocean/version.rb
CHANGED