Skip to content

Files

Latest commit

 

History

History
124 lines (83 loc) · 3.25 KB

devices.md

File metadata and controls

124 lines (83 loc) · 3.25 KB

Devices

devices_api = client.devices

Class Name

DevicesApi

Methods

List Device Codes

Lists all DeviceCodes associated with the merchant.

def list_device_codes(cursor: nil,
                      location_id: nil,
                      product_type: nil,
                      status: nil)

Parameters

Parameter Type Tags Description
cursor String Query, Optional A pagination cursor returned by a previous call to this endpoint.
Provide this to retrieve the next set of results for your original query.

See Paginating results for more information.
location_id String Query, Optional If specified, only returns DeviceCodes of the specified location.
Returns DeviceCodes of all locations if empty.
product_type String (Product Type) Query, Optional If specified, only returns DeviceCodes targeting the specified product type.
Returns DeviceCodes of all product types if empty.
status String (Device Code Status) Query, Optional If specified, returns DeviceCodes with the specified statuses.
Returns DeviceCodes of status PAIRED and UNPAIRED if empty.

Response Type

List Device Codes Response Hash

Example Usage

result = devices_api.list_device_codes()

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Create Device Code

Creates a DeviceCode that can be used to login to a Square Terminal device to enter the connected terminal mode.

def create_device_code(body:)

Parameters

Parameter Type Tags Description
body Create Device Code Request Hash Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

Create Device Code Response Hash

Example Usage

body = {}
body[:idempotency_key] = '01bb00a6-0c86-4770-94ed-f5fca973cd56'
body[:device_code] = {}
body[:device_code][:name] = 'Counter 1'
body[:device_code][:location_id] = 'B5E4484SHHNYH'

result = devices_api.create_device_code(body: body)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end

Get Device Code

Retrieves DeviceCode with the associated ID.

def get_device_code(id:)

Parameters

Parameter Type Tags Description
id String Template, Required The unique identifier for the device code.

Response Type

Get Device Code Response Hash

Example Usage

id = 'id0'

result = devices_api.get_device_code(id: id)

if result.success?
  puts result.data
elsif result.error?
  warn result.errors
end