Skip to content

Latest commit

 

History

History
118 lines (91 loc) · 5.25 KB

gift-card-activities.md

File metadata and controls

118 lines (91 loc) · 5.25 KB

Gift Card Activities

const giftCardActivitiesApi = client.giftCardActivitiesApi;

Class Name

GiftCardActivitiesApi

Methods

List Gift Card Activities

Lists gift card activities. By default, you get gift card activities for all gift cards in the seller's account. You can optionally specify query parameters to filter the list. For example, you can get a list of gift card activities for a gift card, for all gift cards in a specific region, or for activities within a time window.

async listGiftCardActivities(  giftCardId?: string,
  type?: string,
  locationId?: string,
  beginTime?: string,
  endTime?: string,
  limit?: number,
  cursor?: string,
  sortOrder?: string,
requestOptions?: RequestOptions): Promise<ApiResponse<ListGiftCardActivitiesResponse>>

Parameters

Parameter Type Tags Description
giftCardId string | undefined Query, Optional If a gift card ID is provided, the endpoint returns activities related
to the specified gift card. Otherwise, the endpoint returns all gift card activities for
the seller.
type string | undefined Query, Optional If a type is provided, the endpoint returns gift card activities of the specified type.
Otherwise, the endpoint returns all types of gift card activities.
locationId string | undefined Query, Optional If a location ID is provided, the endpoint returns gift card activities for the specified location.
Otherwise, the endpoint returns gift card activities for all locations.
beginTime string | undefined Query, Optional The timestamp for the beginning of the reporting period, in RFC 3339 format.
This start time is inclusive. The default value is the current time minus one year.
endTime string | undefined Query, Optional The timestamp for the end of the reporting period, in RFC 3339 format.
This end time is inclusive. The default value is the current time.
limit number | undefined Query, Optional If a limit is provided, the endpoint returns the specified number
of results (or fewer) per page. The maximum value is 100. The default value is 50.
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.
sortOrder string | undefined Query, Optional The order in which the endpoint returns the activities, based on created_at.

- ASC - Oldest to newest.
- DESC - Newest to oldest (default).
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

ListGiftCardActivitiesResponse

Example Usage

try {
  const { result, ...httpResponse } = await giftCardActivitiesApi.listGiftCardActivities();
  // 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 Activity

Creates a gift card activity to manage the balance or state of a gift card. For example, create an ACTIVATE activity to activate a gift card with an initial balance before first use.

async createGiftCardActivity(  body: CreateGiftCardActivityRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<CreateGiftCardActivityResponse>>

Parameters

Parameter Type Tags Description
body CreateGiftCardActivityRequest 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

CreateGiftCardActivityResponse

Example Usage

const body: CreateGiftCardActivityRequest = {
  idempotencyKey: 'U16kfr-kA70er-q4Rsym-7U7NnY',
  giftCardActivity: {
    type: 'ACTIVATE',
    locationId: '81FN9BNFZTKS4',
    giftCardId: 'gftc:6d55a72470d940c6ba09c0ab8ad08d20',
    activateActivityDetails: {
      orderId: 'jJNGHm4gLI6XkFbwtiSLqK72KkAZY',
      lineItemUid: 'eIWl7X0nMuO9Ewbh0ChIx',
    },
  },
};

try {
  const { result, ...httpResponse } = await giftCardActivitiesApi.createGiftCardActivity(body);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}