An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

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