Class ContentstackClient
To fetch stack level information of your application from Contentstack server.
Inheritance
Inherited Members
Namespace: Contentstack.Core
Assembly: Contentstack.Core.dll
Syntax
public class ContentstackClient
Constructors
| Improve this Doc View SourceContentstackClient(ContentstackOptions)
Declaration
public ContentstackClient(ContentstackOptions options)
Parameters
Type | Name | Description |
---|---|---|
ContentstackOptions | options |
ContentstackClient(IOptions<ContentstackOptions>)
Initializes a instance of the ContentstackClient class.
Declaration
public ContentstackClient(IOptions<ContentstackOptions> options)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Options.IOptions<ContentstackOptions> | options | used to get stack details via class ContentstackOptions to create client. |
Examples
var options = new ContentstackOptions()
{
ApiKey = "api_key",
DeliveryToken = "delivery_token"
Environment = "environment"
}
ContentstackClient stack = new ContentstackClient(options);
ContentType contentType = stack.ContentType("contentType_name");
|
Improve this Doc
View Source
ContentstackClient(String, String, String, String, ContentstackRegion, String)
Initializes a instance of the ContentstackClient class.
Declaration
public ContentstackClient(string apiKey, string deliveryToken, string environment, string host = null, ContentstackRegion region = ContentstackRegion.US, string version = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | apiKey | API Key of your stack on Contentstack. |
System.String | deliveryToken | Accesstoken of your stack on Contentstack. |
System.String | environment | Environment name |
System.String | host | |
ContentstackRegion | region | |
System.String | version |
Examples
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentType contentType = stack.ContentType("contentType_name");
Properties
| Improve this Doc View SourceSerializerSettings
Gets or sets the settings that should be used for deserialization.
Declaration
public JsonSerializerSettings SerializerSettings { get; set; }
Property Value
Type | Description |
---|---|
Newtonsoft.Json.JsonSerializerSettings |
Methods
| Improve this Doc View SourceAsset(String)
Represents a Asset. Creates Asset Instance.
Declaration
public Asset Asset(string Uid)
Parameters
Type | Name | Description |
---|---|---|
System.String | Uid |
Returns
Type | Description |
---|---|
Asset | Current instance of Asset, this will be useful for a chaining calls. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
Asset asset = stack.Asset("asset_uid");
|
Improve this Doc
View Source
AssetLibrary()
Represents a AssetLibrary. Creates AssetLibrary Instance.
Declaration
public AssetLibrary AssetLibrary()
Returns
Type | Description |
---|---|
AssetLibrary | Current instance of Asset, this will be useful for a chaining calls. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = stack.AssetLibrary();
|
Improve this Doc
View Source
ContentType(String)
Represents a ContentType. Creates ContenntType Instance.
Declaration
public ContentType ContentType(string contentTypeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeName | ContentType name. |
Returns
Type | Description |
---|---|
ContentType | Current instance of ContentType, this will be useful for a chaining calls. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
ContentType contentType = stack.ContentType("contentType_name");
|
Improve this Doc
View Source
GetAccessToken()
Get stack access token
Declaration
public string GetAccessToken()
Returns
Type | Description |
---|---|
System.String | access token |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String accessToken = stack.GetAccessToken();
|
Improve this Doc
View Source
GetApplicationKey()
Get stack application key
Declaration
public string GetApplicationKey()
Returns
Type | Description |
---|---|
System.String | stack application key |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String url = stack.GetApplicationKey();
|
Improve this Doc
View Source
GetContentTypes(Dictionary<String, Object>)
This method returns comprehensive information of all the content types of a particular stack in your account.
Declaration
public async Task<IList> GetContentTypes(Dictionary<string, object> param = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | param | is dictionary of additional parameter |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.IList> | The List of content types schema. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
var param = new Dictionary<string, object>();
param.Add("include_global_field_schema",true);
param.Add("limit", 10);
param.Add("skip", 10);
param.Add("include_count", "true");
var result = await stack.GetContentTypes(param);
|
Improve this Doc
View Source
GetEnvironment()
Get stack environment
Declaration
public string GetEnvironment()
Returns
Type | Description |
---|---|
System.String | stack environment |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String environment = stack.GetEnvironment();
|
Improve this Doc
View Source
GetVersion()
Get version.
Declaration
public string GetVersion()
Returns
Type | Description |
---|---|
System.String | Version |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
String url = stack.GetVersion();
|
Improve this Doc
View Source
LivePreviewQuery(Dictionary<String, String>)
To add live preview Query for contentstack preview call
Declaration
public void LivePreviewQuery(Dictionary<string, string> query)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | query | Query parameter containing hash and content type UID |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.LivePreviewQuery(query);
|
Improve this Doc
View Source
RemoveHeader(String)
Remove header key.
Declaration
public void RemoveHeader(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | key to be remove from header |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.RemoveHeader("custom_header_key");
|
Improve this Doc
View Source
SetHeader(String, String)
To set headers for Contentstack rest calls.
Declaration
public void SetHeader(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | header name. |
System.String | value | header value against given header name. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.SetHeader("custom_key", "custom_value");
|
Improve this Doc
View Source
SyncPaginationToken(String)
Syncs the pagination token.
Declaration
public async Task<SyncStack> SyncPaginationToken(string paginationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | paginationToken | Pagination token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SyncStack> | The pagination token. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.SyncPaginationTokenn("pagination_token");
|
Improve this Doc
View Source
SyncRecursive(String, SyncType, String, Nullable<DateTime>)
Syncs the recursive language.
Declaration
public async Task<SyncStack> SyncRecursive(string Locale = null, SyncType SyncType = SyncType.All, string ContentTypeUid = null, DateTime? StartFrom = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Locale | Locale. |
SyncType | SyncType | Sync type. |
System.String | ContentTypeUid | Content type uid. |
System.Nullable<System.DateTime> | StartFrom | Start from. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SyncStack> | The recursive language. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.SyncRecursiveLanguage("SyncType", "Locale");
|
Improve this Doc
View Source
SyncToken(String)
Syncs the token.
Declaration
public async Task<SyncStack> SyncToken(string SyncToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | SyncToken | Sync token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SyncStack> | The token. |
Examples
ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
stack.SyncToken("sync_token");