kontent-delivery-sdk-ruby 2.0.21 → 2.0.22

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: 2a50d5e5d2aeccb6c3c46776716ecada32555b335f60bffa29fa71e50e67ac13
4
- data.tar.gz: c7f7ee90d20ffc94c82ec6696f2b3d041d9d9582634baaa83e57355151361498
3
+ metadata.gz: b93d8bae053c876e19256fc6695fa2dd593dc9479f89da1ede61ec166316a0cb
4
+ data.tar.gz: 21721f7c4105cc9c07e62009b01b5d380f485082d807a1337002d44eaebc52fc
5
5
  SHA512:
6
- metadata.gz: b622ce5287519b7cea0b7a93f27c66f80a677711c71a74ccc988fb901bdfb95348f8fedc1b5fa94b1c46992a82ffd16e72bf15dce75480ae6b7e8c65d7994e3a
7
- data.tar.gz: 197b327d60da93856f53330ebf43488ea3f59087db90c52c7385dbbb293d57758689b214296943b9d924d2c2ddf1944a2c8a26475bd8790488bf15fa1b481d56
6
+ metadata.gz: 8df410c1f68405b40824f82fe7ac866de358e8df90042419bc52406807bd89610adabdbd5dcaf8c4a9bf751bc56882ff670c2d4c704bd1bc5e21ee49bea8927a
7
+ data.tar.gz: 15b2ebbe2e3a98b5a4f5e66e6d7af39c04c6db4d8652cd061f9bf9c0824c4dda87e522f4e7d4b812d2e84a378e9348e2a62c132018ad8032fb6b01b1801be750
data/README.md CHANGED
@@ -18,22 +18,24 @@ See [How to setup a development environment on Windows](https://github.com/Kenti
18
18
  - [Previewing unpublished content](#previewing-unpublished-content)
19
19
  - [Making secure requests](#making-secure-requests)
20
20
  - [Retry policy](#retry-policy)
21
+ - [Custom URLs](#custom-urls)
21
22
  - [Listing items](#listing-items)
22
23
  - [Filtering](#filtering)
23
24
  - [Parameters](#parameters)
24
25
  - [Responses](#responses)
25
26
  - [Requesting the latest content](#requesting-the-latest-content)
26
27
  - [Providing custom headers](#providing-custom-headers)
27
- - [Custom URLs](#custom-urls)
28
- - [Assets](#assets)
29
- - [Linked items](#linked-items)
30
- - [Pagination](#pagination)
28
+ - [Pagination](#pagination)
29
+ - [Working with content items](#working-with-content-items)
30
+ - [Assets](#assets)
31
+ - [Linked items](#linked-items)
32
+ - [Resolving inline content](#resolving-inline-content)
33
+ - [Resolving links](#resolving-links)
31
34
  - [Items feed](#items-feed)
32
35
  - [Retrieving content types](#retrieving-content-types)
33
- - [Taxonomy](#taxonomy)
36
+ - [Retrieving taxonomy](#retrieving-taxonomy)
34
37
  - [Retrieving content type elements](#retrieving-content-type-elements)
35
- - [Resolving links](#resolving-links)
36
- - [Resolving inline content](#resolving-inline-content)
38
+ - [Retrieving languages](#retrieving-languages)
37
39
  - [Image transformation](#image-transformation)
38
40
 
39
41
  ## Installation
@@ -120,6 +122,18 @@ Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
120
122
  with_retry_policy: false
121
123
  ```
122
124
 
125
+ ### Custom URLs
126
+
127
+ 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:
128
+
129
+ ```ruby
130
+ delivery_client.items
131
+ .url('https://deliver.kontent.ai/<your-project-id>/items?system.type=grinder')
132
+ .execute do |response|
133
+ # Do something
134
+ end
135
+ ```
136
+
123
137
  ## Listing items
124
138
 
125
139
 
@@ -264,19 +278,33 @@ delivery_client.items
264
278
  .execute
265
279
  ```
266
280
 
267
- ### Custom URLs
281
+ ### Pagination
268
282
 
269
- 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:
283
+ Most responses also contain 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:
284
+
285
+ - **skip**
286
+ - **limit**
287
+ - **count**
288
+ - **next_page**
289
+ - **total_count** (only if `include_total_count` is called)
290
+
291
+ For example, to access the next page URL you can use:
270
292
 
271
293
  ```ruby
272
294
  delivery_client.items
273
- .url('https://deliver.kontent.ai/<your-project-id>/items?system.type=grinder')
274
- .execute do |response|
275
- # Do something
276
- end
295
+ .skip(0)
296
+ .limit(5)
297
+ .include_total_count
298
+ .execute do |response|
299
+ next_page_url = response.pagination.next_page
300
+ end
277
301
  ```
278
302
 
279
- ## Assets
303
+ :warning: Note that using the `include_total_count` method may increase the response time and should only be used if necessary.
304
+
305
+ ## Working with content items
306
+
307
+ ### Assets
280
308
 
281
309
  You can use `.get_assets(code_name)` to get one or more assets from the specified element. This method will always return an array, so use `.first` to get the first asset:
282
310
 
@@ -284,7 +312,7 @@ You can use `.get_assets(code_name)` to get one or more assets from the specifie
284
312
  url = response.item.get_assets('teaser_image').first.url
285
313
  ```
286
314
 
287
- ## Linked items
315
+ ### Linked items
288
316
 
289
317
  You can get a simple array of code names by accessing the element's value:
290
318
 
@@ -299,30 +327,120 @@ response.item.get_links('facts').each do |link|
299
327
  title = link.elements.title.value
300
328
  end
301
329
  ```
330
+ ### Resolving inline content
302
331
 
303
- ## Pagination
332
+ Existing content items can be inserted into a rich text element, or you can create new content items as components. You need to resolve these in your application just as with content links. You can register a resolver when you instantiate the client by passing it with the hash key `inline_content_item_resolver`:
304
333
 
305
- 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:
334
+ ```ruby
335
+ item_resolver = Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver.new(lambda do |item|
336
+ return "<h1>#{item.elements.zip_code.value}</h1>" if item.system.type.eql? 'cafe'
337
+ return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
338
+ end)
339
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
340
+ inline_content_item_resolver: item_resolver
341
+ ```
306
342
 
307
- - **skip**
308
- - **limit**
309
- - **count**
310
- - **next_page**
311
- - **total_count** (only if `include_total_count` is called)
343
+ The object passed to the resolving method is a complete ContentItem. Similar to content link resolvers, you can create your own class which extends `Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver` and implements the `resolve_item` method:
312
344
 
313
- For example, to access the next page URL you can use:
345
+ ```ruby
346
+ class MyItemResolver < Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver
347
+ def resolve_item(item)
348
+ return "<h1>#{item.elements.zip_code.value}</h1>" if item.system.type.eql? 'cafe'
349
+ return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
350
+ end
351
+ end
352
+ ```
353
+
354
+ You can also set the inline content resolver per-query:
314
355
 
315
356
  ```ruby
357
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>'
358
+ # Client doesn't use InlineContentItemResolver, but query below will
316
359
  delivery_client.items
317
- .skip(0)
318
- .limit(5)
319
- .include_total_count
320
- .execute do |response|
321
- next_page_url = response.pagination.next_page
322
- end
360
+ .with_inline_content_item_resolver MyItemResolver.new
323
361
  ```
324
362
 
325
- :warning: Note that using the `include_total_count` method may increase the response time and should only be used if necessary.
363
+ To resolve inline content in elements, you must call `get_string` similar to content item links:
364
+
365
+ ```ruby
366
+ item_resolver = Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver.new(lambda do |item|
367
+ return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
368
+ end)
369
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: PROJECT_ID,
370
+ inline_content_item_resolver: item_resolver
371
+ delivery_client.item('our_brewers').execute do |response|
372
+ text = response.item.get_string 'body_copy'
373
+ end
374
+ ```
375
+
376
+ ### Resolving links
377
+
378
+ If a rich text element contains links to other content items, you will need to generate the URLs to those items. You can do this by registering a `Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver` when you instantiate the DeliveryClient. When you create a ContentLinkResolver, you must pass a method that will return the URL, and you may pass another method that will be called if the content contains a link, but the content item is not present in the response:
379
+
380
+ ```ruby
381
+ link_resolver = Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver.new(lambda do |link|
382
+ # Link valid
383
+ return "/coffees/#{link.url_slug}" if link.type.eql? 'coffee'
384
+ return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
385
+ end, lambda do |id|
386
+ # Link broken
387
+ return "/notfound?id=#{id}"
388
+ end)
389
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
390
+ content_link_url_resolver: link_resolver
391
+ ```
392
+
393
+ You can also build the logic for your resolver in a separate class and register an instance of that class in the DeliveryClient. The class must extend `Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver` and contain a `resolve_link(link)` method, as well as the `resolve_404(id)` method for broken links. For example, you can create `MyLinkResolver.rb`:
394
+
395
+ ```ruby
396
+ class MyLinkResolver < Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver
397
+ def resolve_link(link)
398
+ return "/coffees/#{link.url_slug}" if link.type.eql? 'coffee'
399
+ return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
400
+ end
401
+
402
+ def resolve_404(id)
403
+ "/notfound?id=#{id}"
404
+ end
405
+ end
406
+ ```
407
+
408
+ Then create an object of this class when instantiating the DeliveryClient:
409
+
410
+ ```ruby
411
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
412
+ content_link_url_resolver: MyLinkResolver.new
413
+ ```
414
+
415
+ You can pass a `ContentLinkResolver` to the DeliveryQuery instead of the client if you only want to resolve links for that query, or they should be resolved differently:
416
+
417
+ ```ruby
418
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>'
419
+ # Client doesn't use ContentLinkResolver, but query below will
420
+ delivery_client.items
421
+ .with_link_resolver MyLinkResolver.new
422
+ ```
423
+
424
+ The `ContentLink` object that is passed to your resolver contains the following attributes:
425
+
426
+ - **id**: the system.id of the linked content item
427
+ - **code_name**: the system.codename of the linked content item
428
+ - **type**: the content type of the linked content item
429
+ - **url_slug**: the URL slug of the linked content item, or nil if there is none
430
+
431
+ To resolve links in rich text elements, you must retrieve the text using `get_string`:
432
+
433
+ ```ruby
434
+ item_resolver = Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver.new(lambda do |link|
435
+ return "/coffees/#{link.url_slug}" if link.type.eql? 'coffee'
436
+ return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
437
+ end)
438
+ delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
439
+ content_link_url_resolver: item_resolver
440
+ delivery_client.item('coffee_processing_techniques').execute do |response|
441
+ text = response.item.get_string 'body_copy'
442
+ end
443
+ ```
326
444
 
327
445
  ## Items feed
328
446
 
@@ -357,8 +475,6 @@ delivery_client.type('coffee').execute do |response|
357
475
  end
358
476
  ```
359
477
 
360
- ### Responses
361
-
362
478
  As with content item queries, all content type queries will return a `Kentico::Kontent::Delivery::Responses::ResponseBase` of the class `DeliveryTypeResponse` or `DeliveryTypeListingResponse` for single and multiple type queries, respectively.
363
479
 
364
480
  For multiple type queries, you can access the array of `ContentType` objects at `.types`, and at `.type` for singe type queries. You can access information about the type(s) dynamically:
@@ -370,7 +486,7 @@ end
370
486
  ```
371
487
  The DeliveryTypeListingResponse also contains pagination data, similar to DeliveryItemListingResponse.
372
488
 
373
- ## Taxonomy
489
+ ## Retrieving taxonomy
374
490
 
375
491
  Use the `.taxonomies` and `.taxonomy(code_name)` endpoints to get information about the taxonomy in your project:
376
492
 
@@ -427,118 +543,21 @@ This returns a `Kentico::Kontent::Delivery::Responses::DeliveryElementResponse`
427
543
 
428
544
  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.
429
545
 
430
- ## Resolving links
431
-
432
- If a rich text element contains links to other content items, you will need to generate the URLs to those items. You can do this by registering a `Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver` when you instantiate the DeliveryClient. When you create a ContentLinkResolver, you must pass a method that will return the URL, and you may pass another method that will be called if the content contains a link, but the content item is not present in the response:
433
-
434
- ```ruby
435
- link_resolver = Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver.new(lambda do |link|
436
- # Link valid
437
- return "/coffees/#{link.url_slug}" if link.type.eql? 'coffee'
438
- return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
439
- end, lambda do |id|
440
- # Link broken
441
- return "/notfound?id=#{id}"
442
- end)
443
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
444
- content_link_url_resolver: link_resolver
445
- ```
446
-
447
- You can also build the logic for your resolver in a separate class and register an instance of that class in the DeliveryClient. The class must extend `Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver` and contain a `resolve_link(link)` method, as well as the `resolve_404(id)` method for broken links. For example, you can create `MyLinkResolver.rb`:
448
-
449
- ```ruby
450
- class MyLinkResolver < Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver
451
- def resolve_link(link)
452
- return "/coffees/#{link.url_slug}" if link.type.eql? 'coffee'
453
- return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
454
- end
455
-
456
- def resolve_404(id)
457
- "/notfound?id=#{id}"
458
- end
459
- end
460
- ```
461
-
462
- Then create an object of this class when instantiating the DeliveryClient:
463
-
464
- ```ruby
465
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
466
- content_link_url_resolver: MyLinkResolver.new
467
- ```
468
-
469
- You can pass a `ContentLinkResolver` to the DeliveryQuery instead of the client if you only want to resolve links for that query, or they should be resolved differently:
470
-
471
- ```ruby
472
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>'
473
- # Client doesn't use ContentLinkResolver, but query below will
474
- delivery_client.items
475
- .with_link_resolver MyLinkResolver.new
476
- ```
477
-
478
- The `ContentLink` object that is passed to your resolver contains the following attributes:
479
-
480
- - **id**: the system.id of the linked content item
481
- - **code_name**: the system.codename of the linked content item
482
- - **type**: the content type of the linked content item
483
- - **url_slug**: the URL slug of the linked content item, or nil if there is none
484
-
485
- To resolve links in rich text elements, you must retrieve the text using `get_string`:
486
-
487
- ```ruby
488
- item_resolver = Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver.new(lambda do |link|
489
- return "/coffees/#{link.url_slug}" if link.type.eql? 'coffee'
490
- return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
491
- end)
492
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
493
- content_link_url_resolver: item_resolver
494
- delivery_client.item('coffee_processing_techniques').execute do |response|
495
- text = response.item.get_string 'body_copy'
496
- end
497
- ```
498
-
499
- ## Resolving inline content
500
-
501
- Existing content items can be inserted into a rich text element, or you can create new content items as components. You need to resolve these in your application just as with content links. You can register a resolver when you instantiate the client by passing it with the hash key `inline_content_item_resolver`:
546
+ ## Retrieving languages
502
547
 
503
- ```ruby
504
- item_resolver = Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver.new(lambda do |item|
505
- return "<h1>#{item.elements.zip_code.value}</h1>" if item.system.type.eql? 'cafe'
506
- return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
507
- end)
508
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>',
509
- inline_content_item_resolver: item_resolver
510
- ```
511
-
512
- The object passed to the resolving method is a complete ContentItem. Similar to content link resolvers, you can create your own class which extends `Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver` and implements the `resolve_item` method:
548
+ Use the `.languages` method to list all of the languages in the project:
513
549
 
514
550
  ```ruby
515
- class MyItemResolver < Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver
516
- def resolve_item(item)
517
- return "<h1>#{item.elements.zip_code.value}</h1>" if item.system.type.eql? 'cafe'
518
- return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
519
- end
551
+ delivery_client.languages.execute do |response|
552
+ puts response.languages.length # number of languages
520
553
  end
521
554
  ```
522
555
 
523
- You can also set the inline content resolver per-query:
524
-
525
- ```ruby
526
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: '<your-project-id>'
527
- # Client doesn't use InlineContentItemResolver, but query below will
528
- delivery_client.items
529
- .with_inline_content_item_resolver MyItemResolver.new
530
- ```
531
-
532
- To resolve inline content in elements, you must call `get_string` similar to content item links:
556
+ The response is a `Kentico::Kontent::Delivery::Responses::DeliveryLanguageListingResponse` where `languages` is an array of all langauges. You can access the system properties of each language as they are returned by Kontent:
533
557
 
534
558
  ```ruby
535
- item_resolver = Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver.new(lambda do |item|
536
- return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
537
- end)
538
- delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: PROJECT_ID,
539
- inline_content_item_resolver: item_resolver
540
- delivery_client.item('our_brewers').execute do |response|
541
- text = response.item.get_string 'body_copy'
559
+ delivery_client.languages.execute do |response|
560
+ puts response.languages[0].system.codename # en-us
542
561
  end
543
562
  ```
544
563
 
@@ -128,6 +128,7 @@ module Kentico
128
128
  @query_string.remove_param 'fp-x'
129
129
  @query_string.remove_param 'fp-y'
130
130
  @query_string.remove_param 'fp-z'
131
+ @query_string.remove_param 'fit'
131
132
  @query_string.remove_param 'crop'
132
133
  @query_string.set_param 'rect', "#{x},#{y},#{width},#{height}"
133
134
  self
@@ -14,6 +14,7 @@ module Kentico
14
14
  URL_TEMPLATE_TAXONOMY = '/taxonomies/%s'.freeze
15
15
  URL_TEMPLATE_TAXONOMIES = '/taxonomies'.freeze
16
16
  URL_TEMPLATE_ITEMS_FEED = '/items-feed'.freeze
17
+ URL_TEMPLATE_LANGUAGES = '/languages'.freeze
17
18
 
18
19
  URL_MAX_LENGTH = 65_519
19
20
  MSG_LONG_QUERY = 'The request url is too long. Split your query into multiple calls.'.freeze
@@ -66,6 +67,8 @@ module Kentico
66
67
  provide_type query
67
68
  when Kentico::Kontent::Delivery::QUERY_TYPE_TAXONOMIES
68
69
  provide_taxonomy query
70
+ when Kentico::Kontent::Delivery::QUERY_TYPE_LANGUAGES
71
+ URL_TEMPLATE_LANGUAGES
69
72
  when Kentico::Kontent::Delivery::QUERY_TYPE_ELEMENT
70
73
  format(URL_TEMPLATE_ELEMENTS, query.content_type, query.code_name)
71
74
  when Kentico::Kontent::Delivery::QUERY_TYPE_ITEMS_FEED
@@ -11,6 +11,7 @@ module Kentico
11
11
  QUERY_TYPE_TAXONOMIES = 'QUERY_TYPE_TAXONOMIES'.freeze
12
12
  QUERY_TYPE_ELEMENT = 'QUERY_TYPE_ELEMENT'.freeze
13
13
  QUERY_TYPE_ITEMS_FEED = 'QUERY_TYPE_ITEMS_FEED'.freeze
14
+ QUERY_TYPE_LANGUAGES = 'QUERY_TYPE_LANGUAGES'.freeze
14
15
 
15
16
  # Executes requests against the Kentico Kontent Delivery API.
16
17
  class DeliveryClient
@@ -170,6 +171,13 @@ module Kentico
170
171
  query_type: QUERY_TYPE_ELEMENT,
171
172
  with_retry_policy: @with_retry_policy
172
173
  end
174
+
175
+ def languages
176
+ DeliveryQuery.new project_id: @project_id,
177
+ secure_key: @secure_key,
178
+ query_type: QUERY_TYPE_LANGUAGES,
179
+ with_retry_policy: @with_retry_policy
180
+ end
173
181
  end
174
182
  end
175
183
  end
@@ -85,6 +85,8 @@ module Kentico
85
85
  respond_taxonomy response
86
86
  when Kentico::Kontent::Delivery::QUERY_TYPE_ELEMENT
87
87
  Kentico::Kontent::Delivery::Responses::DeliveryElementResponse.new response.headers, response.body
88
+ when Kentico::Kontent::Delivery::QUERY_TYPE_LANGUAGES
89
+ Kentico::Kontent::Delivery::Responses::DeliveryLanguageListingResponse.new response.headers, response.body
88
90
  end
89
91
  end
90
92
 
@@ -0,0 +1,29 @@
1
+ require 'ostruct'
2
+
3
+ module Kentico
4
+ module Kontent
5
+ module Delivery
6
+ class Language
7
+ # Parses the 'system' JSON object as a dynamic OpenStruct object.
8
+ #
9
+ # * *Returns*:
10
+ # - +OpenStruct+ The system properties of the language
11
+ def system
12
+ @system unless @system.nil?
13
+ @system = JSON.parse(
14
+ JSON.generate(@source['system']),
15
+ object_class: OpenStruct
16
+ )
17
+ end
18
+
19
+ # Constructor.
20
+ #
21
+ # * *Args*:
22
+ # - *source* (+JSON+) The response from a REST request for a language
23
+ def initialize(source)
24
+ @source = source
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ require 'delivery/models/language'
2
+ require 'delivery/responses/response_base'
3
+
4
+ module Kentico
5
+ module Kontent
6
+ module Delivery
7
+ module Responses
8
+ # The response of a successful query for project languages.
9
+ class DeliveryLanguageListingResponse < ResponseBase
10
+ # Parses the 'pagination' JSON node of the response.
11
+ #
12
+ # * *Returns*:
13
+ # - Kentico::Kontent::Delivery::Pagination
14
+ def pagination
15
+ @pagination unless @pagination.nil?
16
+ @pagination = Pagination.new @response['pagination']
17
+ end
18
+
19
+ # Parses the 'languages' JSON node of the response from a
20
+ # Kentico::Kontent::Delivery::DeliveryClient.languages call.
21
+ #
22
+ # * *Returns*:
23
+ # - +Array+ The content types as Kentico::Kontent::Delivery::Language objects
24
+ def languages
25
+ @languages unless @languages.nil?
26
+ languages = []
27
+ @response['languages'].each do |n|
28
+ languages << Kentico::Kontent::Delivery::Language.new(n)
29
+ end
30
+ @languages = languages
31
+ end
32
+
33
+ def initialize(headers, body)
34
+ @response = JSON.parse(body)
35
+ super 200,
36
+ "Success, #{languages.length} languages returned",
37
+ headers,
38
+ JSON.generate(@response)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -8,7 +8,7 @@
8
8
  "type": "article",
9
9
  "collection": "default",
10
10
  "sitemap_locations": [],
11
- "last_modified": "2019-03-27T13:07:32.29Z",
11
+ "last_modified": "2021-03-20T02:44:46.6377632Z",
12
12
  "workflow_step": "published"
13
13
  },
14
14
  "elements": {
@@ -47,8 +47,10 @@
47
47
  "name": "Body Copy",
48
48
  "images": {},
49
49
  "links": {},
50
- "modular_content": [],
51
- "value": "<p>The history of coffee is patchy and full of myth and hearsay.</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>"
50
+ "modular_content": [
51
+ "london_"
52
+ ],
53
+ "value": "<object type=\"application/kenticocloud\" data-type=\"item\" data-rel=\"link\" data-codename=\"london_\"></object>\n<p>The history of coffee is patchy and full of myth and hearsay.</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>"
52
54
  },
53
55
  "related_articles": {
54
56
  "type": "modular_content",
@@ -172,6 +174,86 @@
172
174
  }
173
175
  },
174
176
  "modular_content": {
177
+ "london_": {
178
+ "system": {
179
+ "id": "473cd60b-a2a7-4e5b-8353-5d1995dd4b50",
180
+ "name": "London",
181
+ "codename": "london_",
182
+ "language": "en-US",
183
+ "type": "cafe",
184
+ "collection": "default",
185
+ "sitemap_locations": [],
186
+ "last_modified": "2019-03-27T13:19:05.507Z",
187
+ "workflow_step": "published"
188
+ },
189
+ "elements": {
190
+ "street": {
191
+ "type": "text",
192
+ "name": "Street",
193
+ "value": "344 King's Road"
194
+ },
195
+ "city": {
196
+ "type": "text",
197
+ "name": "City",
198
+ "value": "London"
199
+ },
200
+ "country": {
201
+ "type": "text",
202
+ "name": "Country",
203
+ "value": "United Kingdom"
204
+ },
205
+ "state": {
206
+ "type": "text",
207
+ "name": "State",
208
+ "value": ""
209
+ },
210
+ "zip_code": {
211
+ "type": "text",
212
+ "name": "ZIP Code",
213
+ "value": "SW3 5UR"
214
+ },
215
+ "phone": {
216
+ "type": "text",
217
+ "name": "Phone",
218
+ "value": "0173-733-6375"
219
+ },
220
+ "email": {
221
+ "type": "text",
222
+ "name": "Email",
223
+ "value": "London@localhost.local"
224
+ },
225
+ "photo": {
226
+ "type": "asset",
227
+ "name": "Photo",
228
+ "value": [
229
+ {
230
+ "name": "cafe01.jpg",
231
+ "description": "Dancing Goat Café - London",
232
+ "type": "image/jpeg",
233
+ "size": 493724,
234
+ "url": "https://assets-us-01.kc-usercontent.com:443/cbb8fcc6-9201-000d-a115-b1050abd8f34/8fccb3b9-a507-48cc-bccd-0639d7fb69ec/cafe01.jpg",
235
+ "width": 849,
236
+ "height": 565
237
+ }
238
+ ]
239
+ },
240
+ "sitemap": {
241
+ "type": "taxonomy",
242
+ "name": "Sitemap",
243
+ "taxonomy_group": "sitemap_538125f",
244
+ "value": [
245
+ {
246
+ "name": "Cafes",
247
+ "codename": "cafes"
248
+ },
249
+ {
250
+ "name": "Europe",
251
+ "codename": "europe"
252
+ }
253
+ ]
254
+ }
255
+ }
256
+ },
175
257
  "on_roasts": {
176
258
  "system": {
177
259
  "id": "f4b3fc05-e988-4dae-9ac1-a94aba566474",
@@ -0,0 +1,24 @@
1
+ {
2
+ "languages": [
3
+ {
4
+ "system": {
5
+ "id": "00000000-0000-0000-0000-000000000000",
6
+ "name": "English (United States)",
7
+ "codename": "en-US"
8
+ }
9
+ },
10
+ {
11
+ "system": {
12
+ "id": "d1f95fde-af02-b3b5-bd9e-f232311ccab8",
13
+ "name": "Spanish (Spain)",
14
+ "codename": "es-ES"
15
+ }
16
+ }
17
+ ],
18
+ "pagination": {
19
+ "skip": 0,
20
+ "limit": 0,
21
+ "count": 2,
22
+ "next_page": ""
23
+ }
24
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "system": {
3
+ "id": "4ce421e9-c403-eee8-fdc2-74f09392a749",
4
+ "name": "Manufacturer",
5
+ "codename": "manufacturer",
6
+ "last_modified": "2017-09-07T08:15:22.7210000Z"
7
+ },
8
+ "terms": [
9
+ {
10
+ "name": "Aerobie",
11
+ "codename": "aerobie",
12
+ "terms": []
13
+ },
14
+ {
15
+ "name": "Chemex",
16
+ "codename": "chemex",
17
+ "terms": []
18
+ },
19
+ {
20
+ "name": "Espro",
21
+ "codename": "espro",
22
+ "terms": []
23
+ },
24
+ {
25
+ "name": "Hario",
26
+ "codename": "hario",
27
+ "terms": []
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "system": {
3
+ "id": "7bc932b3-ce2a-4aa7-954e-04cbcbd214fc",
4
+ "name": "Brewer",
5
+ "codename": "brewer",
6
+ "last_modified": "2019-07-16T07:15:27.5660000Z"
7
+ },
8
+ "elements": {
9
+ "product_name": {
10
+ "type": "text",
11
+ "name": "Product name"
12
+ },
13
+ "metadata__og_description": {
14
+ "type": "text",
15
+ "name": "og:description"
16
+ },
17
+ "metadata__meta_title": {
18
+ "type": "text",
19
+ "name": "Meta title"
20
+ },
21
+ "long_description": {
22
+ "type": "rich_text",
23
+ "name": "Long description"
24
+ },
25
+ "metadata__og_title": {
26
+ "type": "text",
27
+ "name": "og:title"
28
+ },
29
+ "metadata__meta_description": {
30
+ "type": "text",
31
+ "name": "Meta description"
32
+ },
33
+ "metadata__twitter_site": {
34
+ "type": "text",
35
+ "name": "twitter:site"
36
+ },
37
+ "price": {
38
+ "type": "number",
39
+ "name": "Price"
40
+ },
41
+ "manufacturer": {
42
+ "type": "taxonomy",
43
+ "name": "Manufacturer",
44
+ "taxonomy_group": "manufacturer"
45
+ },
46
+ "metadata__twitter_image": {
47
+ "type": "asset",
48
+ "name": "twitter:image"
49
+ },
50
+ "metadata__twitter_creator": {
51
+ "type": "text",
52
+ "name": "twitter:creator"
53
+ },
54
+ "url_pattern": {
55
+ "type": "url_slug",
56
+ "name": "URL pattern"
57
+ },
58
+ "sitemap": {
59
+ "type": "taxonomy",
60
+ "name": "Sitemap",
61
+ "taxonomy_group": "sitemap_538125f"
62
+ },
63
+ "short_description": {
64
+ "type": "rich_text",
65
+ "name": "Short description"
66
+ },
67
+ "product_status": {
68
+ "type": "taxonomy",
69
+ "name": "Product status",
70
+ "taxonomy_group": "product_status"
71
+ },
72
+ "metadata__twitter_title": {
73
+ "type": "text",
74
+ "name": "twitter:title"
75
+ },
76
+ "metadata__twitter_description": {
77
+ "type": "text",
78
+ "name": "twitter:description"
79
+ },
80
+ "metadata__og_image": {
81
+ "type": "asset",
82
+ "name": "og:image"
83
+ },
84
+ "image": {
85
+ "type": "asset",
86
+ "name": "Image"
87
+ }
88
+ }
89
+ }
@@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/delivery/client/request_manager'
4
4
  require File.dirname(__FILE__) + '/delivery/models/content_item'
5
5
  require File.dirname(__FILE__) + '/delivery/models/content_type'
6
6
  require File.dirname(__FILE__) + '/delivery/models/taxonomy_group'
7
+ require File.dirname(__FILE__) + '/delivery/models/language'
7
8
  require File.dirname(__FILE__) + '/delivery/query_parameters/filters'
8
9
  require File.dirname(__FILE__) + '/delivery/responses/delivery_item_listing_response'
9
10
  require File.dirname(__FILE__) + '/delivery/responses/delivery_item_response'
@@ -13,6 +14,7 @@ require File.dirname(__FILE__) + '/delivery/responses/delivery_taxonomy_listing_
13
14
  require File.dirname(__FILE__) + '/delivery/responses/delivery_taxonomy_response'
14
15
  require File.dirname(__FILE__) + '/delivery/responses/delivery_element_response'
15
16
  require File.dirname(__FILE__) + '/delivery/responses/delivery_items_feed_response'
17
+ require File.dirname(__FILE__) + '/delivery/responses/delivery_language_listing_response'
16
18
  require File.dirname(__FILE__) + '/delivery/resolvers/content_link_resolver'
17
19
  require File.dirname(__FILE__) + '/delivery/resolvers/inline_content_item_resolver'
18
20
  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.21
4
+ version: 2.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dugre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-20 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -156,6 +156,7 @@ files:
156
156
  - lib/delivery/client/request_manager.rb
157
157
  - lib/delivery/models/content_item.rb
158
158
  - lib/delivery/models/content_type.rb
159
+ - lib/delivery/models/language.rb
159
160
  - lib/delivery/models/pagination.rb
160
161
  - lib/delivery/models/taxonomy_group.rb
161
162
  - lib/delivery/query_parameters/filters.rb
@@ -168,6 +169,7 @@ files:
168
169
  - lib/delivery/responses/delivery_item_listing_response.rb
169
170
  - lib/delivery/responses/delivery_item_response.rb
170
171
  - lib/delivery/responses/delivery_items_feed_response.rb
172
+ - lib/delivery/responses/delivery_language_listing_response.rb
171
173
  - lib/delivery/responses/delivery_taxonomy_listing_response.rb
172
174
  - lib/delivery/responses/delivery_taxonomy_response.rb
173
175
  - lib/delivery/responses/delivery_type_listing_response.rb
@@ -185,8 +187,11 @@ files:
185
187
  - lib/delivery/tests/generic/items/empty_rich_text.json
186
188
  - lib/delivery/tests/generic/items/rich_text_complex_tables.json
187
189
  - lib/delivery/tests/generic/items/where_does_coffee_come_from_.json
190
+ - lib/delivery/tests/generic/languages.json
188
191
  - lib/delivery/tests/generic/taxonomies.json
192
+ - lib/delivery/tests/generic/taxonomies/manufacturer.json
189
193
  - lib/delivery/tests/generic/types.json
194
+ - lib/delivery/tests/generic/types/brewer.json
190
195
  - lib/delivery/tests/generic/types/brewer/elements/product_status.json
191
196
  - lib/delivery/tests/items_feed/articles_feed_1.json
192
197
  - lib/delivery/tests/items_feed/articles_feed_2.json