GoSquaredAPI 0.8.0

GoSquaredAPI 0.8.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最新发布2019年2月
SPM支持 SPM

Ed Wellbrook 维护。



  • 作者
  • Ed Wellbrook

GoSquared Swift API

Build Status

GoSquared Swift API 库允许您与 GoSquared API 交互。它是编写来使构建展示 GoSquared 数据的应用程序更容易的。

它是用 Swift 3 编写的,并支持 Swift Package Manager

安装

CocoaPods 是推荐安装此库的方式

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

注意:虽然我推荐 CocoaPods,但您也可以手动安装此库,使用 git 子模块、Swift Package Manager 或 Carthage。

示例用法

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

该 API 将每个 GoSquared 产品分解为它自己的命名空间(例如,"now","trends","people")。

每个命名空间都有多个函数,这些函数返回一个 URLRequest。这个 URLRequest 可以通过提供的 GoSquaredAPI.performRequest 或您自己的网络系统执行。

请求构建和执行是解耦的,以让您完全控制网络。

账户

  • 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()

聊天

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

电子商务

  • 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])

当前

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

人群

  • devices(limit: Int, offset: Int)
  • device(deviceId: String)
  • eventTypes()
  • search(_ 查询: String, 参数: [String: String])
  • details(人员ID: String)
  • devices(人员ID: String, 限制: Int, 偏移: Int)
  • feed(人员ID: String, 参数: [String: String])
  • smartGroups()

趋势

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

组合函数

“现在”和“趋势”命名空间提供将多个同一命名空间调用组合成一个请求的能力。以下是一个示例:

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
}

授权

MIT 许可证 (MIT)