kontent-delivery-sdk-ruby 2.0.24 → 2.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +21 -21
  3. data/README.md +603 -603
  4. data/bin/console +14 -14
  5. data/bin/setup +8 -8
  6. data/lib/delivery/builders/image_transformation_builder.rb +272 -272
  7. data/lib/delivery/builders/url_builder.rb +123 -123
  8. data/lib/delivery/client/delivery_client.rb +184 -184
  9. data/lib/delivery/client/delivery_query.rb +302 -302
  10. data/lib/delivery/client/request_manager.rb +126 -126
  11. data/lib/delivery/models/content_item.rb +153 -153
  12. data/lib/delivery/models/content_type.rb +41 -41
  13. data/lib/delivery/models/language.rb +29 -29
  14. data/lib/delivery/models/pagination.rb +22 -22
  15. data/lib/delivery/models/taxonomy_group.rb +39 -39
  16. data/lib/delivery/query_parameters/filters.rb +201 -201
  17. data/lib/delivery/query_parameters/parameter_base.rb +56 -56
  18. data/lib/delivery/query_parameters/query_string.rb +78 -78
  19. data/lib/delivery/resolvers/content_link_resolver.rb +102 -102
  20. data/lib/delivery/resolvers/inline_content_item_resolver.rb +75 -75
  21. data/lib/delivery/resolvers/linked_item_resolver.rb +43 -43
  22. data/lib/delivery/responses/delivery_element_response.rb +34 -34
  23. data/lib/delivery/responses/delivery_item_listing_response.rb +54 -54
  24. data/lib/delivery/responses/delivery_item_response.rb +40 -40
  25. data/lib/delivery/responses/delivery_items_feed_response.rb +58 -58
  26. data/lib/delivery/responses/delivery_language_listing_response.rb +44 -44
  27. data/lib/delivery/responses/delivery_taxonomy_listing_response.rb +47 -47
  28. data/lib/delivery/responses/delivery_taxonomy_response.rb +33 -33
  29. data/lib/delivery/responses/delivery_type_listing_response.rb +46 -46
  30. data/lib/delivery/responses/delivery_type_response.rb +32 -32
  31. data/lib/delivery/responses/response_base.rb +39 -39
  32. data/lib/delivery/tests/401.json +5 -5
  33. data/lib/delivery/tests/429.json +4 -4
  34. data/lib/delivery/tests/fake_responder.rb +99 -99
  35. data/lib/delivery/tests/filtering/items_with_count.json +5384 -5384
  36. data/lib/delivery/tests/filtering/pagination.json +761 -761
  37. data/lib/delivery/tests/generic/items.json +5383 -5383
  38. data/lib/delivery/tests/generic/items/about_us.json +276 -276
  39. data/lib/delivery/tests/generic/items/aeropress_filters.json +155 -155
  40. data/lib/delivery/tests/generic/items/coffee_processing_techniques.json +565 -565
  41. data/lib/delivery/tests/generic/items/where_does_coffee_come_from_.json +598 -598
  42. data/lib/delivery/tests/generic/languages.json +23 -23
  43. data/lib/delivery/tests/generic/taxonomies.json +203 -203
  44. data/lib/delivery/tests/generic/taxonomies/manufacturer.json +29 -29
  45. data/lib/delivery/tests/generic/types.json +835 -835
  46. data/lib/delivery/tests/generic/types/brewer.json +88 -88
  47. data/lib/delivery/tests/generic/types/brewer/elements/product_status.json +5 -5
  48. data/lib/delivery/tests/items_feed/articles_feed_1.json +39 -39
  49. data/lib/delivery/tests/items_feed/articles_feed_2.json +78 -78
  50. data/lib/delivery/tests/items_feed/articles_feed_3.json +104 -104
  51. data/lib/kontent-delivery-sdk-ruby.rb +22 -22
  52. metadata +12 -13
@@ -1,302 +1,302 @@
1
- require 'rubygems'
2
- require 'delivery/builders/url_builder'
3
- require 'delivery/query_parameters/query_string'
4
-
5
- module Kentico
6
- module Kontent
7
- module Delivery
8
- # Responsible for executing REST requests to Kentico Kontent.
9
- class DeliveryQuery
10
- ERROR_PREVIEW = 'Preview is enabled for the query, but the key is null. '\
11
- 'You can set the preview_key attribute of the query, or '\
12
- 'when you initialize the client. See '\
13
- 'https://github.com/Kentico/kontent-delivery-sdk-ruby#previewing-unpublished-content'.freeze
14
- ERROR_PARAMS = 'Only filters may be passed in the .item or .items methods'\
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
19
- attr_accessor :use_preview,
20
- :preview_key,
21
- :project_id,
22
- :code_name,
23
- :secure_key,
24
- :content_link_url_resolver,
25
- :inline_content_item_resolver,
26
- :query_type,
27
- :query_string,
28
- :content_type,
29
- :with_retry_policy
30
-
31
- # Setter for a custom URL.
32
- #
33
- # * *Args*:
34
- # - *url* (+string+) _optional_ Custom URL to use for the query
35
- #
36
- # * *Returns*:
37
- # - +self+
38
- def url(url = nil)
39
- @url = url unless url.nil?
40
- self
41
- end
42
-
43
- # Constructor. Queries should not be instantiated using the constructor, but
44
- # using one of the Kentico::Kontent::Delivery::DeliveryClient methods instead.
45
- #
46
- # * *Args*:
47
- # - *config* (+Hash+) A hash in which each key automatically has its value paired with the corresponding attribute
48
- def initialize(config)
49
- @headers = {}
50
-
51
- # Map each hash value to attr with corresponding key
52
- # from https://stackoverflow.com/a/2681014/5656214
53
- config.each do |k, v|
54
- instance_variable_set("@#{k}", v) unless v.nil?
55
- end
56
- self.query_string = Kentico::Kontent::Delivery::QueryParameters::QueryString.new
57
- return if config.fetch(:qp, nil).nil?
58
-
59
- # Query parameters were passed, parse and validate
60
- validate_params config.fetch(:qp)
61
- end
62
-
63
- # Executes the REST request.
64
- #
65
- # * *Returns*:
66
- # - Kentico::Kontent::Delivery::Responses::ResponseBase or a class extending it
67
- def execute
68
- resp = Kentico::Kontent::Delivery::RequestManager.start self, headers
69
- yield resp if block_given?
70
- resp
71
- end
72
-
73
- # Determines whether the query should use preview mode.
74
- #
75
- # * *Returns*:
76
- # - +boolean+ Whether preview mode should be used for the query
77
- #
78
- # * *Raises*:
79
- # - +StandardError+ if +use_preview+ is true, but +preview_key+ is +nil+
80
- def should_preview
81
- raise ERROR_PREVIEW if use_preview && preview_key.nil?
82
-
83
- use_preview && !preview_key.nil?
84
- end
85
-
86
- # Enables the total_count attribute of the pagination object, which specifies
87
- # the total number of items returned by the query regardless of paging. See
88
- # https://docs.kontent.ai/reference/delivery-api#operation/list-content-items
89
- #
90
- # * *Returns*:
91
- # - +self+
92
- def include_total_count
93
- query_string.set_param('includeTotalCount', 1)
94
- self
95
- end
96
-
97
- # Sets a content link resolver to render links contained in rich text. See
98
- # https://github.com/Kentico/kontent-delivery-sdk-ruby#resolving-links
99
- #
100
- # * *Args*:
101
- # - *resolver* ( Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver ) The resolver. Replaces a resolver registered during +DeliveryClient+ instantiation, for this query only.
102
- #
103
- # * *Returns*:
104
- # - +self+
105
- def with_link_resolver(resolver)
106
- self.content_link_url_resolver = resolver
107
- self
108
- end
109
-
110
- # Sets an inline content itme to render content items and components in rich text.
111
- # See https://github.com/Kentico/kontent-delivery-sdk-ruby#resolving-inline-content
112
- #
113
- # * *Args*:
114
- # - *resolver* ( Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver ) The resolver. Replaces a resolver registered during +DeliveryClient+ instantiation, for this query only.
115
- #
116
- # * *Returns*:
117
- # - +self+
118
- def with_inline_content_item_resolver(resolver)
119
- self.inline_content_item_resolver = resolver
120
- self
121
- end
122
-
123
- # Sets the 'order' query string parameter
124
- #
125
- # * *Args*:
126
- # - *value* (+string+) The value to order by
127
- # - *sort* (+string+) _optional_ The direction of the order, surrounded by brackets. The default value is '[asc]'
128
- #
129
- # * *Returns*:
130
- # - +self+
131
- def order_by(value, sort = '[asc]')
132
- query_string.set_param('order', value + sort)
133
- self
134
- end
135
-
136
- # Sets the 'skip' query string parameter for paging results.
137
- # See https://developer.kenticocloud.com/v1/reference#listing-response-paging
138
- #
139
- # * *Args*:
140
- # - *value* (+integer+) The number to skip by
141
- #
142
- # * *Returns*:
143
- # - +self+
144
- def skip(value)
145
- query_string.set_param('skip', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
146
- self
147
- end
148
-
149
- # Sets the 'language' query string parameter. Language fallbacks will be used
150
- # if untranslated content items are found.
151
- # See https://developer.kenticocloud.com/docs/localization#section-getting-localized-content-items
152
- #
153
- # * *Args*:
154
- # - *value* (+string+) The code name of the desired language
155
- #
156
- # * *Returns*:
157
- # - +self+
158
- def language(value)
159
- query_string.set_param('language', value)
160
- self
161
- end
162
-
163
- # Sets the 'limit' query string parameter for paging results, or just to
164
- # return a specific number of content items.
165
- # See https://developer.kenticocloud.com/v1/reference#listing-response-paging
166
- #
167
- # * *Args*:
168
- # - *value* (+integer+) The number of content items to return
169
- #
170
- # * *Returns*:
171
- # - +self+
172
- def limit(value)
173
- query_string.set_param('limit', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
174
- self
175
- end
176
-
177
- # Sets the 'elements' query string parameter to limit the elements returned
178
- # by the query.
179
- # See https://developer.kenticocloud.com/v1/reference#projection
180
- #
181
- # * *Args*:
182
- # - *value* (+Array+) A single string or array of strings specifying the desired elements, e.g. %w[price product_name image]
183
- #
184
- # * *Returns*:
185
- # - +self+
186
- def elements(value)
187
- query_string.set_param('elements', value)
188
- self
189
- end
190
-
191
- # Sets the 'depth' query string parameter to determine how many levels of
192
- # linked content items should be returned. By default, only 1 level of depth
193
- # is used.
194
- # See https://developer.kenticocloud.com/v1/reference#linked-content
195
- #
196
- # * *Args*:
197
- # - *value* (+integer+) Level of linked items to be returned
198
- #
199
- # * *Returns*:
200
- # - +self+
201
- def depth(value)
202
- query_string.set_param('depth', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
203
- self
204
- end
205
-
206
- # Allows the request to bypass caching and return the latest content
207
- # directly from Kentico Kontent.
208
- # See https://github.com/Kentico/kontent-delivery-sdk-ruby#requesting-the-latest-content
209
- #
210
- # * *Returns*:
211
- # - +self+
212
- def request_latest_content
213
- @headers[HEADER_WAIT_FOR_CONTENT] = true
214
- self
215
- end
216
-
217
- # Uses Kentico::Kontent::Delivery::Builders::UrlBuilder.provide_url to set
218
- # the URL for the query. The +UrlBuilder+ also validates the URL.
219
- #
220
- # * *Raises*:
221
- # - +UriFormatException+ if the URL is 65,519 characters or more
222
- #
223
- # * *Returns*:
224
- # - +string+ The full URL for this query
225
- def provide_url
226
- @url = Kentico::Kontent::Delivery::Builders::UrlBuilder.provide_url self if @url.nil?
227
- Kentico::Kontent::Delivery::Builders::UrlBuilder.validate_url @url
228
- @url
229
- end
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
-
257
- private
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
-
277
- # Initializes the +query_string+ attribute with the passed array of
278
- # Kentico::Kontent::Delivery::QueryParameters::Filter objects.
279
- #
280
- # * *Raises*:
281
- # - +ArgumentError+ if one the passed objects is not a +Filter+
282
- def validate_params(query_parameters)
283
- params = if query_parameters.is_a? Array
284
- query_parameters
285
- else
286
- [query_parameters]
287
- end
288
- params.each do |p|
289
- query_string.set_param p
290
- unless p.is_a? Kentico::Kontent::Delivery::QueryParameters::Filter
291
- raise ArgumentError, ERROR_PARAMS
292
- end
293
- end
294
- end
295
-
296
- def provide_sdk_header
297
- 'rubygems.org;kontent-delivery-sdk-ruby;'
298
- end
299
- end
300
- end
301
- end
302
- end
1
+ require 'rubygems'
2
+ require 'delivery/builders/url_builder'
3
+ require 'delivery/query_parameters/query_string'
4
+
5
+ module Kentico
6
+ module Kontent
7
+ module Delivery
8
+ # Responsible for executing REST requests to Kentico Kontent.
9
+ class DeliveryQuery
10
+ ERROR_PREVIEW = 'Preview is enabled for the query, but the key is null. '\
11
+ 'You can set the preview_key attribute of the query, or '\
12
+ 'when you initialize the client. See '\
13
+ 'https://github.com/Kentico/kontent-delivery-sdk-ruby#previewing-unpublished-content'.freeze
14
+ ERROR_PARAMS = 'Only filters may be passed in the .item or .items methods'\
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
19
+ attr_accessor :use_preview,
20
+ :preview_key,
21
+ :project_id,
22
+ :code_name,
23
+ :secure_key,
24
+ :content_link_url_resolver,
25
+ :inline_content_item_resolver,
26
+ :query_type,
27
+ :query_string,
28
+ :content_type,
29
+ :with_retry_policy
30
+
31
+ # Setter for a custom URL.
32
+ #
33
+ # * *Args*:
34
+ # - *url* (+string+) _optional_ Custom URL to use for the query
35
+ #
36
+ # * *Returns*:
37
+ # - +self+
38
+ def url(url = nil)
39
+ @url = url unless url.nil?
40
+ self
41
+ end
42
+
43
+ # Constructor. Queries should not be instantiated using the constructor, but
44
+ # using one of the Kentico::Kontent::Delivery::DeliveryClient methods instead.
45
+ #
46
+ # * *Args*:
47
+ # - *config* (+Hash+) A hash in which each key automatically has its value paired with the corresponding attribute
48
+ def initialize(config)
49
+ @headers = {}
50
+
51
+ # Map each hash value to attr with corresponding key
52
+ # from https://stackoverflow.com/a/2681014/5656214
53
+ config.each do |k, v|
54
+ instance_variable_set("@#{k}", v) unless v.nil?
55
+ end
56
+ self.query_string = Kentico::Kontent::Delivery::QueryParameters::QueryString.new
57
+ return if config.fetch(:qp, nil).nil?
58
+
59
+ # Query parameters were passed, parse and validate
60
+ validate_params config.fetch(:qp)
61
+ end
62
+
63
+ # Executes the REST request.
64
+ #
65
+ # * *Returns*:
66
+ # - Kentico::Kontent::Delivery::Responses::ResponseBase or a class extending it
67
+ def execute
68
+ resp = Kentico::Kontent::Delivery::RequestManager.start self, headers
69
+ yield resp if block_given?
70
+ resp
71
+ end
72
+
73
+ # Determines whether the query should use preview mode.
74
+ #
75
+ # * *Returns*:
76
+ # - +boolean+ Whether preview mode should be used for the query
77
+ #
78
+ # * *Raises*:
79
+ # - +StandardError+ if +use_preview+ is true, but +preview_key+ is +nil+
80
+ def should_preview
81
+ raise ERROR_PREVIEW if use_preview && preview_key.nil?
82
+
83
+ use_preview && !preview_key.nil?
84
+ end
85
+
86
+ # Enables the total_count attribute of the pagination object, which specifies
87
+ # the total number of items returned by the query regardless of paging. See
88
+ # https://docs.kontent.ai/reference/delivery-api#operation/list-content-items
89
+ #
90
+ # * *Returns*:
91
+ # - +self+
92
+ def include_total_count
93
+ query_string.set_param('includeTotalCount', 1)
94
+ self
95
+ end
96
+
97
+ # Sets a content link resolver to render links contained in rich text. See
98
+ # https://github.com/Kentico/kontent-delivery-sdk-ruby#resolving-links
99
+ #
100
+ # * *Args*:
101
+ # - *resolver* ( Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver ) The resolver. Replaces a resolver registered during +DeliveryClient+ instantiation, for this query only.
102
+ #
103
+ # * *Returns*:
104
+ # - +self+
105
+ def with_link_resolver(resolver)
106
+ self.content_link_url_resolver = resolver
107
+ self
108
+ end
109
+
110
+ # Sets an inline content itme to render content items and components in rich text.
111
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#resolving-inline-content
112
+ #
113
+ # * *Args*:
114
+ # - *resolver* ( Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver ) The resolver. Replaces a resolver registered during +DeliveryClient+ instantiation, for this query only.
115
+ #
116
+ # * *Returns*:
117
+ # - +self+
118
+ def with_inline_content_item_resolver(resolver)
119
+ self.inline_content_item_resolver = resolver
120
+ self
121
+ end
122
+
123
+ # Sets the 'order' query string parameter
124
+ #
125
+ # * *Args*:
126
+ # - *value* (+string+) The value to order by
127
+ # - *sort* (+string+) _optional_ The direction of the order, surrounded by brackets. The default value is '[asc]'
128
+ #
129
+ # * *Returns*:
130
+ # - +self+
131
+ def order_by(value, sort = '[asc]')
132
+ query_string.set_param('order', value + sort)
133
+ self
134
+ end
135
+
136
+ # Sets the 'skip' query string parameter for paging results.
137
+ # See https://developer.kenticocloud.com/v1/reference#listing-response-paging
138
+ #
139
+ # * *Args*:
140
+ # - *value* (+integer+) The number to skip by
141
+ #
142
+ # * *Returns*:
143
+ # - +self+
144
+ def skip(value)
145
+ query_string.set_param('skip', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
146
+ self
147
+ end
148
+
149
+ # Sets the 'language' query string parameter. Language fallbacks will be used
150
+ # if untranslated content items are found.
151
+ # See https://developer.kenticocloud.com/docs/localization#section-getting-localized-content-items
152
+ #
153
+ # * *Args*:
154
+ # - *value* (+string+) The code name of the desired language
155
+ #
156
+ # * *Returns*:
157
+ # - +self+
158
+ def language(value)
159
+ query_string.set_param('language', value)
160
+ self
161
+ end
162
+
163
+ # Sets the 'limit' query string parameter for paging results, or just to
164
+ # return a specific number of content items.
165
+ # See https://developer.kenticocloud.com/v1/reference#listing-response-paging
166
+ #
167
+ # * *Args*:
168
+ # - *value* (+integer+) The number of content items to return
169
+ #
170
+ # * *Returns*:
171
+ # - +self+
172
+ def limit(value)
173
+ query_string.set_param('limit', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
174
+ self
175
+ end
176
+
177
+ # Sets the 'elements' query string parameter to limit the elements returned
178
+ # by the query.
179
+ # See https://developer.kenticocloud.com/v1/reference#projection
180
+ #
181
+ # * *Args*:
182
+ # - *value* (+Array+) A single string or array of strings specifying the desired elements, e.g. %w[price product_name image]
183
+ #
184
+ # * *Returns*:
185
+ # - +self+
186
+ def elements(value)
187
+ query_string.set_param('elements', value)
188
+ self
189
+ end
190
+
191
+ # Sets the 'depth' query string parameter to determine how many levels of
192
+ # linked content items should be returned. By default, only 1 level of depth
193
+ # is used.
194
+ # See https://developer.kenticocloud.com/v1/reference#linked-content
195
+ #
196
+ # * *Args*:
197
+ # - *value* (+integer+) Level of linked items to be returned
198
+ #
199
+ # * *Returns*:
200
+ # - +self+
201
+ def depth(value)
202
+ query_string.set_param('depth', value) unless query_type.eql? Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
203
+ self
204
+ end
205
+
206
+ # Allows the request to bypass caching and return the latest content
207
+ # directly from Kentico Kontent.
208
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#requesting-the-latest-content
209
+ #
210
+ # * *Returns*:
211
+ # - +self+
212
+ def request_latest_content
213
+ @headers[HEADER_WAIT_FOR_CONTENT] = true
214
+ self
215
+ end
216
+
217
+ # Uses Kentico::Kontent::Delivery::Builders::UrlBuilder.provide_url to set
218
+ # the URL for the query. The +UrlBuilder+ also validates the URL.
219
+ #
220
+ # * *Raises*:
221
+ # - +UriFormatException+ if the URL is 65,519 characters or more
222
+ #
223
+ # * *Returns*:
224
+ # - +string+ The full URL for this query
225
+ def provide_url
226
+ @url = Kentico::Kontent::Delivery::Builders::UrlBuilder.provide_url self if @url.nil?
227
+ Kentico::Kontent::Delivery::Builders::UrlBuilder.validate_url @url
228
+ @url
229
+ end
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
+
257
+ private
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
+
277
+ # Initializes the +query_string+ attribute with the passed array of
278
+ # Kentico::Kontent::Delivery::QueryParameters::Filter objects.
279
+ #
280
+ # * *Raises*:
281
+ # - +ArgumentError+ if one the passed objects is not a +Filter+
282
+ def validate_params(query_parameters)
283
+ params = if query_parameters.is_a? Array
284
+ query_parameters
285
+ else
286
+ [query_parameters]
287
+ end
288
+ params.each do |p|
289
+ query_string.set_param p
290
+ unless p.is_a? Kentico::Kontent::Delivery::QueryParameters::Filter
291
+ raise ArgumentError, ERROR_PARAMS
292
+ end
293
+ end
294
+ end
295
+
296
+ def provide_sdk_header
297
+ 'rubygems.org;kontent-delivery-sdk-ruby;'
298
+ end
299
+ end
300
+ end
301
+ end
302
+ end