Client
Client
| Name | Type | Description |
|---|---|---|
| api_key (required) | string | Stack API Key. |
| delivery_token (required) | string | Stack Delivery token. |
| environment (required) | string | Stack Environment name. |
assets
Retrieves all assets of a stack by default.
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@assets = @stack.assets.fetch;asset
Retrieve a single asset with its UID.
| Name | Type | Description |
|---|---|---|
| uid | string | The asset uid |
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@asset = @stack.asset("asset_uid").fetch;content_types
This method returns comprehensive information of all the content types of a particular stack in your account.
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@content_types = @stack.content_types;content_type
| Name | Type | Description |
|---|---|---|
| content_type_uid | string | UID of the existing content type |
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@content_type = @stack.content_type("content_type_uid");live_preview_query
For live preview data to be fetched provide query parameter to this function
| Name | Type | Description |
|---|---|---|
| query | object | Query parameter for live preview contents. |
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@stack.live_preview_query({
"live_preview": "live_preview_hash",
"content_type_uid": "content_type_uid",
"entry_uid": "entry_uid"
});sync
| Name | Type | Description |
|---|---|---|
| param.init | boolean | initializing sync |
| param.locale | string | initializing sync with entries of a specific locale |
| param.start_date | string | Default: initializing sync with entries published after a specific date |
| param.content_type_uid | string | initializing sync with entries of a specific content type |
| param.type | string | Use the type parameter to get a specific type of content.Supports 'asset_published', 'entry_published', 'asset_unpublished', 'entry_unpublished', 'asset_deleted', 'entry_deleted', 'content_type_deleted' |
| param.pagination_token | string | Fetching the next batch of entries using pagination token |
| param.sync_token | string | Performing subsequent sync after initial sync |
For initializing sync:
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack..sync({'init': true});For initializing sync with entries of a specific locale:
sync({'init': true, 'locale': 'en-us'});For initializing sync with entries published after a specific date:
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack.sync({'init': true<span>,</span><span> </span><span>'start_date'</span><span>:</span><span> </span><span>'2018-10-22'</span>});For initializing sync with entries of a specific content type:
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack.sync({'init': true, 'content_type_uid': 'session'});For initializing sync with specific type:
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack.sync({'init': true, 'type': 'entry_published'});For fetching the next batch of entries using pagination token:
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack.sync({'pagination_token': '<page_token>'});For performing subsequent sync after initial sync:
require "contentstack";
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack.sync({'sync_token': '<sync_token>'})