Skip to content

Commit

Permalink
add v 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dnl-blkv authored and Daniil Belyakov committed Jul 31, 2017
1 parent 4fb168b commit ed763c4
Show file tree
Hide file tree
Showing 36 changed files with 13,528 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added CHANGELOG.md
Empty file.
131 changes: 131 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# bunq Java SDK
Version 0.9.0 **BETA**

## Installation
In the root of your project, being in the correct virtual environment, run:
```shell
(bunq_sdk_python) $ pip install bunq_sdk && pip freeze > requirements.txt
```

## Usage

### Creating an API context
In order to start making calls with the bunq API, you must first register your API key and device,
and create a session. In the SDKs, we group these actions and call it "creating an API context". The
context can be created by using the following code snippet:

```
apiContext = context.ApiContext(ENVIRONMENT_TYPE, API_KEY,
DEVICE_DESCRIPTION);
apiContext.save(API_CONTEXT_FILE_PATH);
```

#### Example
See [`api_context_save_example.py`](./examples/api_context_save_example.py)

The API context can then be saved with:

#### Safety considerations
The file storing the context details (i.e. `bunq.conf`) is a key to your account. Anyone having
access to it is able to perform any Public API actions with your account. Therefore, we recommend
choosing a truly safe place to store it.

### Making API calls
There is a class for each endpoint. Each class has functions for each supported action. These
actions can be `create`, `get`, `update`, `delete` and `list`.

Sometimes API calls have dependencies, for instance `MonetaryAccount`. Making changes to a monetary
account always also needs a reference to a `User`. These dependencies are required as arguments when
performing API calls. Take a look at [doc.bunq.com](https://doc.bunq.com) for the full
documentation.

#### Creating objects
Creating objects through the API requires an `ApiContext`, a `requestMap` and identifiers of all
dependencies (such as User ID required for accessing a Monetary Account). Optionally, custom headers
can be passed to requests.


```
request_map = {
generated.Payment.FIELD_AMOUNT: object_.Amount(
_PAYMENT_AMOUNT,
_PAYMENT_CURRENCY
),
generated.Payment.FIELD_COUNTERPARTY_ALIAS: object_.Pointer(
_COUNTERPARTY_POINTER_TYPE,
_COUNTERPARTY_EMAIL
),
generated.Payment.FIELD_DESCRIPTION: _PAYMENT_DESCRIPTION,
}
payment_id = generated.Payment.create(
api_context,
request_map,
_USER_ITEM_ID,
_MONETARY_ACCOUNT_ITEM_ID
)
```

##### Example
See [`PaymentExample.py`](./examples/payment_example.py)

#### Reading objects
Reading objects through the API requires an `ApiContext`, identifiers of all dependencies (such as
User ID required for accessing a Monetary Account), and the identifier of the object to read (ID or
UUID) Optionally, custom headers can be passed to requests.

This type of calls always returns a model.

```
monetary_account = generated.MonetaryAccountBank.get(
api_context,
_USER_ITEM_ID,
_MONETARY_ACCOUNT_ITEM_ID
)
```

##### Example
See [`MonetaryAccountExample.py`](./examples/monetary_account_example.py)

#### Updating objects
Updating objects through the API goes the same way as creating objects, except that also the object to update identifier
(ID or UUID) is needed.

```
request_update_map = {
generated.RequestInquiry.FIELD_STATUS: _STATUS_REVOKED,
}
generated.RequestInquiry.update(
api_context,
request_update_map,
_USER_ITEM_ID,
_MONETARY_ACCOUNT_ITEM_ID,
request_id
).to_json()
```

##### Example
See [`RequestExample.py`](./examples/request_example.py)

#### Deleting objects
Deleting objects through the API requires an `ApiContext`, identifiers of all dependencies (such as User ID required for
accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be
passed to requests.

```
generated.CustomerStatementExport.delete(apiContext, userId, monetaryAccountId, customerStatementId);
```

##### Example
See [`CustomerStatementExportExample.py`](./examples/customer_statement_export_example.py)

#### Listing objects
Listing objects through the API requires an `ApiContext` and identifiers of all dependencies (such as User ID required
for accessing a Monetary Account). Optionally, custom headers can be passed to requests.

```
users = generated.User.list(api_context)
```

##### Example
See [`UserListExample.py`](./examples/user_list_example.py)
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.9.0
Binary file added assets/attachment.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions bunq/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from bunq.sdk.json import registry

registry.initialize()
Empty file added bunq/sdk/__init__.py
Empty file.
Loading

0 comments on commit ed763c4

Please sign in to comment.