Once installed as a package in your project, you can import the package into each file in your project that needs access to the Ctrl Hub API, using the standard Swift import statement:

import CtrlHub

You are now able to start calling the API with an access token.

We will add some documentation about the Access Tokens soon

Asking for Resources

The access pattern for calling resources is intended to be consistent. It follows the format CtrlHub.Resource.Method()

let _ = CtrlHub.Organisations.Get() { response in
    // handle the response
}

The response should be checked in your code, and we either mark it a success or a fail.

let _ = CtrlHub.Organisations.Get() { response in
    switch response {
        case .Success(let data):
            debugPrint(data) // data will be an array of organisations the user has access to
        case .Fail(let error):
            print("an error occurred:", error)
        }
    }
}