DevicesApi devicesApi = client.getDevicesApi();
DevicesApi
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)
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. |
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;
});
Lists all DeviceCodes associated with the merchant.
CompletableFuture<ListDeviceCodesResponse> listDeviceCodesAsync(
final String cursor,
final String locationId,
final String productType,
final String status)
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. |
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;
});
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)
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. |
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;
});
Retrieves DeviceCode with the associated ID.
CompletableFuture<GetDeviceCodeResponse> getDeviceCodeAsync(
final String id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
String |
Template, Required | The unique identifier for the device code. |
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;
});
Retrieves Device with the associated device_id
.
CompletableFuture<GetDeviceResponse> getDeviceAsync(
final String deviceId)
Parameter | Type | Tags | Description |
---|---|---|---|
deviceId |
String |
Template, Required | The unique ID for the desired Device . |
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;
});