Created
October 17, 2019 19:32
-
-
Save basst85/c52f70c82ecdbb326867470b7ca4a60a to your computer and use it in GitHub Desktop.
bunq_events_list.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import warnings | |
from bunq.sdk import context | |
from bunq.sdk.json import converter | |
from bunq.sdk.client import Pagination | |
from bunq.sdk.context import ApiContext | |
from bunq.sdk.context import ApiEnvironmentType | |
from bunq.sdk.context import BunqContext | |
from bunq.sdk.model.generated import endpoint | |
warnings.filterwarnings("ignore") | |
_API_KEY = 'your sandbox API key' | |
_DEVICE_DESCRIPTION = 'TestPython' | |
_CONFIG_FILE_LOCATION = 'bunq_sandbox.conf' | |
_MONETARY_ACCOUNT = '123456' # Replace with one of your monetary account id's | |
def run(): | |
# Run once and then comment | |
ApiContext( | |
ApiEnvironmentType.SANDBOX, | |
_API_KEY, | |
_DEVICE_DESCRIPTION).save(_CONFIG_FILE_LOCATION) | |
# Run always | |
api_context = ApiContext.restore(_CONFIG_FILE_LOCATION) | |
api_context.ensure_session_active() | |
api_context.save(_CONFIG_FILE_LOCATION) | |
BunqContext.load_api_context(api_context) | |
events_list = endpoint.Event.list( | |
params={'monetary_account_id':_MONETARY_ACCOUNT, 'display_user_event':'false'}) | |
for event in events_list.value: | |
if event.object_.MasterCardAction: | |
# List the descriptions of the card payments | |
print(event.object_.MasterCardAction.description) | |
# Run it only if called from the command line | |
if __name__ == '__main__': | |
run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment