klibqonto
A Qonto API client library for Kotlin, Java and more.
This library is written in Kotlin Multiplatform so in theory it can be used from the JVM, Android, and native iOS, Linux, MacOS, Windows and more. In practice this library has been tested and has samples for the JVM (Kotlin and Java), Android (Kotlin), MacOS (Kotlin), and iOS (Swift).
Several flavors of the client are available to match your needs:
- Coroutines (
suspend
) based: the default client for Kotlin projects - Blocking: useful for Java projects, or if you have your own async mechanism
- Callback based: useful for Java and Swift projects
Future
based (JVM only): useful for Java projects
Usage
Minimum requirements
- Java: 1.8? TODO
- Kotlin: 1.3? TODO
- Android: 21
- Swift: ? TODO
1/ Add the dependencies to your project
Gradle based projects
The artifacts are hosted on the Maven Central repository.
Note: prior to v2.3.0, the artifacts used to be hosted on JCenter.
repositories {
/* ... */
mavenCentral()
}
dependencies {
/* ... */
implementation 'org.jraf:klibqonto:2.4.0'
}
OSX based projects
TODO
2/ Use the client
The easiest way to see how to use it is to look at the samples:
- Coroutines (Kotlin)
- Blocking (Java)
- Callback (Kotlin)
- Callback (Swift) TODO
- Future (Java)
Authentication by login and secret key
You will find your login and secret key in the Qonto web application under Settings, in the Integrations (API) tab.
Authentication by OAuth
To use OAuth, you must register your application by reaching out to Qonto as documented here.
OAuth usage is demonstrated in the sample.
Instantiate a QontoClient
val qontoClient = QontoClient.newInstance(
ClientConfiguration(
LoginSecretKeyAuthentication(
LOGIN,
SECRET_KEY
)
// Or use OAuthAuthentication for OAuth
)
)
To get other flavors of the client:
- Blocking:
BlockingQontoClient blockingClient = BlockingQontoClientUtils.asBlockingQontoClient(qontoClient)
- Callback:
CallbackQontoClient callbackClient = CallbackQontoClientUtils.asCallbackQontoClient(qontoClient)
- Future:
FutureQontoClient futureClient = FutureQontoClientUtils.asFutureQontoClient(qontoClient)
Use the QontoClient
The client gives access to several API "areas":
oAuth
organizations
transactions
memberships
labels
attachments
Each area exposes related APIs, for instance: qontoClient.transactions.getTransactionList
.
Pagination
The APIs that are paginated all follow the same principle:
- take a
Pagination
object as a parameter, which defines the page to retrieve, as well as the number of items per page - return a
Page<T>
with the result list but also a reference to the next and previousPagination
objects (handy when retrieving several pages).
Logging
To log HTTP requests/response, pass a HttpConfiguration
to QontoClient.newInstance()
.
Several levels are available: NONE
, INFO
, HEADERS
, BODY
and ALL
Proxy
A proxy can be configured by passing a HttpConfiguration
to QontoClient.newInstance()
.
On Android, the proxy set in the system settings is automatically used.
Javascript support
In theory Kotlin Multiplatform projects can also target Javascript but as of today the author couldn't understand how to make that work. Please contact the author if you want to help :)
Author and License
Note: this project is not officially related to or endorsed by Qonto or Olinda SAS.
Copyright (C) 2019-present Benoit 'BoD' Lubek ([email protected])
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.