com.leonarduk.clearcheckbook.calls.AccountCall Maven / Gradle / Ivy
Show all versions of clearcheckbookapi Show documentation
/**
* AccountCall
*
* @author ${author}
* @since 10-Jul-2016
*/
package com.leonarduk.clearcheckbook.calls;
import java.util.List;
import org.apache.log4j.Logger;
import com.leonarduk.clearcheckbook.ClearCheckBookConnection;
import com.leonarduk.clearcheckbook.ClearcheckbookException;
import com.leonarduk.clearcheckbook.dto.AccountDataType;
import com.leonarduk.clearcheckbook.dto.ParsedNameValuePair;
/**
* The Class AccountCall.
*/
public class AccountCall extends AbstractCall
implements BulkProcessable {
/** The Constant _logger. */
private static final Logger _logger = Logger.getLogger(AccountCall.class);
/** The Constant TYPE. */
public static final String TYPE = "account";
/**
* Instantiates a new account call.
*
* @param connection
* the connection
*/
public AccountCall(final ClearCheckBookConnection connection) {
super(connection, AccountDataType.class);
}
/*
* (non-Javadoc)
*
* @see com.leonarduk.clearcheckbook.calls.AbstractCall#bulkProcess(java.util.List)
*/
@Override
public List bulkProcess(final List dataTypeList)
throws ClearcheckbookException {
return super.bulkProcess(dataTypeList);
}
/**
* Deletes a specific account
* Method: delete
* Call: account
*
* Example:
* https://username:[email protected]/api/account/
*
* Parameters:
* Parameter Required Description
* id Required the id of the account being deleted
*
* Returned Values:
* Value Description
* true / false returns true upon successfull delete or false/null on fail
*
* @param idParameter
* the id parameter
* @return boolean - ok
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public boolean delete(final ParsedNameValuePair idParameter) throws ClearcheckbookException {
return super.delete(idParameter);
}
/**
* Edit the details of an account
* Method: put
* Call: account
*
* Example:
* https://username:[email protected]/api/account/
*
* Parameters:
* Parameter Required Description
* id Required the id of the account being edited
* name Required the new name of the account
* type_id Required the new type_id of the account (1= Cash, 2= Checking Account, 3= Savings
* Account, 4= Credit Card, 5= Investment)
*
* Returned Values:
* Value Description
* true/false returns true on a successful edit or false on fail.
*
* @param input
* the input
* @return boolean - ok
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public boolean edit(final AccountDataType input) throws ClearcheckbookException {
return super.edit(input);
}
/**
* Returns an array of information for a single account
* Method: get
* Call: account
*
* Example:
* https://username:[email protected]/api/account/
*
* Parameters: vParameter Required Description
* id Required the id of the account you're getting information for
*
* Returned Values:
* Value Description
* id The account id
* name the name of the account
* type_id the type of account (1= Cash, 2= Checking Account, 3= Savings Account, 4= Credit
* Card, 5= Investment)
* deposit the float value containing the amount of deposits in this account.
* jive_deposit the float value containing the amount of jived deposits in this account.
* withdrawal the float value containing the amount of withdrawals in this account.
* jive_withdrawal the float value containing the amount of jived withdrawals in this account.
*
* @param id
* the id
* @return AccountDataType
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public AccountDataType get(final ParsedNameValuePair id) throws ClearcheckbookException {
final AccountDataType accountDataType = super.get(id);
AccountCall._logger.debug("get: " + id + " -> " + accountDataType);
return accountDataType;
}
public AccountDataType get(final String name) throws ClearcheckbookException {
final List accounts = this.getAll();
for (final AccountDataType accountDataType : accounts) {
if (accountDataType.getName().equals(name)) {
return accountDataType;
}
}
final String message = "Failed to find account " + name;
AccountCall._logger.warn(message);
throw new ClearcheckbookException(message);
}
/**
* Returns an array of all accounts and account balances for this user.
* Method: get
* Call: accounts
*
* Example:
* https://username:[email protected]/api/accounts/
*
* Parameters:
* Parameter Required Description
* is_overview Optional Should be set to "true" if you want to return all accounts that just
* have a balance (Including transactions not assigned to an account)
*
* Returned Values:
* Value Description
* id The account id
* name the name of the account
* type_id the type of account (1= Cash, 2= Checking Account, 3= Savings Account, 4= Credit
* Card, 5= Investment)
* deposit the float value containing the amount of deposits in this account.
* jive_deposit the float value containing the amount of jived deposits in this account.
* withdrawal the float value containing the amount of withdrawals in this account.
* jive_withdrawal the float value containing the amount of jived withdrawals in this account.
*
* @return returns a list of accounts.
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public List getAll() throws ClearcheckbookException {
return super.getAll();
}
/*
* (non-Javadoc)
*
* @see com.leonarduk.clearcheckbook.calls.AbstractCall#getUrlSuffix()
*/
@Override
protected String getUrlSuffix() {
return AccountCall.TYPE;
}
/**
* Adds an account to the site
* Method: post
* Call: account
*
* Example:
* https://username:[email protected]/api/account/
*
* Parameters:
* Parameter Required Description
* name Required The name of the account
* type_id Required the type of account (1= Cash, 2= Checking Account, 3= Savings Account, 4=
* Credit Card, 5= Investment)
* initial_balance Optional A float value identifying the existing balance in this account (if
* negative, put a '-' symbol before the number... -100.00)
*
* Returned Values:
* Value Description
* Multiple Responses* The newly created id for the account on success or false/null on fail.
*
* @param input
* the input
* @return id
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public String insert(final AccountDataType input) throws ClearcheckbookException {
return super.insert(input);
}
/*
* (non-Javadoc)
*
* @see
* com.leonarduk.clearcheckbook.calls.AbstractCall#process(com.leonarduk.clearcheckbook.dto.
* AbstractDataType)
*/
@Override
public String process(final AccountDataType dataType) throws ClearcheckbookException {
return super.process(dataType);
}
}