@@ -21,7 +21,7 @@ This SDK is in **beta**. We cannot guarantee constant availability or stability.
2121Thanks to your feedback we will make improvements on it.
2222
2323## Installation
24- `` pip install bunq_sdk --upgrade ``
24+ pip install bunq_sdk --upgrade
2525
2626## Usage
2727
@@ -30,19 +30,37 @@ In order to start making calls with the bunq API, you must first register your A
3030and create a session. In the SDKs, we group these actions and call it "creating an API context". The
3131context can be created by using the following code snippet:
3232
33- ```
34- apiContext = context.ApiContext(ENVIRONMENT_TYPE, API_KEY,
35- DEVICE_DESCRIPTION);
36- apiContext.save(API_CONTEXT_FILE_PATH)
37- context.BunqContext.loadApiContext(apiContext)
38- ```
3933
40- This code snippet, except for ` context.BunqContext.loadApiContext(apiContext) ` should be called once per API key.
34+ apiContext = ApiContext.create(ENVIRONMENT_TYPE, API_KEY, DEVICE_DESCRIPTION)
35+ apiContext.save(API_CONTEXT_FILE_PATH)
36+
37+
38+ ** Please note** : initialising your application is a heavy task and it is recommended to do it only once per device.
39+
40+ apiContext = ApiContext.restore(self.API_CONTEXT_FILE_PATH)
41+ BunqContext.loadApiContext(apiContext)
42+
43+ After saving the context, you can restore it at any time:
4144
4245#### Example
4346
4447See [ ` tinker/setup_context ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L44-L59 )
4548
49+ #### PSD2
50+ It is possible to create an ApiContext as PSD2 Service Provider. Although this might seem a complex task, we wrote some
51+ helper implementations to get you started. You need to create a certificate and private key to get you started.
52+ Our sandbox environment currently accepts all certificates, if these criteria are met:
53+
54+ - Up to 64 characters
55+ - PISP and/or AISP used in the end.
56+
57+ Make sure you have your unique eIDAS certificate number and certificates ready when you want to perform these tasks on
58+ our production environment.
59+
60+ Creating a PSD2 context is very easy:
61+
62+ apiContext = ApiContext.create_for_psd2(ENVIRONMENT_TYPE, CERTIFICATE, PRIVATE_KEY, CERTIFICATE_CHAIN, DEVICE_DESCRIPTION)
63+
4664#### Safety considerations
4765The file storing the context details (i.e. ` bunq.conf ` ) is a key to your account. Anyone having
4866access to it is able to perform any Public API actions with your account. Therefore, we recommend
@@ -62,14 +80,11 @@ Creating objects through the API requires an `ApiContext`, a `requestMap` and id
6280dependencies (such as User ID required for accessing a Monetary Account). Optionally, custom headers
6381can be passed to requests.
6482
65-
66- ```
67- payment_id = endpoint.Payment.create(
68- amount=Amount(amount_string, self._CURRENCY_EURL),
69- counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient),
70- description=description
83+ payment_id = endpoint.Payment.create(
84+ amount=Amount(amount_string, self._CURRENCY_EURL),
85+ counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient),
86+ description=description
7187 )
72- ```
7388
7489##### Example
7590See [ ` tinker/make_payment ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L140-L151 )
@@ -81,11 +96,9 @@ UUID) Optionally, custom headers can be passed to requests.
8196
8297This type of calls always returns a model.
8398
84- ```
85- monetary_account = generated.MonetaryAccountBank.get(
86- _MONETARY_ACCOUNT_ITEM_ID
87- )
88- ```
99+ monetary_account = generated.MonetaryAccountBank.get(
100+ _MONETARY_ACCOUNT_ITEM_ID
101+ )
89102
90103##### Example
91104See [ ` tinker/list_all_payment ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L85-L103 )
@@ -94,12 +107,10 @@ See [`tinker/list_all_payment`](https://github.com/bunq/tinker_python/blob/2182b
94107Updating objects through the API goes the same way as creating objects, except that also the object to update identifier
95108(ID or UUID) is needed.
96109
97- ```
98- endpoint.Card.update(
99- card_id=int(card_id),
100- monetary_account_current_id=int(account_id)
101- )
102- ```
110+ endpoint.Card.update(
111+ card_id=int(card_id),
112+ monetary_account_current_id=int(account_id)
113+ )
103114
104115##### Example
105116See [ ` tinker/update_card ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L167-L174 )
@@ -109,20 +120,15 @@ Deleting objects through the API requires an `ApiContext`, identifiers of all de
109120accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be
110121passed to requests.
111122
112- ```
113- Session.delete(self._SESSION_ID)
114- ```
123+ Session.delete(self._SESSION_ID)
115124
116125##### Example
117126
118-
119127#### Listing objects
120128Listing objects through the API requires an ` ApiContext ` and identifiers of all dependencies (such as User ID required
121129for accessing a Monetary Account). Optionally, custom headers can be passed to requests.
122130
123- ```
124- users = generated.User.list(api_context)
125- ```
131+ users = endpoint.User.list(api_context)
126132
127133##### Example
128134See [ ` UserListExample.py ` ] ( ./examples/user_list_example.py )
@@ -133,8 +139,8 @@ To get an indication on how the SDK works you can use the python tinker which is
133139## Running Tests
134140
135141Information regarding the test cases can be found in the [ README.md] ( ./tests/README.md )
136- located in [ test] ( /tests )
142+ located in [ test] ( /tests ) .
137143
138144## Exceptions
139145The SDK can raise multiple exceptions. For an overview of these exceptions please
140- take a look at [ EXCEPTIONS.md] ( ./bunq/sdk/exception/EXCEPTIONS.md )
146+ take a look at [ EXCEPTIONS.md] ( ./bunq/sdk/exception/EXCEPTIONS.md ) .
0 commit comments