1 package com.leonarduk.clearcheckbook.calls; 2 3 import java.util.List; 4 5 import org.apache.log4j.Logger; 6 7 import com.leonarduk.clearcheckbook.ClearCheckBookConnection; 8 import com.leonarduk.clearcheckbook.ClearcheckbookException; 9 import com.leonarduk.clearcheckbook.dto.ParsedNameValuePair; 10 import com.leonarduk.clearcheckbook.dto.ReportDataType; 11 import com.leonarduk.clearcheckbook.dto.ReportDataType.Fields; 12 import com.leonarduk.clearcheckbook.dto.ReportDataType.Type; 13 14 public class ReportCall extends AbstractCall<ReportDataType> { 15 16 private static final Logger _logger = Logger.getLogger(ReportCall.class); 17 18 public static final String TYPE = "report"; 19 20 public ReportCall(ClearCheckBookConnection connection) { 21 super(connection, ReportDataType.class); 22 } 23 24 @Override 25 protected String getUrlSuffix() { 26 return TYPE; 27 } 28 29 /*** 30 * 31 Returns an array of images containing reports for the current user <br> 32 * Method: get <br> 33 * Call: reports 34 * <p> 35 * Example: <br> 36 * https://username:password@www.clearcheckbook.com/api/reports/ 37 * <p> 38 * Parameters: <br> 39 * Parameter Required Description <br> 40 * type Required "pie" or "line". No data will be returned if one of those 41 * is not sent. <br> 42 * months Optional Integer value representing the number of months worth of 43 * data to use. Default is 6. <br> 44 * bgcolor Optional Background color of the returned image. Send as a color 45 * hex code (eg: "F3F3F3"). Default is FFFFFF (white) <br> 46 * height Optional The integer height in pixels of the returned image. 47 * Default is 150 <br> 48 * width Optional The integer width in pixels of the returned image. Default 49 * is 320 50 * <p> 51 * Returned Values: <br> 52 * Value Description <br> 53 * label The name of the Account (if type="line") or the date in yyyy-mm-dd 54 * format (if type="pie") <br> 55 * url The URL to the image being returned. 56 * 57 * @Override {@link AbstractCall#getAll()} 58 */ 59 public List<ReportDataType> getAll(Type type, int months, String bgcolor, 60 int height, int width) throws ClearcheckbookException { 61 ParsedNameValuePair[] params = new ParsedNameValuePair[] { 62 new ParsedNameValuePair(Fields.TYPE.name().toLowerCase(), type 63 .name().toLowerCase()), 64 new ParsedNameValuePair(Fields.MONTHS.name().toLowerCase(), 65 String.valueOf(months)), 66 new ParsedNameValuePair(Fields.BGCOLOR.name().toLowerCase(), 67 bgcolor), 68 new ParsedNameValuePair(Fields.HEIGHT.name().toLowerCase(), 69 String.valueOf(height)), 70 new ParsedNameValuePair(Fields.WIDTH.name().toLowerCase(), 71 String.valueOf(width)) }; 72 List<ReportDataType> all = super.getAll(params); 73 _logger.debug("getAll: " + all); 74 return all; 75 } 76 77 public List<ReportDataType> getAll(Type type, int months) 78 throws ClearcheckbookException { 79 ParsedNameValuePair[] params = new ParsedNameValuePair[] { 80 new ParsedNameValuePair(Fields.TYPE.name().toLowerCase(), type 81 .name().toLowerCase()), 82 new ParsedNameValuePair(Fields.MONTHS.name().toLowerCase(), 83 String.valueOf(months)) }; 84 List<ReportDataType> all = super.getAll(params); 85 _logger.debug("getAll: " + all); 86 return all; 87 } 88 89 /*** 90 * Brings back a list of links to graphs in google graph 91 * 92 * @param type 93 * @return 94 * @throws ClearcheckbookException 95 */ 96 public List<ReportDataType> getAll(Type type) 97 throws ClearcheckbookException { 98 ParsedNameValuePair[] params = new ParsedNameValuePair[] { new ParsedNameValuePair( 99 Fields.TYPE.name().toLowerCase(), type.name().toLowerCase()) }; 100 List<ReportDataType> all = super.getAll(params); 101 _logger.debug("getAll: " + all); 102 return all; 103 } 104 105 public List<ReportDataType> getAll() throws ClearcheckbookException { 106 ParsedNameValuePair[] params = new ParsedNameValuePair[] { new ParsedNameValuePair( 107 Fields.TYPE.name().toLowerCase(), Type.LINE.name() 108 .toLowerCase()) }; 109 List<ReportDataType> all = super.getAll(params); 110 _logger.debug("getAll: " + all); 111 return all; 112 } 113 114 }