View Javadoc

1   package com.leonarduk.clearcheckbook.calls;
2   
3   import java.io.IOException;
4   import java.util.List;
5   
6   import org.apache.log4j.Logger;
7   
8   import com.leonarduk.clearcheckbook.ClearCheckBookConnection;
9   import com.leonarduk.clearcheckbook.ClearcheckbookException;
10  import com.leonarduk.clearcheckbook.dto.ParsedNameValuePair;
11  import com.leonarduk.clearcheckbook.dto.ReminderDataType;
12  
13  public class ReminderCall extends AbstractCall<ReminderDataType> {
14  
15  	private static final Logger _logger = Logger.getLogger(ReminderCall.class);
16  
17  	public static final String TYPE = "reminder";
18  
19  	public ReminderCall(ClearCheckBookConnection connection) {
20  		super(connection, ReminderDataType.class);
21  	}
22  
23  	@Override
24  	protected String getUrlSuffix() {
25  		return TYPE;
26  	}
27  
28  	/***
29  	 * Returns an array of reminders for the current user <br>
30  	 * Method: get <br>
31  	 * Call: reminders
32  	 * <p>
33  	 * Example: <br>
34  	 * https://username:password@www.clearcheckbook.com/api/reminders/
35  	 * <p>
36  	 * Parameters: <br>
37  	 * Parameter Required Description <br>
38  	 * upcoming_days Optional The number of days worth of reminders you would
39  	 * like to receive. Default = 30
40  	 * <p>
41  	 * Returned Values: <br>
42  	 * Value Description <br>
43  	 * reminder_id the id of the reminder in the ClearCheckbook system <br>
44  	 * date the next date this reminder is set to occur on <br>
45  	 * reminder_date_id the id of the date in the ClearCheckbook system <br>
46  	 * title the title of the reminder <br>
47  	 * start_date the date the reminder is set to start <br>
48  	 * end_date the date the reminder is set to end <br>
49  	 * notify 0 or 1. 1 if the user selected to be emailed before the reminder
50  	 * occurs. <br>
51  	 * notify_time 0-7. The number of days ahead of the reminder the user would
52  	 * like to be emailed <br>
53  	 * repeat 0 or 1. 1 if this reminder is set to repeat <br>
54  	 * repeat_every_num Integer for how often this should repeat. If set to 2
55  	 * and repeat_every = 3, this reminder will repeat every 2 months. <br>
56  	 * repeat_every 1-4. 1=Day, 2=Week, 3=Month, 4=Year <br>
57  	 * floats 0 or 1. 1 if this reminder is set to float <br>
58  	 * floats_every_num When this reminder floats. 1= First, 2= Second, 3=
59  	 * Third, 4= Fourth, -1= Last <br>
60  	 * floats_every When this reminder floats. 0= Sunday, 1= Monday, 2= Tuesday,
61  	 * 3= Wednesday, 4= Thursday, 5= Friday, 6= Saturday, -1= Day <br>
62  	 * trans_amount If there is a recurring transaction associated with this
63  	 * reminder, this is the amount <br>
64  	 * trans_description If there is a recurring transaction associated with
65  	 * this reminder, this is the description <br>
66  	 * trans_transaction_type If there is a recurring transaction associated
67  	 * with this reminder, this is the transaction type (0=withdrawal,
68  	 * 1=deposit, 3= transfer) <br>
69  	 * trans_account_id If there is a recurring transaction associated with this
70  	 * reminder, this is the account_id <br>
71  	 * trans_category_id If there is a recurring transaction associated with
72  	 * this reminder, this is the category_id <br>
73  	 * trans_transfertoaccount If there is a recurring transaction associated
74  	 * with this reminder, this is the account_id of the account being
75  	 * transferred to <br>
76  	 * trans_check_num If there is a recurring transaction associated with this
77  	 * reminder, this is the check_num <br>
78  	 * trans_memo If there is a recurring transaction associated with this
79  	 * reminder, this is the memo <br>
80  	 * trans_payee If there is a recurring transaction associated with this
81  	 * reminder, this is the payee
82  	 */
83  	@Override
84  	public List<ReminderDataType> getAll() throws ClearcheckbookException {
85  		return super.getAll();
86  	}
87  
88  	/***
89  	 * Returns information about a specific reminder. <br>
90  	 * Method: get <br>
91  	 * Call: reminder
92  	 * <p>
93  	 * Example: <br>
94  	 * https://username:password@www.clearcheckbook.com/api/reminder/
95  	 * <p>
96  	 * Parameters: <br>
97  	 * Parameter Required Description <br>
98  	 * id Required The id of the reminder you want
99  	 * <p>
100 	 * Returned Values: <br>
101 	 * Value Description <br>
102 	 * id the id of the reminder in the ClearCheckbook system <br>
103 	 * title the title of the reminder <br>
104 	 * start_date the date the reminder is set to start <br>
105 	 * end_date the date the reminder is set to end <br>
106 	 * notify 0 or 1. 1 if the user selected to be emailed before the reminder
107 	 * occurs. <br>
108 	 * notify_time 0-7. The number of days ahead of the reminder the user would
109 	 * like to be emailed <br>
110 	 * repeat 0 or 1. 1 if this reminder is set to repeat <br>
111 	 * repeat_every_num Integer for how often this should repeat. If set to 2
112 	 * and repeat_every = 3, this reminder will repeat every 2 months. <br>
113 	 * repeat_every 1-4. 1=Day, 2=Week, 3=Month, 4=Year <br>
114 	 * floats 0 or 1. 1 if this reminder is set to float <br>
115 	 * floats_every_num When this reminder floats. 1= First, 2= Second, 3=
116 	 * Third, 4= Fourth, -1= Last <br>
117 	 * floats_every When this reminder floats. 0= Sunday, 1= Monday, 2= Tuesday,
118 	 * 3= Wednesday, 4= Thursday, 5= Friday, 6= Saturday, -1= Day <br>
119 	 * trans_amount If there is a recurring transaction associated with this
120 	 * reminder, this is the amount <br>
121 	 * trans_description If there is a recurring transaction associated with
122 	 * this reminder, this is the description <br>
123 	 * trans_transaction_type If there is a recurring transaction associated
124 	 * with this reminder, this is the transaction type (0=withdrawal,
125 	 * 1=deposit, 3= transfer) <br>
126 	 * trans_account_id If there is a recurring transaction associated with this
127 	 * reminder, this is the account_id <br>
128 	 * trans_category_id If there is a recurring transaction associated with
129 	 * this reminder, this is the category_id <br>
130 	 * trans_transfertoaccount If there is a recurring transaction associated
131 	 * with this reminder, this is the account_id of the account being
132 	 * transferred to <br>
133 	 * trans_check_num If there is a recurring transaction associated with this
134 	 * reminder, this is the check_num <br>
135 	 * trans_memo If there is a recurring transaction associated with this
136 	 * reminder, this is the memo <br>
137 	 * trans_payee If there is a recurring transaction associated with this
138 	 * reminder, this is the payee
139 	 */
140 	@Override
141 	public ReminderDataType get(ParsedNameValuePair id)
142 			throws ClearcheckbookException {
143 		ReminderDataType reminderDataType = super.get(id);
144 		_logger.debug("get: " + reminderDataType);
145 		return reminderDataType;
146 	}
147 
148 	/***
149 	 * Inserts a reminder for the current user <br>
150 	 * Method: post <br>
151 	 * Call: reminder
152 	 * <p>
153 	 * Example: <br>
154 	 * https://username:password@www.clearcheckbook.com/api/reminder/
155 	 * <p>
156 	 * Parameters: <br>
157 	 * Parameter Required Description <br>
158 	 * title Required The title of the reminder <br>
159 	 * email Required "true" or "false". "true" if you want to this email to
160 	 * remind the user <br>
161 	 * emailDays Optional If email is set to "true", this is the number of days
162 	 * ahead of time the user will be emailed (1-7) <br>
163 	 * start_year Required the year of the start date (YYYY) <br>
164 	 * start_month Required the month of the start date (MM) <br>
165 	 * start_day Required the day of the start date (DD) <br>
166 	 * end_year Optional the year of the end date (YYYY) <br>
167 	 * end_month Optional the month of the end date (MM) <br>
168 	 * end_day Optional the day of the end date (DD) <br>
169 	 * occur_once Optional "true" if this reminder is only occuring once. <br>
170 	 * occur_repeating Optional "true" if this reminder is repeating <br>
171 	 * occur_floating Optional "true" if this reminder is floating <br>
172 	 * repeat_every Optional 1-4. 1=Day, 2=Week, 3=Month, 4=Year <br>
173 	 * repeat_every_num Optional Integer for how often this should repeat. If
174 	 * set to 2 and repeat_every = 3, this reminder will repeat every 2 months.
175 	 * <br>
176 	 * float_every Optional When this reminder floats. 0= Sunday, 1= Monday, 2=
177 	 * Tuesday, 3= Wednesday, 4= Thursday, 5= Friday, 6= Saturday, -1= Day <br>
178 	 * float_every_num Optional When this reminder floats. 1= First, 2= Second,
179 	 * 3= Third, 4= Fourth, -1= Last <br>
180 	 * transaction Required "true" or "false". "true" if there is a transaction
181 	 * associated with this reminder. <br>
182 	 * trans_amount Optional The amount associated with the transaction <br>
183 	 * trans_description Optional the description associated with the
184 	 * transaction <br>
185 	 * trans_payee Optional the payee associated with this transaction <br>
186 	 * trans_memo Optional the memo associated with this transaction <br>
187 	 * trans_check_num Optional the check number associated with this
188 	 * transaction <br>
189 	 * trans_account_id Optional the account_id associated with this transaction
190 	 * <br>
191 	 * trans_category_id Optional the category_id associated with this
192 	 * transaction <br>
193 	 * trans_transaction_type Optional The transaction type associated with this
194 	 * transaction. (0=withdrawal, 1=deposit, 3= transfer) <br>
195 	 * trans_accountFrom Optional If trans_transaction_type = 3, this is the
196 	 * account_id you're transferring from <br>
197 	 * trans_accountTo Optional If trans_transaction_type = 3, this is the
198 	 * account_id you're transferring to
199 	 * <p>
200 	 * Returned Values: <br>
201 	 * Value Description <br>
202 	 * id / false Returns the id of the newly created reminder or false/null on
203 	 * fail
204 	 */
205 	@Override
206 	public String insert(ReminderDataType input) throws ClearcheckbookException {
207 		return super.insert(input);
208 	}
209 
210 	/***
211 	 * 
212 	 Edit a specific reminder for the current user. <br>
213 	 * Method: put <br>
214 	 * Call: reminder
215 	 * <p>
216 	 * Example: <br>
217 	 * https://username:password@www.clearcheckbook.com/api/reminder/
218 	 * <p>
219 	 * Parameters: <br>
220 	 * Parameter Required Description <br>
221 	 * reminder_id Required The id of the reminder being edited. <br>
222 	 * title Required The title of the reminder <br>
223 	 * email Required "true" or "false". "true" if you want to this email to
224 	 * remind the user <br>
225 	 * emailDays Optional If email is set to "true", this is the number of days
226 	 * ahead of time the user will be emailed (1-7) <br>
227 	 * start_year Required the year of the start date (YYYY) <br>
228 	 * start_month Required the month of the start date (MM) <br>
229 	 * start_day Required the day of the start date (DD) <br>
230 	 * end_year Optional the year of the end date (YYYY) <br>
231 	 * end_month Optional the month of the end date (MM) <br>
232 	 * end_day Optional the day of the end date (DD) <br>
233 	 * occur_once Optional "true" if this reminder is only occuring once. <br>
234 	 * occur_repeating Optional "true" if this reminder is repeating <br>
235 	 * occur_floating Optional "true" if this reminder is floating <br>
236 	 * repeat_every Optional 1-4. 1=Day, 2=Week, 3=Month, 4=Year <br>
237 	 * repeat_every_num Optional Integer for how often this should repeat. If
238 	 * set to 2 and repeat_every = 3, this reminder will repeat every 2 months.
239 	 * <br>
240 	 * float_every Optional When this reminder floats. 0= Sunday, 1= Monday, 2=
241 	 * Tuesday, 3= Wednesday, 4= Thursday, 5= Friday, 6= Saturday, -1= Day <br>
242 	 * float_every_num Optional When this reminder floats. 1= First, 2= Second,
243 	 * 3= Third, 4= Fourth, -1= Last <br>
244 	 * transaction Required "true" or "false". "true" if there is a transaction
245 	 * associated with this reminder. <br>
246 	 * trans_amount Optional The amount associated with the transaction <br>
247 	 * trans_description Optional the description associated with the
248 	 * transaction <br>
249 	 * trans_payee Optional the payee associated with this transaction <br>
250 	 * trans_memo Optional the memo associated with this transaction <br>
251 	 * trans_check_num Optional the check number associated with this
252 	 * transaction <br>
253 	 * trans_account_id Optional the account_id associated with this transaction
254 	 * <br>
255 	 * trans_category_id Optional the category_id associated with this
256 	 * transaction <br>
257 	 * trans_transaction_type Optional The transaction type associated with this
258 	 * transaction. (0=withdrawal, 1=deposit, 3= transfer) <br>
259 	 * trans_accountFrom Optional If trans_transaction_type = 3, this is the
260 	 * account_id you're transferring from <br>
261 	 * trans_accountTo Optional If trans_transaction_type = 3, this is the
262 	 * account_id you're transferring to
263 	 * <p>
264 	 * Returned Values: <br>
265 	 * Value Description <br>
266 	 * true / false Returns true on a successful edit or false/null on fail.
267 	 * NB - this appears to change the id so you cannot do edit (id) then get(id) as the id will change
268 	 */
269 	@Override
270 	public boolean edit(ReminderDataType dataType)
271 			throws ClearcheckbookException {
272 		return super.edit(dataType);
273 	}
274 
275 	/***
276 	 * Delete a single occurrence of a reminder for the current user. <br>
277 	 * Method: delete <br>
278 	 * Call: reminder
279 	 * <p>
280 	 * Example: <br>
281 	 * https://username:password@www.clearcheckbook.com/api/reminder/
282 	 * <p>
283 	 * Parameters: <br>
284 	 * Parameter Required Description <br>
285 	 * id Required The id of the reminder to delete
286 	 * <p>
287 	 * Returned Values: <br>
288 	 * Value Description <br>
289 	 * true / false Returns true on a successful delete or false/null on fail
290 	 */
291 	@Override
292 	public boolean delete(ParsedNameValuePair input)
293 			throws ClearcheckbookException {
294 		return super.delete(input);
295 	}
296 
297 	/***
298 	 * Delete all occurrences of a reminder for the current user. <br>
299 	 * Method: delete <br>
300 	 * Call: reminders
301 	 * <p>
302 	 * Example: <br>
303 	 * https://username:password@www.clearcheckbook.com/api/reminders/
304 	 * <p>
305 	 * Parameters: <br>
306 	 * Parameter Required Description <br>
307 	 * id Required The id of the reminder to delete
308 	 * <p>
309 	 * Returned Values: <br>
310 	 * Value Description <br>
311 	 * true / false Returns true on a successful delete or false/null on fail
312 	 * 
313 	 * @return
314 	 * @throws ClearcheckbookException
315 	 */
316 	public boolean deleteAll(ParsedNameValuePair id)
317 			throws ClearcheckbookException {
318 		_logger.debug("delete: " + id.getValue());
319 		String returnString;
320 		try {
321 			returnString = this.getConnection().deletePage(getPluralUrl(), id);
322 			boolean ok = Boolean.valueOf(returnString);
323 			_logger.info("insert : deleted " + ok);
324 			return ok;
325 		} catch (IOException e) {
326 			throw new ClearcheckbookException("Failed to delete "
327 					+ getUrlSuffix() + " id: " + id.getValue(), e);
328 		}
329 	}
330 
331 }