Git Product home page Git Product logo

sdk_python's People

Contributors

andrederoos avatar angelomelonas avatar bunq-bot avatar csdenboer avatar davide-giordano avatar dnl-blkv avatar eavanvalkenburg avatar lexym avatar nickvandegroes avatar ogkevin avatar pjullrich avatar sandervdo avatar siccovansas avatar smukhibillaev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk_python's Issues

Add test CI

Steps to reproduce:

  1. Make a PR

What should happen:

  1. There should be a test CI

What happens:

  1. There is no such thing.

reference bunq/sdk_php#126

It is not possible to refresh userContext data

Steps to reproduce:

  1. Make a payment from your main account.
  2. Check the balance of the main account stored in user context.

What should happen:

  1. The balance is correct.

What happens:

  1. The balances is the old balance before the payment was mande.

Traceback

SDK version and environment

  • Tested on 0.13.0
  • Sandbox
  • Production

Response id

  • Response id:

Extra info:

Reference bunq/sdk_php#122

ScheduledPayment causes decode error due to Typo

There is a typo in the bunq\Model\Generated\Endpoint\SchedulePayment class. It has the constant const OBJECT_TYPE = 'SchedulePayment'; while the API returns an object of type ScheduledPayment. When I change the constant to this, it works fine.

Steps to reproduce:

  1. Run this piece of code: https://gist.github.com/mbernson/dd8c966e277b4acd820463335cd47e24

What should happen:

  1. I see a var_dump of my scheduled payments.

What happens:

  1. PHP Notice: Undefined index: SchedulePayment in /Users/mathijs/Code/bunqapibouwsel/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php on line 115

Extra info:

Reference

Improve decoder to recognise child object

Steps to reproduce:

  1. Try and decode a child object into a model that is expecting its parent

What should happen:

  1. The model is correctly populated with data.

What happens:

  1. All the fields, including the parent field will be null.

Logs

  • Logs no logs

Extra info:

Reference

ImportError: cannot import name 'JSONDecodeError'

Steps to reproduce:

  • Running python 3.4.2 on Debian GNU/Linux 8 (jessie).
  • Installed with pip3 install bunq_sdk --upgrade
  • Run test.py which contains from bunq.sdk import context

What happens:

~ $ python3 test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from bunq.sdk import context
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/context.py", line 6, in <module>
    from bunq.sdk.model import core
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/model/core.py", line 1, in <module>
    from bunq.sdk import client
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/client.py", line 2, in <module>
    from json import JSONDecodeError
ImportError: cannot import name 'JSONDecodeError'

SDK version and environment

needs #78

generated.Payment.FIELD_COUNTERPARTY_ALIAS not working with IBAN

lOOKS LIKE THE generated.Payment.FIELD_COUNTERPARTY_ALIAS is not supporting IBANs for sending money
For example using
generated.Payment.FIELD_COUNTERPARTY_ALIAS: object_.Pointer(
'IBAN',
'IBAN number',
'Name'
),
The Name option looks like it is not there at all

Monetary account joint cannot be retrieved.

Steps to reproduce:

  1. Create a new joint account
  2. try something like MonetaryAccount.list

What should happen:

  1. Monetary account joints are also listed

What happens:

  1. you will get all accounts except the new joint accounts

Logs

  • Logs no logs

Extra info:

Reference

Put name in Pointer __init__

As of now, the init function of the object_.Pointer class does not have a field for the name of e.g. a counterparty_alias, however such a name is important when making payments to IBAN numbers. One can set the name afterwards, but this is awkward especially when a Pointer is created in a request map as e.g. shown in the PaymentExample.

I suggest the following changes:
As it is now:

class Pointer(model.BunqModel):
    def __init__(self, type_, value):
        self.type_ = type_
        self.value = value
        self.name = None

My suggestion:

class Pointer(model.BunqModel):
    def __init__(self, type_, value, name=None):
        self.type_ = type_
        self.value = value
        self.name = name

Python 3.4.2: ImportError: cannot import name 'context' (cyclic import?)

Steps to reproduce:

  • Running python 3.4.2 on Debian GNU/Linux 8 (jessie).
  • Installed with pip3 install bunq_sdk --upgrade
  • Make a workaroudn for issue #72 : change
    from json import JSONDecodeError

    to
    from simplejson import JSONDecodeError
  • Run test.py which contains from bunq.sdk import context

What happens:

~ $ python3 test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from bunq.sdk import context
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/context.py", line 9, in <module>
    from bunq.sdk.model.generated import endpoint
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/model/generated/endpoint.py", line 3, in <module>
    from bunq.sdk import context
ImportError: cannot import name 'context'

It looks like a cyclic import (`context` importing `endpoint` and `endpoint` importing `context`), but I don't know why this is a problem for python 3.4.2.

Break the SDK's dependence on the bunq.conf file

It would be nice to have the option to save the API parameters to e.g. a database instead of to the bunq.conf file. For now, one can download the code and rewrite the saving function, or mock the saving function, either possibility is not very desirable.

DraftPayment object field causes converter error

Steps to reproduce:

  1. Use the PHP Pub API SDK
  2. Make a draft payment via the SDK
  3. Accept this draft payment
  4. Retrieve this draft payment

What should happen:

  1. The SDK will raise and error as described here bunq/sdk_php#63

What happens:

  1. No error is raised

Extra info:

  • Tested on SDK release 0.12.1
  • This is an issue with all SDK's

Response is missing response headers and pagination

How to Reproduce

  1. Make a valid listing request to bunq API via the Python SDK
  2. Make a valid get/put/post/delete request to bunq API via the Python SDK

What Should Happen

  1. The response contains response headers and pagination
  2. The response contains response headers

What Happens

  1. The response does not contain response header nor pagination
  2. The response does not contain response header

Notes

  1. The structural fix would be to introduce BunqResponse object which, besides the response model, includes the response headers and pagination

Add header verification test 

Steps to reproduce:

  1. Response verification should be tested,

What should happen:

  1. Response verification is not tested.

What happens:

  1. Response verification is tested.

Logs

  • Logs no logs

Extra info:

References

Introduce from_json method 

Steps to reproduce:

  1. Take a look at the methods inside BunqModel

What should happen:

  1. There is a method to convert a JSON to class defined like to_json

What happens:

  1. 👆 is not implemented

Logs

  • Logs no logs

Extra info:

References

More flexibility for sessionContext handling

Steps to reproduce:

  1. Try and find out if your session context is expired

What should happen:

  1. There is a way to know if your session has expired without resetting/calling ensureSesiosActive()

What happens:

  1. There is no way to achieve such thing

Extra info:

Why

  • This way you wont have to execute this code before each call but only if your session did expire
api_context.ensure_session_active()
api_context.save(filename_bunq_config_full)

Which means you will be saving an unchanged context on each call

Submit this as package to PyPi

It would be very handy if you could package this SDK and put it on PyPi so that it can easily be integrated into e.g. requirements.txt and I don't have to copy & paste the source code if I want to use the SDK.

Instructions on how to submit this as a package can be found here

Add more example scripts

This issue is meant to keep track of the example scripts included in the SDK.

  • ApiContext

    • Save/restore
    • Ensure that session is active
  • Attachments

  • Callbacks

  • Cards

    • Order card
  • Card payments

    • MasterCard action
  • Cash registers

  • Chat

  • Connects

  • Export statements

  • Invoices

  • Monetary accounts

  • Payment

    • Draft Payment
    • Scheduled Payment
    • Payment batch
    • Tab Payment
  • Request for payment / Request inquiry

  • User

Better error handling

Steps to reproduce:

  1. Look at the exceptions that the SDK throws.

What should happen:

  1. The SDK has at least 1 exception per error status code (400+).

What happens:

  1. The SDK will only throw exceptions of two types: client-side and server-side.

Extract JsonAdapter as own library

Your functionality on de- & serialising (especially nested) JSON data to Python classes is pretty neat and actually high in demand in the Python community at the moment.

Until now, JSONPickle is mostly the library of choice when de/serialising nested JSON data from and to Python objects, but "pickled" JSON Data (with Pickle serialised Python Objects) can only be deserialised with the same methods as with which they were serialised. Therefore, nested JSON data received from somewhere else cannot be deserialised without knowing how it was serialised.

Your JSONAdapter class seems to be able to do just that without knowing how the data was serialised. Given the need for such functionality in the Python community, I'd like to propose that you extract this functionality into a separate library and preferably put it on PyPi.

Add missing fields for cvc endpoint

Steps to reproduce:

  1. Try and get id, created or updated from CardGeneratedCvc2

What should happen:

  1. These fields are there with getters/setters

What happens:

  1. There are no such fields

Logs

  • no logs

Extra info:

Optimise test framework

Steps to reproduce:

  1. Try and execute tests

What should happen:

  1. It should be easy and fast

What happens:

  1. It is hard to set up and can take up to 10 mins to complete.

Traceback

SDK version and environment

  • Tested on 0.12.4
  • Sandbox
  • Production

Response id

  • Response id:

Extra info:

Reference: bunq/sdk_php#120

Add Threadsafety for x-bunq-server-signature

Hello! It's me again!

I encountered a problem when making calls with the SDK in a concurrent manner. Especially, I got the following error when making calls to the production API (no errors occurred in Sandbox)
Here's the stacktrace:

# Making a call with a ApiContext to the User object. I deleted calls in my own code.
    users = generated.User.list(api.Client.ctx())
  File "/usr/lib/python3.6/site-packages/bunq/sdk/model/generated/endpoint.py", line 9480, in list
    response = api_client.get(endpoint_url, custom_headers)
  File "/usr/lib/python3.6/site-packages/bunq/sdk/client.py", line 246, in get
    custom_headers
  File "/usr/lib/python3.6/site-packages/bunq/sdk/client.py", line 109, in _request
    response.headers
  File "/usr/lib/python3.6/site-packages/bunq/sdk/security.py", line 250, in validate_response
    signer.verify(digest, base64.b64decode(headers[_HEADER_SERVER_SIGNATURE]))
  File "/usr/lib/python3.6/site-packages/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'x-bunq-server-signature'

Do you have an idea what could cause the problem that out of a sudden the server signature is not found anymore when making concurrent calls and no problem occurs when making sequential calls?

Update: I experienced this issue whenever I create 2 Threads which create and 'get' Payments to the production API. So basically, I make 2 independent Payments from e.g. account A to C and account B to C and then there seems to be some kind of issue with the verification function of the bunq response

Tests need a minor cleanup

How to Reproduce

  1. Look at the tests structure

What Should Happen

  1. Test structure mimics the code structure
  2. Test naming is consistent (test classes all start with word Test)

What Happens

  1. TestApiContext is located in Model/Generated
  2. Test for Avatar is called AvatarTest

Add Pagination

How to Reproduce

  1. Make a LIST call with count=1 over a resource for which you have at least 2 items
  2. Try to get the next page of the results

What Should Happen

  1. The next page is specified in Pagination object and is easy to get

What Happens

  1. There is no pagination in Python SDK and therefore no way to get the next page

[python] Update examples in readme

Steps to reproduce:

  1. Take a look the readme

What should happen:

  1. The examples are accurate and references to tinker.

What happens:

  1. Examples is outdated

Ignore generated code for reviews

How to Reproduce

  1. Look at the files in this project.

What Should Happen

  1. There is a .gitattributes file which lists generated code as generated.

What Happens

  1. There is no .gitattributes file.

Notes

  • This will make code review easier as of the generated code will be collapsed automatically .

Add proxy support to Python SDK

How to Reproduce

  1. Look for proxy in the SDK codebase

What Should Happen

  1. Proxy can be set in ApiContext

What Happens

  1. No proxy can be set in ApiContext

Missing a callback sample

Is it possible to ad a callback code sample.
The webserver i can configure my self etc but love to have a sample on how to setup the callback so for example when a pin or other transaction happens i can react on it.

Not an issue just a request :-)

Add strictly typed BunqResponses

How to Reproduce

  1. Write code to make a request via the SDK
  2. Write a code using the response of the request from (1)

What Should Happen

  1. The response.value has a strict type in docstring, and the IDE auto-completion works on it

What Happens

  1. The response.value doesn't have a strict type in docstring and therefore IDE auto-completion doesn't work on it

Auto save the session after automatic session reset has been executed 

Steps to reproduce:

  1. Make a request with an expired session

What should happen:

  1. The session gets automatically reset before the actual call is made.
  2. The reset session should be saved after the reset. So that the next call has a fresh new session, instead of resetting the session again.
  3. The user should be able to turn the automatic session save off.

What happens:

  1. If implemented incorrectly, users will make 6 calls to session-server within 2 seconds because on each call the session needs to be reset.

Logs

  • Logs no logs

Extra info:

Reference

needs #78

Callback models for holding callback data

Steps to reproduce:

  1. Receive a callback as described here: https://doc.bunq.com/api/1/page/callbacks

What should happen:

  1. There is a model available so that you can do the following:
$callbackModel = NotificationUrl::fromJson($CallbackJson);
$callbackModel->getReferencedObject();

if (!$callbackModel isntanceof CallbackModelImExcpeting) {
    throw new Exception();
}

What happens:

  1. Such thing is not possible yet

Logs

  • Logs no logs

Extra info:

Reference

Payment.list() pagination workaround

I heard from @OGKevin that pagination of payment lists does not work yet, but I wanted to ask whether you maybe have a temporary workaround for that?

I thought about maybe using the Payment ID, but I'm not sure whether that ID is specific per user (i.e. increases by 1 whenever the user makes a payment, independently of the actions of other users) or global (increases whenever any user makes a payment).

Do you maybe have an idea of a workaround in mind?

Add zappr integration for better quality control 

The purpose of this issue is to introduce https://zappr.opensource.zalan.do so that quality control on pull requests can be assured.

The following configuration should be used:

autobranch:
  pattern: 'bunq/sdk_python#{number}-{title}'
  length: 100
commit:
  message:
    patterns:
      - '([A-Za-z0-9 ]+)\. (\(bunq\/sdk_python#[0-9]+\))'
specification:
  title:
    minimum-length:
      enabled: true
      length: 8
  body:
    minimum-length:
      enabled: true
      length: 8
    contains-url: true
    contains-issue-number: true
  template:
    differs-from-body: true
pull-request:
  labels:
    additional: true
    required:
      - Reviewed by André
      - Can be merged

Name field for pointer counterparty

Hey Guys!

Awesome work on the API. Been playing around with it for a while now and thought now was the time to get into automated payments.

When doing this I ran into to the problem of transfering money to myself. The only way I found that would work, is to transfer it to the iban of the account I wanted it in.

So i started with the payment requestmap, like the example:

request_map = {
    generated.Payment.FIELD_AMOUNT: object_.Amount(
        str(pin_saving_amount),
        'EUR'
    ),
    generated.Payment.FIELD_COUNTERPARTY_ALIAS: object_.Pointer(
        'IBAN',
        'NL13BUNQ3713371337'
    ),
    generated.Payment.FIELD_DESCRIPTION: 'Pinsparen {}'.format(yesterday),
}

This bounded when creating the payment, because the name field was not set. Now i thought this was an error on my end, but looking in the SDK code I came across the reason didn't see it coming in the first place. Note that the api docs state this is needed, so I could have used my eyes to start with 😇 .

class Pointer(model.BunqModel):
    """
    :type type_: str
    :type value: str
    :type name: str
    """

    def __init__(self, type_, value):
        """
        :type type_: str
        :type value: str
        """

        self.type_ = type_
        self.value = value
        self.name = None

This is a piece of code from:

class Pointer(model.BunqModel):

As can be seen the name object is None by default and not set-able on init, which would make sense to do if you'd like to enforce people to use it in some cases.

Since this code is in the "generated" directory i didn't start creating a PR already, because i would like to verify if that would be a 'good move' or this is something that had to be done on bunq's side for generating the code.

Anyway, the following code would make a good replacement:

class Pointer(model.BunqModel):
    """
    :type type_: str
    :type value: str
    :type name: str
    """

    def __init__(self, type_, value, name=None):
        """
        :type type_: str
        :type value: str
        :type name: str
        """

        self.type_ = type_
        self.value = value
        self.name = name

This way name will be None by default, but at least set-able at creation 🙂

TokenQrRequestIdeal returns the wrong type

Steps to reproduce:

  1. Try to create a TokenQrRequestIdeal using the SDK.

What should happen:

  1. The item is created and a TokenQrRequestIdeal object is returned.

What happens:

  1. The API returns a RequestResponse object, but the SDK tries to cast it to a TokenQrRequestIdeal, resulting in an error.

Extra info:

Reference

Return base class from createFromJsonString

Steps to reproduce:

  1. Create a class from JSON string by using the method createFromJsonString

What should happen:

  1. The return value is casted to the subclass.

What happens:

  1. The return value is casted to BunqModel.

Logs

  • Logs No logs

Extra info:

Reference

Add more information to template

Steps to reproduce:

  1. Create a new issue or pull request

What should happen:

  1. The issue template should include a template to list the SDK version number and link to its release.
  2. There are comments explaining some basic flows.
  3. The PR template should contain a Tested check box and says which issue the PR will close.

What happens:

  1. The template is to basic.

Logs

  • Logs no logs

Extra info:

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.