Latest 0.7.2
Homepage https://github.com/schedjoules/swift-api-client
License MIT
Platforms ios 11.0, requires ARC
Dependencies Alamofire, Result
Frameworks UIKit
Authors

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.

Latest podspec

{
    "name": "SchedJoulesApiClient",
    "platforms": {
        "ios": "11.0"
    },
    "summary": "The ApiClient for the SchedJoules API, written in Swift.",
    "requires_arc": true,
    "version": "0.7.2",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Schedjoules": "[email protected]"
    },
    "homepage": "https://github.com/schedjoules/swift-api-client",
    "source": {
        "git": "https://github.com/schedjoules/swift-api-client.git",
        "tag": "0.7.2"
    },
    "frameworks": "UIKit",
    "dependencies": {
        "Alamofire": [
            "~> 4.5"
        ],
        "Result": [
            "~> 3.0.0"
        ]
    },
    "source_files": "ApiClient/Source/**/*.{swift}",
    "swift_version": "4.0"
}

Pin It on Pinterest

Share This