public class Stack
extends java.lang.Object
implements com.contentstack.sdk.INotifyClass
Modifier and Type | Class and Description |
---|---|
static class |
Stack.PublishType |
Modifier and Type | Field and Description |
---|---|
protected Config |
config |
protected java.lang.String |
contentType |
protected android.util.ArrayMap<java.lang.String,java.lang.Object> |
headerGroup_app |
protected java.lang.String |
limit |
protected java.lang.String |
localeCode |
protected android.util.ArrayMap<java.lang.String,java.lang.Object> |
localHeader |
protected java.lang.String |
pagination_token |
protected Stack.PublishType |
publishType |
protected java.lang.String |
skip |
protected java.lang.String |
start_from_date |
protected java.lang.String |
SYNC_KEY |
protected java.lang.String |
sync_token |
protected java.lang.String |
URL |
protected java.lang.String |
URLSCHEMA |
protected java.lang.String |
VERSION |
Modifier | Constructor and Description |
---|---|
protected |
Stack(java.lang.String stackApiKey) |
Modifier and Type | Method and Description |
---|---|
protected Asset |
asset()
Create
Asset instance. |
Asset |
asset(java.lang.String uid)
Create
Asset instance. |
AssetLibrary |
assetLibrary()
Create
AssetLibrary instance. |
ContentType |
contentType(java.lang.String contentTypeName)
|
java.lang.String |
getAccessToken()
Get stack access token
|
java.lang.String |
getApplicationKey()
Get stack application key
|
void |
getContentTypes(org.json.JSONObject params,
com.contentstack.sdk.ContentTypesCallback callback) |
void |
getResult(java.lang.Object object,
java.lang.String controller) |
void |
getResultObject(java.util.List<java.lang.Object> object,
org.json.JSONObject jsonObject,
boolean isSingleEntry) |
java.lang.String |
ImageTransform(java.lang.String image_url,
java.util.LinkedHashMap<java.lang.String,java.lang.Object> parameters) |
void |
removeHeader(java.lang.String key)
Remove header key.
|
protected void |
setConfig(Config config) |
void |
setHeader(java.lang.String key,
java.lang.String value)
To set headers for Built.io Contentstack rest calls.
|
void |
sync(java.lang.String contentType,
java.util.Date from_date,
com.contentstack.sdk.Language language,
Stack.PublishType type,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
sync(com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
syncContentType(java.lang.String content_type,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
syncFromDate(java.util.Date from_date,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
syncLocale(com.contentstack.sdk.Language language,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
syncPaginationToken(java.lang.String pagination_token,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
syncPublishType(Stack.PublishType type,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
void |
syncToken(java.lang.String sync_token,
com.contentstack.sdk.SyncResultCallBack syncCallBack) |
protected android.util.ArrayMap<java.lang.String,java.lang.Object> localHeader
protected java.lang.String URLSCHEMA
protected java.lang.String URL
protected java.lang.String VERSION
protected java.lang.String SYNC_KEY
protected Config config
protected android.util.ArrayMap<java.lang.String,java.lang.Object> headerGroup_app
protected java.lang.String skip
protected java.lang.String limit
protected java.lang.String sync_token
protected java.lang.String pagination_token
protected java.lang.String contentType
protected java.lang.String localeCode
protected Stack.PublishType publishType
protected java.lang.String start_from_date
protected void setConfig(Config config)
public ContentType contentType(java.lang.String contentTypeName)
contentTypeName
- contentType name.ContentType
instance.
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); ContentType contentType = stack.contentType("blog");
public Asset asset(java.lang.String uid)
Asset
instance.ContentType
instance.
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Asset asset = stack.asset("assetUid");
protected Asset asset()
Asset
instance.ContentType
instance.
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Asset asset = stack.asset();
public AssetLibrary assetLibrary()
AssetLibrary
instance.ContentType
instance.
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); AssetLibrary assetLib = stack.assetLibrary();
public java.lang.String getApplicationKey()
Example :
String stackApiKey = stack.getApplicationKey();
public java.lang.String getAccessToken()
Example :
String accessToken = stack.getAccessToken();
public void removeHeader(java.lang.String key)
key
- custom_header_key
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false);
stack.removeHeader("custom_header_key");
public void setHeader(java.lang.String key, java.lang.String value)
key
- header name.value
- header value against given header name.
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false);
stack.setHeader("custom_key", "custom_value");
public java.lang.String ImageTransform(java.lang.String image_url, java.util.LinkedHashMap<java.lang.String,java.lang.Object> parameters)
image_url
- on which we want to manipulate.parameters
- It is an second parameter in which we want to place different manipulation key and value in array form//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false);
// resize the image by specifying width and height LinkedHashMap imageParams = new LinkedHashMap(); imageParams.put("width", 100); imageParams.put("height",100); imageUrl = Stack.ImageTransform(image_url, parameters); stack.ImageTransform(image_url, parameters);
public void getContentTypes(org.json.JSONObject params, com.contentstack.sdk.ContentTypesCallback callback)
params
- query parameterscallback
- ContentTypesCallback
This call returns comprehensive information of all the content types available in a particular stack in your account.
JSONObject params = new JSONObject(); params.put("include_snippet_schema", true); params.put("limit", 3); stack.getContentTypes(params, new ContentTypesCallback() {
public void sync(com.contentstack.sdk.SyncResultCallBack syncCallBack)
syncCallBack
- returns callback for sync result.
The Sync request performs a complete sync of your app data.
It returns all the published entries and assets of the specified stack in response.
The response also contains a sync token, which you need to store,
since this token is used to get subsequent delta updates later.
stack.sync(SyncResultCallBack syncCallBack){ }
public void syncPaginationToken(java.lang.String pagination_token, com.contentstack.sdk.SyncResultCallBack syncCallBack)
pagination_token
- If the response is paginated, use the pagination token under this parameter.syncCallBack
- returns callback for sync result
If the result of the initial sync (or subsequent sync) contains more than 100 records,
the response would be paginated. It provides pagination token in the response. However,
you do not have to use the pagination token manually to get the next batch,
the SDK does that automatically until the sync is complete.
Pagination token can be used in case you want to fetch only selected batches.
It is especially useful if the sync process is interrupted midway (due to network issues, etc.).
In such cases, this token can be used to restart the sync process from where it was interrupted.
// dummy pagination_token = "blt7f35951d259183fba680e1"; stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
public void syncToken(java.lang.String sync_token, com.contentstack.sdk.SyncResultCallBack syncCallBack)
sync_token
- Use the sync token that you received in the previous/initial sync under this parameter.syncCallBack
- returns callback for sync result
You can use the sync token (that you receive after initial sync) to get the updated content next time.
The sync token fetches only the content that was added after your last sync,
and the details of the content that was deleted or updated.
//dummy sync_token = "blt28937206743728463"; stack.syncToken(sync_token, new SyncResultCallBack() ){ }
public void syncFromDate(java.util.Date from_date, com.contentstack.sdk.SyncResultCallBack syncCallBack)
from_date
- Enter the start date for initial sync.syncCallBack
- Returns callback for sync result.
You can also initialize sync with entries published after a specific date. To do this, use syncWithDate
and specify the start date as its value.
// dummy date final Date start_date = sdf.parse("2018-10-07"); stack.syncFromDate(start_date, new SyncResultCallBack()) { }
public void syncContentType(java.lang.String content_type, com.contentstack.sdk.SyncResultCallBack syncCallBack)
content_type
- Provide uid of your content_typesyncCallBack
- Returns callback for sync result.
You can also initialize sync with entries of only specific content_type.
To do this, use syncContentType and specify the content type uid as its value.
However, if you do this, the subsequent syncs will only include the entries of the specified content_type.
// dummy content_type like "session" stack.syncContentType(String content_type, new SyncResultCallBack()){ }
public void syncLocale(com.contentstack.sdk.Language language, com.contentstack.sdk.SyncResultCallBack syncCallBack)
language
- Select the required locale from the Language class.syncCallBack
- Returns callback for sync result.
You can also initialize sync with entries of only specific locales.
To do this, use syncLocale and specify the locale code as its value.
However, if you do this, the subsequent syncs will only include the entries of the specified locales.
// dummy language- Language.ENGLISH_UNITED_STATES stackInstance.syncLocale(Language.ENGLISH_UNITED_STATES, new SyncResultCallBack() ) { }
public void syncPublishType(Stack.PublishType type, com.contentstack.sdk.SyncResultCallBack syncCallBack)
type
- - Use the type parameter to get a specific type of content
like ( asset_published, entry_published, asset_unpublished, asset_deleted, entry_unpublished, entry_deleted, content_type_deleted.)syncCallBack
- returns callback for sync result.
Use the type parameter to get a specific type of content. You can pass one of the following values:
asset_published, entry_published, asset_unpublished, asset_deleted, entry_unpublished, entry_deleted, content_type_deleted.
If you do not specify any value, it will bring all published entries and published assets.
stackInstance.syncPublishType(Stack.PublishType.entry_published, new SyncResultCallBack()) { }
public void sync(java.lang.String contentType, java.util.Date from_date, com.contentstack.sdk.Language language, Stack.PublishType type, com.contentstack.sdk.SyncResultCallBack syncCallBack)
contentType
- from_date
- language
- type
- syncCallBack
- You can also initialize sync with entries that satisfy multiple parameters.
To do this, use syncWith and specify the parameters.
However, if you do this, the subsequent syncs will only include the entries of the specified parameters
stackInstance.sync(String contentType, Date from_date, Language language, PublishType type, SyncResultCallBack syncCallBack) { }
public void getResult(java.lang.Object object, java.lang.String controller)
getResult
in interface com.contentstack.sdk.INotifyClass
public void getResultObject(java.util.List<java.lang.Object> object, org.json.JSONObject jsonObject, boolean isSingleEntry)
getResultObject
in interface com.contentstack.sdk.INotifyClass