Skip to content

Latest commit

 

History

History
290 lines (199 loc) · 9.2 KB

gift-cards.md

File metadata and controls

290 lines (199 loc) · 9.2 KB

Gift Cards

gift_cards_api = client.gift_cards

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.

def list_gift_cards(self,
                   mtype=None,
                   state=None,
                   limit=None,
                   cursor=None,
                   customer_id=None)

Parameters

Parameter Type Tags Description
mtype str 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 str 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 int 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 str 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.
customer_id str Query, Optional If a customer ID is provided, the endpoint returns only the gift cards linked to the specified customer.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type List Gift Cards Response.

Example Usage

result = gift_cards_api.list_gift_cards()

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

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.

def create_gift_card(self,
                    body)

Parameters

Parameter Type Tags Description
body Create Gift Card Request Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Create Gift Card Response.

Example Usage

body = {
    'idempotency_key': 'NC9Tm69EjbjtConu',
    'location_id': '81FN9BNFZTKS4',
    'gift_card': {
        'type': 'DIGITAL'
    }
}

result = gift_cards_api.create_gift_card(body)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Retrieve Gift Card From GAN

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

def retrieve_gift_card_from_gan(self,
                               body)

Parameters

Parameter Type Tags Description
body Retrieve Gift Card From GAN Request Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Retrieve Gift Card From GAN Response.

Example Usage

body = {
    'gan': '7783320001001635'
}

result = gift_cards_api.retrieve_gift_card_from_gan(body)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Retrieve Gift Card From Nonce

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

def retrieve_gift_card_from_nonce(self,
                                 body)

Parameters

Parameter Type Tags Description
body Retrieve Gift Card From Nonce Request Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Retrieve Gift Card From Nonce Response.

Example Usage

body = {
    'nonce': 'cnon:7783322135245171'
}

result = gift_cards_api.retrieve_gift_card_from_nonce(body)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Link Customer to Gift Card

Links a customer to a gift card, which is also referred to as adding a card on file.

def link_customer_to_gift_card(self,
                              gift_card_id,
                              body)

Parameters

Parameter Type Tags Description
gift_card_id str Template, Required The ID of the gift card to be linked.
body Link Customer to Gift Card Request Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Link Customer to Gift Card Response.

Example Usage

gift_card_id = 'gift_card_id8'

body = {
    'customer_id': 'GKY0FZ3V717AH8Q2D821PNT2ZW'
}

result = gift_cards_api.link_customer_to_gift_card(
    gift_card_id,
    body
)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Unlink Customer From Gift Card

Unlinks a customer from a gift card, which is also referred to as removing a card on file.

def unlink_customer_from_gift_card(self,
                                  gift_card_id,
                                  body)

Parameters

Parameter Type Tags Description
gift_card_id str Template, Required The ID of the gift card to be unlinked.
body Unlink Customer From Gift Card Request Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Unlink Customer From Gift Card Response.

Example Usage

gift_card_id = 'gift_card_id8'

body = {
    'customer_id': 'GKY0FZ3V717AH8Q2D821PNT2ZW'
}

result = gift_cards_api.unlink_customer_from_gift_card(
    gift_card_id,
    body
)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Retrieve Gift Card

Retrieves a gift card using the gift card ID.

def retrieve_gift_card(self,
                      id)

Parameters

Parameter Type Tags Description
id str Template, Required The ID of the gift card to retrieve.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Retrieve Gift Card Response.

Example Usage

id = 'id0'

result = gift_cards_api.retrieve_gift_card(id)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)