Class ExpensesApiImpl

Object
ch.aaap.harvestclient.impl.ExpensesApiImpl
All Implemented Interfaces:
Api.Create<Expense>, Api.Delete<Expense>, Api.Get<Expense>, Api.Simple<Expense>, ExpensesApi

public class ExpensesApiImpl extends Object implements ExpensesApi
  • Constructor Details

  • Method Details

    • list

      public List<Expense> list(ExpenseFilter filter)
      Specified by:
      list in interface ExpensesApi
      Parameters:
      filter - filtering options
      Returns:
      a list of all Expenses in the account, sorted by creation date, newest first. If no admin rights, return only the user expenses.
    • list

      public Pagination<Expense> list(ExpenseFilter filter, int page, int perPage)
      Specified by:
      list in interface ExpensesApi
      Parameters:
      filter - filtering options
      page - the page number
      perPage - how many results to return for one page. Max 100
      Returns:
      a list of all Expenses in the account, sorted by creation date, newest first. If no admin rights, return only the user expenses.
    • get

      public Expense get(Reference<Expense> expenseReference)
      Description copied from interface: ExpensesApi
      Return an existing Expense.
      Specified by:
      get in interface Api.Get<Expense>
      Specified by:
      get in interface ExpensesApi
      Parameters:
      expenseReference - a reference to an existing Expense
      Returns:
      the full Expense object
    • create

      public Expense create(Expense creationInfo)
      Description copied from interface: ExpensesApi
      Create a new Expense. Example:
       Expense expense = harvest.expenses().create(ImmutableExpense.builder()
               .name("expense name")
               .build());
       
      Specified by:
      create in interface Api.Create<Expense>
      Specified by:
      create in interface ExpensesApi
      Parameters:
      creationInfo - creation information
      Returns:
      the created Expense
    • update

      public Expense update(Reference<Expense> expenseReference, ExpenseUpdateInfo toChange)
      Description copied from interface: ExpensesApi
      Updates the specific expense by setting the values of the parameters passed. Any parameters not provided will be left unchanged
      Specified by:
      update in interface ExpensesApi
      Parameters:
      expenseReference - An existing Expense to be updated
      toChange - the changes to be performed
      Returns:
      the updated Expense
    • attachReceipt

      public Expense attachReceipt(Reference<Expense> expenseReference, InputStream inputStream, String fileName) throws IOException
      Description copied from interface: ExpensesApi
      Attach a file as a receipt for an Expense
      Specified by:
      attachReceipt in interface ExpensesApi
      Parameters:
      expenseReference - An existing Expense to be updated
      inputStream - a receipt inputstream (allowed filetypes: png, gif, pdf, jpeg, jpg). Calling code is responsible for closing the stream
      fileName - a filename for Harvest
      Returns:
      the updated Expense
      Throws:
      IOException - if there is a problem reading the inputStream
    • attachReceipt

      public Expense attachReceipt(Reference<Expense> expenseReference, File file)
      Description copied from interface: ExpensesApi
      Attach a file as a receipt for an Expense
      Specified by:
      attachReceipt in interface ExpensesApi
      Parameters:
      expenseReference - An existing Expense to be updated
      file - a receipt file (allowed extensions: png, gif, pdf, jpeg, jpg)
      Returns:
      the updated Expense
    • delete

      public void delete(Reference<Expense> expenseReference)
      Description copied from interface: ExpensesApi
      Delete an existing Expense. Only possible if no time entries are associated with it
      Specified by:
      delete in interface Api.Delete<Expense>
      Specified by:
      delete in interface ExpensesApi
      Parameters:
      expenseReference - a reference to the Expense to be deleted