delivery-sdk-ruby 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/delivery/client/delivery_query.rb +1 -0
- data/lib/delivery/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5935e3de30556622cdc1d6c9ba309ea22120e0c17e79d0b0f72f22d75ba85619
|
4
|
+
data.tar.gz: 78c3a84a4c97a324b1cee12065f6a0b441b44d200054a0cd2df3d1f1d992f2cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb47f64b96aacb9b892833288972e108377b991c9fcf14faf1b1a48f529ac737ad8c73130abc5e9391cec67a53f332e0f82c2bc5827b276196433f014194653
|
7
|
+
data.tar.gz: abe85df664b4f113b60cf84727953cf99db8d14ee7aa88557b372a1f78f4fa875fb148278b3969a9d27960f3ab108d741da14451604e1da4d97b97bcf49dee08
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ You will use `KenticoCloud::Delivery::DeliveryClient` to obtain content from Ken
|
|
51
51
|
delivery_client = KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>'
|
52
52
|
```
|
53
53
|
|
54
|
-
**Pro tip:** You can alias namespaces to make them shorter, e.g.
|
54
|
+
:gem: **Pro tip:** You can alias namespaces to make them shorter, e.g.
|
55
55
|
|
56
56
|
```ruby
|
57
57
|
KC = KenticoCloud::Delivery
|
@@ -64,7 +64,7 @@ To enable [preview](https://developer.kenticocloud.com/docs/previewing-content-i
|
|
64
64
|
|
65
65
|
```ruby
|
66
66
|
delivery_client = KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>',
|
67
|
-
|
67
|
+
preview_key: '<your-preview-key>'
|
68
68
|
```
|
69
69
|
|
70
70
|
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:
|
@@ -87,7 +87,7 @@ If you've [secured access](https://developer.kenticocloud.com/docs/securing-publ
|
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>',
|
90
|
-
|
90
|
+
secure_key: '<your-secure-key>'
|
91
91
|
```
|
92
92
|
|
93
93
|
## Listing items
|
@@ -330,7 +330,7 @@ delivery_client.taxonomy('personas').execute do |response|
|
|
330
330
|
end
|
331
331
|
```
|
332
332
|
|
333
|
-
##
|
333
|
+
## Retrieving content type elements
|
334
334
|
|
335
335
|
Kentico Cloud 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:
|
336
336
|
|
@@ -342,7 +342,7 @@ end
|
|
342
342
|
|
343
343
|
This returns a `KenticoCloud::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.
|
344
344
|
|
345
|
-
The element will always contain __codename__, __type__, and __name__, but multiple choice elements will also contain __options__ and taxonomy elements will contain __taxonomy_group__.
|
345
|
+
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.
|
346
346
|
|
347
347
|
## Resolving links
|
348
348
|
|
@@ -354,7 +354,7 @@ link_resolver = KenticoCloud::Delivery::Resolvers::ContentLinkResolver.new(lambd
|
|
354
354
|
return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
|
355
355
|
end)
|
356
356
|
delivery_client = KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>',
|
357
|
-
|
357
|
+
content_link_url_resolver: link_resolver
|
358
358
|
```
|
359
359
|
|
360
360
|
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 `KenticoCloud::Delivery::Resolvers::ContentLinkResolver` and contain a `resolve_link(link)` method. For example, you can create `MyLinkResolver.rb`:
|
@@ -372,7 +372,7 @@ Then create an object of this class when instantiating the DeliveryClient:
|
|
372
372
|
|
373
373
|
```ruby
|
374
374
|
delivery_client = KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>',
|
375
|
-
|
375
|
+
content_link_url_resolver: MyLinkResolver.new
|
376
376
|
```
|
377
377
|
|
378
378
|
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:
|
@@ -399,7 +399,7 @@ item_resolver = KenticoCloud::Delivery::Resolvers::ContentLinkResolver.new(lambd
|
|
399
399
|
return "/brewers/#{link.url_slug}" if link.type.eql? 'brewer'
|
400
400
|
end)
|
401
401
|
delivery_client = KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>',
|
402
|
-
|
402
|
+
content_link_url_resolver: item_resolver
|
403
403
|
delivery_client.item('coffee_processing_techniques').execute do |response|
|
404
404
|
text = response.item.get_string 'body_copy'
|
405
405
|
end
|
@@ -415,7 +415,7 @@ item_resolver = KenticoCloud::Delivery::Resolvers::InlineContentItemResolver.new
|
|
415
415
|
return "<div>$#{item.elements.price.value}</div>" if item.system.type.eql? 'brewer'
|
416
416
|
end)
|
417
417
|
delivery_client = KenticoCloud::Delivery::DeliveryClient.new project_id: '<your-project-id>',
|
418
|
-
|
418
|
+
inline_content_item_resolver: item_resolver
|
419
419
|
```
|
420
420
|
|
421
421
|
The object passed to the resolving method is a complete ContentItem. Similar to content link resolvers, you can create your own class which extends `KenticoCloud::Delivery::Resolvers::InlineContentItemResolver` and implements the `resolve_item` method:
|
@@ -445,8 +445,8 @@ When you've obtained the URL for an asset, you can use our [Image Transformation
|
|
445
445
|
```ruby
|
446
446
|
url = response.item.get_assets('teaser_image').first.url
|
447
447
|
url = KenticoCloud::Delivery::Builders::ImageTransformationBuilder.transform(url)
|
448
|
-
|
449
|
-
|
448
|
+
# methods...
|
449
|
+
.url
|
450
450
|
```
|
451
451
|
|
452
452
|
The available methods are:
|
data/lib/delivery/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delivery-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
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-03-
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|