@@ -21,7 +21,7 @@ This SDK is in **beta**. We cannot guarantee constant availability or stability.
21
21
Thanks to your feedback we will make improvements on it.
22
22
23
23
## Installation
24
- `` pip install bunq_sdk --upgrade ``
24
+ pip install bunq_sdk --upgrade
25
25
26
26
## Usage
27
27
@@ -30,19 +30,37 @@ In order to start making calls with the bunq API, you must first register your A
30
30
and create a session. In the SDKs, we group these actions and call it "creating an API context". The
31
31
context can be created by using the following code snippet:
32
32
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
- ```
39
33
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:
41
44
42
45
#### Example
43
46
44
47
See [ ` tinker/setup_context ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L44-L59 )
45
48
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
+
46
64
#### Safety considerations
47
65
The file storing the context details (i.e. ` bunq.conf ` ) is a key to your account. Anyone having
48
66
access 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
62
80
dependencies (such as User ID required for accessing a Monetary Account). Optionally, custom headers
63
81
can be passed to requests.
64
82
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
71
87
)
72
- ```
73
88
74
89
##### Example
75
90
See [ ` 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.
81
96
82
97
This type of calls always returns a model.
83
98
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
+ )
89
102
90
103
##### Example
91
104
See [ ` 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
94
107
Updating objects through the API goes the same way as creating objects, except that also the object to update identifier
95
108
(ID or UUID) is needed.
96
109
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
+ )
103
114
104
115
##### Example
105
116
See [ ` 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
109
120
accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be
110
121
passed to requests.
111
122
112
- ```
113
- Session.delete(self._SESSION_ID)
114
- ```
123
+ Session.delete(self._SESSION_ID)
115
124
116
125
##### Example
117
126
118
-
119
127
#### Listing objects
120
128
Listing objects through the API requires an ` ApiContext ` and identifiers of all dependencies (such as User ID required
121
129
for accessing a Monetary Account). Optionally, custom headers can be passed to requests.
122
130
123
- ```
124
- users = generated.User.list(api_context)
125
- ```
131
+ users = endpoint.User.list(api_context)
126
132
127
133
##### Example
128
134
See [ ` 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
133
139
## Running Tests
134
140
135
141
Information regarding the test cases can be found in the [ README.md] ( ./tests/README.md )
136
- located in [ test] ( /tests )
142
+ located in [ test] ( /tests ) .
137
143
138
144
## Exceptions
139
145
The 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