Entry

View as Markdown

Entry

An Entry is the actual piece of content created using one of the defined content types.

NameTypeDescription
cachePolicy CachePolicy

Set cache policy for the entry request.

stack Stack

Stack instance for Entry to be fetched



parameters [String : Any]

URI Parameters.

queryParameter [String : Any]

Query parameter

query()

To fetch all or find Entries query method is used.

let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")


let query = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>").query()

query(_:)

To fetch all or find Entries to specific model query method is used.

NameTypeDescription
entry (required)EntryType.Type

A entry type for querying on.

let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")


let query = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>").query(Product.self)

fetch(_:)

This call fetches the latest version of a specific Entry of a particular stack.

NameTypeDescription
completion (required)Result<ResourceType, Error>, ResponseType) -> Void

A handler which will be called on completion of the operation.

let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")


stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>")

.fetch { (result: Result<EntryModel, Error>, response: ResponseType) in

   switch result {

   case .success(let model):


   case .failure(let error):


   }

}

Variants

The variants method retrieves details of a specific entry variant or an array of entry variants based on the applied query.

When Personalize creates a variant in the CMS, it assigns a "Variant Alias" to identify that specific variant. When fetching entry variants using the Delivery API, you can pass variant aliases in place of variant UIDs in the x-cs-variant-uid header.

NameTypeDescription
uid | uids (required)string | string[]

Enter the UID of the variant

Example 1:

import Contentstack

let stack = Contentstack.stack(

    apiKey: <API_KEY>,

    deliveryToken: <DELIVERY_TOKEN>,

    environment: <ENVIRONMENT>

)


stack

.contentType(uid: <CT_UID>)

.entry(uid: <ENTRY_UID>)

.variants(uid: <VARIANT_UID/VARIANT_ALIAS>)

.fetch { (result: Result<EntryModel, Error>, response: ResponseType) in

    switch result {

        case .success(let contentstackResponse):

            // Contentstack response with variant entry data

        case .failure(let error):

            // Error Message

    }

}

Example 2:

import Contentstack

let stack = Contentstack.stack(

    apiKey: <API_KEY>,

    deliveryToken: <DELIVERY_TOKEN>,

    environment: <ENVIRONMENT>

)


stack

.contentType(uid: <CT_UID>)

.entry(uid: <ENTRY_UID>)

.variants(uids: [<VARIANT_UID_1/VARIANT_ALIAS_1>, <VARIANT_UID_2/<VARIANT_ALIAS_2>, <VARIANT_UID_3/VARIANT_ALIAS_3>])

.fetch { (result: Result<EntryModel, Error>, response: ResponseType) in

    switch result {

        case .success(let contentstackResponse):

            // Contentstack response with variant entry data

        case .failure(let error):

            // Error Message

    }

}