class Kentico::Kontent::Delivery::DeliveryClient
Attributes
Public Class Methods
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
)
-
-
# 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
Public Instance Methods
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:
# 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
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 moreKentico::Kontent::Delivery::QueryParameters::Filter
objects. A single object will automatically be converted into an Array.
-
-
Returns:
# 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
Return all content items of the project
-
Args:
-
query_parameters (
Array
) optional One or moreKentico::Kontent::Delivery::QueryParameters::Filter
objects. A single object will automatically be converted into an Array.
-
-
Returns:
# 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
Return all taxonomy groups of the project
-
Args:
-
query_parameters (
Array
) optional One or moreKentico::Kontent::Delivery::QueryParameters::Filter
objects. A single object will automatically be converted into an Array.
-
-
Returns:
# 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
Return a single taxonomy group of the project
-
Args:
-
code_name (
string
) The code name of the desired taxonomy group
-
-
Returns:
# 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
Return a single content type of the project
-
Args:
-
code_name (
string
) Code name of the desired content type
-
-
Returns:
# 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
Return all content types of the project
# 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