Class Asset

java.lang.Object
com.contentstack.sdk.Asset

public class Asset
extends Object
The type Asset.
  • Field Details

  • Constructor Details

  • Method Details

    • setStackInstance

      protected void setStackInstance​(@NotNull Stack stack)
    • configure

      public Asset configure​(org.json.JSONObject jsonObject)
      Configure asset.
      Parameters:
      jsonObject - the json object
      Returns:
      the asset
    • setHeader

      public void setHeader​(@NotNull String headerKey, @NotNull String headerValue)
      Sets header.
      Parameters:
      headerKey - the header key
      headerValue - the header value

      Example :
                          Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                          Asset asset = stack.asset(asset_uid);
                          asset.setHeader();
                          
    • removeHeader

      public void removeHeader​(@NotNull String headerKey)
      Remove header.
      Parameters:
      headerKey - the header key

      Example :
                        Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                        Asset asset = stack.asset(asset_uid);
                        asset.removeHeader();
      
                        
    • setUid

      protected void setUid​(@NotNull String assetUid)
    • getAssetUid

      public String getAssetUid()
      Gets asset uid.
      Returns:
      the asset uid

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getAssetUid();
                   }
               });
      
               
    • getFileType

      public String getFileType()
      Gets file type.
      Returns:
      the file type

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getFileType();
                   }
               });
      
               
    • getFileSize

      public String getFileSize()
      Gets file size.
      Returns:
      the file size

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getFileSize();
                   }
               });
      
               
    • getFileName

      public String getFileName()
      Gets file name.
      Returns:
      the file name

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getFileName();
                   }
               });
      
               
    • getUrl

      public String getUrl()
      Gets url.
      Returns:
      the url

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getUrl();
                   }
               });
      
               
    • toJSON

      public org.json.JSONObject toJSON()
      To json json object.
      Returns:
      the json object

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.toJSON();
                   }
               });
      
               
    • getCreateAt

      public Calendar getCreateAt()
      Gets create at.
      Returns:
      the create at

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getCreateAt();
                   }
               });
      
               
    • getCreatedBy

      public String getCreatedBy()
      Gets created by.
      Returns:
      the created by

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getCreatedBy();
                   }
               });
      
               
    • getUpdateAt

      public Calendar getUpdateAt()
      Gets update at.
      Returns:
      the update at

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getUpdateAt();
                   }
               });
      
               
    • getUpdatedBy

      public String getUpdatedBy()
      Gets updated by.
      Returns:
      the updated by

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getUpdatedBy();
                   }
               });
      
               
    • getDeleteAt

      public Calendar getDeleteAt()
      Gets delete at.
      Returns:
      the delete at

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getDeleteAt();
                   }
               });
      
               
    • getDeletedBy

      public String getDeletedBy()
      Gets deleted by.
      Returns:
      the deleted by

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getDeletedBy();
                   }
               });
      
               
    • getTags

      public String[] getTags()
      Get tags string [ ].
      Returns:
      the string [ ]

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.fetch(new FetchResultCallback() {
                   @Override
                   public void onCompletion(ResponseType responseType, Error error) {
                       asset.getTags();
                   }
               });
      
               
    • setTags

      protected Asset setTags​(String[] tags)
    • includeDimension

      public Asset includeDimension()
      Include dimension asset.
      Returns:
      the asset

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.includeDimension();
               
    • addParam

      public Asset addParam​(@NotNull String paramKey, @NotNull String paramValue)
      Add param asset.
      Parameters:
      paramKey - the param key
      paramValue - the param value
      Returns:
      the asset

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.addParam();
               
    • includeFallback

      public Asset includeFallback()
      Include fallback asset.
      Returns:
      the asset

      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.includeFallback();
               
    • includeBranch

      public Asset includeBranch()
      Includes Branch in the asset response
      Returns:
      Asset object, so you can chain this call.


      Example :
               Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
               Asset asset = stack.asset(asset_uid);
               asset.includeBranch();
               
    • fetch

      public void fetch​(FetchResultCallback callback)
      Fetch.
      Parameters:
      callback - the callback