Client

open class Client

Client object for performing requests against the Contentful API.

  • Fetch the space this client is constrained to.

    Declaration

    Swift

    @discardableResult public func fetchSpace(then completion: @escaping ResultsHandler<Space>) -> URLSessionDataTask?

    Parameters

    completion

    A handler being called on completion of the request.

    Return Value

    The data task being used, which enables cancellation of requests, or nil if 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.

  • 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

    query

    The Query object to match results againts.

    completion

    A 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

    query

    The 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 Assets from Contentful matching the specified query.

    Declaration

    Swift

    @discardableResult public func fetchAssets(with query: AssetQuery,
                                                   then completion: @escaping ResultsHandler<ArrayResponse<Asset>>) -> URLSessionDataTask?

    Parameters

    query

    The Query object to match results againts.

    completion

    A 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

    query

    The Query object to match results againts.

    Return Value

    A tuple of data task and an observable for the resulting array of Assets.

  • Fetch a collection of Assets from Contentful matching the specified query.

    Declaration

    Swift

    @discardableResult public func fetchMappedEntries(with query: Query) -> Observable<Result<MappedContent>>

    Parameters

    query

    The Query object to match results againts.

    Return Value

    An Observable forr the resulting MappedContent container.

  • Fetches all entries and includes matching the passed in Query. The completion handler returned will return a MappedContent object which contains an array of Assets and a dictionary of ContentTypeId’s to arrays of EntryModellable types of your own defining.

    Declaration

    Swift

    @discardableResult public func fetchMappedEntries(with query: Query,
                                                          then completion: @escaping ResultsHandler<MappedContent>) -> URLSessionDataTask?

    Parameters

    query

    The Query object to match results against.

    completion

    A handler being called on completion of the request containing a MappedContent instance.

    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, completion: @escaping ResultsHandler<Asset>) -> URLSessionDataTask?

    Parameters

    id

    The identifier of the Asset to be fetched.

    completion

    A 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

    id

    The 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

    matching

    An optional list of search parameters the Assets must match.

    completion

    A 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

    matching

    Optional 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, with imageOptions: [ImageOption] = []) -> Observable<Result<Data>>

    Parameters

    asset

    The Asset which contains the relevant media file.

    imageOptions

    An optional array of options for server side manipulations.

    Return Value

    Tuple of the data task and a signal for the Data result.

  • Fetch a single Content Type from Contentful.

    Declaration

    Swift

    @discardableResult public func fetchContentType(id: String,
                                                        completion: @escaping ResultsHandler<ContentType>) -> URLSessionDataTask?

    Parameters

    id

    The identifier of the Content Type to be fetched.

    completion

    A 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

    id

    The 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

    matching

    Optional list of search parameters the Content Types must match.

    completion

    A 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

    matching

    Optional 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

    matching

    Optional list of search parameters the Entries must match.

    completion

    A 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

    matching

    Optional 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

    id

    The identifier of the Entry to be fetched.

    completion

    A 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

    id

    The identifier of the Entry to be fetched.

    Return Value

    A tuple of data task and a signal for the resulting Entry.

  • 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

    matching

    Additional options for the synchronization.

    completion

    A 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

    matching

    Additional options for the synchronization.

    Return Value

    A tuple of data task and a signal for the resulting SyncSpace.

  • Perform a subsequent synchronization operation, updating the passed in SyncSpace with the latest content from Contentful.

    Calling this will mutate passed in SyncSpace and also return a reference to itself to the completion handler in order to allow chaining of operations.

    Declaration

    Swift

    @discardableResult public func nextSync(for syncSpace: SyncSpace,
                                                matching: [String: Any] = [:],
                                                completion: @escaping ResultsHandler<SyncSpace>) -> URLSessionDataTask?

    Parameters

    syncSpace

    the relevant SyncSpace to perform the subsequent sync on.

    matching

    Additional options for the synchronization

    completion

    A handler which will be called on completion of the operation

    Return Value

    The data task being used, enables cancellation of requests

  • Fetch the underlying media file as UIImage.

    Declaration

    Swift

    public func fetchImage(for asset: Asset, with imageOptions: [ImageOption] = []) -> Observable<Result<UIImage>>

    Return Value

    The signal for the UIImage result