Using the Clover iOS SDK

Introduction

You can find the repo on GitHub here.

 

Installing the Clover iOS SDK

You can use CocoaPods to install the SDK. Add pod 'CloverSDK' into your Podfile.

 

Get an Access Token for your app

Getting an access token for the first time a user is using the app:

CLVSession.authenticateUser(forClientId: "####", domain: .US, activeView: self,
  success: { session in
  // Persist the values in Keychain to use later
  }, failure: { err in
})

 

How to use Clover iOS SDK

Here’s a basic example of how you can get an order for a merchant, with line-items expanded:

CLVSession(accessToken: "####", domain: .US, merchantId: "####")
  .getMerchantOrder(withId: "####", expands: ["lineItems"],
  success: { order in },
  failure: { error in })

 

Here’s a more detailed example of how you can get employees with an admin role, sorted by name, with shifts expanded:

let session = CLVSession(accessToken: "####", domain: .US, merchantId: "####")
session.getMerchantEmployees(
  filters: ["role": "ADMIN"],
  expands: ["shifts"],
    sorts: ["name": .ASC],
   params: [:],
    limit: 50,
   offset: 0,
  success: { employees in
    for employee in employees {
       print(employee.name!)
    }
  },
  failure: { error in
    switch error {
    case .UnacceptableStatusCode(let statusCode, let serverMessage):
      print("(statusCode) - (serverMessage)")
    case .Error(let error): print(error)
    case .UnknownError: print("Unknown error!")
  }
})

 

Once you initialize a session object with access code and merchant id, you can call endpoint methods on the session object. Parameters can be used or omitted to get back the data you need.

Currently, all v3 GET endpoints are supported in the alpha version. Please refer to the readme file on the repo for more details.