An open API service indexing awesome lists of open source software.

https://github.com/ctrl-hub/sdk.swift

An SDK for interacting with the Ctrl Hub API in Swift
https://github.com/ctrl-hub/sdk.swift

sdk sdk-ios swift

Last synced: 2 months ago
JSON representation

An SDK for interacting with the Ctrl Hub API in Swift

Awesome Lists containing this project

README

        

# CtrlHub

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fctrl-hub%2Fsdk.swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/ctrl-hub/sdk.swift)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fctrl-hub%2Fsdk.swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/ctrl-hub/sdk.swift)

This swift package is an SDK for the [Ctrl Hub API](https://docs.ctrl-hub.com/api-reference).

## Installation

Add the package with your package manager using `https://github.com/ctrl-hub/sdk.swift`

Then import the package into your bundle:

```swift
import CtrlHub
```

## Getting Started

The SDK uses a `.plist` configuration file called `CtrlHubConfig.plist` to collect all of the variables required to connect to the platform which you should add to to the root of your own project when integrating the SDK.

```xml

authDomain
https://auth.ctrl-hub.com
apiDomain
https://api.ctrl-hub.com

```

To use the SDK, you need to import the package before calling any methods:

```swift
import CtrlHub

// Read the configuration from the CtrlHubConfig.plist in your app bundle:
if let configuration = CtrlHub.Config() {
CtrlHub.config = configuration
} else {
// there are errors in the config file
}

// Make requests to Ctrl Hub via the SDK:
do {
let orgs = try await CtrlHub.Organisations.shared.Get()
} catch let error as CtrlHub.APIError {
// handle the error
}
```