devices_api = client.devices
DevicesApi
Lists all DeviceCodes associated with the merchant.
def list_device_codes(self,
cursor=None,
location_id=None,
product_type=None,
status=None)
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 |
str (Product Type) |
Query, Optional | If specified, only returns DeviceCodes targeting the specified product type. Returns DeviceCodes of all product types if empty. |
status |
str (Device Code Status) |
Query, Optional | If specified, returns DeviceCodes with the specified statuses. Returns DeviceCodes of status PAIRED and UNPAIRED if empty. |
cursor = 'cursor6'
location_id = 'location_id4'
product_type = 'TERMINAL_API'
status = 'UNKNOWN'
result = devices_api.list_device_codes(cursor, location_id, product_type, status)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Creates a DeviceCode that can be used to login to a Square Terminal device to enter the connected terminal mode.
def create_device_code(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Device Code Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
body = {}
body['idempotency_key'] = '01bb00a6-0c86-4770-94ed-f5fca973cd56'
body['device_code'] = {}
body['device_code']['id'] = 'id0'
body['device_code']['name'] = 'Counter 1'
body['device_code']['code'] = 'code8'
body['device_code']['device_id'] = 'device_id6'
body['device_code']['product_type'] = 'TERMINAL_API'
body['device_code']['location_id'] = 'B5E4484SHHNYH'
result = devices_api.create_device_code(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Retrieves DeviceCode with the associated ID.
def get_device_code(self,
id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | The unique identifier for the device code. |
id = 'id0'
result = devices_api.get_device_code(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)