const merchantsApi = client.merchantsApi;
MerchantsApi
Provides details about the merchant associated with a given access token.
The access token used to connect your application to a Square seller is associated
with a single merchant. That means that ListMerchants
returns a list
with a single Merchant
object. You can specify your personal access token
to get your own merchant information or specify an OAuth token to get the
information for the merchant that granted your application access.
If you know the merchant ID, you can also use the RetrieveMerchant endpoint to retrieve the merchant information.
async listMerchants(
cursor?: number,
requestOptions?: RequestOptions
): Promise<ApiResponse<ListMerchantsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
number | undefined |
Query, Optional | The cursor generated by the previous response. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await merchantsApi.listMerchants();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves the Merchant
object for the given merchant_id
.
async retrieveMerchant(
merchantId: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<RetrieveMerchantResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
merchantId |
string |
Template, Required | The ID of the merchant to retrieve. If the string "me" is supplied as the ID, then retrieve the merchant that is currently accessible to this call. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const merchantId = 'merchant_id0';
try {
const { result, ...httpResponse } = await merchantsApi.retrieveMerchant(merchantId);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}