def _payments_required(self): """ :rtype: list[endpoint.Payment] """ pagination = client.Pagination() pagination.count = self._PAYMENT_REQUIRED_COUNT_MINIMUM return self._list_payments(pagination.url_params_count_only).value
def _create_pagination_with_all_properties_set(self): """ :rtype: Pagination """ pagination = client.Pagination() pagination.older_id = self._PAGINATION_OLDER_ID_CUSTOM pagination.newer_id = self._PAGINATION_NEWER_ID_CUSTOM pagination.future_id = self._PAGINATION_FUTURE_ID_CUSTOM pagination.count = self._PAGINATION_COUNT_CUSTOM return pagination
def deserialize(cls, target_class, pagination_response): """ :type target_class: client.Pagination|type :type pagination_response: dict :rtype: client.Pagination """ pagination = client.Pagination() pagination.__dict__.update( cls.parse_pagination_dict(pagination_response)) return pagination
def all_accounts(is_joint=False): # determine account type account_type = endpoint.MonetaryAccountJoint if is_joint else endpoint.MonetaryAccountBank # ensure the session is still active refresh_api_context() # setup pagination pagination = bunqClient.Pagination() pagination.count = 25 # make the request all_accounts = account_type.list(pagination.url_params_count_only).value # only include active accounts all_active_accounts = filter(lambda acc: acc.status == 'ACTIVE', all_accounts) all_active_accounts_json = map(account_to_json, all_active_accounts) return all_active_accounts_json
def all_cards(): # ensure the session is still active refresh_api_context() # setup pagination pagination = bunqClient.Pagination() pagination.count = 10 # make the request all_cards = CardHotfix.list(pagination.url_params_count_only).value # only include non-virtual, active cards non_virtual_cards = filter(lambda card: card.type_ != 'MASTERCARD_VIRTUAL', all_cards) all_active_cards = filter(lambda card: card.status == 'ACTIVE', non_virtual_cards) all_active_cards_json = map(card_to_json, all_active_cards) return all_active_cards_json
def test_api_scenario_payment_listing_with_pagination(self): self._ensure_enough_payments() payments_expected = self._payments_required() pagination = client.Pagination() pagination.count = self._PAYMENT_LISTING_PAGE_SIZE response_latest = self._list_payments(pagination.url_params_count_only) pagination_latest = response_latest.pagination response_previous = self._list_payments( pagination_latest.url_params_previous_page) pagination_previous = response_previous.pagination response_previous_next = self._list_payments( pagination_previous.url_params_next_page) payments_previous = response_previous.value payments_previous_next = response_previous_next.value payments_actual = payments_previous_next + payments_previous payments_expected_serialized = converter.serialize(payments_expected) payments_actual_serialized = converter.serialize(payments_actual) self.assertEqual(payments_expected_serialized, payments_actual_serialized)
def run(): api_context = context.ApiContext.restore() pagination = client.Pagination() pagination.count = _PAGE_SIZE payments_response = endpoint.Payment.list(api_context, _USER_ITEM_ID, _MONETARY_ACCOUNT_ITEM_ID, pagination.url_params_count_only) print(_MESSAGE_LATEST_PAGE_IDS) for payment in payments_response.value: print(payment.id_) if payments_response.pagination.has_previous_page(): print(_MESSAGE_SECOND_LATEST_PAGE_IDS) payments_response_previous = endpoint.Payment.list( api_context, _USER_ITEM_ID, _MONETARY_ACCOUNT_ITEM_ID, payments_response.pagination.url_params_previous_page) for payment in payments_response_previous.value: print(payment.id_) else: print(_MESSAGE_NO_PRIOR_PAYMENTS_FOUND)