Class ContentType


  • public class ContentType
    extends Object
    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.
    • Field Detail

      • contentTypeName

        protected String contentTypeName
      • stackInstance

        protected Stack stackInstance
    • Constructor Detail

      • ContentType

        protected ContentType​(String contentTypeName)
    • Method Detail

      • setStackInstance

        protected void setStackInstance​(Stack stack)
      • setHeader

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

        Example :
         //'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("form_name");
        contentType.setHeader("custom_key", "custom_value");
      • removeHeader

        public void removeHeader​(String key)
        Remove header key.
        Parameters:
        key - custom_header_key

        Example :
         //'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("form_name");
        contentType.removeHeader("custom_header_key");
      • entry

        public Entry entry​(String entryUid)
        Represents a Entry. Create Entry instance
        Parameters:
        entryUid - Set entry uid.
        Returns:
        Entry instance.

        Example :
          //'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("form_name");
        // setUid will identify the object, and calling save will update it ENTRY entry = contentType.entry("bltf4fbbc94e8c851db");
      • entry

        protected Entry entry()
      • query

        public Query query()
        Represents a Query. Create Query instance.
        Returns:
        Query instance.

        Example :
          //'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("form_name");
        Query csQuery = contentType.query();
      • fetch

        public void fetch​(ContentTypesCallback callback)
        This call returns information of a specific content type. It returns the content type schema, but does not include its entries.
        Parameters:
        callback - ContentTypesCallback

        Example :
         ContentType  contentType = stack.contentType("content_type_uid");
         contentType.fetch(new ContentTypesCallback() {
        
         public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
         if (error==null){
        
         }else {
        
         }
         }
         });