Class Expenses


public class Expenses extends AccountingResource
FreshBooks expenses resource with calls to get, list, create, update, delete
  • Constructor Details

  • Method Details

    • getPath

      protected String getPath()
      Specified by:
      getPath in class AccountingResource
    • list

      public ExpenseList list(String accountId) throws FreshBooksException
      Get a list of expenses using the query strings generated by the QueryBuilder list.
      Parameters:
      accountId - Id of the account
      Returns:
      ExpenseList containing expenses and pagination details
      Throws:
      FreshBooksException - If the call is not successful
    • list

      public ExpenseList list(String accountId, List<QueryBuilder> builders) throws FreshBooksException
      Get a list of expenses using the query strings generated by the QueryBuilder list.
      Parameters:
      accountId - Id of the account
      builders - List of QueryBuilders
      Returns:
      ExpenseList containing expenses and pagination details
      Throws:
      FreshBooksException - If the call is not successful
    • get

      public Expense get(String accountId, long expenseId) throws FreshBooksException
      Get a single expense with the corresponding id.
      Parameters:
      accountId - The alpha-numeric account id
      expenseId - Id of the resource to return
      Returns:
      The Expense
      Throws:
      FreshBooksException - If the call is not successful
    • get

      public Expense get(String accountId, long expenseId, IncludesQueryBuilder builder) throws FreshBooksException
      Get a single expense with the corresponding id.
      Parameters:
      accountId - The alpha-numeric account id
      expenseId - Id of the resource to return
      builder - IncludesQueryBuilder object for including additional data, sub-resources, etc.
      Returns:
      The Expense
      Throws:
      FreshBooksException - If the call is not successful
    • create

      public Expense create(String accountId, Expense data) throws FreshBooksException
      Create a new expense from the provided Expense model. Makes a POST call against the expense resource endpoint.

      This calls expense.getContent() to get a hash map of data.
      Parameters:
      accountId - The alpha-numeric account id
      data - Expense model with create data
      Returns:
      The created Expense
      Throws:
      FreshBooksException - If the call is not successful
    • create

      public Expense create(String accountId, Map<String,Object> data) throws FreshBooksException
      Create a new expense from the provided data. Makes a POST call against the expense resource endpoint.
      Parameters:
      accountId - The alpha-numeric account id
      data - Map of create data
      Returns:
      The created Expense
      Throws:
      FreshBooksException - If the call is not successful
    • update

      public Expense update(String accountId, long expenseId, Expense data) throws FreshBooksException
      Update the expense with the corresponding id. Makes a PUT call against the expense resource endpoint.
      Parameters:
      accountId - The alpha-numeric account id
      expenseId - Id of the resource to return
      data - Expense model with updated data
      Returns:
      The updated Expense
      Throws:
      FreshBooksException - If the call is not successful
    • update

      public Expense update(String accountId, long expenseId, Map<String,Object> data) throws FreshBooksException
      Update the expense with the corresponding id. Makes a PUT call against the expense resource endpoint.
      Parameters:
      accountId - The alpha-numeric account id
      expenseId - Id of the resource to update
      data - Map of data to change
      Returns:
      The updated Expense
      Throws:
      FreshBooksException - If the call is not successful
    • delete

      public Expense delete(String accountId, long expenseId) throws FreshBooksException
      Delete the expense with the corresponding id. Makes a PUT call against the expense resource endpoint with a `vis_state` of deleted.

      Note: Most FreshBooks resources are soft-deleted,
      Parameters:
      accountId - The alpha-numeric account id
      expenseId - Id of the resource to update
      Returns:
      The deleted Expense
      Throws:
      FreshBooksException - If the call is not successful
      See Also: