Client
open class Client
Client object for performing requests against the Contentful API.
-
Initializes a new Contentful client instance
Declaration
Swift
public init(spaceId: String, accessToken: String, clientConfiguration: ClientConfiguration = .default, sessionConfiguration: URLSessionConfiguration = .default)Parameters
spaceIdThe space you want to perform requests against.
accessTokenThe access token used for authorization.
clientConfigurationCustom Configuration of the Client.
sessionConfigurationThe configuration for the URLSession. Note that HTTP headers will be overwritten interally by the SDK so that requests can be authorized correctly.
Return Value
An initialized client instance.
-
Fetch a collection of Entries from Contentful matching the specified query. This method does not specify the content_type in the query parameters, so the entries returned in the results can be of any type.
Declaration
Swift
@discardableResult public func fetchEntries(with query: Query, then completion: @escaping ResultsHandler<ArrayResponse<Entry>>) -> URLSessionDataTask?Parameters
queryThe Query object to match results againts.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a collection of Entries from Contentful matching the specified query. This method does not specify the content_type in the query parameters, so the entries returned in the results can be of any type.
Declaration
Swift
@discardableResult public func fetchEntries(with query: Query) -> Observable<Result<ArrayResponse<Entry>>>Parameters
queryThe Query object to match results againts.
Return Value
A tuple of data task and an observable for the resulting array of Entry’s.
-
Fetch a collection of Entries of a specified content type matching the query. The content_type parameter is specified by passing in a generic parameter: a model class conforming to
EntryModellable.Declaration
Swift
@discardableResult public func fetchMappedEntries<EntryType: EntryModellable>(with query: QueryOn<EntryType>, then completion: @escaping ResultsHandler<MappedArrayResponse<EntryType>>) -> URLSessionDataTask?Parameters
queryA QueryOn object to match results of the specified EntryModellable against.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a collection of Entries of a specified content type matching the query. The content_type parameter is specified by passing in a generic parameter: a model class conforming to
EntryModellable.Declaration
Swift
@discardableResult public func fetchMappedEntries<EntryType: EntryModellable>(with query: QueryOn<EntryType>) -> Observable<Result<MappedArrayResponse<EntryType>>>Parameters
queryA QueryOn object to match results of the specified EntryModellable against.
Return Value
A tuple of data task and an observable for the resulting array of EntryModellable types.
-
Fetch a collection of Assets from Contentful matching the specified query.
Declaration
Swift
@discardableResult public func fetchAssets(with query: AssetQuery, then completion: @escaping ResultsHandler<ArrayResponse<Asset>>) -> URLSessionDataTask?Parameters
queryThe Query object to match results againts.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a collection of Assets from Contentful matching the specified query.
Declaration
Swift
@discardableResult public func fetchAssets(query: AssetQuery) -> Observable<Result<ArrayResponse<Asset>>>Parameters
queryThe Query object to match results againts.
Return Value
A tuple of data task and an observable for the resulting array of Assets.
-
Fetch a single Asset from Contentful.
Declaration
Swift
@discardableResult public func fetchAsset(id: String, completion: @escaping ResultsHandler<Asset>) -> URLSessionDataTask?Parameters
idThe identifier of the Asset to be fetched.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a single Asset from Contentful.
Declaration
Swift
@discardableResult public func fetchAsset(id: String) -> Observable<Result<Asset>>Parameters
idThe identifier of the Asset to be fetched.
Return Value
A tuple of data task and a signal for the resulting Asset.
-
Fetch a collection of Assets from Contentful.
Declaration
Swift
@discardableResult public func fetchAssets(matching: [String: Any] = [:], completion: @escaping ResultsHandler<ArrayResponse<Asset>>) -> URLSessionDataTask?Parameters
matchingAn optional list of search parameters the Assets must match.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a collection of Assets from Contentful.
Declaration
Swift
@discardableResult public func fetchAssets(matching: [String: Any] = [:]) -> Observable<Result<ArrayResponse<Asset>>>Parameters
matchingOptional list of search parameters the Assets must match.
Return Value
A tuple of data task and a signal for the resulting array of Assets.
-
Fetch the underlying media file as
Data.Declaration
Swift
public func fetchData(for asset: Asset) -> Observable<Result<Data>>Return Value
Tuple of the data task and a signal for the
Dataresult. -
Fetch the underlying media file as
UIImage.Declaration
Swift
public func fetchImage(for asset: Asset) -> Observable<Result<UIImage>>Return Value
The signal for the
UIImageresult
-
Fetch a single Content Type from Contentful.
Declaration
Swift
@discardableResult public func fetchContentType(id: String, completion: @escaping ResultsHandler<ContentType>) -> URLSessionDataTask?Parameters
idThe identifier of the Content Type to be fetched.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a single Content Type from Contentful.
Declaration
Swift
@discardableResult public func fetchContentType(id: String) -> Observable<Result<ContentType>>Parameters
idThe identifier of the Content Type to be fetched.
Return Value
A tuple of data task and a signal for the resulting Content Type.
-
Fetch a collection of Content Types from Contentful.
Declaration
Swift
@discardableResult public func fetchContentTypes(matching: [String: Any] = [:], completion: @escaping ResultsHandler<ArrayResponse<ContentType>>) -> URLSessionDataTask?Parameters
matchingOptional list of search parameters the Content Types must match.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a collection of Content Types from Contentful.
Declaration
Swift
@discardableResult public func fetchContentTypes(matching: [String: Any] = [:]) -> Observable<Result<ArrayResponse<ContentType>>>Parameters
matchingOptional list of search parameters the Content Types must match.
Return Value
A tuple of data task and a signal for the resulting array of Content Types.
-
Fetch a collection of Entries from Contentful.
Declaration
Swift
@discardableResult public func fetchEntries(matching: [String: Any] = [:], completion: @escaping ResultsHandler<ArrayResponse<Entry>>) -> URLSessionDataTask?Parameters
matchingOptional list of search parameters the Entries must match.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests
-
Fetch a collection of Entries from Contentful.
Declaration
Swift
@discardableResult public func fetchEntries(matching: [String: Any] = [:]) -> Observable<Result<ArrayResponse<Entry>>>Parameters
matchingOptional list of search parameters the Entries must match.
Return Value
A tuple of data task and a signal for the resulting array of Entries.
-
Fetch a single Entry from Contentful.
Declaration
Swift
@discardableResult public func fetchEntry(id: String, completion: @escaping ResultsHandler<Entry>) -> URLSessionDataTask?Parameters
idThe identifier of the Entry to be fetched.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Fetch a single Entry from Contentful.
Declaration
Swift
@discardableResult public func fetchEntry(id: String) -> Observable<Result<Entry>>Parameters
idThe identifier of the Entry to be fetched.
Return Value
A tuple of data task and a signal for the resulting Entry.
-
Fetch the space this client is constrained to.
Declaration
Swift
@discardableResult public func fetchSpace(then completion: @escaping ResultsHandler<Space>) -> URLSessionDataTask?Parameters
completionA handler being called on completion of the request.
Return Value
The data task being used, which enables cancellation of requests, or
nilif the. Space was already cached locally -
Fetch the space this client is constrained to.
Declaration
Swift
@discardableResult public func fetchSpace() -> Observable<Result<Space>>Return Value
A tuple of data task and a signal for the resulting Space.
-
Perform an initial synchronization of the Space this client is constrained to.
Declaration
Swift
@discardableResult public func initialSync(matching: [String: Any] = [:], completion: @escaping ResultsHandler<SyncSpace>) -> URLSessionDataTask?Parameters
matchingAdditional options for the synchronization.
completionA handler being called on completion of the request.
Return Value
The data task being used, enables cancellation of requests.
-
Perform an initial synchronization of the Space this client is constrained to.
Declaration
Swift
@discardableResult public func initialSync(matching: [String: Any] = [:]) -> Observable<Result<SyncSpace>>Parameters
matchingAdditional options for the synchronization.
Return Value
A tuple of data task and a signal for the resulting SyncSpace.
View on GitHub
Client Class Reference