Ejemplo n.º 1
0
 def __request_spending_money(self):
     endpoint.RequestInquiry.create(
         object_.Amount(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR),
         object_.Pointer(self._POINTER_EMAIL,
                         self.__SPENDING_MONEY_RECIPIENT),
         self.__REQUEST_SPENDING_DESCRIPTION, False)
     endpoint.RequestInquiry.create(
         object_.Amount(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR),
         object_.Pointer(self._POINTER_EMAIL,
                         self.__SPENDING_MONEY_RECIPIENT),
         self.__REQUEST_SPENDING_DESCRIPTION, False,
         self._second_monetary_account.id_)
Ejemplo n.º 2
0
def run():
    api_context = context.ApiContext.restore()
    request_map = {
        endpoint.RequestInquiry.FIELD_AMOUNT_INQUIRED:
        object_.Amount(_REQUEST_AMOUNT, _REQUEST_CURRENCY),
        endpoint.RequestInquiry.FIELD_COUNTERPARTY_ALIAS:
        object_.Pointer(_COUNTERPARTY_POINTER_TYPE, _COUNTERPARTY_EMAIL),
        endpoint.RequestInquiry.FIELD_DESCRIPTION:
        _REQUEST_DESCRIPTION,
        endpoint.RequestInquiry.FIELD_ALLOW_BUNQME:
        True,
    }
    request_id = endpoint.RequestInquiry.create(
        api_context, request_map, _USER_ITEM_ID,
        _MONETARY_ACCOUNT_ITEM_ID).value
    print(
        endpoint.RequestInquiry.get(api_context, _USER_ITEM_ID,
                                    _MONETARY_ACCOUNT_ITEM_ID,
                                    request_id).value.to_json())

    request_update_map = {
        endpoint.RequestInquiry.FIELD_STATUS: _STATUS_REVOKED,
    }
    print(
        endpoint.RequestInquiry.update(api_context, request_update_map,
                                       _USER_ITEM_ID,
                                       _MONETARY_ACCOUNT_ITEM_ID,
                                       request_id).value.to_json())
def run():
    api_context = context.ApiContext.restore()
    request_map = {
        endpoint.PaymentBatch.FIELD_PAYMENTS: [
            {
                endpoint.Payment.FIELD_AMOUNT: object_.Amount(
                    _PAYMENT_AMOUNT,
                    _PAYMENT_CURRENCY),
                endpoint.Payment.FIELD_COUNTERPARTY_ALIAS: object_.Pointer(
                    _COUNTERPARTY_POINTER_TYPE,
                    _COUNTERPARTY_EMAIL
                ),
                endpoint.Payment.FIELD_DESCRIPTION: _PAYMENT_DESCRIPTION,
            }
        ]
    }

    payment_id = endpoint.PaymentBatch.create(
        api_context,
        request_map,
        _USER_ITEM_ID,
        _MONETARY_ACCOUNT_ITEM_ID
    ).value

    print(
        endpoint.PaymentBatch.get(
            api_context,
            _USER_ITEM_ID,
            _MONETARY_ACCOUNT_ITEM_ID,
            payment_id
        ).value.to_json()
    )
Ejemplo n.º 4
0
    def get_pointer_counter_party_self(cls):
        """
        :rtype: Pointer
        """

        type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][
            cls._FIELD_TYPE]
        alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][
            cls._FIELD_ALIAS]

        return object_.Pointer(type_, alias)
Ejemplo n.º 5
0
def run():
    api_context = context.ApiContext.restore()
    pointer = object_.Pointer(_POINTER_TYPE_EMAIL, _EMAIL_YOUR_COMPANY)
    pointer.name = _POINTER_NAME_TEST
    request_map = {
        endpoint.CardDebit.FIELD_ALIAS: pointer,
        endpoint.CardDebit.FIELD_NAME_ON_CARD: _NAME_YOUR_COMPANY,
        endpoint.CardDebit.FIELD_PIN_CODE: _PIN_CODE,
        endpoint.CardDebit.FIELD_SECOND_LINE: _make_second_line()
    }

    print(
        endpoint.CardDebit.create(api_context, request_map,
                                  _USER_ITEM_ID).value.to_json())
Ejemplo n.º 6
0
    def _create_payment_request_map(self, account_to, amount):
        """Creates a request map for an IBAN -> IBAN transaction with a
        given (absolute) amount (in EUR)
        """
        request_map = {
            generated.Payment.FIELD_AMOUNT:
            object_.Amount(abs(amount), 'EUR'),
            generated.Payment.FIELD_COUNTERPARTY_ALIAS:
            object_.Pointer('IBAN', util.get_iban(account_to)),
            generated.Payment.FIELD_DESCRIPTION:
            self._SAVING_PAYMENT_DESCRIPTION,
        }

        request_map[generated.Payment.FIELD_COUNTERPARTY_ALIAS].name = \
            util.get_attr_from_alias(account_to, 'name', 'IBAN')

        return request_map
Ejemplo n.º 7
0
    def __create_payment_list(self) -> List[endpoint.Payment]:
        """
        :rtype: List[Payment]
        """

        all_payment = []

        while len(all_payment) < self._MAXIMUM_PAYMENT_IN_BATCH:
            all_payment.append(
                endpoint.Payment(
                    object_.Amount(self._PAYMENT_AMOUNT_EUR,
                                   self._PAYMENT_CURRENCY),
                    object_.Pointer(self._POINTER_EMAIL, self._EMAIL_BRAVO),
                    self._PAYMENT_DESCRIPTION))

        self.assertIsInstance(all_payment, List)
        self.assertIsInstance(all_payment[0], endpoint.Payment)
        return all_payment
Ejemplo n.º 8
0
def create_share(acct_id: int, recip_phnum: str):
    counterparty = object_.Pointer('PHONE_NUMBER', recip_phnum)

    share_detail = object_.ShareDetail(
        payment=object_.ShareDetailPayment(make_payments=True,
                                           view_balance=True,
                                           view_old_events=False,
                                           view_new_events=True))

    try:
        response = endpoint.ShareInviteBankInquiry.create(
            counter_user_alias=counterparty,
            share_detail=share_detail,
            status='PENDING',
            monetary_account_id=acct_id,
        )

    except exception.BadRequestException as e:
        # Share with counterparty already may already exist -> return it
        existing_alias = _get_alias_from_error_message(e.message)
        matching_shares = []
        if existing_alias:
            current_shares = list_shares(acct_id)
            matching_shares = [
                s for s in current_shares
                if s['counterparty'] == existing_alias
            ]

        if len(matching_shares) == 1:
            return matching_shares[0]
        else:
            raise _convert_exception(e)

    except Exception as e:
        raise _convert_exception(e)

    share_id = response.value

    response = endpoint.ShareInviteBankInquiry.get(share_id, acct_id)
    share = response.value

    return share_summary(share)
Ejemplo n.º 9
0
def make_payment_to_iban(acct_id,
                         to_iban,
                         to_name,
                         amount,
                         description='Subsidy Service payment'):
    counterparty = object_.Pointer(type_='IBAN', value=to_iban, name=to_name)
    amt = object_.Amount(value=str(amount), currency=CURRENCY)

    try:
        response = endpoint.Payment.create(
            amt,
            counterparty,
            description,
            monetary_account_id=acct_id,
        )

    except Exception as e:
        raise _convert_exception(e)

    pmt = endpoint.Payment.get(response.value, acct_id).value

    return payment_summary(pmt)
Ejemplo n.º 10
0
def run():
    api_context = context.ApiContext.restore()
    request_map = {
        endpoint.Payment.FIELD_AMOUNT:
        object_.Amount(_PAYMENT_AMOUNT, _PAYMENT_CURRENCY),
        endpoint.Payment.FIELD_COUNTERPARTY_ALIAS:
        object_.Pointer(_COUNTERPARTY_POINTER_TYPE, _COUNTERPARTY_EMAIL),
        endpoint.Payment.FIELD_DESCRIPTION:
        _PAYMENT_DESCRIPTION,
    }

    payment_id = endpoint.Payment.create(api_context, request_map,
                                         _USER_ITEM_ID,
                                         _MONETARY_ACCOUNT_ITEM_ID).value

    print(
        endpoint.Payment.get(api_context, _USER_ITEM_ID,
                             _MONETARY_ACCOUNT_ITEM_ID,
                             payment_id).value.to_json())

    # Save the API context to account for all the changes that might have occurred to it during the example execution
    api_context.save()
Ejemplo n.º 11
0
    def _get_pointer_bravo(self):
        """
        :rtype: object_.Pointer
        """

        return object_.Pointer(self._POINTER_EMAIL, self._EMAIL_BRAVO)