Skip to content

Latest commit

 

History

History
130 lines (94 loc) · 3.6 KB

devices.md

File metadata and controls

130 lines (94 loc) · 3.6 KB

Devices

DevicesApi devicesApi = client.getDevicesApi();

Class Name

DevicesApi

Methods

List Device Codes

Lists all DeviceCodes associated with the merchant.

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

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.

Response Type

ListDeviceCodesResponse

Example Usage

String cursor = "cursor6";
String locationId = "location_id4";
String productType = "TERMINAL_API";

devicesApi.listDeviceCodesAsync(cursor, locationId, productType).thenAccept(result -> {
    // TODO success callback handler
}).exceptionally(exception -> {
    // TODO failure callback handler
    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

DeviceCode bodyDeviceCode = new DeviceCode.Builder(
        "TERMINAL_API")
    .id("id0")
    .name("Counter 1")
    .code("code8")
    .deviceId("device_id6")
    .locationId("B5E4484SHHNYH")
    .build();
CreateDeviceCodeRequest body = new CreateDeviceCodeRequest.Builder(
        "01bb00a6-0c86-4770-94ed-f5fca973cd56",
        bodyDeviceCode)
    .build();

devicesApi.createDeviceCodeAsync(body).thenAccept(result -> {
    // TODO success callback handler
}).exceptionally(exception -> {
    // TODO failure callback handler
    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
}).exceptionally(exception -> {
    // TODO failure callback handler
    return null;
});