Ejemplo n.º 1
0
 def __request_spending_money(self):
     RequestInquiry.create(
         Amount(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR),
         Pointer(self._POINTER_EMAIL, self.__SPENDING_MONEY_RECIPIENT),
         self.__REQUEST_SPENDING_DESCRIPTION, False)
     RequestInquiry.create(
         Amount(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR),
         Pointer(self._POINTER_EMAIL, self.__SPENDING_MONEY_RECIPIENT),
         self.__REQUEST_SPENDING_DESCRIPTION, False,
         self._second_monetary_account.id_)
Ejemplo n.º 2
0
    def get_pointer_counter_party_other(cls) -> Pointer:
        type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][
            cls._FIELD_TYPE]
        alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][
            cls._FIELD_ALIAS]

        return Pointer(type_, alias)
Ejemplo n.º 3
0
 def make_payment(self, PaymentInfo: object):
     recipient = Pointer('IBAN', PaymentInfo.to_iban, "bunq")
     endpoint.Payment.create(
         amount=Amount(PaymentInfo.amount_string, 'EUR'),
         counterparty_alias=recipient,
         description=PaymentInfo.description,
         monetary_account_id=self._get_monetary_account_id_from_iban(
             PaymentInfo.from_iban))
Ejemplo n.º 4
0
    def make_request(self, amount_string, description, recipient):
        BunqContext._api_context = self._api_context
        BunqContext._user_context = self._user_context

        endpoint.RequestInquiry.create(
            amount_inquired=Amount(amount_string, self._CURRENCY_EUR),
            counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient),
            description=description,
            allow_bunqme=True,
        )
Ejemplo n.º 5
0
 def __request_spending_money_if_needed(self):
     if self.__should_request_spending_money():
         endpoint.RequestInquiry.create(
             amount_inquired=Amount(self._REQUEST_SPENDING_MONEY_AMOUNT,
                                    self._CURRENCY_EUR),
             counterparty_alias=Pointer(
                 self._POINTER_TYPE_EMAIL,
                 self._REQUEST_SPENDING_MONEY_RECIPIENT),
             description=self._REQUEST_SPENDING_MONEY_DESCRIPTION,
             allow_bunqme=False)
         sleep(self._REQUEST_SPENDING_MONEY_WAIT_TIME_SECONDS)
Ejemplo n.º 6
0
def make_request(amount_string, description, recipient):
    """
    :type amount_string: str
    :type description: str
    :type recipient: str
    """

    endpoint.RequestInquiry.create(
        amount_inquired=Amount(amount_string, "EUR"),
        counterparty_alias=Pointer("PHONE_NUMBER", recipient),
        description=description,
        allow_bunqme=True)
Ejemplo n.º 7
0
    def make_request(self, amount_string, description, recipient):
        """
        :type amount_string: str
        :type description: str
        :type recipient: str
        """

        endpoint.RequestInquiry.create(
            amount_inquired=Amount(amount_string, self._CURRENCY_EURL),
            counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient),
            description=description,
            allow_bunqme=True)
Ejemplo n.º 8
0
    def make_payment(self, amount_string, description, recipient):
        """
        :type amount_string: str
        :type description: str
        :type recipient: str
        """

        endpoint.Payment.create(amount=Amount(amount_string,
                                              self._CURRENCY_EURL),
                                counterparty_alias=Pointer(
                                    self._POINTER_TYPE_EMAIL, recipient),
                                description=description)
Ejemplo n.º 9
0
    def __create_payment_list(self) -> List[Payment]:
        all_payment = []

        while len(all_payment) < self._MAXIMUM_PAYMENT_IN_BATCH:
            all_payment.append(
                Payment(
                    Amount(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY),
                    Pointer(self._POINTER_EMAIL, self._EMAIL_BRAVO),
                    self._PAYMENT_DESCRIPTION))
        self.assertIsInstance(all_payment, List)
        self.assertIsInstance(all_payment[0], Payment)

        return all_payment
Ejemplo n.º 10
0
 def make_payment(self,
                  amount_string,
                  description,
                  recipient,
                  geolocation=None):
     """
     :type amount_string: str
     :type description: str
     :type recipient: str
     """
     if geolocation is None:
         endpoint.Payment.create(amount=Amount(amount_string,
                                               self._CURRENCY_EURL),
                                 counterparty_alias=Pointer(
                                     self._POINTER_TYPE_EMAIL, recipient),
                                 description=description)
     else:
         endpoint.Payment.create(
             amount=Amount(amount_string, self._CURRENCY_EURL),
             counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL,
                                        recipient),
             description=description,
             custom_headers={"X-Bunq-Geolocation": geolocation})
Ejemplo n.º 11
0
def convert_to_pointer(input: str) -> Pointer:
    """Convert input to Pointer

    Args:
        input (str): email, iban or phonenumber

    Returns:
        Pointer: converted input
    """
    # Split since iban is passed as 'NL92BUNQ12445345,T Test'
    value = convert_comma_seperated_to_list(input)

    # Determine type and return
    if validators.email(value[0]):
        return Pointer(type_="EMAIL", value=value[0])
    elif validators.iban(value[0]):
        return Pointer(type_="IBAN", value=value[0], name=value[1])
    # TODO: implement phonenumber validation in validators
    elif value[0][1:].isdigit():  # removes + sign from phonenumber
        return Pointer(type_="PHONE_NUMBER", value=value[0])
    else:
        # TODO: Create some logging class and exit with message
        print("No valid API Type")
        exit(1)
Ejemplo n.º 12
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(OPTION_API_KEY)
    all_option = parser.parse_args()

    if all_option.api_key is None:
        raise BunqException(ERROR_OPTION_MISSING_API_KEY)

    api_context = ApiContext(ApiEnvironmentType.PRODUCTION, all_option.api_key, '*')
    BunqContext.load_api_context(api_context)
    end = 50
    for i in range(0, end):
        endpoint.Payment.create(amount=Amount('0.01', 'EUR'),
                                counterparty_alias=Pointer('IBAN', '', ''),
                                description=str(round(i / end * 100, 2)) + " Prozent von deinem Geld",
                                monetary_account_id=)
        time.sleep(0.33333)
def top_up(conf=None, amount=1000.):
    """Top up a sandbox bunq account by the specified amount"""
    CTX = service.config.Context

    if conf:
        CTX._reload_bunq_ctx(conf)

    acct = service.bunq.list_accounts()[0]

    acct_id = acct['id']
    balance = float(acct['balance'])
    click.echo(f'Current balance: {balance:.2f}')
    time.sleep(1.5)

    amount_to_add = amount
    max_request_amount = 500

    while amount_to_add > 0:
        if amount_to_add > max_request_amount:
            request_amount = max_request_amount
        else:
            request_amount = amount_to_add

        amount_to_add -= request_amount

        endpoint.RequestInquiry.create(
            amount_inquired=Amount(str(request_amount), 'EUR'),
            counterparty_alias=Pointer('EMAIL', '*****@*****.**'),
            description='Requesting some spending money.',
            allow_bunqme=False,
            monetary_account_id=acct_id)

        click.echo(f'\rTotal added: {amount-amount_to_add:.2f}')
        time.sleep(1.5)

    acct = service.bunq.list_accounts()[0]
    balance = float(acct['balance'])
    click.echo(f'New balance: {balance:.2f}')
Ejemplo n.º 14
0
 def test_send_pay_request(self):
     RequestInquiry.create(amount_inquired=Amount('400', currency='EUR'),
                           counterparty_alias=Pointer(
                               'EMAIL', '*****@*****.**'),
                           description='Gimme tha monnies',
                           allow_bunqme=True)
Ejemplo n.º 15
0
 def _get_savings_account():
     return Pointer('IBAN', Config.get_option('SAVINGS_IBAN'),
                    Config.get_option('SAVINGS_OWNER'))
Ejemplo n.º 16
0
 def getExternalIbanPointer(iban: str, recipient: str) -> [Pointer]:
     return Pointer("IBAN", iban, recipient)
Ejemplo n.º 17
0
 def _get_pointer_bravo(self) -> Pointer:
     return Pointer(self._POINTER_EMAIL, self._EMAIL_BRAVO)