Skip to content

Latest commit

 

History

History
325 lines (241 loc) · 10.7 KB

gift-cards.md

File metadata and controls

325 lines (241 loc) · 10.7 KB

Gift Cards

const giftCardsApi = client.giftCardsApi;

Class Name

GiftCardsApi

Methods

List Gift Cards

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>>

Parameters

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 200. 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.

Response Type

ListGiftCardsResponse

Example Usage

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;
  }
}

Create Gift Card

Creates a digital gift card or registers a physical (plastic) gift card. The resulting gift card has a PENDING state. To activate a gift card so that it can be redeemed for purchases, call CreateGiftCardActivity and create an ACTIVATE activity with the initial balance. Alternatively, you can use RefundPayment to refund a payment to the new gift card.

async createGiftCard(  body: CreateGiftCardRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<CreateGiftCardResponse>>

Parameters

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.

Response Type

CreateGiftCardResponse

Example Usage

const body: CreateGiftCardRequest = {
  idempotencyKey: 'NC9Tm69EjbjtConu',
  locationId: '81FN9BNFZTKS4',
  giftCard: {
    type: 'DIGITAL',
  },
};

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;
  }
}

Retrieve Gift Card From GAN

Retrieves a gift card using the gift card account number (GAN).

async retrieveGiftCardFromGAN(  body: RetrieveGiftCardFromGANRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveGiftCardFromGANResponse>>

Parameters

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.

Response Type

RetrieveGiftCardFromGANResponse

Example Usage

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;
  }
}

Retrieve Gift Card From Nonce

Retrieves a gift card using a secure payment token that represents the gift card.

async retrieveGiftCardFromNonce(  body: RetrieveGiftCardFromNonceRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveGiftCardFromNonceResponse>>

Parameters

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.

Response Type

RetrieveGiftCardFromNonceResponse

Example Usage

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;
  }
}

Link Customer to Gift Card

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>>

Parameters

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.

Response Type

LinkCustomerToGiftCardResponse

Example Usage

const giftCardId = 'gift_card_id8';

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;
  }
}

Unlink Customer From Gift Card

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>>

Parameters

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.

Response Type

UnlinkCustomerFromGiftCardResponse

Example Usage

const giftCardId = 'gift_card_id8';

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;
  }
}

Retrieve Gift Card

Retrieves a gift card using the gift card ID.

async retrieveGiftCard(  id: string,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveGiftCardResponse>>

Parameters

Parameter Type Tags Description
id string Template, Required The ID of the gift card to retrieve.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

RetrieveGiftCardResponse

Example Usage

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;
  }
}