const devicesApi = client.devicesApi;
DevicesApi
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 contentType = null;
const bodyDeviceCode: DeviceCode = {
productType: null,
};
bodyDeviceCode.name = 'Counter 1';
bodyDeviceCode.locationId = 'B5E4484SHHNYH';
const body: CreateDeviceCodeRequest = {
idempotencyKey: '01bb00a6-0c86-4770-94ed-f5fca973cd56',
deviceCode: bodyDeviceCode,
};
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;
}
}