AssetQuery
public final class AssetQuery : BaseQuery
To fetch all or find Assets
use AssetQuery
.
-
Undocumented
Declaration
Swift
public typealias ResourceType = AssetModel
-
Stack instance for Entry to be fetched
Declaration
Swift
public var stack: Stack
-
URI Parameters
Declaration
Swift
public var parameters: [String : Any]
-
Query Parameters
Declaration
Swift
public var queryParameter: [String : Any]
-
Declaration
Swift
public var cachePolicy: CachePolicy
-
Instance method to fetch
Assets
for specific locale.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) // To retrive single asset with specific locale stack.asset().query().locale("en-us") .fetch { (result: Result<AssetModel, Error>, response: ResponseType) in switch result { case .success(let model): //Model retrive from API case .failure(let error): //Error Message } }
Declaration
Swift
public func locale(_ locale: String) -> Self
Parameters
locale
The code for fetching entry for locale.
Return Value
A
AssetQuery
to enable chaining. -
Use this method to do a search on
Assets
which enables searching for entries based on value’s for members of referenced entries.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.asset().query().where(queryableCodingKey: .title, .equals("Asset Title")) .find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
public func `where`(queryableCodingKey: AssetModel.QueryableCodingKey, _ operation: Query.Operation) -> AssetQuery
Parameters
queryableCodingKey
The member of your
QueryableCodingKey
that you are performing your select operation against.operation
The query operation used in the query.
Return Value
A AssetQuery to enable chaining.
-
Include URI paramertes to fetch Asset with relative url and dimansion
Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.asset().query().include(params: [.all]) .find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
public func include(params: Include) -> AssetQuery
Parameters
params
The member of your
AssetQuery.Include
that you want to include in responseReturn Value
A AssetQuery to enable chaining.
-
The
See moreAssetQuery.Include
is parameter for includingcount
,relative URLs
, anddimensions
in result.Declaration
Swift
public struct Include : OptionSet