const giftCardsApi = client.giftCardsApi;
GiftCardsApi
- List Gift Cards
- Create Gift Card
- Retrieve Gift Card From GAN
- Retrieve Gift Card From Nonce
- Link Customer to Gift Card
- Unlink Customer From Gift Card
- Retrieve Gift Card
Lists all gift cards. You can specify optional filters to retrieve
a subset of the gift cards. Results are sorted by created_at
in ascending order.
async listGiftCards(
type?: string,
state?: string,
limit?: number,
cursor?: string,
customerId?: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<ListGiftCardsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
type |
string | undefined |
Query, Optional | If a type is provided, the endpoint returns gift cards of the specified type. Otherwise, the endpoint returns gift cards of all types. |
state |
string | undefined |
Query, Optional | If a state is provided, the endpoint returns the gift cards in the specified state. Otherwise, the endpoint returns the gift cards of all states. |
limit |
number | undefined |
Query, Optional | If a limit is provided, the endpoint returns only the specified number of results per page. The maximum value is 50. The default value is 30. For more information, see Pagination. |
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. If a cursor is not provided, the endpoint returns the first page of the results. For more information, see Pagination. |
customerId |
string | undefined |
Query, Optional | If a customer ID is provided, the endpoint returns only the gift cards linked to the specified customer. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await giftCardsApi.listGiftCards();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Creates a digital gift card or registers a physical (plastic) gift card. After the gift card is created, you must call CreateGiftCardActivity to activate the card with an initial balance before it can be used for payment.
async createGiftCard(
body: CreateGiftCardRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<CreateGiftCardResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateGiftCardRequest |
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 bodyGiftCard: GiftCard = {
type: 'DIGITAL',
};
const body: CreateGiftCardRequest = {
idempotencyKey: 'NC9Tm69EjbjtConu',
locationId: '81FN9BNFZTKS4',
giftCard: bodyGiftCard,
};
try {
const { result, ...httpResponse } = await giftCardsApi.createGiftCard(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves a gift card using the gift card account number (GAN).
async retrieveGiftCardFromGAN(
body: RetrieveGiftCardFromGANRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<RetrieveGiftCardFromGANResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
RetrieveGiftCardFromGANRequest |
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. |
RetrieveGiftCardFromGANResponse
const contentType = null;
const body: RetrieveGiftCardFromGANRequest = {
gan: '7783320001001635',
};
try {
const { result, ...httpResponse } = await giftCardsApi.retrieveGiftCardFromGAN(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves a gift card using a secure payment token that represents the gift card.
async retrieveGiftCardFromNonce(
body: RetrieveGiftCardFromNonceRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<RetrieveGiftCardFromNonceResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
RetrieveGiftCardFromNonceRequest |
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. |
RetrieveGiftCardFromNonceResponse
const contentType = null;
const body: RetrieveGiftCardFromNonceRequest = {
nonce: 'cnon:7783322135245171',
};
try {
const { result, ...httpResponse } = await giftCardsApi.retrieveGiftCardFromNonce(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Links a customer to a gift card, which is also referred to as adding a card on file.
async linkCustomerToGiftCard(
giftCardId: string,
body: LinkCustomerToGiftCardRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<LinkCustomerToGiftCardResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
giftCardId |
string |
Template, Required | The ID of the gift card to be linked. |
body |
LinkCustomerToGiftCardRequest |
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. |
LinkCustomerToGiftCardResponse
const giftCardId = 'gift_card_id8';
const contentType = null;
const body: LinkCustomerToGiftCardRequest = {
customerId: 'GKY0FZ3V717AH8Q2D821PNT2ZW',
};
try {
const { result, ...httpResponse } = await giftCardsApi.linkCustomerToGiftCard(giftCardId, body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Unlinks a customer from a gift card, which is also referred to as removing a card on file.
async unlinkCustomerFromGiftCard(
giftCardId: string,
body: UnlinkCustomerFromGiftCardRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<UnlinkCustomerFromGiftCardResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
giftCardId |
string |
Template, Required | The ID of the gift card to be unlinked. |
body |
UnlinkCustomerFromGiftCardRequest |
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. |
UnlinkCustomerFromGiftCardResponse
const giftCardId = 'gift_card_id8';
const contentType = null;
const body: UnlinkCustomerFromGiftCardRequest = {
customerId: 'GKY0FZ3V717AH8Q2D821PNT2ZW',
};
try {
const { result, ...httpResponse } = await giftCardsApi.unlinkCustomerFromGiftCard(giftCardId, body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves a gift card using the gift card ID.
async retrieveGiftCard(
id: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<RetrieveGiftCardResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | The ID of the gift card to retrieve. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const id = 'id0';
try {
const { result, ...httpResponse } = await giftCardsApi.retrieveGiftCard(id);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}