Skip to content

Commit 594dbb5

Browse files
authored
Merge pull request #152 from WinkPascal/develop
bunq Update 28 | Update object naming, fix parsing and fix tests
2 parents 2218b0d + 678a432 commit 594dbb5

File tree

325 files changed

+13781
-7673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+13781
-7673
lines changed

.DS_Store

-8 KB
Binary file not shown.

.gitignore

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
1-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
2-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3-
4-
# User-specific stuff:
5-
.idea/**/workspace.xml
6-
.idea/**/tasks.xml
7-
.idea/dictionaries
8-
9-
# Sensitive or high-churn files:
10-
.idea/**/dataSources/
11-
.idea/**/dataSources.ids
12-
.idea/**/dataSources.xml
13-
.idea/**/dataSources.local.xml
14-
.idea/**/sqlDataSources.xml
15-
.idea/**/dynamic.xml
16-
.idea/**/uiDesigner.xml
17-
18-
# Gradle:
19-
.idea/**/gradle.xml
20-
.idea/**/libraries
21-
221
# CMake
232
cmake-build-debug/
243

25-
# Mongo Explorer plugin:
26-
.idea/**/mongoSettings.xml
27-
284
## File-based project format:
295
*.iws
306

@@ -33,14 +9,11 @@ cmake-build-debug/
339
# IntelliJ
3410
/out/
3511

36-
# mpeltonen/sbt-idea plugin
37-
.idea_modules/
38-
3912
# JIRA plugin
4013
atlassian-ide-plugin.xml
4114

42-
# Cursive Clojure plugin
43-
.idea/replstate.xml
15+
# IDE
16+
.idea
4417

4518
# Crashlytics plugin (for Android Studio and IntelliJ)
4619
com_crashlytics_export_strings.xml
@@ -72,5 +45,11 @@ context-save-restore-test.conf
7245
/tmp
7346
config.properties
7447
bunq-test.conf
75-
.idea/codeStyles/
76-
.idea
48+
49+
# Test files
50+
/src/test/Resource/bunq-oauth-test.conf
51+
/src/test/Resource/bunq-psd2-test.conf
52+
/src/test/Resource/certificate.pem
53+
/src/test/Resource/key.pem
54+
55+
.DS_STORE

README.md

Lines changed: 1 addition & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1 @@
1-
# bunq Java SDK
2-
3-
## Introduction
4-
Hi developers!
5-
6-
Welcome to the bunq Java SDK! 👨‍💻
7-
8-
We're very happy to introduce yet another unique product: complete banking SDKs!
9-
Now you can build even bigger and better apps and integrate them with your bank of the free! 🌈
10-
11-
Before you dive into this brand new SDK, please consider:
12-
- Learning how bunq works and what objects you will work with by reading [the intro to our API](https://github.com/bunq/doc/blob/develop/README.md) 🤓
13-
- Checking out [our developer portal](https://developer.bunq.com/) 🙌
14-
- Grabbing your Production API key from [our developer portal](https://developer.bunq.com/) or the bunq app 🗝
15-
- Generating a Sandbox API key using [our developer portal](https://developer.bunq.com/) or [Tinker](https://www.bunq.com/developer) 🗝
16-
- Visiting [our forum](https://together.bunq.com/t/api) where you can share your creations,
17-
questions and experience 🎤
18-
19-
Give us your feedback, create pull requests, build your very own bunq apps and most importantly:
20-
have fun! 💪
21-
22-
This SDK is in **beta**. We cannot guarantee constant availability or stability.
23-
Thanks to your feedback we will make improvements on it.
24-
25-
## Installation
26-
To install the package, please follow the instructions corresponding to your build tool under "How to" on the package page on JitPack: https://jitpack.io/#bunq/sdk_java
27-
28-
## Usage
29-
30-
### Creating an API context
31-
In order to start making calls with the bunq API, you must first register your API key and device,
32-
and create a session. In the SDKs, we group these actions and call it "creating an API context". The
33-
context can be created by using the following code snippet:
34-
35-
```
36-
ApiContext apiContext = ApiContext.create(ENVIRONMENT_TYPE, API_KEY,
37-
DEVICE_DESCRIPTION);
38-
apiContext.save(API_CONTEXT_FILE_PATH);
39-
```
40-
41-
**Please note:** <u>initialising your application is a heavy task and it is recommended to do it only once per device.</u>
42-
43-
After saving the context, you can restore it at any time:
44-
45-
```
46-
ApiContext apiContext = ApiContext.restore(API_CONTEXT_FILE_PATH);
47-
BunqContext.loadApiContext(apiContext);
48-
```
49-
50-
**Tip:** both saving and restoring the context can be done without any arguments. In this case the context will be saved to/restored from the `bunq.conf` file in the same folder with your executable.
51-
52-
#### Example
53-
See [`tinker/load_api_context`](https://github.com/bunq/tinker_java/blob/b03cbc2b84f35de9721a4083843c4015665d67f8/src/main/java/com/bunq/tinker/libs/BunqLib.java#L96-L101)
54-
55-
##### PSD2
56-
It is possible to create an ApiContext as PSD2 Service Provider. Although this might seem a complex task, we wrote some helper implementations to get you started.
57-
You need to create a certificate and private key to get you started. Our sandbox environment currently accepts all certificates, if these criteria are met:
58-
- Up to 64 characters
59-
- PISP and/or AISP used in the end.
60-
61-
Make sure you have your unique eIDAS certificate number and certificates ready when you want to perform these tasks on our production environment.
62-
63-
Creating a PSD2 context is very easy:
64-
```java
65-
ApiContext apiContext = ApiContext.createForPsd2(
66-
ENVIRONMENT_TYPE,
67-
SecurityUtils.getCertificateFromFile(PATH_TO_CERTIFICATE),
68-
SecurityUtils.getPrivateKeyFromFile(PATH_TO_PRIVATE_KEY),
69-
new Certificate[]{
70-
SecurityUtils.getCertificateFromFile(PATH_TO_CERTIFICATE_CHAIN)
71-
},
72-
DESCRIPTION
73-
)
74-
```
75-
76-
This context can be saved the same way as a normal ApiContext. After creating this context, create an OAuth client to get your users to grant you access.
77-
For a more detailed example, check the [tinker_java](https://github.com/bunq/tinker_java/) repository.
78-
79-
#### Safety considerations
80-
The file storing the context details (i.e. `bunq.conf`) is a key to your account. Anyone having
81-
access to it is able to perform any Public API actions with your account. Therefore, we recommend
82-
choosing a truly safe place to store it.
83-
84-
### Making API calls
85-
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`.
86-
87-
When making calls, The `userId` and `monetaryAccountId` needed to make calls will be determined by the SDK it. When no `monetaryAccountId` has been passed, the SDK will use the first active monetary account it can find. This is normally the monetary account used for billing.
88-
89-
Before you make a call, make sure that you have loaded `ApiContext` in to the `BunqContext`.
90-
91-
#### Creating objects
92-
With the `create` method you can create new models. This method normally returns the `id` of the created model.
93-
94-
95-
```
96-
Payment.create(
97-
new Amount(amount, CURRENCY_EURO),
98-
new Pointer(POINTER_TYPE_EMAIL, recipient),
99-
description
100-
);
101-
```
102-
103-
##### Example
104-
See [`tinker/make_payment`](https://github.com/bunq/tinker_java/blob/cc41ff072d01e61b44bb53169edb80bde9620dc5/src/main/java/com/bunq/tinker/MakePayment.java#L46)
105-
106-
##### NotificationFilters / Callbacks
107-
**Note!** Due to an in internal change in the way we handle `NotificationFilters` (Callbacks), you should not use the default classes included in this SDK.
108-
Please make sure you make use of the associated `Internal`-classes. For example when you need `NotificationFilterUrlUser`, make use of `NotificationFilterUrlUserInternal`.
109-
You can use every method of these classes, except for the `create()` method. **Always use `createWithListResponse()` instead.**
110-
111-
##### Example
112-
```java
113-
NotificationFilterPushUserInternal.createWithListResponse(...)
114-
NotificationFilterUrlUserInternal.createWithListResponse(...)
115-
NotificationFilterUrlMonetaryAccountInternal.createWithListResponse(...)
116-
```
117-
#### Reading objects
118-
119-
Reading objects can be done via the `get` or `list` method.
120-
121-
These type of calls always returns the model or binary data.
122-
123-
```
124-
Payment.list(
125-
monetaryAccountBank.getId(),
126-
pagination.getUrlParamsCountOnly()
127-
)
128-
```
129-
130-
##### Example
131-
See [`tinker/get_all_payment`](https://github.com/bunq/tinker_java/blob/b03cbc2b84f35de9721a4083843c4015665d67f8/src/main/java/com/bunq/tinker/libs/BunqLib.java#L161-L164)
132-
133-
#### Updating objects
134-
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.
135-
136-
The `update` method will also normally return the `Id` of the updated model.
137-
138-
```
139-
MonetaryAccountBank.update(Integer.parseInt(accountId), name);
140-
```
141-
142-
##### Example
143-
See [`tinker/update_monetary_account`](https://github.com/bunq/tinker_java/blob/b03cbc2b84f35de9721a4083843c4015665d67f8/src/main/java/com/bunq/tinker/UpdateAccount.java#L36)
144-
145-
#### Deleting objects
146-
147-
Deleting object can be done via the `delete` method. This method also requires the object identifier which could be an `Id` or `uuid`.
148-
149-
This method normally returns an empty response.
150-
151-
```
152-
CustomerStatementExport.delete(customerStatementId);
153-
```
154-
155-
## Running Examples
156-
157-
To have an idea on how the SDK works you can play around with the java tinker located at: https://github.com/bunq/tinker_java
158-
159-
## Running tests
160-
Information regarding the test cases can be found in the [README.md](./src/test/README.md)
161-
located in [test](/src/test).
162-
163-
## Exceptions
164-
The SDK can throw multiple exceptions. For an overview of these exceptions please
165-
take a look at [EXCEPTIONS.md](./src/main/java/com/bunq/sdk/exception/EXCEPTIONS.md)
1+
📚 For full documentation about this sdk, visit [doc.bunq.com](https://doc.bunq.com/getting-started/tools/software-development-kits-sdks/java/usage).

build.gradle

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ group 'com.bunq.sdk'
22
version '1.14.1'
33

44
apply plugin: 'java'
5-
apply plugin: 'maven'
6-
sourceCompatibility = 1.8
5+
apply plugin: 'maven-publish'
76

7+
sourceCompatibility = 1.8
8+
targetCompatibility = 1.8
89

910
sourceSets {
1011
main {
@@ -22,23 +23,23 @@ repositories {
2223

2324
dependencies {
2425
// https://mvnrepository.com/artifact/junit/junit
25-
testCompile group: 'junit', name: 'junit', version: '4.13'
26+
testImplementation group: 'junit', name: 'junit', version: '4.13'
2627
// https://mvnrepository.com/artifact/com.google.code.gson/gson
27-
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
28+
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
2829
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
29-
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.9'
30+
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.9'
3031
// https://mvnrepository.com/artifact/commons-io/commons-io
31-
compile group: 'commons-io', name: 'commons-io', version: '2.7'
32+
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
3233
// https://mvnrepository.com/artifact/com.squareup.okio/okio
33-
compile group: 'com.squareup.okio', name: 'okio', version: '1.17.5'
34+
implementation group: 'com.squareup.okio', name: 'okio', version: '1.17.5'
3435
// https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api
35-
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
36+
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
3637
// https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core
37-
compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0.1'
38+
implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0.1'
3839
// https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl
39-
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.3'
40+
implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.3'
4041
// https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
41-
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
42+
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
4243
}
4344

4445
apply plugin: 'idea'

gradle/wrapper/gradle-wrapper.jar

7.04 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
4-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
4+
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)