kontent-delivery-sdk-ruby 2.0.15 → 2.0.16

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: a504c6a9439735535f7373339c04ec54df37c90afc23ac90c662b6ecb3bf2e4d
4
- data.tar.gz: bf8bfa8745c9c66a9f2e9fe2d4637da7d2748d2e9ed61505aabfb36dd4f55a95
3
+ metadata.gz: 96b761a2d404fbb7f7d4277dc11777b5518f89091243cf5a2c3a24974e554270
4
+ data.tar.gz: 0f5404b57090c5d827576d9e4a84a71a24e151a7fa848847509c6f7134f006c8
5
5
  SHA512:
6
- metadata.gz: b8affbb16b1db59f18d6cb75fcf8ea8a0f68a51fdacc3a42a574bcd8a0fe6f611116238ea4781e3ca9ad00aa41a06f5d51e18d185441c1123c404966a70f3978
7
- data.tar.gz: 9fadf919b125de5b03851a5daf0209269648ac883d6df83413976005dced4775d368ac5c57431b8f4dc052be3c438c67c8e433c8cdbf134c2a940dbbc88b6993
6
+ metadata.gz: 83c79acbeabffaaa8002414f5dc28d90a310e66085382922fcc9d03bc416afa0113a9a6836c2be44f92073e534ef601982e2363d647e32c75f4a04c0e2ae7e38
7
+ data.tar.gz: a3e94e33ab180278b446f76275e2f6e51716caca29f87fd7c7d49545807fd6d0f584133f85d646e56feeb824d4952fd6c1be35d54dfe81036619b614dc0ef757
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
  [![Join the chat at https://kentico-community.slack.com](https://img.shields.io/badge/join-slack-E6186D.svg)](https://kentico-community.slack.com)
3
3
  [![Stack Overflow](https://img.shields.io/badge/Stack%20Overflow-ASK%20NOW-FE7A16.svg?logo=stackoverflow&logoColor=white)](https://stackoverflow.com/tags/kentico-kontent)
4
4
  [![Version](https://img.shields.io/gem/v/kontent-delivery-sdk-ruby.svg?style=flat)](https://rubygems.org/gems/kontent-delivery-sdk-ruby)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/b2e3fae28a2b2601d815/maintainability)](https://codeclimate.com/github/Kentico/kontent-delivery-sdk-ruby/maintainability)
6
- [![Test coverage](https://api.codeclimate.com/v1/badges/b2e3fae28a2b2601d815/test_coverage)](https://codeclimate.com/github/Kentico/delivery-sdk-ruby/test_coverage)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/c83f2067f9cae9bde737/maintainability)](https://codeclimate.com/github/Kentico/kontent-delivery-sdk-ruby/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/c83f2067f9cae9bde737/test_coverage)](https://codeclimate.com/github/Kentico/kontent-delivery-sdk-ruby/test_coverage)
7
7
 
8
8
  # Delivery Ruby SDK
9
9
 
@@ -316,6 +316,26 @@ delivery_client.items
316
316
 
317
317
  :warning: Note that using the `include_total_count` method may increase the response time and should only be used if necessary.
318
318
 
319
+ ## Items feed
320
+
321
+ Use the `items_feed` method to retrieve a dynamically paginated list of content items in your project. The result will have a `more_results?` method which indicates that more items can be retrieved from the feed, using the `next_result` method.
322
+
323
+ This method accepts all [filtering](https://github.com/Kentico/kontent-delivery-sdk-ruby#filtering) and [parameters](https://github.com/Kentico/kontent-delivery-sdk-ruby#parameters) except _depth_, _skip_, and _limit_. You can read more about the /items-feed endpoint in the [Kontent documentation](https://docs.kontent.ai/reference/delivery-api#operation/enumerate-content-items)
324
+
325
+ Below is an example that will load all content items of a project into a single array:
326
+
327
+ ```ruby
328
+ result = delivery_client.items_feed.execute
329
+ items = result.items
330
+ if result.more_results?
331
+ loop do
332
+ result = result.next_result
333
+ items.push *result.items
334
+ break unless result.more_results?
335
+ end
336
+ end
337
+ ```
338
+
319
339
  ## Retrieving content types
320
340
 
321
341
  You can use the `.type` and `.types` methods to request your content types from Kentico Kontent:
@@ -13,6 +13,7 @@ module Kentico
13
13
  URL_TEMPLATE_ELEMENTS = '/types/%s/elements/%s'.freeze
14
14
  URL_TEMPLATE_TAXONOMY = '/taxonomies/%s'.freeze
15
15
  URL_TEMPLATE_TAXONOMIES = '/taxonomies'.freeze
16
+ URL_TEMPLATE_ITEMS_FEED = '/items-feed'.freeze
16
17
 
17
18
  URL_MAX_LENGTH = 65_519
18
19
  MSG_LONG_QUERY = 'The request url is too long. Split your query into multiple calls.'.freeze
@@ -67,6 +68,8 @@ module Kentico
67
68
  provide_taxonomy query
68
69
  when Kentico::Kontent::Delivery::QUERY_TYPE_ELEMENT
69
70
  format(URL_TEMPLATE_ELEMENTS, query.content_type, query.code_name)
71
+ when Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
72
+ URL_TEMPLATE_ITEMS_FEED
70
73
  end
71
74
  end
72
75
 
@@ -10,6 +10,7 @@ module Kentico
10
10
  QUERY_TYPE_ITEMS = 'QUERY_TYPE_ITEMS'.freeze
11
11
  QUERY_TYPE_TAXONOMIES = 'QUERY_TYPE_TAXONOMIES'.freeze
12
12
  QUERY_TYPE_ELEMENT = 'QUERY_TYPE_ELEMENT'.freeze
13
+ QUERY_TYPE_ITEMS_FEED = 'QUERY_TYPE_ITEMS_FEED'.freeze
13
14
 
14
15
  # Executes requests against the Kentico Kontent Delivery API.
15
16
  class DeliveryClient
@@ -61,6 +62,26 @@ module Kentico
61
62
  with_retry_policy: @with_retry_policy
62
63
  end
63
64
 
65
+ # Return a paginated feed of all content items of the project
66
+ #
67
+ # * *Args*:
68
+ # - *query_parameters* (+Array+) _optional_ One or more Kentico::Kontent::Delivery::QueryParameters::Filter objects. A single object will automatically be converted into an Array.
69
+ #
70
+ # * *Returns*:
71
+ # - Kentico::Kontent::Delivery::DeliveryQuery
72
+ def items_feed(query_parameters = [])
73
+ q = DeliveryQuery.new project_id: @project_id,
74
+ secure_key: @secure_key,
75
+ qp: query_parameters,
76
+ content_link_url_resolver: @content_link_url_resolver,
77
+ inline_content_item_resolver: @inline_content_item_resolver,
78
+ query_type: QUERY_TYPE_ITEMS_FEED,
79
+ with_retry_policy: @with_retry_policy
80
+ q.use_preview = use_preview
81
+ q.preview_key = @preview_key
82
+ q
83
+ end
84
+
64
85
  # Return all content items of the project
65
86
  #
66
87
  # * *Args*:
@@ -13,6 +13,9 @@ module Kentico
13
13
  'https://github.com/Kentico/kontent-delivery-sdk-ruby#previewing-unpublished-content'.freeze
14
14
  ERROR_PARAMS = 'Only filters may be passed in the .item or .items methods'\
15
15
  '. See https://github.com/Kentico/kontent-delivery-sdk-ruby#filtering'.freeze
16
+ HEADER_WAIT_FOR_CONTENT = 'X-KC-Wait-For-Loading-New-Content'.freeze
17
+ HEADER_SDK_ID = 'X-KC-SDKID'.freeze
18
+ HEADER_CONTINUATION = 'X-Continuation'.freeze
16
19
  attr_accessor :use_preview,
17
20
  :preview_key,
18
21
  :project_id,
@@ -139,7 +142,7 @@ module Kentico
139
142
  # * *Returns*:
140
143
  # - +self+
141
144
  def skip(value)
142
- query_string.set_param('skip', value)
145
+ query_string.set_param('skip', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
143
146
  self
144
147
  end
145
148
 
@@ -167,7 +170,7 @@ module Kentico
167
170
  # * *Returns*:
168
171
  # - +self+
169
172
  def limit(value)
170
- query_string.set_param('limit', value)
173
+ query_string.set_param('limit', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
171
174
  self
172
175
  end
173
176
 
@@ -196,7 +199,7 @@ module Kentico
196
199
  # * *Returns*:
197
200
  # - +self+
198
201
  def depth(value)
199
- query_string.set_param('depth', value)
202
+ query_string.set_param('depth', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
200
203
  self
201
204
  end
202
205
 
@@ -207,7 +210,7 @@ module Kentico
207
210
  # * *Returns*:
208
211
  # - +self+
209
212
  def request_latest_content
210
- @headers['X-KC-Wait-For-Loading-New-Content'] = true
213
+ @headers[HEADER_WAIT_FOR_CONTENT] = true
211
214
  self
212
215
  end
213
216
 
@@ -238,6 +241,19 @@ module Kentico
238
241
  self
239
242
  end
240
243
 
244
+ def update_continuation(token)
245
+ @headers[HEADER_CONTINUATION] = token
246
+ self
247
+ end
248
+
249
+ def continuation_exists?
250
+ !continuation_token.nil?
251
+ end
252
+
253
+ def continuation_token
254
+ @headers[HEADER_CONTINUATION]
255
+ end
256
+
241
257
  private
242
258
 
243
259
  # Returns request headers that are extended with custom headers.
@@ -247,7 +263,7 @@ module Kentico
247
263
  # - +Hash+
248
264
  def headers
249
265
  headers = @headers.clone
250
- headers['X-KC-SDKID'] = provide_sdk_header
266
+ headers[HEADER_SDK_ID] = provide_sdk_header
251
267
  headers['Authorization'] = "Bearer #{preview_key}" if should_preview
252
268
  headers['Authorization'] = "Bearer #{secure_key}" if !should_preview && secure_key
253
269
 
@@ -71,6 +71,12 @@ module Kentico
71
71
  # - An object derived from the Kentico::Kontent::Delivery::Responses::ResponseBase class
72
72
  def make_response(response)
73
73
  case @query.query_type
74
+ when Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
75
+ Kentico::Kontent::Delivery::Responses::DeliveryItemsFeedResponse.new(
76
+ response.headers,
77
+ response.body,
78
+ @query
79
+ )
74
80
  when Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS
75
81
  respond_item response
76
82
  when Kentico::Kontent::Delivery::QUERY_TYPE_TYPES
@@ -103,15 +109,13 @@ module Kentico
103
109
  Kentico::Kontent::Delivery::Responses::DeliveryItemListingResponse.new(
104
110
  response.headers,
105
111
  response.body,
106
- @query.content_link_url_resolver,
107
- @query.inline_content_item_resolver
112
+ @query
108
113
  )
109
114
  else
110
115
  Kentico::Kontent::Delivery::Responses::DeliveryItemResponse.new(
111
116
  response.headers,
112
117
  response.body,
113
- @query.content_link_url_resolver,
114
- @query.inline_content_item_resolver
118
+ @query
115
119
  )
116
120
  end
117
121
  end
@@ -38,10 +38,10 @@ module Kentico
38
38
  @items = items
39
39
  end
40
40
 
41
- def initialize(headers, body, content_link_url_resolver, inline_content_item_resolver)
41
+ def initialize(headers, body, query)
42
42
  @response = JSON.parse(body)
43
- @content_link_url_resolver = content_link_url_resolver
44
- @inline_content_item_resolver = inline_content_item_resolver
43
+ @content_link_url_resolver = query.content_link_url_resolver
44
+ @inline_content_item_resolver = query.inline_content_item_resolver
45
45
  super 200,
46
46
  "Success, #{items.length} items returned",
47
47
  headers,
@@ -24,10 +24,10 @@ module Kentico
24
24
  )
25
25
  end
26
26
 
27
- def initialize(headers, body, content_link_url_resolver, inline_content_item_resolver)
27
+ def initialize(headers, body, query)
28
28
  @response = JSON.parse(body)
29
- @content_link_url_resolver = content_link_url_resolver
30
- @inline_content_item_resolver = inline_content_item_resolver
29
+ @content_link_url_resolver = query.content_link_url_resolver
30
+ @inline_content_item_resolver = query.inline_content_item_resolver
31
31
  super 200,
32
32
  "Success, '#{item.system.codename}' returned",
33
33
  headers,
@@ -0,0 +1,58 @@
1
+ require 'delivery/models/content_item'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module Kentico
6
+ module Kontent
7
+ module Delivery
8
+ module Responses
9
+ # The response of a successful query for content items.
10
+ class DeliveryItemsFeedResponse < ResponseBase
11
+ # A collection of Kentico::Kontent::Delivery::ContentItem objects from
12
+ # a Kentico::Kontent::Delivery::DeliveryClient.items_feed call.
13
+ #
14
+ # * *Returns*:
15
+ # - +Array+ One or more Kentico::Kontent::Delivery::ContentItem objects
16
+ def items
17
+ @items unless @items.nil?
18
+ linked_items_resolver = Kentico::Kontent::Delivery::Resolvers::LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
19
+ items = []
20
+ @response['items'].each do |n|
21
+ items << Kentico::Kontent::Delivery::ContentItem.new(
22
+ n,
23
+ @content_link_url_resolver,
24
+ @inline_content_item_resolver,
25
+ linked_items_resolver
26
+ )
27
+ end
28
+ @items = items
29
+ end
30
+
31
+ def initialize(headers, body, query)
32
+ @query = query
33
+ @response = JSON.parse(body)
34
+ @content_link_url_resolver = query.content_link_url_resolver
35
+ @inline_content_item_resolver = query.inline_content_item_resolver
36
+ super 200,
37
+ "Success, #{items.length} items returned",
38
+ headers,
39
+ JSON.generate(@response)
40
+ end
41
+
42
+ def next_result
43
+ @query.update_continuation continuation_token
44
+ @query.execute
45
+ end
46
+
47
+ def more_results?
48
+ !continuation_token.nil?
49
+ end
50
+
51
+ def continuation_token
52
+ headers[Kentico::Kontent::Delivery::DeliveryQuery::HEADER_CONTINUATION]
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -14,6 +14,9 @@ module Kentico
14
14
  PREVIEW_KEY = ENV['PREVIEW_KEY']
15
15
  BASE_URL = "https://deliver.kontent.ai/#{PROJECT_ID}".freeze
16
16
  PREVIEW_URL = "https://preview-deliver.kontent.ai/#{PROJECT_ID}".freeze
17
+ CONTINUATION_HEADER_1 = '+RID:~lmJ4ALSekwpBTQAAAAAADA==#RT:1#TRC:100#RTD:NrCNpn14PWTcji51F4ccBWJlYm5geGZqaHBtZWBgYHVmdHVqbnBvamJtAA==#ISV:2#IEO:65551#QCF:1#FPC:AggAAAAAADAAAAMAAAAAMAAAAAAAAAAwAAD2AgPA4N8A+A8+EYAkABBCCEEQgBAAK4BRABCSFoAhAACgQgBg4AMAMgAAqAEAM4BPgAXAICSSgAAAoBIEAFEAgANTAP7/AwAACC6AAcADACyAVABSRWIUIoqAAH2ABMCAQpFEEQAEAEIAGDAMABuAI4AyAACQCwAzACJBJBJIQhgAUYJIBFGiAhAERSKKSCkQADIAAP4fACIAqQAQABEAAAURAABgL4AEwA+APwDAjwYAMgAQqEIAEgCgqgIAUgDwAYAHIQA6ABEAADBSAAD/AQAhAMP/EUAfABKAgQD4/2JAAQD4/zFAHwARAPgAEQCABBIAPAAs/iFAfwAxAADgGIBxAH7/JgABSKRd22trW1KpUpkmACQIogAAUElJkpUCAYQA+P//A+z/AwdRAAD4coFBAAD8IEASAAD/BwBWgC+AAcACAYEAwAESAAD/BwAmgKEAMA0SAAL/HwBGgBmAYgDgh3EAUoCdgAHAcAAxgCIA4AcgABEAgD9RAAAPj4ADwAUAAAAAI9aAIQAgFTKAEQAAHm+A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uAK4ARgBOAQgAA4AMAroBcgW2BmII8gA2AUwCA//9PhwBsgAbAEAQAgACAvx8D+AcAKICigALABgAIAHuAE4BggI6AGYChAAMAmIBWhAIAAAAAMAAADgFyAqCAAgA2gBmALoCxAAAD4wAACRAgAAJjAMAA9+8DAGSAKoAggDIBXAEQAG6AAIAogDCAPYAGgJEAACh/gFEAAAejAGB/8///B5GAIQBgAOEAyB6SAECAMQAZgBGAuoAqgIGAAIAOgA+A7oBMgCiAD4AJgAHAPAARgAHAMABDAAB+AYHz/xFA3/9TQP/fGwAQIBEAgANiAPgAAAgRAMAAEQGVAL6AA8AAIgMAAQCxAABIIYKBAOARQQPkATEAQARwgZOBCYIhAYABARcGAFaAUAAiQP8PAGBRARgAMgAA0P8AIIBBAAyANUBP4Pf+AQDw/0kCMgAAwOcBIQAAMDWAWIAvgKEAwAAugBEAwAIDAAAAADAAAHQAn4EAgBQEABz/D0EA8AFiABgcBACzBQDAj/8DAGqAQQAA4BIAADwCEBEAjAESADAOCAAhAGAQNwBEjt8/wOAHAO8DEiA4ABEB4AEiAA8A4A9xCQc4QgCDAABAMwDA/zf//wc0AAAHEFCAgf8AMwAAPIAB+OM='.freeze
17
20
 
18
21
  class << self
19
22
  def get_response(query, url, headers)
@@ -35,6 +38,9 @@ module Kentico
35
38
  return respond_429 if @query.code_name == '429'
36
39
 
37
40
  qs = url.contains('?') ? url.split('?')[1] : nil
41
+
42
+ return respond_feed if query.query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
43
+
38
44
  return respond_filtering qs unless qs.nil? # e.g. /items/about_us?skip=0&limit=5
39
45
 
40
46
  respond_generic url # Didn't match other clauses, so response should be located in corresponding filepath
@@ -48,6 +54,26 @@ module Kentico
48
54
  )
49
55
  end
50
56
 
57
+ def respond_feed
58
+ if @query.continuation_exists?
59
+ if @query.continuation_token.include? '#RT:1#'
60
+ headers = {Kentico::Kontent::Delivery::DeliveryQuery::HEADER_CONTINUATION => CONTINUATION_HEADER_2}
61
+ path = Pathname.new(File.dirname(__FILE__) + '/items_feed/articles_feed_2.json')
62
+ else
63
+ headers = ''
64
+ path = Pathname.new(File.dirname(__FILE__) + '/items_feed/articles_feed_3.json')
65
+ end
66
+ else
67
+ headers = {Kentico::Kontent::Delivery::DeliveryQuery::HEADER_CONTINUATION => CONTINUATION_HEADER_1}
68
+ path = Pathname.new(File.dirname(__FILE__) + '/items_feed/articles_feed_1.json')
69
+ end
70
+
71
+ OpenStruct.new(
72
+ headers: headers,
73
+ body: path.read
74
+ )
75
+ end
76
+
51
77
  def respond_filtering(query)
52
78
  path =
53
79
  case CGI.unescape query
@@ -0,0 +1,39 @@
1
+ {
2
+ "items": [{
3
+ "system": {
4
+ "id": "b2fea94c-73fd-42ec-a22f-f409878de187",
5
+ "name": "Origins of Arabica Bourbon",
6
+ "codename": "origins_of_arabica_bourbon",
7
+ "language": "en-US",
8
+ "type": "article",
9
+ "sitemap_locations": [],
10
+ "last_modified": "2019-03-27T13:21:49.151Z"
11
+ },
12
+ "elements": {
13
+ "title": {
14
+ "type": "text",
15
+ "name": "Title",
16
+ "value": "Origins of Arabica Bourbon"
17
+ },
18
+ "summary": {
19
+ "type": "text",
20
+ "name": "Summary",
21
+ "value": "This one particular type of coffee, the Arabica Bourbon, is now sold only in Japan. It has been brought back to life by enthusiasts after being almost forgotten for nearly sixty years."
22
+ },
23
+ "personas": {
24
+ "type": "taxonomy",
25
+ "name": "Personas",
26
+ "taxonomy_group": "personas",
27
+ "value": [{
28
+ "name": "Barista",
29
+ "codename": "barista"
30
+ }, {
31
+ "name": "Coffee blogger",
32
+ "codename": "coffee_blogger"
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "items": [{
3
+ "system": {
4
+ "id": "3120ec15-a4a2-47ec-8ccd-c85ac8ac5ba5",
5
+ "name": "Which brewing fits you?",
6
+ "codename": "which_brewing_fits_you_",
7
+ "language": "en-US",
8
+ "type": "article",
9
+ "sitemap_locations": [],
10
+ "last_modified": "2019-03-27T13:24:54.042Z"
11
+ },
12
+ "elements": {
13
+ "title": {
14
+ "type": "text",
15
+ "name": "Title",
16
+ "value": "Which brewing fits you?"
17
+ },
18
+ "summary": {
19
+ "type": "text",
20
+ "name": "Summary",
21
+ "value": "We have put down three procedures with clearly written steps describing the process of making coffee. Read this article to convince yourself that brewing coffee is no science"
22
+ },
23
+ "personas": {
24
+ "type": "taxonomy",
25
+ "name": "Personas",
26
+ "taxonomy_group": "personas",
27
+ "value": [{
28
+ "name": "Coffee lover",
29
+ "codename": "coffee_lover"
30
+ }, {
31
+ "name": "Coffee blogger",
32
+ "codename": "coffee_blogger"
33
+ }, {
34
+ "name": "Barista",
35
+ "codename": "barista"
36
+ }
37
+ ]
38
+ }
39
+ }
40
+ }, {
41
+ "system": {
42
+ "id": "f4b3fc05-e988-4dae-9ac1-a94aba566474",
43
+ "name": "On Roasts",
44
+ "codename": "on_roasts",
45
+ "language": "en-US",
46
+ "type": "article",
47
+ "sitemap_locations": [],
48
+ "last_modified": "2019-03-27T13:21:11.38Z"
49
+ },
50
+ "elements": {
51
+ "title": {
52
+ "type": "text",
53
+ "name": "Title",
54
+ "value": "On Roasts"
55
+ },
56
+ "summary": {
57
+ "type": "text",
58
+ "name": "Summary",
59
+ "value": "Roasting coffee beans can take from 6 to 13 minutes. Different roasting times produce different types of coffee, with varying concentration of caffeine and intensity of the original flavor."
60
+ },
61
+ "personas": {
62
+ "type": "taxonomy",
63
+ "name": "Personas",
64
+ "taxonomy_group": "personas",
65
+ "value": [{
66
+ "name": "Barista",
67
+ "codename": "barista"
68
+ }, {
69
+ "name": "Coffee blogger",
70
+ "codename": "coffee_blogger"
71
+ }
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ ],
77
+ "modular_content": {}
78
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "items": [{
3
+ "system": {
4
+ "id": "cf106f4e-30a4-42ef-b313-b8ea3fd3e5c5",
5
+ "name": "Coffee Beverages Explained",
6
+ "codename": "coffee_beverages_explained",
7
+ "language": "en-US",
8
+ "type": "article",
9
+ "sitemap_locations": [],
10
+ "last_modified": "2019-03-27T13:12:58.578Z"
11
+ },
12
+ "elements": {
13
+ "title": {
14
+ "type": "text",
15
+ "name": "Title",
16
+ "value": "Coffee Beverages Explained"
17
+ },
18
+ "summary": {
19
+ "type": "text",
20
+ "name": "Summary",
21
+ "value": "Espresso and filtered coffee are the two main categories of coffee, based on the method of preparation. Learn about individual types of coffee that fall under these categories."
22
+ },
23
+ "personas": {
24
+ "type": "taxonomy",
25
+ "name": "Personas",
26
+ "taxonomy_group": "personas",
27
+ "value": [{
28
+ "name": "Coffee lover",
29
+ "codename": "coffee_lover"
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ }, {
35
+ "system": {
36
+ "id": "117cdfae-52cf-4885-b271-66aef6825612",
37
+ "name": "Coffee processing techniques",
38
+ "codename": "coffee_processing_techniques",
39
+ "language": "en-US",
40
+ "type": "article",
41
+ "sitemap_locations": [],
42
+ "last_modified": "2019-03-27T13:13:35.312Z"
43
+ },
44
+ "elements": {
45
+ "title": {
46
+ "type": "text",
47
+ "name": "Title",
48
+ "value": "Coffee processing techniques"
49
+ },
50
+ "summary": {
51
+ "type": "text",
52
+ "name": "Summary",
53
+ "value": "Learn about the techniques of processing the products of coffee plants. Different methods are used in different parts of the world depending mainly on their weather conditions."
54
+ },
55
+ "personas": {
56
+ "type": "taxonomy",
57
+ "name": "Personas",
58
+ "taxonomy_group": "personas",
59
+ "value": [{
60
+ "name": "Coffee blogger",
61
+ "codename": "coffee_blogger"
62
+ }, {
63
+ "name": "Coffee lover",
64
+ "codename": "coffee_lover"
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ }, {
70
+ "system": {
71
+ "id": "23f71096-fa89-4f59-a3f9-970e970944ec",
72
+ "name": "Donate with us",
73
+ "codename": "donate_with_us",
74
+ "language": "en-US",
75
+ "type": "article",
76
+ "sitemap_locations": [],
77
+ "last_modified": "2019-03-27T13:14:07.384Z"
78
+ },
79
+ "elements": {
80
+ "title": {
81
+ "type": "text",
82
+ "name": "Title",
83
+ "value": "Donate with us"
84
+ },
85
+ "summary": {
86
+ "type": "text",
87
+ "name": "Summary",
88
+ "value": "Dancing Goat regularly donates money to Children in Africa, a foundation helping children with food, accommodation, education, and other essentials. Donate with us and create a better world."
89
+ },
90
+ "personas": {
91
+ "type": "taxonomy",
92
+ "name": "Personas",
93
+ "taxonomy_group": "personas",
94
+ "value": [{
95
+ "name": "Cafe owner",
96
+ "codename": "cafe_owner"
97
+ }
98
+ ]
99
+ }
100
+ }
101
+ }
102
+ ],
103
+ "modular_content": {}
104
+ }
@@ -1,7 +1,7 @@
1
1
  module Kentico
2
2
  module Kontent
3
3
  module Delivery
4
- VERSION = '2.0.15'.freeze
4
+ VERSION = '2.0.16'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -12,6 +12,7 @@ require File.dirname(__FILE__) + '/delivery/responses/delivery_type_response'
12
12
  require File.dirname(__FILE__) + '/delivery/responses/delivery_taxonomy_listing_response'
13
13
  require File.dirname(__FILE__) + '/delivery/responses/delivery_taxonomy_response'
14
14
  require File.dirname(__FILE__) + '/delivery/responses/delivery_element_response'
15
+ require File.dirname(__FILE__) + '/delivery/responses/delivery_items_feed_response'
15
16
  require File.dirname(__FILE__) + '/delivery/resolvers/content_link_resolver'
16
17
  require File.dirname(__FILE__) + '/delivery/resolvers/inline_content_item_resolver'
17
18
  require File.dirname(__FILE__) + '/delivery/resolvers/linked_item_resolver'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontent-delivery-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dugre
@@ -112,14 +112,14 @@ dependencies:
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: 0.18.5
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: '0'
122
+ version: 0.18.5
123
123
  description: Kentico Kontent Delivery SDK for Ruby
124
124
  email:
125
125
  - EricD@kentico.com
@@ -149,6 +149,7 @@ files:
149
149
  - lib/delivery/responses/delivery_element_response.rb
150
150
  - lib/delivery/responses/delivery_item_listing_response.rb
151
151
  - lib/delivery/responses/delivery_item_response.rb
152
+ - lib/delivery/responses/delivery_items_feed_response.rb
152
153
  - lib/delivery/responses/delivery_taxonomy_listing_response.rb
153
154
  - lib/delivery/responses/delivery_taxonomy_response.rb
154
155
  - lib/delivery/responses/delivery_type_listing_response.rb
@@ -169,6 +170,9 @@ files:
169
170
  - lib/delivery/tests/generic/taxonomies.json
170
171
  - lib/delivery/tests/generic/types.json
171
172
  - lib/delivery/tests/generic/types/brewer/elements/product_status.json
173
+ - lib/delivery/tests/items_feed/articles_feed_1.json
174
+ - lib/delivery/tests/items_feed/articles_feed_2.json
175
+ - lib/delivery/tests/items_feed/articles_feed_3.json
172
176
  - lib/delivery/version.rb
173
177
  - lib/kontent-delivery-sdk-ruby.rb
174
178
  homepage: https://github.com/Kentico/kontent-delivery-sdk-ruby