Class: Kentico::Kontent::Delivery::DeliveryClient
- Inherits:
-
Object
- Object
- Kentico::Kontent::Delivery::DeliveryClient
- Defined in:
- lib/delivery/client/delivery_client.rb
Overview
Executes requests against the Kentico Kontent Delivery API.
Instance Attribute Summary collapse
-
#use_preview ⇒ Object
Returns the value of attribute use_preview.
Instance Method Summary collapse
-
#element(content_type, element) ⇒ Object
Return a single element of a content type.
-
#initialize(config) ⇒ DeliveryClient
constructor
Constructor.
-
#item(code_name, query_parameters = []) ⇒ Object
Return a single content item of the project.
-
#items(query_parameters = []) ⇒ Object
Return all content items of the project.
-
#taxonomies(query_parameters = []) ⇒ Object
Return all taxonomy groups of the project.
-
#taxonomy(code_name) ⇒ Object
Return a single taxonomy group of the project.
-
#type(code_name) ⇒ Object
Return a single content type of the project.
-
#types ⇒ Object
Return all content types of the project.
Constructor Details
#initialize(config) ⇒ DeliveryClient
Constructor. Accepts a hash with the options for client.
-
Args:
-
config (
Hash
) May contain the following keys:-
project_id (
string
) required -
preview_key (
string
) -
secure_key (
string
) -
content_link_url_resolver ( Kentico::Kontent::Delivery::Resolvers::ContentLinkResolver )
-
inline_content_item_resolver ( Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver )
-
with_retry_policy (
bool
)
-
-
28 29 30 31 32 33 34 35 36 |
# File 'lib/delivery/client/delivery_client.rb', line 28 def initialize(config) @project_id = config.fetch(:project_id) @preview_key = config.fetch(:preview_key, nil) @secure_key = config.fetch(:secure_key, nil) @content_link_url_resolver = config.fetch(:content_link_url_resolver, nil) @inline_content_item_resolver = config.fetch(:inline_content_item_resolver, nil) @with_retry_policy = config.fetch(:with_retry_policy, true) self.use_preview = !@preview_key.nil? end |
Instance Attribute Details
#use_preview ⇒ Object
Returns the value of attribute use_preview.
16 17 18 |
# File 'lib/delivery/client/delivery_client.rb', line 16 def use_preview @use_preview end |
Instance Method Details
#element(content_type, element) ⇒ Object
Return a single element of a content type
-
Args:
-
content_type (
string
) The code name of the content type containing the element -
element (
string
) The code name of the desired element
-
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
144 145 146 147 148 149 150 151 |
# File 'lib/delivery/client/delivery_client.rb', line 144 def element(content_type, element) DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, code_name: element, content_type: content_type, query_type: QUERY_TYPE_ELEMENT, with_retry_policy: @with_retry_policy end |
#item(code_name, query_parameters = []) ⇒ Object
Return a single content item of the project
-
Args:
-
code_name (
string
) The code name of the desired content item -
query_parameters (
Array
) optional One or more Kentico::Kontent::Delivery::QueryParameters::Filter objects. A single object will automatically be converted into an Array.
-
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/delivery/client/delivery_client.rb', line 92 def item(code_name, query_parameters = []) q = DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, code_name: code_name, qp: query_parameters, content_link_url_resolver: @content_link_url_resolver, inline_content_item_resolver: @inline_content_item_resolver, query_type: QUERY_TYPE_ITEMS, with_retry_policy: @with_retry_policy q.use_preview = use_preview q.preview_key = @preview_key q end |
#items(query_parameters = []) ⇒ Object
Return all content items of the project
-
Args:
-
query_parameters (
Array
) optional One or more Kentico::Kontent::Delivery::QueryParameters::Filter objects. A single object will automatically be converted into an Array.
-
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/delivery/client/delivery_client.rb', line 71 def items(query_parameters = []) q = DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, qp: query_parameters, content_link_url_resolver: @content_link_url_resolver, inline_content_item_resolver: @inline_content_item_resolver, query_type: QUERY_TYPE_ITEMS, with_retry_policy: @with_retry_policy q.use_preview = use_preview q.preview_key = @preview_key q end |
#taxonomies(query_parameters = []) ⇒ Object
Return all taxonomy groups of the project
-
Args:
-
query_parameters (
Array
) optional One or more Kentico::Kontent::Delivery::QueryParameters::Filter objects. A single object will automatically be converted into an Array.
-
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
113 114 115 116 117 118 119 |
# File 'lib/delivery/client/delivery_client.rb', line 113 def taxonomies(query_parameters = []) DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, qp: query_parameters, query_type: QUERY_TYPE_TAXONOMIES, with_retry_policy: @with_retry_policy end |
#taxonomy(code_name) ⇒ Object
Return a single taxonomy group of the project
-
Args:
-
code_name (
string
) The code name of the desired taxonomy group
-
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
128 129 130 131 132 133 134 |
# File 'lib/delivery/client/delivery_client.rb', line 128 def taxonomy(code_name) DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, code_name: code_name, query_type: QUERY_TYPE_TAXONOMIES, with_retry_policy: @with_retry_policy end |
#type(code_name) ⇒ Object
Return a single content type of the project
-
Args:
-
code_name (
string
) Code name of the desired content type
-
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
56 57 58 59 60 61 62 |
# File 'lib/delivery/client/delivery_client.rb', line 56 def type(code_name) DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, code_name: code_name, query_type: QUERY_TYPE_TYPES, with_retry_policy: @with_retry_policy end |
#types ⇒ Object
Return all content types of the project
-
Returns:
-
Kentico::Kontent::Delivery::DeliveryQuery
-
42 43 44 45 46 47 |
# File 'lib/delivery/client/delivery_client.rb', line 42 def types DeliveryQuery.new project_id: @project_id, secure_key: @secure_key, query_type: QUERY_TYPE_TYPES, with_retry_policy: @with_retry_policy end |