コード例 #1
0
    def cards_list(
        self,
        token: str = None,
        page: int = None,
        page_size: int = None,
        begin: str = None,
        end: str = None,
    ) -> typing.Iterable[Card]:
        """
        Get an iterator of the cards owned by this account.

        Args:
            token (str, optional): Used to get a specific card.
            page (str, optional): Used to specify the start page.
            page_size (str, optional): Used to specify the page size.
            begin (str, optional): The start date of the results as a date string (`YYYY-MM-DD`).
            end (str, optional): The end date of the results as a date string (`YYYY-MM-DD`).

        Returns:
            `privacy.util.pagination.PaginatedResponse` [ `privacy.schema.cards.Card` ]

        Raises:
            APIException (privacy.http_client.APIException): On status code 5xx and certain 429s.
        """
        return Card.paginate(
            self,
            Routes.CARDS_LIST,
            params=optional(card_token=token,
                            page=page,
                            page_size=page_size,
                            begin=begin,
                            end=end),
        )
コード例 #2
0
    def cards_create(
        self,
        card_type: Type,
        memo: str = None,
        spend_limit: int = None,
        spend_limit_duration: SpendLimitDuration = None,
    ) -> Card:
        """
        PREMIUM ENDPOINT - Create a card.

        Args:
            card_type (privacy.schema.cards.Type): The card type.
            memo (str, optional): The card's name.
            spend_limit (int, optional): The spending limit of the card (in pennies).
            spend_limit_duration (privacy.schema.cards.SpendLimitDuration, optional): The spend limit duration.

        Returns:
            `privacy.schema.cards.Card`

        Raises:
            APIException (privacy.http_client.APIException): On status code 5xx and certain 429s.
        """
        response = self.http(
            Routes.CARDS_CREATE,
            json=optional(
                type=card_type,
                memo=memo,
                spend_limit=spend_limit,
                spend_limit_duration=spend_limit_duration,
            ),
        )
        return Card(client=self, **response.json())
コード例 #3
0
    def transactions_list(
        self,
        approval_status: str = "all",
        token: str = None,
        card_token: str = None,
        page: int = None,
        page_size: int = None,
        begin: str = None,
        end: str = None,
    ) -> typing.Iterable[Transaction]:
        """
        Get an iterator of the transactions under this account.

        Args:
            approval_status (str, optional): One of [`approvals`, `declines`, `all`] used to
                get transactions with a specific status.
            token (str, optional): Used to get a specific transaction.
            card_token (str, optional): Used to get the transactions associated with a specific card.
            page (int, optional): Used to specify the start page.
            page_size (int, optional): Used to specify the page size.
            begin (str, optional): The starting date of the results as a date string (`YYYY-MM-DD`).
            end (str, optional): The end date of the results as a date string (`YYYY-MM-DD`).

        Returns:
            `privacy.util.pagination.PaginatedResponse`[ `privacy.schema.transactions.Transaction` ]

        Raises:
            APIException (privacy.http_client.APIException): On status code 5xx and certain 429s.
        """
        return Transaction.paginate(
            self,
            Routes.TRANSACTIONS_LIST,
            dict(approval_status=approval_status),
            params=optional(
                transaction_token=token,
                card_token=card_token,
                page=page,
                page_size=page_size,
                begin=begin,
                end=end,
            ),
        )
コード例 #4
0
    def cards_modify(
        self,
        token: str,
        state: State = None,
        memo: str = None,
        spend_limit: int = None,
        spend_limit_duration: SpendLimitDuration = None,
    ) -> Card:
        """
        PREMIUM ENDPOINT - Modify an existing card.

        Args:
            token (str): The unique token of the card being modified.
            state (privacy.schema.cards.State, optional): The new card state.
            memo (str, optional): The name card name.
            spend_limit (int, optional): The new card spend limit (in pennies).
            spend_limit_duration (privacy.schema.cards.SpendLimitDuration, optional): The spend limit duration.

        Returns:
            `privacy.schema.cards.Card`

        Raises:
            APIException (privacy.http_client.APIException): On status code 5xx and certain 429s.

        Note:
            Setting state to `privacy.schema.cards.State.CLOSED` cannot be undone.
        """
        response = self.http(
            Routes.CARDS_MODIFY,
            json=optional(
                card_token=token,
                state=state,
                memo=memo,
                spend_limit=spend_limit,
                spend_limit_duration=spend_limit_duration,
            ),
        )
        return Card(client=self, **response.json())