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

https://github.com/edwellbrook/gosquared-swift

Interact with the GoSquared API in Swift
https://github.com/edwellbrook/gosquared-swift

api client gosquared ios macos osx swift wrapper

Last synced: 3 months ago
JSON representation

Interact with the GoSquared API in Swift

Awesome Lists containing this project

README

          

# GoSquared Swift API

[![Build Status](https://travis-ci.org/edwellbrook/gosquared-swift.svg?branch=master)](https://travis-ci.org/edwellbrook/gosquared-swift)

The GoSquared Swift API library allows you to interact with the [GoSquared API](https://www.gosquared.com/docs/api/). It was written to make building apps to present the GoSquared data easier.

It is written in Swift 3 and has support for the [Swift Package Manager](https://github.com/apple/swift-package-manager).

## Installation

[CocoaPods](https://cocoapods.org) is the recommended way to install this library:

```ruby
# In your Podfile add the following, then
# save and run `pod install`:
pod 'GoSquaredAPI'
```

> **Note:** Although I recommend CocoaPods, you can install this library manually, with git submodules, the Swift Package Manager or Carthage.

## Example Usage

```swift
import GoSquaredAPI

// Configure client
let gosquared = GoSquared(apiKey: "API_KEY", project: "PROJECT_TOKEN")

// Build request
let request = gosquared.now.concurrents()

// Execute request
GoSquaredAPI.performRequest(request) { response, error in
// do something with response/error
}
```

## API

The API breaks down each GoSquared product into its own namespace (e.g. "now", "trends", "people").

Each namespace then has multiple functions, which return a `URLRequest`. This `URLRequest` can then be executed with the provided `GoSquaredAPI.performRequest`, or your own networking system.

The request building and execution are decoupled to give you full control over your networking.

### Account

- `blockedItems()`
- `isBotBlockingEnabled()`
- `setBotBlockingEnabled(enabled: Bool)`
- `blockedIPs()`
- `blockIPs(ipAddresses: [String])`
- `unblockIPs(ipAddresses: [String])`
- `blockedVisitors()`
- `blockVisitors(visitorIds: [String])`
- `unblockVisitors(visitorIds: [String])`
- `reportPreferences()`
- `sharedUsers()`
- `projects()`
- `taggedVisitors()`
- `webhooks()`
- `addWebhook(_ webhookUrl: String, name: String)`
- `webhookTriggers(webhookId: Int)`
- `addWebhookTrigger(webhookId: Int, trigger: String, value: AnyObject)`
- `removeWebhookTrigger(_ webhookId: Int, triggerId: Int)`
- `me()`

### Chat

- `chats()`
- `messages(personId: String, limit: Int, offset: Int)`
- `stream()`

### Ecommerce

- `aggregate(parameters: [String: String])`
- `browsers(parameters: [String: String])`
- `categories(parameters: [String: String])`
- `countries(parameters: [String: String])`
- `languages(parameters: [String: String])`
- `os(parameters: [String: String])`
- `products(parameters: [String: String])`
- `sources(parameters: [String: String])`
- `transactions(parameters: [String: String])`

### Now

- `browsers()`
- `campaigns()`
- `concurrents()`
- `engagement()`
- `geo()`
- `overview()`
- `pages()`
- `sources()`
- `timeSeries()`
- `visitors()`

### People

- `devices(limit: Int, offset: Int)`
- `device(deviceId: String)`
- `eventTypes()`
- `search(_ query: String, parameters: [String: String])`
- `details(personId: String)`
- `devices(personId: String, limit: Int, offset: Int)`
- `feed(personId: String, parameters: [String: String])`
- `smartGroups()`

### Trends

- `aggregate(parameters: [String: String])`
- `browsers(parameters: [String: String])`
- `categories(parameters: [String: String])`
- `countries(parameters: [String: String])`
- `events(parameters: [String: String])`
- `languages(parameters: [String: String])`
- `organisations(parameters: [String: String])`
- `os(parameters: [String: String])`
- `pages(parameters: [String: String])`
- `basePaths(parameters: [String: String])`
- `products(parameters: [String: String])`
- `screenDimensions(parameters: [String: String])`
- `sources(parameters: [String: String])`
- `transactions(parameters: [String: String])`

### Combining Functions

The **Now** and **Trends** namespaces offer the ability to group multiple calls to the same namespace into one request. An example of this can be seen below:

```swift
import GoSquaredAPI

// Configure client
let gosquared = GoSquared(apiKey: "API_KEY", project: "PROJECT_TOKEN")

// Build request with endpoints and parameters
let request = gosquared.now.combiningFunction(functions: [
GoSquaredAPI.CombiningFunction(endpoint: "timeSeries", parameters: [ "limit": "0" ]),
GoSquaredAPI.CombiningFunction(endpoint: "concurrents", parameters: [ "limit": "0" ])
])

// Execute request
GoSquaredAPI.performRequest(request) { response, error in
// do something with response/error
}
```

## License

The MIT License (MIT)