Using the Clover iOS SDK

Introduction

The iOS SDK is available on GitHub.

 

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

To return an access token the first time an individual uses the app, implement the following code:

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

 

How to use the Clover iOS SDK

The following code demonstrates how to 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 })

 

The more detailed example below shows how to get a list of employees who have been assigned admin roles. The list is sorted by name, and includes expanded shifts:

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 accessToken and merchantId, you can call endpoint methods on the session object, using or omitting parameters to retrieve the data you need.

Currently, all v3 GET endpoints are supported in the alpha version. Please refer to the README file in the GitHub repository for more information.