@@ -33,13 +33,15 @@ context can be created by using the following code snippet:
33
33
```
34
34
apiContext = context.ApiContext(ENVIRONMENT_TYPE, API_KEY,
35
35
DEVICE_DESCRIPTION);
36
- apiContext.save(API_CONTEXT_FILE_PATH);
36
+ apiContext.save(API_CONTEXT_FILE_PATH)
37
+ context.BunqContext.loadApiContext(apiContext)
37
38
```
38
39
40
+ This code snippet, except for ` context.BunqContext.loadApiContext(apiContext) ` should be called once per API key.
41
+
39
42
#### Example
40
- See [ ` api_context_save_example.py ` ] ( ./examples/api_context_save_example.py )
41
43
42
- The API context can then be saved with:
44
+ See [ ` tinker/setup_context ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L44-L59 )
43
45
44
46
#### Safety considerations
45
47
The file storing the context details (i.e. ` bunq.conf ` ) is a key to your account. Anyone having
@@ -62,28 +64,15 @@ can be passed to requests.
62
64
63
65
64
66
```
65
- request_map = {
66
- generated.Payment.FIELD_AMOUNT: object_.Amount(
67
- _PAYMENT_AMOUNT,
68
- _PAYMENT_CURRENCY
69
- ),
70
- generated.Payment.FIELD_COUNTERPARTY_ALIAS: object_.Pointer(
71
- _COUNTERPARTY_POINTER_TYPE,
72
- _COUNTERPARTY_EMAIL
73
- ),
74
- generated.Payment.FIELD_DESCRIPTION: _PAYMENT_DESCRIPTION,
75
- }
76
-
77
- payment_id = generated.Payment.create(
78
- api_context,
79
- request_map,
80
- _USER_ITEM_ID,
81
- _MONETARY_ACCOUNT_ITEM_ID
82
- )
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
71
+ )
83
72
```
84
73
85
74
##### Example
86
- See [ ` PaymentExample.py ` ] ( ./examples/payment_example .py)
75
+ See [ ` tinker/make_payment ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib .py#L140-L151 )
87
76
88
77
#### Reading objects
89
78
Reading objects through the API requires an ` ApiContext ` , identifiers of all dependencies (such as
@@ -94,46 +83,38 @@ This type of calls always returns a model.
94
83
95
84
```
96
85
monetary_account = generated.MonetaryAccountBank.get(
97
- api_context,
98
- _USER_ITEM_ID,
99
86
_MONETARY_ACCOUNT_ITEM_ID
100
87
)
101
88
```
102
89
103
90
##### Example
104
- See [ ` MonetaryAccountExample.py ` ] ( ./examples/monetary_account_example .py)
91
+ See [ ` tinker/list_all_payment ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib .py#L85-L103 )
105
92
106
93
#### Updating objects
107
94
Updating objects through the API goes the same way as creating objects, except that also the object to update identifier
108
95
(ID or UUID) is needed.
109
96
110
97
```
111
- request_update_map = {
112
- generated.RequestInquiry.FIELD_STATUS: _STATUS_REVOKED,
113
- }
114
- generated.RequestInquiry.update(
115
- api_context,
116
- request_update_map,
117
- _USER_ITEM_ID,
118
- _MONETARY_ACCOUNT_ITEM_ID,
119
- request_id
120
- ).to_json()
98
+ endpoint.Card.update(
99
+ card_id=int(card_id),
100
+ monetary_account_current_id=int(account_id)
101
+ )
121
102
```
122
103
123
104
##### Example
124
- See [ ` RequestExample.py ` ] ( ./examples/request_example .py)
105
+ See [ ` tinker/update_card ` ] ( https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib .py#L167-L174 )
125
106
126
107
#### Deleting objects
127
108
Deleting objects through the API requires an ` ApiContext ` , identifiers of all dependencies (such as User ID required for
128
109
accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be
129
110
passed to requests.
130
111
131
112
```
132
- generated.CustomerStatementExport. delete(apiContext, userId, monetaryAccountId, customerStatementId);
113
+ Session. delete(self._SESSION_ID)
133
114
```
134
115
135
116
##### Example
136
- See [ ` CustomerStatementExportExample.py ` ] ( ./examples/customer_statement_export_example.py )
117
+
137
118
138
119
#### Listing objects
139
120
Listing objects through the API requires an ` ApiContext ` and identifiers of all dependencies (such as User ID required
@@ -147,37 +128,7 @@ users = generated.User.list(api_context)
147
128
See [ ` UserListExample.py ` ] ( ./examples/user_list_example.py )
148
129
149
130
## Running Samples
150
- In order to make the experience of getting into bunq Python SDK smoother, we
151
- have bundled it with example use cases (located under ` /examples ` ).
152
-
153
- To run an example, please do the following:
154
- 1 . In your IDE, open the example you are interested in and adjust the constants,
155
- such as ` _API_KEY ` or ` _USER_ID ` , to hold your data.
156
- 2 . In your terminal, go to the root of bunq SDK project:
157
-
158
- ``` shell
159
- $ cd /path/to/bunq/sdk/
160
- ```
161
- 3 . In the terminal, run:
162
-
163
- ``` shell
164
- $ python3 run.py examples/< something_example.py>
165
- ```
166
- Replace ` <something_example.py> ` with the name of the example you would like
167
- to run. If you wish to run the example with python 2, also replace
168
- ` python3 ` with ` python ` .
169
-
170
- In order for examples to run, you would need a valid context file (` bunq.conf ` )
171
- to be present in the bunq SDK project root directory. The file can either copied
172
- from somewhere else (e.g. tests) or created by running the following command
173
- in your bunq SDK project root directory:
174
-
175
- ``` shell
176
- $ python3 run.py examples/api_context_save_example.py
177
- ```
178
-
179
- Please do not forget to set the ` _API_KEY ` constant in
180
- ` api_context_save_example.py ` to your actual API key before running the sample!
131
+ To get an indication on how the SDK works you can use the python tinker which is located at https://github.com/bunq/tinker_python
181
132
182
133
## Running Tests
183
134
0 commit comments