@@ -33,13 +33,15 @@ context can be created by using the following code snippet:
3333```
3434apiContext = context.ApiContext(ENVIRONMENT_TYPE, API_KEY,
3535 DEVICE_DESCRIPTION);
36- apiContext.save(API_CONTEXT_FILE_PATH);
36+ apiContext.save(API_CONTEXT_FILE_PATH)
37+ context.BunqContext.loadApiContext(apiContext)
3738```
3839
40+ This code snippet, except for ` context.BunqContext.loadApiContext(apiContext) ` should be called once per API key.
41+
3942#### Example
40- See [ ` api_context_save_example.py ` ] ( ./examples/api_context_save_example.py )
4143
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 )
4345
4446#### Safety considerations
4547The 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.
6264
6365
6466```
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+ )
8372```
8473
8574##### 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 )
8776
8877#### Reading objects
8978Reading 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.
9483
9584```
9685monetary_account = generated.MonetaryAccountBank.get(
97- api_context,
98- _USER_ITEM_ID,
9986 _MONETARY_ACCOUNT_ITEM_ID
10087)
10188```
10289
10390##### 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 )
10592
10693#### Updating objects
10794Updating objects through the API goes the same way as creating objects, except that also the object to update identifier
10895(ID or UUID) is needed.
10996
11097```
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+ )
121102```
122103
123104##### 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 )
125106
126107#### Deleting objects
127108Deleting objects through the API requires an ` ApiContext ` , identifiers of all dependencies (such as User ID required for
128109accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be
129110passed to requests.
130111
131112```
132- generated.CustomerStatementExport. delete(apiContext, userId, monetaryAccountId, customerStatementId);
113+ Session. delete(self._SESSION_ID)
133114```
134115
135116##### Example
136- See [ ` CustomerStatementExportExample.py ` ] ( ./examples/customer_statement_export_example.py )
117+
137118
138119#### Listing objects
139120Listing 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)
147128See [ ` UserListExample.py ` ] ( ./examples/user_list_example.py )
148129
149130## 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
181132
182133## Running Tests
183134
0 commit comments