All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.leonarduk.clearcheckbook.calls.CategoryCall Maven / Gradle / Ivy

Go to download

A Java library to access the HTTP developer API for Clearcheckbook.com, the money management website.

There is a newer version: 1.4
Show newest version
/**
 * CategoryCall
 *
 * @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.CategoryDataType;
import com.leonarduk.clearcheckbook.dto.ParsedNameValuePair;

/**
 * The Class CategoryCall.
 */
public class CategoryCall extends AbstractCall {

	/** The Constant _logger. */
	private static final Logger _logger = Logger.getLogger(CategoryCall.class);

	/** The Constant TYPE. */
	public static final String TYPE = "category";

	/**
	 * Instantiates a new category call.
	 *
	 * @param connection
	 *            the connection
	 */
	public CategoryCall(final ClearCheckBookConnection connection) {
		super(connection, CategoryDataType.class);
	}

	/**
	 * Deletes a specific category for the current user 
* Method: delete
* Call: category *

* Example:
* https://username:[email protected]/api/category/ *

* Parameters: Parameter Required Description
* id Required The id of the category being deleted *

* Returned Values:
* Value Description
* true / false Returns true upon removal of the category or false/null on fail * * @param id * the id * @return true, if successful * @throws ClearcheckbookException * the clearcheckbook exception */ @Override public boolean delete(final ParsedNameValuePair id) throws ClearcheckbookException { final boolean delete = super.delete(id); CategoryCall._logger.debug("edit: OK?" + delete + " " + id); return delete; } /** * Edit a specific category for the current user.
* Method: put
* Call: category *

* Example:
* https://username:[email protected]/api/category/ *

* Parameters:
* Parameter Required Description
* id Required The id of the category being edited
* name Required The new name for the category
* parent Required The new parent id for the category *

* Returned Values:
* Value Description
* true / false Returns true on a successful edit or false/null on fail. * * @param input * the input * @return true, if successful * @throws ClearcheckbookException * the clearcheckbook exception */ @Override public boolean edit(final CategoryDataType input) throws ClearcheckbookException { final boolean edit = super.edit(input); CategoryCall._logger.debug("edit: OK?" + edit + " " + input); return edit; } /** * Gets all of the current users categories
* Method: get
* Call: categories *

*
* Example:
* https://username:[email protected]/api/categories/ *

*
* Parameters:
* Parameter Required Description
* None *

* Returned Values:
* Value Description
* id The id of the category
* name The name of the category
* parent The id of this category's parent. 0 if there is no parent. * * @return the all * @throws ClearcheckbookException * the clearcheckbook exception */ @Override public List getAll() throws ClearcheckbookException { final List all = super.getAll(); CategoryCall._logger.debug("getAll: " + all.size() + " returned"); return all; } /* * (non-Javadoc) * * @see com.leonarduk.clearcheckbook.calls.AbstractCall#getPluralUrl() */ @Override protected String getPluralUrl() { return "categories"; } /* * (non-Javadoc) * * @see com.leonarduk.clearcheckbook.calls.AbstractCall#getUrlSuffix() */ @Override protected String getUrlSuffix() { return CategoryCall.TYPE; } /** * Adds a category to the current users accout.
* Method: post
* Call: category *

* Example:
* https://username:[email protected]/api/category/ *

* Parameters:
* Parameter Required Description
* name Required The name of the new category
* parent Optional The id of this category's parent. *

*
* Returned Values:
* Value Description
* id / false The id of the newly created category or false/null on fail. * * @param input * the input * @return the string * @throws ClearcheckbookException * the clearcheckbook exception */ @Override public String insert(final CategoryDataType input) throws ClearcheckbookException { final String insert = super.insert(input); CategoryCall._logger.debug("insert: id " + insert + " " + input); return insert; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy