public class FireBusinessAPI extends Object
Configure the API client with your API Token credentials.
Credentials credentials = new Credentials()
.setClientId("<clientId>")
.setClientKey("<clientKey>")
.setRefreshToken("<refreshToken>");
FireBusinessAPI api = new FireBusinessAPI().initialise(credentials);
Optionally, you can configure the API to use a different endpoint:
HttpConfiguration config = new HttpConfiguration();
config.setEndpoint("https://api-preprod.fire.com/business/v1");
FireBusinessAPI api = new FireBusinessAPI(config).initialise(credentials);
AccountListResponse accountList = api.send(new AccountListRequest());
Long accountId = accountList.getAccounts().get(0).getIcan();
AccountResponse account = api.send(new AccountRequest().setAccountId(accountId));
logger.info("Account details: {}, {} / {}", account.getName(), account.getCbic(), account.getCiban());
AccountTransactionListResponse transactions = api.send(
new AccountTransactionListRequest()
.setAccountId(2150l)
);
logger.info("Transaction 0 details: {}", transactions.getTransactions().get(0).getType());
Or a single transaction by ID:
TransactionResponse transaction = api.send(new TransactionRequest().setTransactionId(203162l));
Or filter by date range, keyword or transaction type.
AccountTransactionListResponse transactions = null;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
transactions = api.send(new AccountTransactionListRequest()
.setAccountId(2150l)
.setDateRangeFrom(df.parse("2017-05-01"))
.setDateRangeTo(df.parse("2017-06-01"))
);
} catch (ParseException e) {
e.printStackTrace();
}
logger.info("Transaction 0 details: {}", transactions.getTransactions().get(0).getType());
// All batches:
BatchListResponse batches = api.send(new BatchListRequest());
// Just the pending batches:
BatchListResponse batches = api.send( new BatchListRequest()
.setBatchStatuses(new BatchStatus[] { BatchStatus.PENDING_APPROVAL, BatchStatus.PENDING_PARENT_BATCH_APPROVAL })
);
logger.info("Batch 0 = {}", batches.getBatches().get(0).getBatchName());
Create a new batch, add an internal transfer and submit the batch:
// Create the Batch Object
Batch internalTransferBatch = new Batch()
.setType(Batch.BatchType.INTERNAL_TRANSFER)
.setCurrency("EUR")
.setBatchName("Java SDK test")
.setJobNumber("2019-01-09")
.setCallbackUrl("https://www.example.com/batch/callback");
// Open this batch in fire.com
BatchNewRequest newBatchRequest = new BatchNewRequest().setBatch(internalTransferBatch);
BatchNewResponse newBatch = api.send(newBatchRequest);
logger.info("New batch ID = {}", newBatch.getBatchUuid());
// Get the batchUUID
String batchUuid = newBatch.getBatchUuid();
// Create the internal transfer objects
InternalTransfer internalTransfer = new InternalTransfer()
.setAmount(500L)
.setIcanFrom(5532L)
.setIcanTo(2150L)
.setRef("Testing Java SDK");
// Add them to the batch
BatchAddItemResponse newItem = api.send(new BatchAddItemRequest()
.setBatchUuid(batchUuid)
.setBatchItem(internalTransfer)
);
// List the items in the batch if required
BatchListItemsResponse items = api.send(new BatchListItemsRequest()
.setBatchUuid(batchUuid)
.setBatchType(Batch.BatchType.INTERNAL_TRANSFER)
);
logger.info("Batch Items: {}", items.getBatchItems());
// Submit the batch for processing. Internal Transfer are processed immediately.
api.send(new BatchSubmitRequest().setBatchUuid(batchUuid));
Create a new batch, add external transfers of various types and submit the batch:
// Create the Batch Object
Batch internalTransferBatch = new Batch()
.setType(Batch.BatchType.BANK_TRANSFER)
.setCurrency("EUR")
.setBatchName("Java SDK test")
.setJobNumber("2019-01-09")
.setCallbackUrl("https://www.example.com/batch/callback");
// Open this batch in fire.com
BatchNewRequest newBatchRequest = new BatchNewRequest().setBatch(internalTransferBatch);
BatchNewResponse newBatch = api.send(newBatchRequest);
logger.info("New batch ID = {}", newBatch.getBatchUuid());
// Get the batchUUID
String batchUuid = newBatch.getBatchUuid();
// Create the bank transfer objects (Using account details)
BankTransfer bankTransfer = new BankTransfer()
.setAmount(1000L)
.setPayeeType(PayeeType.ACCOUNT_DETAILS)
.setDestAccountHolderName("John Q. Doe")
// GBP Account number and sort code
.setDestAccountNumber("12345678")
.setDestNsc("999999")
// EUR IBAN
.setDestIban("IE99BANK99999999999999")
.setIcanFrom(2150L)
.setMyRef("testing API")
.setYourRef("From API");
// Create the bank transfer objects (Using saved payee details)
BankTransfer bankTransfer = new BankTransfer()
.setAmount(1000L)
.setPayeeType(PayeeType.PAYEE_ID)
.setPayeeId(1231234L)
.setIcanFrom(2150L)
.setMyRef("testing API")
.setYourRef("From API");
// Add them to the batch
BatchAddItemResponse newItem = api.send(new BatchAddItemRequest()
.setBatchUuid(batchUuid)
.setBatchItem(bankTransfer)
);
// List the items in the batch if required
BatchListItemsResponse items = api.send(new BatchListItemsRequest()
.setBatchUuid(batchUuid)
.setBatchType(Batch.BatchType.BANK_TRANSFER)
);
logger.info("Batch Items: {}", items.getBatchItems());
// Submit the batch for processing. Bank Transfers require approval before they are processed.
api.send(new BatchSubmitRequest().setBatchUuid(batchUuid));
| Constructor and Description |
|---|
FireBusinessAPI()
Default Fire client constructor.
|
FireBusinessAPI(org.apache.http.client.HttpClient httpClient,
HttpConfiguration httpConfiguration)
Fire client constructor accepting configuration and a custom
HttpClient. |
FireBusinessAPI(HttpConfiguration httpConfiguration)
Fire client constructor accepting configuration.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.http.client.HttpClient |
getHttpClient()
Returns the
HttpClient used by this API Client |
HttpConfiguration |
getHttpConfiguration()
Returns the
HttpConfiguration used by this API Client |
FireBusinessAPI |
initialise(Credentials credentials)
Initialise the API Client with Credentials.
|
<T,U extends Response<U>> |
send(Request<T,U> request)
Sends a request to Fire.
|
FireBusinessAPI |
setHttpClient(org.apache.http.client.HttpClient httpClient)
Sets a customised
HttpClient after initialisation |
FireBusinessAPI |
setHttpConfiguration(HttpConfiguration httpConfiguration)
Sets a customised
HttpConfiguration after initialisation |
public FireBusinessAPI()
public FireBusinessAPI(HttpConfiguration httpConfiguration)
HttpConfiguration instance can be passed to this
constructor if a custom implementation is required.httpConfiguration - A custom configuration for this API client.public FireBusinessAPI(org.apache.http.client.HttpClient httpClient,
HttpConfiguration httpConfiguration)
HttpClient.
HttpClient and HttpConfiguration instances can be passed to this
constructor if a custom implementation is required.httpClient - A customised HttpClient for this API clienthttpConfiguration - A custom configuration for this API client.public org.apache.http.client.HttpClient getHttpClient()
HttpClient used by this API Clientpublic FireBusinessAPI setHttpClient(org.apache.http.client.HttpClient httpClient)
HttpClient after initialisationhttpClient - A customised HttpClient for this API clientpublic HttpConfiguration getHttpConfiguration()
HttpConfiguration used by this API Clientpublic FireBusinessAPI setHttpConfiguration(HttpConfiguration httpConfiguration)
HttpConfiguration after initialisationhttpConfiguration - A customised HttpConfiguration for this API clientpublic FireBusinessAPI initialise(Credentials credentials)
credentials - the API token credentials from fire.compublic <T,U extends Response<U>> U send(Request<T,U> request)
Request to the Fire Business API, and receive a Response.
For example:
AccountListResponse accountList = api.send(new AccountListRequest());
T - the class of the request objectU - the class of the response objectrequest - an object containing the details of the request.Copyright © 2019. All rights reserved.