kontent-delivery-sdk-ruby 2.0.11 → 2.0.18

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: 10a1940690541523126a2bd9f3767e54a68de48c14ca7acfb311f392e0cb3707
4
- data.tar.gz: 80b485b19bef5ddc40e8964133b96dc0c1d3543f2c477c704973502c86495832
3
+ metadata.gz: 3f75c228e2b2a9c4fabf5971b8610e8659fcafa31ebb603bb77918bd1ba314db
4
+ data.tar.gz: 16048be6a0cc5e3749f090ef93b40e9b0899f18f576b1333e34cf93d05417f5f
5
5
  SHA512:
6
- metadata.gz: e11259c855f2dc4caf3146a704b0330acf6314d68cff4259a1acb03c60bee8359b567f68d10c033e2fef3bd36a51da864f8f5501485b032e05feba6b37f0a57b
7
- data.tar.gz: 0a4ab01bb8be8744d83faf31ed25e35fa986b1fedaf531e7c85978138a3e58563ead1e5d19ba42e494af9d79ba73bedc87e3f1c0ea80088582a3b06790f6dbeb
6
+ metadata.gz: bdace49434ca1bcbcb6947af19649696380290402df204650e165e984ba9d9b2901f3eee3f79ee7b1dc9198f6b17a2356fd52e0a48befb2c3aded4c0b08164d1
7
+ data.tar.gz: e7067f01848f4de3ce01bcbd55fac0aafd2973e3b41013cd237bab00d9a2401e7698fdc91d69878767aaa7cbd7d4f7eb39c66a1bb89359d2433720e4965c11b2
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
 
@@ -23,7 +23,7 @@ class ApplicationController < ActionController::Base
23
23
  PROJECT_ID = '<your-project-id>'.freeze
24
24
  ```
25
25
 
26
- If you don't have the sample project installed in Kentico Kontent, you can generate a new project [here](https://app.kontent.ai/sample-project-generator). Save the file, then open a terminal in the `/dancing_goat` directory and run the following commands:
26
+ If you don't have the sample project installed in Kentico Kontent, you can [generate a new sample project](https://docs.kontent.ai/tutorials/set-up-projects/manage-projects/managing-projects#a-creating-a-sample-project). Save the file, then open a terminal in the `/dancing_goat` directory and run the following commands:
27
27
 
28
28
  ```
29
29
  bundle install
@@ -63,14 +63,14 @@ delivery_client = KK::DeliveryClient.new project_id: '<your-project-id>'
63
63
 
64
64
  ### Previewing unpublished content
65
65
 
66
- To enable [preview](https://developer.kenticocloud.com/docs/previewing-content-in-a-separate-environment "preview"), pass the Preview API Key to the constructor:
66
+ To [enable preview](https://docs.kontent.ai/tutorials/develop-apps/get-content/configuring-preview-for-content-items "See how to configure your app and Kontent project to enable content preview"), pass the Preview API Key to the constructor:
67
67
 
68
68
  ```ruby
69
69
  delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
70
70
  preview_key: '<your-preview-key>'
71
71
  ```
72
72
 
73
- This enables preview, but you can toggle preview at any time by setting the `use_preview` attribute of DeliveryClient which is propogated to all queries created by the client, _or_ per-query by setting it's `use_preview` attribute:
73
+ This enables preview, but you can toggle preview at any time by setting the `use_preview` attribute of `DeliveryClient` which is propagated to all queries created by the client, _or_ per-query by setting its `use_preview` attribute:
74
74
 
75
75
  ```ruby
76
76
  # For all queries created by client
@@ -86,14 +86,14 @@ end
86
86
 
87
87
  ### Making secure requests
88
88
 
89
- If you've [secured access](https://developer.kenticocloud.com/docs/securing-public-access "Securing public access") to your project, you need to provide the DeliveryClient with the primary or secondary key:
89
+ If you've [secured access](https://docs.kontent.ai/tutorials/develop-apps/get-content/securing-public-access "See how to enable secured access for your Kontent project") to your project, you need to provide the `DeliveryClient` with either the primary or secondary key:
90
90
 
91
91
  ```ruby
92
92
  Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
93
93
  secure_key: '<your-secure-key>'
94
94
  ```
95
95
 
96
- You can then request the secure published content in your project. Be sure to not expose the key if the file(s) it appears in are publicly-available.
96
+ You can then securely request published content in your project. Be sure to not expose the key if the file(s) it appears in are publicly available.
97
97
 
98
98
  ### Retry policy
99
99
 
@@ -137,7 +137,7 @@ response = delivery_client.items.execute
137
137
 
138
138
  ### Filtering
139
139
 
140
- You can use [filtering](https://developer.kenticocloud.com/v1/reference#content-filtering "filtering") to retrieve particular items. The filtering methods are applied directly to a string and the available methods are:
140
+ You can use [filtering](https://docs.kontent.ai/reference/delivery-api#tag/Filtering-content "See content filtering options in Delivery API") to retrieve particular items. The filtering methods are applied directly to a string and the available methods are:
141
141
 
142
142
  |Method|Example|REST equivalent|
143
143
  |--|--|--|
@@ -171,12 +171,12 @@ The `.item` and `.items` methods return a `Kentico::Kontent::Delivery::DeliveryQ
171
171
 
172
172
  |Method|Example|REST equivalent
173
173
  |--|--|--|
174
- |[order_by](https://developer.kenticocloud.com/v1/reference#content-ordering "order_by")|`order_by 'system.last_modified' '[desc]'`|?order=system.last_modified[desc]
175
- |[skip](https://developer.kenticocloud.com/v1/reference#listing-response-paging "skip")|`skip 5`|?skip=5
176
- |[limit](https://developer.kenticocloud.com/v1/reference#listing-response-paging "limit")|`limit 5`|?limit=5
177
- |[elements](https://developer.kenticocloud.com/v1/reference#projection "elements")|`elements %w[price product_name image]`|?elements=price,product_name,image
178
- |[depth](https://developer.kenticocloud.com/v1/reference#linked-content "depth")|`depth 0`|?depth=0
179
- |[language](https://developer.kenticocloud.com/docs/understanding-language-fallbacks "language")|`language 'en'`|?language=en
174
+ |[order_by](https://docs.kontent.ai/reference/delivery-api#operation/list-content-items "order_by")|`order_by 'system.last_modified' '[desc]'`|?order=system.last_modified[desc]
175
+ |[skip](https://docs.kontent.ai/reference/delivery-api#operation/list-content-items "skip")|`skip 5`|?skip=5
176
+ |[limit](https://docs.kontent.ai/reference/delivery-api#operation/list-content-items "limit")|`limit 5`|?limit=5
177
+ |[elements](https://docs.kontent.ai/reference/delivery-api#tag/Projection "elements")|`elements %w[price product_name image]`|?elements=price,product_name,image
178
+ |[depth](https://docs.kontent.ai/reference/delivery-api#tag/Linked-content-and-components/linked-content-depth "depth")|`depth 0`|?depth=0
179
+ |[language](https://docs.kontent.ai/tutorials/set-up-projects/set-up-languages/localization-in-kentico-kontent#a-understanding-language-fallbacks "language")|`language 'en'`|?language=en
180
180
 
181
181
  For example:
182
182
 
@@ -224,7 +224,7 @@ price = response.item.elements.price.value
224
224
 
225
225
  ### Requesting the latest content
226
226
 
227
- Kentico caches content using Fastly, so requests made to Kentico Kontent may not be up-to-date. In some cases, such as when reacting to [webhook](https://developer.kenticocloud.com/docs/webhooks) notifications, you might want to request the latest content from your Kentico Kontent project.
227
+ Kentico caches content using Fastly, so requests made to Kentico Kontent may not be up-to-date. In some cases, such as when reacting to [webhook](https://docs.kontent.ai/tutorials/develop-apps/integrate/using-webhooks-for-automatic-updates) notifications, you might want to request the latest content from your Kentico Kontent project.
228
228
 
229
229
  You can check the headers of the response for the **X-Stale-Content** header to check if the response was served from cache:
230
230
 
@@ -244,6 +244,18 @@ delivery_client.item('about_us')
244
244
  .execute
245
245
  ```
246
246
 
247
+ ### Providing custom headers
248
+
249
+ If you want to pass custom headers in the request, you can use `custom_headers`. This could be useful when you are developing your package on top of the SDK.
250
+
251
+ Note that you can not override internal headers such as `Authorization`. If headers with an existing key are passed into the method, they will be ignored.
252
+
253
+ ```ruby
254
+ delivery_client.items
255
+ .custom_headers({ 'MY-HEADER' => 'HEADER VALUE' })
256
+ .execute
257
+ ```
258
+
247
259
  ### Custom URLs
248
260
 
249
261
  When you have a URL (i.e. `next_page` for paging, for testing purposes, or if you prefer to build it on your own) and still want to leverage SDK functionality such as rich text resolving, use the .url method:
@@ -282,7 +294,7 @@ end
282
294
 
283
295
  ### Pagination
284
296
 
285
- The `DeliveryItemListingResponse` also contains a `pagination` attribute to access the [paging](https://developer.kenticocloud.com/v1/reference#listing-response-paging "paging") data for the Delivery query. This object contains the following attributes:
297
+ The `DeliveryItemListingResponse` also contains a `pagination` attribute to access the [paging](https://docs.kontent.ai/reference/delivery-api#operation/list-content-items "paging") data for the Delivery query. This object contains the following attributes:
286
298
 
287
299
  - **skip**
288
300
  - **limit**
@@ -304,6 +316,26 @@ delivery_client.items
304
316
 
305
317
  :warning: Note that using the `include_total_count` method may increase the response time and should only be used if necessary.
306
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](#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
+
307
339
  ## Retrieving content types
308
340
 
309
341
  You can use the `.type` and `.types` methods to request your content types from Kentico Kontent:
@@ -375,7 +407,7 @@ end
375
407
 
376
408
  ## Retrieving content type elements
377
409
 
378
- Kentico Kontent provides an [endpoint](https://developer.kenticocloud.com/v1/reference#view-a-content-type-element) for obtaining details about a specific element of a content type. In the Ruby SDK, you can use the `.element` method:
410
+ Kentico Kontent provides an [endpoint](https://docs.kontent.ai/reference/delivery-api#operation/retrieve-a-content-element) for obtaining details about a specific element of a content type. In the Ruby SDK, you can use the `.element` method:
379
411
 
380
412
  ```ruby
381
413
  delivery_client.element('brewer', 'product_status').execute do |response|
@@ -385,7 +417,7 @@ end
385
417
 
386
418
  This returns a `Kentico::Kontent::Delivery::Responses::DeliveryElementResponse` where the `element` attribute is a dynamic OStruct representation of the JSON response. This means that you can access any property of the element by simply typing the name as in the above example.
387
419
 
388
- The element will always contain __codename__, __type__, and __name__, but multiple choice elements will also contain __options__ and taxonomy elements will contain __taxonomy_group__. The Ruby SDK fully supports obtaining [custom elements](https://developer.kenticocloud.com/v1/reference#custom-elements-api) using this approach and any other methods.
420
+ The element will always contain __codename__, __type__, and __name__, but multiple choice elements will also contain __options__ and taxonomy elements will contain __taxonomy_group__. The Ruby SDK fully supports obtaining [custom elements](https://docs.kontent.ai/reference/custom-elements-js-api) using this approach and any other methods.
389
421
 
390
422
  ## Resolving links
391
423
 
@@ -489,9 +521,22 @@ delivery_client.items
489
521
  .with_inline_content_item_resolver MyItemResolver.new
490
522
  ```
491
523
 
524
+ To resolve inline content in elements, you must call `get_string` similar to content item links:
525
+
526
+ ```ruby
527
+ item_resolver = Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver.new(lambda do |item|
528
+ return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
529
+ end)
530
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: PROJECT_ID,
531
+ inline_content_item_resolver: item_resolver
532
+ delivery_client.item('our_brewers').execute do |response|
533
+ text = response.item.get_string 'body_copy'
534
+ end
535
+ ```
536
+
492
537
  ## Image transformation
493
538
 
494
- When you've obtained the URL for an asset, you can use our [Image Transformation API](https://developer.kenticocloud.com/v1/reference#image-transformation) to make on-the-fly modifications to the image. To do this, use the static `.transform` method of `Kentico::Kontent::Delivery::Builders::ImageTransformationBuilder`, then call the transformation methods. When you're done, call the `.url` method to get the new URL:
539
+ When you've obtained the URL for an asset, you can use our [Image Transformation API](https://docs.kontent.ai/reference/image-transformation) to make on-the-fly modifications to the image. To do this, use the static `.transform` method of `Kentico::Kontent::Delivery::Builders::ImageTransformationBuilder`, then call the transformation methods. When you're done, call the `.url` method to get the new URL:
495
540
 
496
541
  ```ruby
497
542
  url = response.item.get_assets('teaser_image').first.url
@@ -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,
@@ -62,11 +65,6 @@ module Kentico
62
65
  # * *Returns*:
63
66
  # - Kentico::Kontent::Delivery::Responses::ResponseBase or a class extending it
64
67
  def execute
65
- headers = @headers.clone
66
- headers['X-KC-SDKID'] = provide_sdk_header
67
- headers['Authorization'] = "Bearer #{preview_key}" if should_preview
68
- headers['Authorization'] = "Bearer #{secure_key}" if !should_preview && secure_key
69
-
70
68
  resp = Kentico::Kontent::Delivery::RequestManager.start self, headers
71
69
  yield resp if block_given?
72
70
  resp
@@ -144,7 +142,7 @@ module Kentico
144
142
  # * *Returns*:
145
143
  # - +self+
146
144
  def skip(value)
147
- query_string.set_param('skip', value)
145
+ query_string.set_param('skip', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
148
146
  self
149
147
  end
150
148
 
@@ -172,7 +170,7 @@ module Kentico
172
170
  # * *Returns*:
173
171
  # - +self+
174
172
  def limit(value)
175
- query_string.set_param('limit', value)
173
+ query_string.set_param('limit', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
176
174
  self
177
175
  end
178
176
 
@@ -201,7 +199,7 @@ module Kentico
201
199
  # * *Returns*:
202
200
  # - +self+
203
201
  def depth(value)
204
- query_string.set_param('depth', value)
202
+ query_string.set_param('depth', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
205
203
  self
206
204
  end
207
205
 
@@ -212,7 +210,7 @@ module Kentico
212
210
  # * *Returns*:
213
211
  # - +self+
214
212
  def request_latest_content
215
- @headers['X-KC-Wait-For-Loading-New-Content'] = true
213
+ @headers[HEADER_WAIT_FOR_CONTENT] = true
216
214
  self
217
215
  end
218
216
 
@@ -230,8 +228,52 @@ module Kentico
230
228
  @url
231
229
  end
232
230
 
231
+ # Allows providing custom headers for client requests.
232
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#providing-custom-headers
233
+ #
234
+ # * *Args*:
235
+ # - *headers* (+Hash+) A hash that corresponds to provided headers
236
+ #
237
+ # * *Returns*:
238
+ # - +self+
239
+ def custom_headers(headers)
240
+ @custom_headers = headers
241
+ self
242
+ end
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
+
233
257
  private
234
258
 
259
+ # Returns request headers that are extended with custom headers.
260
+ # Custom headers do not override existing headers.
261
+ #
262
+ # * *Returns*
263
+ # - +Hash+
264
+ def headers
265
+ headers = @headers.clone
266
+ headers[HEADER_SDK_ID] = provide_sdk_header
267
+ headers['Authorization'] = "Bearer #{preview_key}" if should_preview
268
+ headers['Authorization'] = "Bearer #{secure_key}" if !should_preview && secure_key
269
+
270
+ if @custom_headers
271
+ headers.merge!(@custom_headers) { |key, v1, v2| v1 }
272
+ end
273
+
274
+ headers
275
+ end
276
+
235
277
  # Initializes the +query_string+ attribute with the passed array of
236
278
  # Kentico::Kontent::Delivery::QueryParameters::Filter objects.
237
279
  #
@@ -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
@@ -15,9 +15,9 @@ module Kentico
15
15
  # * *Args*:
16
16
  # - *http_code* (+integer+) The status code returned by the REST request
17
17
  # - *message* (+string+) An informative message about the response, visible when calling +to_s+
18
- # - *headers* (+hash+) The headers of the REST response
18
+ # - *headers* (+hash+) _optional_ The headers of the REST response
19
19
  # - *json* (+string+) _optional_ The complete, unmodified JSON response from the server
20
- def initialize(http_code, message, headers, json = '')
20
+ def initialize(http_code, message, headers = {}, json = '')
21
21
  self.http_code = http_code
22
22
  self.message = message
23
23
  self.headers = headers
@@ -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/AwAACC6AAcADACyAVABSRWIUIoqAAH2ABMCAQpFEEQAEAEIAGDAMABuAI4AyAACQCwAzACJBJBJIQhgAUYJIBFGiAhAERSKK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ggAAYAGVhIBhAGAAd4DSAABwADBSABABAAo2gB2AAIAhADAAEgCrBWg1YgCA/w8AEgDg8f8AIQB+ABMAQBQgAEoAUQAABzKAIgACWAAELoAFwG21DhUJUqmmqgBvggCAH4IBwOMAcQDAARmAQ4ABwABQz4AEwP8AAMD//w8AsQGAATIAIoABAoEAMAATAACQqto2Ir+ADYC4gCIAAAMIAGiAmIBhAAD4EUAPAEQAASTAA1wFAwAfgAOADYAVgZIAAKASACGAMQC/AZIAsCAEAJIAEAQCAMGABcAA8P7/////wwEAwIABAQCgIQAA+D2AT4ACwPD/hwDRAmAAooARAAwAggIg+B4AoQAAYCuAK4ARgBOAQgAA4AMAroBcgW2BmII8gA2AUwCA//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,24 @@
1
+ {
2
+ "item": {
3
+ "system": {
4
+ "id": "00000000-0000-0000-0000-000000000001",
5
+ "name": "Fake item 1",
6
+ "codename": "empty_rich_text",
7
+ "language": "en-US",
8
+ "type": "fake_type_1",
9
+ "sitemap_locations": [],
10
+ "last_modified": "2018-01-01T00:00:00.0000000Z"
11
+ },
12
+ "elements": {
13
+ "body_copy": {
14
+ "type": "rich_text",
15
+ "name": "Body Copy",
16
+ "images": {},
17
+ "links": {},
18
+ "modular_content": [],
19
+ "value": ""
20
+ }
21
+ }
22
+ },
23
+ "modular_content": {}
24
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "item": {
3
+ "system": {
4
+ "id": "4ffc70ea-62f6-4726-a5bf-39896d7c91c4",
5
+ "name": "TEST tables",
6
+ "codename": "rich_text_complex_tables",
7
+ "language": "en-US",
8
+ "type": "simple_rich_text",
9
+ "sitemap_locations": [],
10
+ "last_modified": "2020-03-16T17:49:42.7165723Z"
11
+ },
12
+ "elements": {
13
+ "rich_text": {
14
+ "type": "rich_text",
15
+ "name": "Rich text",
16
+ "images": {
17
+ "bf509e0d-d9ed-4925-968e-29a1f6a561c4": {
18
+ "image_id": "bf509e0d-d9ed-4925-968e-29a1f6a561c4",
19
+ "description": null,
20
+ "url": "https://qa-assets-us-01.global.ssl.fastly.net:443/34aaa010-a788-0004-ce89-a1c49a062a65/625c11f0-9783-47d3-b80e-2afafb8862e3/pikachu.jpg",
21
+ "width": 945,
22
+ "height": 819
23
+ },
24
+ "a0c1b647-e0b1-478a-b7bd-8df80b55e9f7": {
25
+ "image_id": "a0c1b647-e0b1-478a-b7bd-8df80b55e9f7",
26
+ "description": null,
27
+ "url": "https://qa-assets-us-01.global.ssl.fastly.net:443/34aaa010-a788-0004-ce89-a1c49a062a65/d74603bb-2109-4d45-885d-ff15c6ed9582/likeaboss.jpg",
28
+ "width": 1280,
29
+ "height": 720
30
+ }
31
+ },
32
+ "links": {
33
+ "5e1997a2-9f9b-43ba-92f3-3cb36409d811": {
34
+ "codename": "paper_filters_for_chemex",
35
+ "type": "accessory",
36
+ "url_slug": "paper-filters-for-chemex"
37
+ },
38
+ "4ffc70ea-62f6-4726-a5bf-39896d7c91c4": {
39
+ "codename": "test_tables",
40
+ "type": "simple_rich_text",
41
+ "url_slug": ""
42
+ },
43
+ "3120ec15-a4a2-47ec-8ccd-c85ac8ac5ba5": {
44
+ "codename": "which_brewing_fits_you_",
45
+ "type": "article",
46
+ "url_slug": "which-brewing-fits-you"
47
+ }
48
+ },
49
+ "modular_content": [],
50
+ "value": "<p>Hello world</p>\n<figure data-asset-id=\"bf509e0d-d9ed-4925-968e-29a1f6a561c4\" data-image-id=\"bf509e0d-d9ed-4925-968e-29a1f6a561c4\"><img src=\"https://qa-assets-us-01.global.ssl.fastly.net:443/34aaa010-a788-0004-ce89-a1c49a062a65/625c11f0-9783-47d3-b80e-2afafb8862e3/pikachu.jpg\" data-asset-id=\"bf509e0d-d9ed-4925-968e-29a1f6a561c4\" data-image-id=\"bf509e0d-d9ed-4925-968e-29a1f6a561c4\" alt=\"\"></figure>\n<p>Hello <a data-item-id=\"3ce384e6-ba4b-49c4-993a-ae4ee1e0a1cc\" href=\"\">world</a></p>\n<p><a data-item-id=\"5e1997a2-9f9b-43ba-92f3-3cb36409d811\" href=\"\">Hello </a>world</p>\n<table><tbody>\n <tr><td><h1>Beautiful table on steroids</h1>\n<h2>Which was changed BTW</h2>\n<p>Supports</p>\n<ul>\n <li>Lists</li>\n <li><strong>Formatting</strong></li>\n <li>Images\n <ol>\n <li>Yes, <a data-item-id=\"4ffc70ea-62f6-4726-a5bf-39896d7c91c4\" href=\"\">totally</a></li>\n <li>Really</li>\n <li><a data-item-id=\"3120ec15-a4a2-47ec-8ccd-c85ac8ac5ba5\" href=\"\">Wanna </a>see?</li>\n </ol>\n </li>\n</ul>\n<figure data-asset-id=\"a0c1b647-e0b1-478a-b7bd-8df80b55e9f7\" data-image-id=\"a0c1b647-e0b1-478a-b7bd-8df80b55e9f7\"><img src=\"https://qa-assets-us-01.global.ssl.fastly.net:443/34aaa010-a788-0004-ce89-a1c49a062a65/d74603bb-2109-4d45-885d-ff15c6ed9582/likeaboss.jpg\" data-asset-id=\"a0c1b647-e0b1-478a-b7bd-8df80b55e9f7\" data-image-id=\"a0c1b647-e0b1-478a-b7bd-8df80b55e9f7\" alt=\"\"></figure>\n<p><em>Thanks for watching!</em></p>\n</td><td>with</td><td>some</td></tr>\n <tr><td>text</td><td>in</td><td>various</td></tr>\n <tr><td>table</td><td>cells</td><td>!</td></tr>\n</tbody></table>\n<p>z</p>\n<p>dd</p>\n<table><tbody>\n <tr><td>d</td><td>f</td><td>g</td></tr>\n <tr><td>g</td><td>g</td><td>gg</td></tr>\n <tr><td>g</td><td>g</td><td>g</td></tr>\n</tbody></table>\n<p>x</p>"
51
+ },
52
+ "rich_text_2": {
53
+ "type": "rich_text",
54
+ "name": "Rich text 2",
55
+ "images": {},
56
+ "links": {},
57
+ "modular_content": [],
58
+ "value": "<p><br></p>"
59
+ },
60
+ "simple_text": {
61
+ "type": "text",
62
+ "name": "Simple text",
63
+ "value": ""
64
+ },
65
+ "second_rich_text": {
66
+ "type": "rich_text",
67
+ "name": "Second rich text",
68
+ "images": {},
69
+ "links": {},
70
+ "modular_content": [],
71
+ "value": "<p><br></p>"
72
+ },
73
+ "ultimate_answer_to_life_universe_and_everything": {
74
+ "type": "number",
75
+ "name": "Ultimate answer to life universe and everything",
76
+ "value": null
77
+ }
78
+ }
79
+ },
80
+ "modular_content": {}
81
+ }
@@ -50,7 +50,7 @@
50
50
  "modular_content": [
51
51
  "aeropress"
52
52
  ],
53
- "value": "<p>The history of coffee is patchy and full of myth and hearsay.</p>\n<object type=\"application/kenticocloud\" data-type=\"item\" data-rel=\"link\" data-codename=\"aeropress\"></object>\n<p><br></p>\n<p>One of the most popular story goes that Kaldi, an Ethiopian goatherd, saw his goats eating coffee berries and as a result becoming elated. So, Kaldi then tried them himself and thus discovered the potential of coffee. And that's where we got our name - Dancing Goat.</p>\n<p>Although it's far more likely that uses for coffee were developed over time and were discovered by people tasting various parts of the cherry, &nbsp;the old fables do add a bit of romance and are very cute.</p>\n<p>Coffee requires a warm climate and lots of moisture, so it is produced within a belt extending around the world between the Tropic of Cancer and the Tropic of Capricorn.</p>\n<p>Coffee grows on trees that flower and produce fleshy red fruit (orange or yellow is also possible) called a drupe though it is popularly referred to as the ‘berry’ or ‘cherry’. What we refer to as coffee beans are actually seeds, which are produced in the centre of the drupe, often in pairs. After harvesting, the flesh of the drupe is washed or dried and the ‘beans’ extracted.</p>\n<p>Coffee beans vary in their shape, size, color as well as flavor depending on the region and conditions in which they were grown. The difference of aromas and flavors between various regional varietals is as vast as the regions they grow in. Just like the teas and wines of the world, and even more so. It is always worth trying new varietals that may stimulate your taste buds in a different way.</p>\n<p>The two major species of coffee are <em>Coffea arabica</em> and <em>Coffea canephora</em> (also called <em>Coffea robusta</em>).</p>\n<p>Arabica is believed to be the first species of coffee to have been cultivated.</p>\n<p>It requires more care during cultivation and is considered to produce better coffee than robusta. Arabica plants grow at high altitudes of around 1,000 to 2,000 meters, approximately 3,200 to 6,500 ft, above sea level in regions across South and Central America as well as Africa. Arabica is costlier to grow as it produces lower yields than Robusta despite requiring more labor. Despite all that, it is considered superior to robusta. The high demand and lower availability drives the price high. Arabica is the species most associated with specialty (sometimes referred to as gourmet) coffees.</p>\n<p>The only place where Arabica coffee grows indigenously is Ethiopia. It is the birthplace of coffee and also the only place in which it truly grows wild. All countries that produce Arabica coffees have transplanted plant stock directly from Ethiopia or from other countries that had already done so.</p>"
53
+ "value": "<p><object type=\"application/kenticocloud\" data-type=\"item\" data-rel=\"link\" data-codename=\"aeropress\"></object>The history of coffee is patchy and full of myth and hearsay.</p>\n<object type=\"application/kenticocloud\" data-type=\"item\" data-rel=\"link\" data-codename=\"aeropress\"></object>\n<p><br></p>\n<p>One of the most popular story goes that Kaldi, an Ethiopian goatherd, saw his goats eating coffee berries and as a result becoming elated. So, Kaldi then tried them himself and thus discovered the potential of coffee. And that's where we got our name - Dancing Goat.</p>\n<p>Although it's far more likely that uses for coffee were developed over time and were discovered by people tasting various parts of the cherry, &nbsp;the old fables do add a bit of romance and are very cute.</p>\n<p>Coffee requires a warm climate and lots of moisture, so it is produced within a belt extending around the world between the Tropic of Cancer and the Tropic of Capricorn.</p>\n<p>Coffee grows on trees that flower and produce fleshy red fruit (orange or yellow is also possible) called a drupe though it is popularly referred to as the ‘berry’ or ‘cherry’. What we refer to as coffee beans are actually seeds, which are produced in the centre of the drupe, often in pairs. After harvesting, the flesh of the drupe is washed or dried and the ‘beans’ extracted.</p>\n<p>Coffee beans vary in their shape, size, color as well as flavor depending on the region and conditions in which they were grown. The difference of aromas and flavors between various regional varietals is as vast as the regions they grow in. Just like the teas and wines of the world, and even more so. It is always worth trying new varietals that may stimulate your taste buds in a different way.</p>\n<p>The two major species of coffee are <em>Coffea arabica</em> and <em>Coffea canephora</em> (also called <em>Coffea robusta</em>).</p>\n<p>Arabica is believed to be the first species of coffee to have been cultivated.</p>\n<p>It requires more care during cultivation and is considered to produce better coffee than robusta. Arabica plants grow at high altitudes of around 1,000 to 2,000 meters, approximately 3,200 to 6,500 ft, above sea level in regions across South and Central America as well as Africa. Arabica is costlier to grow as it produces lower yields than Robusta despite requiring more labor. Despite all that, it is considered superior to robusta. The high demand and lower availability drives the price high. Arabica is the species most associated with specialty (sometimes referred to as gourmet) coffees.</p>\n<p>The only place where Arabica coffee grows indigenously is Ethiopia. It is the birthplace of coffee and also the only place in which it truly grows wild. All countries that produce Arabica coffees have transplanted plant stock directly from Ethiopia or from other countries that had already done so.</p>"
54
54
  },
55
55
  "related_articles": {
56
56
  "type": "modular_content",
@@ -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.11'.freeze
4
+ VERSION = '2.0.18'.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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontent-delivery-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.0.18
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-12-13 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -28,40 +28,40 @@ dependencies:
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.10.8
31
34
  - - ">="
32
35
  - !ruby/object:Gem::Version
33
36
  version: 1.8.4
34
- - - "~>"
35
- - !ruby/object:Gem::Version
36
- version: 1.10.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 1.10.8
41
44
  - - ">="
42
45
  - !ruby/object:Gem::Version
43
46
  version: 1.8.4
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: 1.10.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: 2.1.0.rc1
54
- - - "~>"
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: 2.1.0.rc1
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: 2.1.0.rc1
64
- - - "~>"
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: 2.1.0.rc1
67
67
  - !ruby/object:Gem::Dependency
@@ -82,44 +82,44 @@ dependencies:
82
82
  name: rake
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - "~>"
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: '10.0'
87
+ version: 12.3.3
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - "~>"
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: '10.0'
94
+ version: 12.3.3
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rspec
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '3.0'
101
+ version: '3.8'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '3.0'
108
+ version: '3.8'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: simplecov
111
111
  requirement: !ruby/object:Gem::Requirement
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
@@ -165,10 +166,15 @@ files:
165
166
  - lib/delivery/tests/generic/items/about_us.json
166
167
  - lib/delivery/tests/generic/items/aeropress_filters.json
167
168
  - lib/delivery/tests/generic/items/coffee_processing_techniques.json
169
+ - lib/delivery/tests/generic/items/empty_rich_text.json
170
+ - lib/delivery/tests/generic/items/rich_text_complex_tables.json
168
171
  - lib/delivery/tests/generic/items/where_does_coffee_come_from_.json
169
172
  - lib/delivery/tests/generic/taxonomies.json
170
173
  - lib/delivery/tests/generic/types.json
171
174
  - lib/delivery/tests/generic/types/brewer/elements/product_status.json
175
+ - lib/delivery/tests/items_feed/articles_feed_1.json
176
+ - lib/delivery/tests/items_feed/articles_feed_2.json
177
+ - lib/delivery/tests/items_feed/articles_feed_3.json
172
178
  - lib/delivery/version.rb
173
179
  - lib/kontent-delivery-sdk-ruby.rb
174
180
  homepage: https://github.com/Kentico/kontent-delivery-sdk-ruby
@@ -194,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
200
  - !ruby/object:Gem::Version
195
201
  version: '0'
196
202
  requirements: []
197
- rubygems_version: 3.0.6
203
+ rubygems_version: 3.1.4
198
204
  signing_key:
199
205
  specification_version: 4
200
206
  summary: Kentico Kontent Delivery SDK for Ruby