Skip to content

Gift card

GiftCard

Bases: BaseAPIWrapper

Source code in pykuda2/wrappers/sync_wrappers/gift_card.py
class GiftCard(BaseAPIWrapper):
    def get_gift_cards(self, request_reference: Optional[str] = None) -> APIResponse:
        """Retrieves a curated list of gift cards supported by Kuda.

        Args:
            request_reference: a unique identifier for this api call.
                it is automatically generated if not provided.

        Returns:
            An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
                of calling this function.

        Raises:
            ConnectionException: when the request times out or in the absence of an internet connection.
        """
        return self._api_call(
            service_type=ServiceType.GET_GIFT_CARD, request_reference=request_reference
        )

    def purchase_gift_card(
        self,
        amount: Union[int, float],
        customer_name: str,
        customer_mobile: str,
        customer_email: str,
        biller_identifier: str,
        note: Optional[str] = None,
        request_reference: Optional[str] = None,
    ) -> APIResponse:
        """Buy gift cards from the admin account

        Args:
            amount: The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved.
                a `Decimal` would have been the preferred type compared to `Union[int, float]` that was used.
                it is advisable that static values are passed for this parameter. see
                https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
            customer_name: Name of the customer receiving the gift card.
            customer_mobile: Mobile number of customer.
            customer_email: The email address of customer.
            biller_identifier: The Biller ID or identifier. You can find it in the `APIResponse` of
                `self.gift_cards`.
            note: An optional gift card note.
            request_reference: a unique identifier for this api call.
                it is automatically generated if not provided.

        Returns:
            An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
                of calling this function.

        Raises:
            ConnectionException: when the request times out or in the absence of an internet connection.
        """
        data = {
            "amount": amount,
            "requestingCustomerName": customer_name,
            "requestingCustomerMobile": customer_mobile,
            "requestingCustomerEmail": customer_email,
            "billerIdentifier": biller_identifier,
            "note": note,
        }
        return self._api_call(
            service_type=ServiceType.ADMIN_BUY_GIFT_CARD,
            data=data,
            request_reference=request_reference,
        )

    def purchase_gift_card_from_virtual_account(
        self,
        tracking_reference: str,
        amount: Union[int, float],
        customer_name: str,
        customer_mobile: str,
        customer_email: str,
        biller_identifier: str,
        note: Optional[str] = None,
        request_reference: Optional[str] = None,
    ) -> APIResponse:
        """Buy gift cards from the virtual account.

        Args:
            tracking_reference: The unique identifier of the virtual account.
            amount: The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved.
                a `Decimal` would have been the preferred type compared to `Union[int, float]` that was used.
                it is advisable that static values are passed for this parameter. see
                https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
            customer_name: Name of the customer receiving the gift card.
            customer_mobile: Mobile number of customer.
            customer_email: The email address of customer.
            biller_identifier: The Biller ID or identifier. You can find it in the `APIResponse` of
                `self.gift_cards`.
            note: An optional gift card note.
            request_reference: a unique identifier for this api call.
                it is automatically generated if not provided.

        Returns:
            An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
                of calling this function.

        Raises:
            ConnectionException: when the request times out or in the absence of an internet connection.
        """
        data = {
            "trackingReference": tracking_reference,
            "amount": amount,
            "requestingCustomerName": customer_name,
            "requestingCustomerMobile": customer_mobile,
            "requestingCustomerEmail": customer_email,
            "billerIdentifier": biller_identifier,
            "note": note,
        }
        return self._api_call(
            service_type=ServiceType.BUY_GIFT_CARD,
            data=data,
            request_reference=request_reference,
        )

    def get_gift_card_status(
        self,
        tracking_reference: str,
        amount: Union[int, float],
        customer_name: str,
        customer_mobile: str,
        customer_email: str,
        biller_identifier: str,
        note: Optional[str] = None,
        request_reference: Optional[str] = None,
    ) -> APIResponse:
        """Retrieves the status of all gift cards purchased.

        Args:
            tracking_reference: The unique identifier of the virtual account.
            amount: The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved.
                a `Decimal` would have been the preferred type compared to `Union[int, float]` that was used.
                it is advisable that static values are passed for this parameter. see
                https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
            customer_name: Name of the customer receiving the gift card.
            customer_mobile: Mobile number of customer.
            customer_email: The email address of customer.
            biller_identifier: The Biller ID or identifier. You can find it in the `APIResponse` of
                `self.gift_cards`.
            note: An optional gift card note.
            request_reference: a unique identifier for this api call.
                it is automatically generated if not provided.

        Returns:
            An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
                of calling this function.

        Raises:
            ConnectionException: when the request times out or in the absence of an internet connection.
        """
        data = {
            "trackingReference": tracking_reference,
            "amount": amount,
            "requestingCustomerName": customer_name,
            "requestingCustomerMobile": customer_mobile,
            "requestingCustomerEmail": customer_email,
            "billerIdentifier": biller_identifier,
            "note": note,
        }
        return self._api_call(
            service_type=ServiceType.GIFT_CARD_TSQ,
            data=data,
            request_reference=request_reference,
        )

get_gift_card_status(tracking_reference, amount, customer_name, customer_mobile, customer_email, biller_identifier, note=None, request_reference=None)

Retrieves the status of all gift cards purchased.

Parameters:

Name Type Description Default
tracking_reference str

The unique identifier of the virtual account.

required
amount Union[int, float]

The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved. a Decimal would have been the preferred type compared to Union[int, float] that was used. it is advisable that static values are passed for this parameter. see https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency

required
customer_name str

Name of the customer receiving the gift card.

required
customer_mobile str

Mobile number of customer.

required
customer_email str

The email address of customer.

required
biller_identifier str

The Biller ID or identifier. You can find it in the APIResponse of self.gift_cards.

required
note Optional[str]

An optional gift card note.

None
request_reference Optional[str]

a unique identifier for this api call. it is automatically generated if not provided.

None

Returns:

Type Description
APIResponse

An APIResponse which is basically just a dataclass containing the data returned by the server as result of calling this function.

Raises:

Type Description
ConnectionException

when the request times out or in the absence of an internet connection.

Source code in pykuda2/wrappers/sync_wrappers/gift_card.py
def get_gift_card_status(
    self,
    tracking_reference: str,
    amount: Union[int, float],
    customer_name: str,
    customer_mobile: str,
    customer_email: str,
    biller_identifier: str,
    note: Optional[str] = None,
    request_reference: Optional[str] = None,
) -> APIResponse:
    """Retrieves the status of all gift cards purchased.

    Args:
        tracking_reference: The unique identifier of the virtual account.
        amount: The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved.
            a `Decimal` would have been the preferred type compared to `Union[int, float]` that was used.
            it is advisable that static values are passed for this parameter. see
            https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
        customer_name: Name of the customer receiving the gift card.
        customer_mobile: Mobile number of customer.
        customer_email: The email address of customer.
        biller_identifier: The Biller ID or identifier. You can find it in the `APIResponse` of
            `self.gift_cards`.
        note: An optional gift card note.
        request_reference: a unique identifier for this api call.
            it is automatically generated if not provided.

    Returns:
        An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
            of calling this function.

    Raises:
        ConnectionException: when the request times out or in the absence of an internet connection.
    """
    data = {
        "trackingReference": tracking_reference,
        "amount": amount,
        "requestingCustomerName": customer_name,
        "requestingCustomerMobile": customer_mobile,
        "requestingCustomerEmail": customer_email,
        "billerIdentifier": biller_identifier,
        "note": note,
    }
    return self._api_call(
        service_type=ServiceType.GIFT_CARD_TSQ,
        data=data,
        request_reference=request_reference,
    )

get_gift_cards(request_reference=None)

Retrieves a curated list of gift cards supported by Kuda.

Parameters:

Name Type Description Default
request_reference Optional[str]

a unique identifier for this api call. it is automatically generated if not provided.

None

Returns:

Type Description
APIResponse

An APIResponse which is basically just a dataclass containing the data returned by the server as result of calling this function.

Raises:

Type Description
ConnectionException

when the request times out or in the absence of an internet connection.

Source code in pykuda2/wrappers/sync_wrappers/gift_card.py
def get_gift_cards(self, request_reference: Optional[str] = None) -> APIResponse:
    """Retrieves a curated list of gift cards supported by Kuda.

    Args:
        request_reference: a unique identifier for this api call.
            it is automatically generated if not provided.

    Returns:
        An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
            of calling this function.

    Raises:
        ConnectionException: when the request times out or in the absence of an internet connection.
    """
    return self._api_call(
        service_type=ServiceType.GET_GIFT_CARD, request_reference=request_reference
    )

purchase_gift_card(amount, customer_name, customer_mobile, customer_email, biller_identifier, note=None, request_reference=None)

Buy gift cards from the admin account

Parameters:

Name Type Description Default
amount Union[int, float]

The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved. a Decimal would have been the preferred type compared to Union[int, float] that was used. it is advisable that static values are passed for this parameter. see https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency

required
customer_name str

Name of the customer receiving the gift card.

required
customer_mobile str

Mobile number of customer.

required
customer_email str

The email address of customer.

required
biller_identifier str

The Biller ID or identifier. You can find it in the APIResponse of self.gift_cards.

required
note Optional[str]

An optional gift card note.

None
request_reference Optional[str]

a unique identifier for this api call. it is automatically generated if not provided.

None

Returns:

Type Description
APIResponse

An APIResponse which is basically just a dataclass containing the data returned by the server as result of calling this function.

Raises:

Type Description
ConnectionException

when the request times out or in the absence of an internet connection.

Source code in pykuda2/wrappers/sync_wrappers/gift_card.py
def purchase_gift_card(
    self,
    amount: Union[int, float],
    customer_name: str,
    customer_mobile: str,
    customer_email: str,
    biller_identifier: str,
    note: Optional[str] = None,
    request_reference: Optional[str] = None,
) -> APIResponse:
    """Buy gift cards from the admin account

    Args:
        amount: The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved.
            a `Decimal` would have been the preferred type compared to `Union[int, float]` that was used.
            it is advisable that static values are passed for this parameter. see
            https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
        customer_name: Name of the customer receiving the gift card.
        customer_mobile: Mobile number of customer.
        customer_email: The email address of customer.
        biller_identifier: The Biller ID or identifier. You can find it in the `APIResponse` of
            `self.gift_cards`.
        note: An optional gift card note.
        request_reference: a unique identifier for this api call.
            it is automatically generated if not provided.

    Returns:
        An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
            of calling this function.

    Raises:
        ConnectionException: when the request times out or in the absence of an internet connection.
    """
    data = {
        "amount": amount,
        "requestingCustomerName": customer_name,
        "requestingCustomerMobile": customer_mobile,
        "requestingCustomerEmail": customer_email,
        "billerIdentifier": biller_identifier,
        "note": note,
    }
    return self._api_call(
        service_type=ServiceType.ADMIN_BUY_GIFT_CARD,
        data=data,
        request_reference=request_reference,
    )

purchase_gift_card_from_virtual_account(tracking_reference, amount, customer_name, customer_mobile, customer_email, biller_identifier, note=None, request_reference=None)

Buy gift cards from the virtual account.

Parameters:

Name Type Description Default
tracking_reference str

The unique identifier of the virtual account.

required
amount Union[int, float]

The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved. a Decimal would have been the preferred type compared to Union[int, float] that was used. it is advisable that static values are passed for this parameter. see https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency

required
customer_name str

Name of the customer receiving the gift card.

required
customer_mobile str

Mobile number of customer.

required
customer_email str

The email address of customer.

required
biller_identifier str

The Biller ID or identifier. You can find it in the APIResponse of self.gift_cards.

required
note Optional[str]

An optional gift card note.

None
request_reference Optional[str]

a unique identifier for this api call. it is automatically generated if not provided.

None

Returns:

Type Description
APIResponse

An APIResponse which is basically just a dataclass containing the data returned by the server as result of calling this function.

Raises:

Type Description
ConnectionException

when the request times out or in the absence of an internet connection.

Source code in pykuda2/wrappers/sync_wrappers/gift_card.py
def purchase_gift_card_from_virtual_account(
    self,
    tracking_reference: str,
    amount: Union[int, float],
    customer_name: str,
    customer_mobile: str,
    customer_email: str,
    biller_identifier: str,
    note: Optional[str] = None,
    request_reference: Optional[str] = None,
) -> APIResponse:
    """Buy gift cards from the virtual account.

    Args:
        tracking_reference: The unique identifier of the virtual account.
        amount: The gift card amount to be purchased. It could be in USD/ GBP/ EUR/ NGN/ AED , e.t.c. Note care should be taken when performing calculations as money is involved.
            a `Decimal` would have been the preferred type compared to `Union[int, float]` that was used.
            it is advisable that static values are passed for this parameter. see
            https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
        customer_name: Name of the customer receiving the gift card.
        customer_mobile: Mobile number of customer.
        customer_email: The email address of customer.
        biller_identifier: The Biller ID or identifier. You can find it in the `APIResponse` of
            `self.gift_cards`.
        note: An optional gift card note.
        request_reference: a unique identifier for this api call.
            it is automatically generated if not provided.

    Returns:
        An `APIResponse` which is basically just a dataclass containing the data returned by the server as result
            of calling this function.

    Raises:
        ConnectionException: when the request times out or in the absence of an internet connection.
    """
    data = {
        "trackingReference": tracking_reference,
        "amount": amount,
        "requestingCustomerName": customer_name,
        "requestingCustomerMobile": customer_mobile,
        "requestingCustomerEmail": customer_email,
        "billerIdentifier": biller_identifier,
        "note": note,
    }
    return self._api_call(
        service_type=ServiceType.BUY_GIFT_CARD,
        data=data,
        request_reference=request_reference,
    )