An client for the SchedJoules API in Swift
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ApiClient
.gitattributes
.gitignore
LICENSE
README.md
SchedJoulesApiClient.podspec

README.md

Swift API Client

This repository contains the API client written in Swift, which is also used by our Swift SDK.

Usage

Currently, we support queries to retrieve a single page by an identifer, a localized home page and to search pages.

Making a request

To send a request (query in our case), first initialize an instance of SchedJoulesApiClient with your API access token.

let apiClient = SchedJoulesApiClient(accessToken: "YOUR_API_ACCESS_TOKEN")

After you have an instance, use the execute function to execute a query.

apiClient.execute(query: HomePageQuery(), completion: { result in
            switch result {
            case let .success(page):
                // Do something with the retreived page object
            case let .failure(apiError):
                print(apiError)
            }
        })

The execute function uses a completion handler which returns a Result type. Use a switch statement to deconstruct the result.

Models

The Api Client also includes model classes. These all conform to the Decodable protocol and can be decoded from JSON data.