Skip to content

Latest commit

 

History

History
212 lines (153 loc) · 6.2 KB

devices.md

File metadata and controls

212 lines (153 loc) · 6.2 KB

Devices

DevicesApi devicesApi = client.getDevicesApi();

Class Name

DevicesApi

Methods

List Devices

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

CompletableFuture<ListDevicesResponse> listDevicesAsync(
    final String cursor,
    final String sortOrder,
    final Integer limit,
    final String locationId)

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 Integer 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

ListDevicesResponse

Example Usage

devicesApi.listDevicesAsync(null, null, null, null).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

List Device Codes

Lists all DeviceCodes associated with the merchant.

CompletableFuture<ListDeviceCodesResponse> listDeviceCodesAsync(
    final String cursor,
    final String locationId,
    final String productType,
    final String status)

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

ListDeviceCodesResponse

Example Usage

devicesApi.listDeviceCodesAsync(null, null, null, null).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Create Device Code

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

CompletableFuture<CreateDeviceCodeResponse> createDeviceCodeAsync(
    final 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

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();

devicesApi.createDeviceCodeAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Get Device Code

Retrieves DeviceCode with the associated ID.

CompletableFuture<GetDeviceCodeResponse> getDeviceCodeAsync(
    final String id)

Parameters

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

Response Type

GetDeviceCodeResponse

Example Usage

String id = "id0";

devicesApi.getDeviceCodeAsync(id).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Get Device

Retrieves Device with the associated device_id.

CompletableFuture<GetDeviceResponse> getDeviceAsync(
    final String deviceId)

Parameters

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

Response Type

GetDeviceResponse

Example Usage

String deviceId = "device_id6";

devicesApi.getDeviceAsync(deviceId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});