com.leonarduk.clearcheckbook.calls.ReminderCall Maven / Gradle / Ivy
Show all versions of clearcheckbookapi Show documentation
/**
* ReminderCall
*
* @author ${author}
* @since 10-Jul-2016
*/
package com.leonarduk.clearcheckbook.calls;
import java.io.IOException;
import java.util.List;
import org.apache.log4j.Logger;
import com.leonarduk.clearcheckbook.ClearCheckBookConnection;
import com.leonarduk.clearcheckbook.ClearcheckbookException;
import com.leonarduk.clearcheckbook.dto.ParsedNameValuePair;
import com.leonarduk.clearcheckbook.dto.ReminderDataType;
/**
* The Class ReminderCall.
*/
public class ReminderCall extends AbstractCall {
/** The Constant _logger. */
private static final Logger _logger = Logger.getLogger(ReminderCall.class);
/** The Constant TYPE. */
public static final String TYPE = "reminder";
/**
* Instantiates a new reminder call.
*
* @param connection
* the connection
*/
public ReminderCall(final ClearCheckBookConnection connection) {
super(connection, ReminderDataType.class);
}
/**
* Delete a single occurrence of a reminder for the current user.
* Method: delete
* Call: reminder
*
* Example:
* https://username:[email protected]/api/reminder/
*
* Parameters:
* Parameter Required Description
* id Required The id of the reminder to delete
*
* Returned Values:
* Value Description
* true / false Returns true on a successful delete or false/null on fail
*
* @param input
* the input
* @return true, if successful
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public boolean delete(final ParsedNameValuePair input) throws ClearcheckbookException {
return super.delete(input);
}
/**
* Delete all occurrences of a reminder for the current user.
* Method: delete
* Call: reminders
*
* Example:
* https://username:[email protected]/api/reminders/
*
* Parameters:
* Parameter Required Description
* id Required The id of the reminder to delete
*
* Returned Values:
* Value Description
* true / false Returns true on a successful delete or false/null on fail
*
* @param id
* the id
* @return true, if successful
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
public boolean deleteAll(final ParsedNameValuePair id) throws ClearcheckbookException {
ReminderCall._logger.debug("delete: " + id.getValue());
String returnString;
try {
returnString = this.getConnection().deletePage(this.getPluralUrl(), id);
final boolean ok = Boolean.valueOf(returnString);
ReminderCall._logger.info("insert : deleted " + ok);
return ok;
}
catch (final IOException e) {
throw new ClearcheckbookException(
"Failed to delete " + this.getUrlSuffix() + " id: " + id.getValue(), e);
}
}
/**
* Edit a specific reminder for the current user.
* Method: put
* Call: reminder
*
* Example:
* https://username:[email protected]/api/reminder/
*
* Parameters:
* Parameter Required Description
* reminder_id Required The id of the reminder being edited.
* title Required The title of the reminder
* email Required "true" or "false". "true" if you want to this email to remind the user
* emailDays Optional If email is set to "true", this is the number of days ahead of time the
* user will be emailed (1-7)
* start_year Required the year of the start date (YYYY)
* start_month Required the month of the start date (MM)
* start_day Required the day of the start date (DD)
* end_year Optional the year of the end date (YYYY)
* end_month Optional the month of the end date (MM)
* end_day Optional the day of the end date (DD)
* occur_once Optional "true" if this reminder is only occuring once.
* occur_repeating Optional "true" if this reminder is repeating
* occur_floating Optional "true" if this reminder is floating
* repeat_every Optional 1-4. 1=Day, 2=Week, 3=Month, 4=Year
* repeat_every_num Optional Integer for how often this should repeat. If set to 2 and
* repeat_every = 3, this reminder will repeat every 2 months.
* float_every Optional When this reminder floats. 0= Sunday, 1= Monday, 2= Tuesday, 3=
* Wednesday, 4= Thursday, 5= Friday, 6= Saturday, -1= Day
* float_every_num Optional When this reminder floats. 1= First, 2= Second, 3= Third, 4= Fourth,
* -1= Last
* transaction Required "true" or "false". "true" if there is a transaction associated with this
* reminder.
* trans_amount Optional The amount associated with the transaction
* trans_description Optional the description associated with the transaction
* trans_payee Optional the payee associated with this transaction
* trans_memo Optional the memo associated with this transaction
* trans_check_num Optional the check number associated with this transaction
* trans_account_id Optional the account_id associated with this transaction
* trans_category_id Optional the category_id associated with this transaction
* trans_transaction_type Optional The transaction type associated with this transaction.
* (0=withdrawal, 1=deposit, 3= transfer)
* trans_accountFrom Optional If trans_transaction_type = 3, this is the account_id you're
* transferring from
* trans_accountTo Optional If trans_transaction_type = 3, this is the account_id you're
* transferring to
*
* Returned Values:
* Value Description
* true / false Returns true on a successful edit or false/null on fail. NB - this appears to
* change the id so you cannot do edit (id) then get(id) as the id will change
*
* @param dataType
* the data type
* @return true, if successful
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public boolean edit(final ReminderDataType dataType) throws ClearcheckbookException {
return super.edit(dataType);
}
/**
* Returns information about a specific reminder.
* Method: get
* Call: reminder
*
* Example:
* https://username:[email protected]/api/reminder/
*
* Parameters:
* Parameter Required Description
* id Required The id of the reminder you want
*
* Returned Values:
* Value Description
* id the id of the reminder in the ClearCheckbook system
* title the title of the reminder
* start_date the date the reminder is set to start
* end_date the date the reminder is set to end
* notify 0 or 1. 1 if the user selected to be emailed before the reminder occurs.
* notify_time 0-7. The number of days ahead of the reminder the user would like to be emailed
*
* repeat 0 or 1. 1 if this reminder is set to repeat
* repeat_every_num Integer for how often this should repeat. If set to 2 and repeat_every = 3,
* this reminder will repeat every 2 months.
* repeat_every 1-4. 1=Day, 2=Week, 3=Month, 4=Year
* floats 0 or 1. 1 if this reminder is set to float
* floats_every_num When this reminder floats. 1= First, 2= Second, 3= Third, 4= Fourth, -1=
* Last
* floats_every When this reminder floats. 0= Sunday, 1= Monday, 2= Tuesday, 3= Wednesday, 4=
* Thursday, 5= Friday, 6= Saturday, -1= Day
* trans_amount If there is a recurring transaction associated with this reminder, this is the
* amount
* trans_description If there is a recurring transaction associated with this reminder, this is
* the description
* trans_transaction_type If there is a recurring transaction associated with this reminder,
* this is the transaction type (0=withdrawal, 1=deposit, 3= transfer)
* trans_account_id If there is a recurring transaction associated with this reminder, this is
* the account_id
* trans_category_id If there is a recurring transaction associated with this reminder, this is
* the category_id
* trans_transfertoaccount If there is a recurring transaction associated with this reminder,
* this is the account_id of the account being transferred to
* trans_check_num If there is a recurring transaction associated with this reminder, this is
* the check_num
* trans_memo If there is a recurring transaction associated with this reminder, this is the
* memo
* trans_payee If there is a recurring transaction associated with this reminder, this is the
* payee
*
* @param id
* the id
* @return the reminder data type
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public ReminderDataType get(final ParsedNameValuePair id) throws ClearcheckbookException {
final ReminderDataType reminderDataType = super.get(id);
ReminderCall._logger.debug("get: " + reminderDataType);
return reminderDataType;
}
/**
* Returns an array of reminders for the current user
* Method: get
* Call: reminders
*
* Example:
* https://username:[email protected]/api/reminders/
*
* Parameters:
* Parameter Required Description
* upcoming_days Optional The number of days worth of reminders you would like to receive.
* Default = 30
*
* Returned Values:
* Value Description
* reminder_id the id of the reminder in the ClearCheckbook system
* date the next date this reminder is set to occur on
* reminder_date_id the id of the date in the ClearCheckbook system
* title the title of the reminder
* start_date the date the reminder is set to start
* end_date the date the reminder is set to end
* notify 0 or 1. 1 if the user selected to be emailed before the reminder occurs.
* notify_time 0-7. The number of days ahead of the reminder the user would like to be emailed
*
* repeat 0 or 1. 1 if this reminder is set to repeat
* repeat_every_num Integer for how often this should repeat. If set to 2 and repeat_every = 3,
* this reminder will repeat every 2 months.
* repeat_every 1-4. 1=Day, 2=Week, 3=Month, 4=Year
* floats 0 or 1. 1 if this reminder is set to float
* floats_every_num When this reminder floats. 1= First, 2= Second, 3= Third, 4= Fourth, -1=
* Last
* floats_every When this reminder floats. 0= Sunday, 1= Monday, 2= Tuesday, 3= Wednesday, 4=
* Thursday, 5= Friday, 6= Saturday, -1= Day
* trans_amount If there is a recurring transaction associated with this reminder, this is the
* amount
* trans_description If there is a recurring transaction associated with this reminder, this is
* the description
* trans_transaction_type If there is a recurring transaction associated with this reminder,
* this is the transaction type (0=withdrawal, 1=deposit, 3= transfer)
* trans_account_id If there is a recurring transaction associated with this reminder, this is
* the account_id
* trans_category_id If there is a recurring transaction associated with this reminder, this is
* the category_id
* trans_transfertoaccount If there is a recurring transaction associated with this reminder,
* this is the account_id of the account being transferred to
* trans_check_num If there is a recurring transaction associated with this reminder, this is
* the check_num
* trans_memo If there is a recurring transaction associated with this reminder, this is the
* memo
* trans_payee If there is a recurring transaction associated with this reminder, this is the
* payee
*
* @return the all
* @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 ReminderCall.TYPE;
}
/**
* Inserts a reminder for the current user
* Method: post
* Call: reminder
*
* Example:
* https://username:[email protected]/api/reminder/
*
* Parameters:
* Parameter Required Description
* title Required The title of the reminder
* email Required "true" or "false". "true" if you want to this email to remind the user
* emailDays Optional If email is set to "true", this is the number of days ahead of time the
* user will be emailed (1-7)
* start_year Required the year of the start date (YYYY)
* start_month Required the month of the start date (MM)
* start_day Required the day of the start date (DD)
* end_year Optional the year of the end date (YYYY)
* end_month Optional the month of the end date (MM)
* end_day Optional the day of the end date (DD)
* occur_once Optional "true" if this reminder is only occuring once.
* occur_repeating Optional "true" if this reminder is repeating
* occur_floating Optional "true" if this reminder is floating
* repeat_every Optional 1-4. 1=Day, 2=Week, 3=Month, 4=Year
* repeat_every_num Optional Integer for how often this should repeat. If set to 2 and
* repeat_every = 3, this reminder will repeat every 2 months.
* float_every Optional When this reminder floats. 0= Sunday, 1= Monday, 2= Tuesday, 3=
* Wednesday, 4= Thursday, 5= Friday, 6= Saturday, -1= Day
* float_every_num Optional When this reminder floats. 1= First, 2= Second, 3= Third, 4= Fourth,
* -1= Last
* transaction Required "true" or "false". "true" if there is a transaction associated with this
* reminder.
* trans_amount Optional The amount associated with the transaction
* trans_description Optional the description associated with the transaction
* trans_payee Optional the payee associated with this transaction
* trans_memo Optional the memo associated with this transaction
* trans_check_num Optional the check number associated with this transaction
* trans_account_id Optional the account_id associated with this transaction
* trans_category_id Optional the category_id associated with this transaction
* trans_transaction_type Optional The transaction type associated with this transaction.
* (0=withdrawal, 1=deposit, 3= transfer)
* trans_accountFrom Optional If trans_transaction_type = 3, this is the account_id you're
* transferring from
* trans_accountTo Optional If trans_transaction_type = 3, this is the account_id you're
* transferring to
*
* Returned Values:
* Value Description
* id / false Returns the id of the newly created reminder or false/null on fail
*
* @param input
* the input
* @return the string
* @throws ClearcheckbookException
* the clearcheckbook exception
*/
@Override
public String insert(final ReminderDataType input) throws ClearcheckbookException {
return super.insert(input);
}
}