Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing a callback sample #15

Closed
CharlPels opened this issue Aug 17, 2017 · 7 comments

Comments

@CharlPels
Copy link

commented Aug 17, 2017

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 :-)

@OGKevin

This comment has been minimized.

Copy link
Contributor

commented Aug 17, 2017

Hey @CharlPels

Here an example to set a call back to UserPerson 👍

from bunq.sdk.model.generated.endpoint import UserPerson
from bunq.sdk.model.generated.object_ import NotificationFilter
from bunq.sdk.context import ApiContext

ctx = ApiContext.restore()
USER_ID = 400

filter_ = NotificationFilter('URL', 'myurl.com', 'BILLING')

request_body = {
    UserPerson.FIELD_NOTIFICATION_FILTERS: filter_
}

UserPerson.update(ctx, request_body, USER_ID)

Let me know if this is what you were looking for 😄.

@CharlPels

This comment has been minimized.

Copy link
Author

commented Aug 17, 2017

No luck, get an error
bunq.sdk.exception.ApiException: HTTP Response Code: 400
Invalid type for field "notification_filters" (expected ARRAY containing STRUCT).

filter i use is
filter_ = NotificationFilter('URL', 'https://bunqsample.azurewebsites.net/api1', 'BILLING')

@dnl-blkv

This comment has been minimized.

Copy link
Contributor

commented Aug 17, 2017

@OGKevin @CharlPels
I believe it should have been:

from bunq.sdk.model.generated.endpoint import UserPerson
from bunq.sdk.model.generated.object_ import NotificationFilter
from bunq.sdk.context import ApiContext

ctx = ApiContext.restore()
USER_ID = 400

filters = [NotificationFilter('URL', 'myurl.com', 'BILLING')]

request_body = {
    UserPerson.FIELD_NOTIFICATION_FILTERS: filters
}

UserPerson.update(ctx, request_body, USER_ID)

Source: https://doc.bunq.com/api/1/call/user-person/method/put

@CharlPels please let me know if this doesn't work. I did not run the code myself yet - will do so as the first thing tomorrow, if it still doesn't work :)

@OGKevin

This comment has been minimized.

Copy link
Contributor

commented Aug 18, 2017

@CharlPels 😁 I forgot to array it indeed @dnl-blkv example looks to be the correct example 😉

@CharlPels

This comment has been minimized.

Copy link
Author

commented Aug 18, 2017

It is working now, and now how to remove a callback endpoint would also be nice to know :-)

@OGKevin

This comment has been minimized.

Copy link
Contributor

commented Aug 18, 2017

@CharlPels To remove a callback you can do this:

filters = [NotificationFilter('PUSH', None, 'BILLING')]

You can read more about this here: https://together.bunq.com/topic/unregister-callback-webhook#comment-7926

UserPerson.update(ctx, request_body, USER_ID)

Will return an id as shown here: https://doc.bunq.com/api/1/call/user-company/method/put

If you get this id, means that the request came back with status 200 (which means everything went successful)

Afterwards depending on the category you've chosen, which are listed here: https://doc.bunq.com/api/1/page/callbacks

You will get a POST request to the url you defined.

@OGKevin

This comment has been minimized.

Copy link
Contributor

commented Aug 18, 2017

Closing the issue, feel free to comment afterwards.

@OGKevin OGKevin closed this Aug 18, 2017

@OGKevin OGKevin added the question label Oct 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.