https://github.com/rubenwardy/monzo_retrofit
Monzo API wrapper using RetroFit
https://github.com/rubenwardy/monzo_retrofit
Last synced: about 2 months ago
JSON representation
Monzo API wrapper using RetroFit
- Host: GitHub
- URL: https://github.com/rubenwardy/monzo_retrofit
- Owner: rubenwardy
- License: mit
- Created: 2016-11-19T17:25:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-19T18:48:06.000Z (over 8 years ago)
- Last Synced: 2025-02-12T20:37:59.832Z (4 months ago)
- Language: Java
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-monzo - Monzo Retrofit - Clean class based API interaction using Retrofit (Code & Client Libraries)
README
# MonzoAPI Retrofit
License: MIT.
Created by rubenwardy## Installation
This library isn't currently on Maven, so you'll need to download a .jar archive
[from the releases section](https://github.com/rubenwardy/monzo_retrofit/releases),
place it in `libs`, and then add the following to the repositories and dependences
part of your app's Gradle file:```Gradle
repositories {
flatDir {
dirs 'libs'
}
}dependencies {
compile name: 'monzo_retrofit-M.M.P'
}
```Replace M.M.P with the version you choose.
## Aquiring a Retrofit Interface
Use MonzoAPIBuilder to create MonzoAPI instances.
```Java
MonzoAPI monzo_unauthorized = MonzoAPIBuilder.createService();
MonzoAPI monzo_authorized = MonzoAPIBuilder.createService("accesstoken");
```MonzoAPI is an interface which specifies MonzoAPI endpoints.
## Endpoints
### Exchange Auth Token for AccessToken
Get an access token. The first parameter must be "authorization_code".
```Java
monzo_unauthorized.getAccessTokenFromAuthCode("authorization_code", BuildConfig.CLIENT_ID,
BuildConfig.CLIENT_SECRET, redirectUri, code).enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
AccessToken token = response.body();
if (token != null) {
// success
} else {
// failure
}
}@Override
public void onFailure(Call call, Throwable t) {
// failure
}
});
```### Getting list of accounts
```Java
monzo_authorized.getAccounts().enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
MonzoAPIService.AccountList accountList = response.body();
if (accountList != null && accountList.accounts.size() > 0) {
List accounts = accountList.accounts;
// success
} else {
// failure
}
}@Override
public void onFailure(Call call, Throwable t) {
// failure
}
});
```### Getting transactions
The second parameter must be "merchant" - the future we'll make this optional.
```Java
monzo_authorized.getTransactions(account_id, "merchant").enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
if (response.body() != null) {
List full_transactions = response.body().transactions;
// success
} else {
// failure
}
}@Override
public void onFailure(Call call, Throwable t) {
// failure
}
});
```### Get Balance
```Java
monzo_authorized.getBalance(account_id).enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
Balance balance = response.body();
if (balance != null) {
// success
} else {
// failure
}
}@Override
public void onFailure(Call call, Throwable t) {
// failure
}
});
```### Coming Soon (PRs accepted)
* Ping
* Token refresh
* Pagination support
* Retrieve single transaction from id
* Annotate transaction
* Create feed item
* Webhooks
* create
* list
* delete
* Attachments
* upload
* register
* deregister