const devicesApi = client.devicesApi;
DevicesApi
List devices associated with the merchant. Currently, only Terminal API devices are supported.
async listDevices( cursor?: string,
sortOrder?: string,
limit?: number,
locationId?: string,
requestOptions?: RequestOptions): Promise<ApiResponse<ListDevicesResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
string | undefined |
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 | undefined |
Query, Optional | The order in which results are listed. - ASC - Oldest to newest.- DESC - Newest to oldest (default). |
limit |
number | undefined |
Query, Optional | The number of results to return in a single page. |
locationId |
string | undefined |
Query, Optional | If present, only returns devices at the target location. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await devicesApi.listDevices();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Lists all DeviceCodes associated with the merchant.
async listDeviceCodes( cursor?: string,
locationId?: string,
productType?: string,
status?: string,
requestOptions?: RequestOptions): Promise<ApiResponse<ListDeviceCodesResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
string | undefined |
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 | undefined |
Query, Optional | If specified, only returns DeviceCodes of the specified location. Returns DeviceCodes of all locations if empty. |
productType |
string | undefined |
Query, Optional | If specified, only returns DeviceCodes targeting the specified product type. Returns DeviceCodes of all product types if empty. |
status |
string | undefined |
Query, Optional | If specified, returns DeviceCodes with the specified statuses. Returns DeviceCodes of status PAIRED and UNPAIRED if empty. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await devicesApi.listDeviceCodes();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Creates a DeviceCode that can be used to login to a Square Terminal device to enter the connected terminal mode.
async createDeviceCode( body: CreateDeviceCodeRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<CreateDeviceCodeResponse>>
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. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const body: CreateDeviceCodeRequest = {
idempotencyKey: '01bb00a6-0c86-4770-94ed-f5fca973cd56',
deviceCode: {
productType: 'TERMINAL_API',
name: 'Counter 1',
locationId: 'B5E4484SHHNYH',
},
};
try {
const { result, ...httpResponse } = await devicesApi.createDeviceCode(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves DeviceCode with the associated ID.
async getDeviceCode( id: string,
requestOptions?: RequestOptions): Promise<ApiResponse<GetDeviceCodeResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | The unique identifier for the device code. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const id = 'id0';
try {
const { result, ...httpResponse } = await devicesApi.getDeviceCode(id);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves Device with the associated device_id
.
async getDevice( deviceId: string,
requestOptions?: RequestOptions): Promise<ApiResponse<GetDeviceResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
deviceId |
string |
Template, Required | The unique ID for the desired Device . |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const deviceId = 'device_id6';
try {
const { result, ...httpResponse } = await devicesApi.getDevice(deviceId);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}