delivery-sdk-ruby 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17b341ec92359e512b2638aba5a81ac13a30721434f518ceff2b11e7f1cbea58
4
- data.tar.gz: 19db0ecfb6e1317d2fc4079ee3a908d33afbafed49a56a49beb63c743a3ca4da
3
+ metadata.gz: d82deddb6aa006c988be4506bc17f86c7048525315cf6b76171c27e7f41439c3
4
+ data.tar.gz: 4141518bc2e19f310a0c7f6ef3f4c6c761c38602352926e030c3ba7091a7a1bd
5
5
  SHA512:
6
- metadata.gz: 919f879192f09a7bd4ce3f233eb696a5e81317ea66f13e00c9c76695bac3ecfe6d6fa3d717417e1498539040bd7e00cb1cc871ff622b93396fa20af9c5caceef
7
- data.tar.gz: bf334e2f3acc95688be1b3fc69082938f0b21d1368b877298a21232dd4df238d139faea5e1fd7759afb0789e0f38f6178102c7dd0d325c9aa24171f2a56f6a16
6
+ metadata.gz: 11eadae9a4d4602975d861d5fe8e3dd0b7313e44de307fbbe53c45aba75ccafd6fb350769f1962e9db0e2a735bcd6decf177e0b2b165f1e34ee5901d6c5d2b44
7
+ data.tar.gz: 1a0919f05191b5b46b12dd7908e19306a61cb210db6e85280618c8ad01afa34469881396f9b18a055c4b73db0d366d800e5a58a05130a06dfb67cc63221e5142
data/README.md CHANGED
@@ -162,6 +162,8 @@ delivery_client.items.execute do |response|
162
162
  end
163
163
  ```
164
164
 
165
+ You can also view the raw JSON response of the the query using the `.json` attribute.
166
+
165
167
  For successful content item queries, you will get either `DeliveryItemResponse` for single item queries, or `DeliveryItemListingResponse` for multiple item queries. You can access the returned content item(s) at `.item` or `.items` respectively.
166
168
 
167
169
  The `ContentItem` object gives you access to all system elements and content type elements at the `.system` and `.elements` properies. These are dynamic objects, so you can simply type the name of the element you need:
@@ -23,14 +23,21 @@ module Delivery
23
23
  )
24
24
  end
25
25
 
26
- def initialize(source, content_link_url_resolver, inline_content_item_resolver)
26
+ def initialize(source, content_link_url_resolver, inline_content_item_resolver, modular_content = nil)
27
27
  @source =
28
28
  if source['item'].nil?
29
29
  source
30
30
  else
31
31
  source['item']
32
32
  end
33
- @modular_content = source['modular_content']
33
+ # Multiple item responses have modular_content on the root, single item
34
+ # responses have modular content in the item
35
+ @modular_content =
36
+ if modular_content.nil?
37
+ source['modular_content']
38
+ else
39
+ modular_content
40
+ end
34
41
  self.content_link_url_resolver = content_link_url_resolver
35
42
  self.inline_content_item_resolver = inline_content_item_resolver
36
43
  end
@@ -18,7 +18,8 @@ module Delivery
18
18
  items << Delivery::ContentItem.new(
19
19
  n,
20
20
  @content_link_url_resolver,
21
- @inline_content_item_resolver
21
+ @inline_content_item_resolver,
22
+ @response['modular_content']
22
23
  )
23
24
  end
24
25
  @items = items
@@ -28,7 +29,10 @@ module Delivery
28
29
  @response = response
29
30
  @content_link_url_resolver = content_link_url_resolver
30
31
  @inline_content_item_resolver = inline_content_item_resolver
31
- super 200, "Success, #{items.length} items returned"
32
+ super 200,
33
+ "Success,
34
+ #{items.length} items returned",
35
+ JSON.generate(@response)
32
36
  end
33
37
  end
34
38
  end
@@ -7,14 +7,21 @@ module Delivery
7
7
  class DeliveryItemResponse < ResponseBase
8
8
  def item
9
9
  @item unless @item.nil?
10
- @item = Delivery::ContentItem.new(@response, @content_link_url_resolver, @inline_content_item_resolver)
10
+ @item = Delivery::ContentItem.new(
11
+ @response,
12
+ @content_link_url_resolver,
13
+ @inline_content_item_resolver
14
+ )
11
15
  end
12
16
 
13
17
  def initialize(response, content_link_url_resolver, inline_content_item_resolver)
14
18
  @response = response
15
19
  @content_link_url_resolver = content_link_url_resolver
16
20
  @inline_content_item_resolver = inline_content_item_resolver
17
- super 200, "Success, '#{item.system.code_name}' returned"
21
+ super 200,
22
+ "Success,
23
+ '#{item.system.code_name}' returned",
24
+ JSON.generate(@response)
18
25
  end
19
26
  end
20
27
  end
@@ -3,11 +3,13 @@ module Delivery
3
3
  # Base class for all responses from DeliveryQuery.execute
4
4
  class ResponseBase
5
5
  attr_accessor :http_code,
6
- :message
6
+ :message,
7
+ :json
7
8
 
8
- def initialize(http_code, message)
9
+ def initialize(http_code, message, json = '')
9
10
  self.http_code = http_code
10
11
  self.message = message
12
+ self.json = json
11
13
  end
12
14
 
13
15
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Delivery
2
- VERSION = '0.11.1'.freeze
2
+ VERSION = '0.11.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delivery-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dugre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-12 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri