Class AssetLibrary

  • All Implemented Interfaces:
    INotifyClass

    public class AssetLibrary
    extends Object
    implements INotifyClass
    MIT License Copyright (c) 2012 - 2019 Contentstack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    • Constructor Detail

      • AssetLibrary

        protected AssetLibrary()
    • Method Detail

      • setStackInstance

        protected void setStackInstance​(Stack stack)
      • setHeader

        public void setHeader​(String key,
                              String value)
        To set headers for Contentstack rest calls.
        Scope is limited to this object only.
        Parameters:
        key - header name.
        value - header value against given header name.

        Example :
         //'blt5d4sample2633b' is a dummy Application API key
         AssetLibrary assetLibObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv",  config).assetLibrary();
         assetLibObject.setHeader("custom_header_key", "custom_header_value");
         
      • removeHeader

        public void removeHeader​(String key)
        Remove a header for a given key from headers.
        Scope is limited to this object only.
        Parameters:
        key - header key.

        Example :
         //'blt5d4sample2633b' is a dummy Application API key
         AssetLibrary assetLibObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv",  config).assetLibrary();
        
         assetLibObject.removeHeader("custom_header_key");
         
      • sort

        public AssetLibrary sort​(String key,
                                 AssetLibrary.ORDERBY orderby)
        Sort assets by fieldUid.
        Parameters:
        key - field Uid.
        orderby - AssetLibrary.ORDERBY value for ascending or descending.
        Returns:
        AssetLibrary object, so you can chain this call.

        Example :
         //'blt5d4sample2633b' is a dummy Application API key
         AssetLibrary assetLibObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv",  config).assetLibrary();
         assetLibObject.sort("fieldUid", AssetLibrary.ORDERBY.ASCENDING);
         
      • includeCount

        public AssetLibrary includeCount()
        Retrieve count and data of assets in result.
        Returns:
        AssetLibrary object, so you can chain this call.

        Example :
         //'blt5d4sample2633b' is a dummy Stack API key
         //'bltdtsample_accessToken767vv' is dummy access token.
         AssetLibrary assetLibObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv",  config).assetLibrary();
         assetLibObject.includeCount();
         
      • includeRelativeUrl

        public AssetLibrary includeRelativeUrl()
        Retrieve relative urls objects in result.
        Returns:
        AssetLibrary object, so you can chain this call.

        Example :
         //'blt5d4sample2633b' is a dummy Stack API key
         //'bltdtsample_accessToken767vv' is dummy access token.
         AssetLibrary assetLibObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv",  config).assetLibrary();
         assetLibObject.includeRelativeUrl();
         
      • getCount

        public int getCount()
        Get a count of assets in success callback of FetchAssetsCallback.
        Returns:
        int @count
      • fetchAll

        public void fetchAll​(FetchAssetsCallback assetsCallback)
        Fetch a all asset.
        Parameters:
        assetsCallback - FetchAssetsCallback instance for success and failure result.

        Example :
            //'blt5d4sample2633b' is a dummy Stack API key
            //'bltdtsample_accessToken767vv' is dummy access token.
            AssetLibrary assetLibObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv",  config).assetLibrary();
           assetLibObject.fetchAll(new FetchAssetsCallback() {
           public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
              if (error == null) {
                 //Success Block.
              } else {
                 //Error Block.
              }
           }
          });
        
         
      • getResultObject

        public void getResultObject​(List<Object> objects,
                                    org.json.JSONObject jsonObject,
                                    boolean isSingleEntry)
        Specified by:
        getResultObject in interface INotifyClass