GoSquaredAPI 0.8.0

GoSquaredAPI 0.8.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2019
SPMSupports SPM

Maintained by Ed Wellbrook.



  • By
  • Ed Wellbrook

GoSquared Swift API

Build Status

The GoSquared Swift API library allows you to interact with the GoSquared 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.

Installation

CocoaPods is the recommended way to install this library:

# 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

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:

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)