Skip to content

Latest commit

 

History

History
215 lines (158 loc) · 5.54 KB

devices.md

File metadata and controls

215 lines (158 loc) · 5.54 KB

Devices

IDevicesApi devicesApi = client.DevicesApi;

Class Name

DevicesApi

Methods

List Devices

List devices associated with the merchant. Currently, only Terminal API devices are supported.

ListDevicesAsync(
    string cursor = null,
    string sortOrder = null,
    int? limit = null,
    string locationId = null)

Parameters

Parameter Type Tags Description
cursor string Query, Optional A pagination cursor returned by a previous call to this endpoint.
Provide this cursor to retrieve the next set of results for the original query.
See Pagination for more information.
sortOrder string Query, Optional The order in which results are listed.

- ASC - Oldest to newest.
- DESC - Newest to oldest (default).
limit int? Query, Optional The number of results to return in a single page.
locationId string Query, Optional If present, only returns devices at the target location.

Response Type

Task<Models.ListDevicesResponse>

Example Usage

try
{
    ListDevicesResponse result = await devicesApi.ListDevicesAsync();
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

List Device Codes

Lists all DeviceCodes associated with the merchant.

ListDeviceCodesAsync(
    string cursor = null,
    string locationId = null,
    string productType = null,
    string status = null)

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.
locationId string Query, Optional If specified, only returns DeviceCodes of the specified location.
Returns DeviceCodes of all locations if empty.
productType string Query, Optional If specified, only returns DeviceCodes targeting the specified product type.
Returns DeviceCodes of all product types if empty.
status string Query, Optional If specified, returns DeviceCodes with the specified statuses.
Returns DeviceCodes of status PAIRED and UNPAIRED if empty.

Response Type

Task<Models.ListDeviceCodesResponse>

Example Usage

try
{
    ListDeviceCodesResponse result = await devicesApi.ListDeviceCodesAsync();
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Create Device Code

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

CreateDeviceCodeAsync(
    Models.CreateDeviceCodeRequest body)

Parameters

Parameter Type Tags Description
body CreateDeviceCodeRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

Task<Models.CreateDeviceCodeResponse>

Example Usage

CreateDeviceCodeRequest body = new CreateDeviceCodeRequest.Builder(
    "01bb00a6-0c86-4770-94ed-f5fca973cd56",
    new DeviceCode.Builder(
        "TERMINAL_API"
    )
    .Name("Counter 1")
    .LocationId("B5E4484SHHNYH")
    .Build()
)
.Build();

try
{
    CreateDeviceCodeResponse result = await devicesApi.CreateDeviceCodeAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Get Device Code

Retrieves DeviceCode with the associated ID.

GetDeviceCodeAsync(
    string id)

Parameters

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

Response Type

Task<Models.GetDeviceCodeResponse>

Example Usage

string id = "id0";
try
{
    GetDeviceCodeResponse result = await devicesApi.GetDeviceCodeAsync(id);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Get Device

Retrieves Device with the associated device_id.

GetDeviceAsync(
    string deviceId)

Parameters

Parameter Type Tags Description
deviceId string Template, Required The unique ID for the desired Device.

Response Type

Task<Models.GetDeviceResponse>

Example Usage

string deviceId = "device_id6";
try
{
    GetDeviceResponse result = await devicesApi.GetDeviceAsync(deviceId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}