Interface ExpensesApi

All Superinterfaces:
Api.Create<Expense>, Api.Delete<Expense>, Api.Get<Expense>, Api.Simple<Expense>
All Known Implementing Classes:
ExpensesApiImpl

public interface ExpensesApi extends Api.Simple<Expense>
See Also:
  • Method Details

    • list

      List<Expense> list(ExpenseFilter filter)
      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

      Pagination<Expense> list(ExpenseFilter filter, int page, int perPage)
      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

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

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

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

      Expense attachReceipt(Reference<Expense> expenseReference, InputStream inputStream, String fileName) throws IOException
      Attach a file as a receipt for an Expense
      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

      Expense attachReceipt(Reference<Expense> expenseReference, File file)
      Attach a file as a receipt for an Expense
      Parameters:
      expenseReference - An existing Expense to be updated
      file - a receipt file (allowed extensions: png, gif, pdf, jpeg, jpg)
      Returns:
      the updated Expense
    • removeReceipt

      default Expense removeReceipt(Reference<Expense> expenseReference)
      Remove a receipt from an Expense, if one is currently present. Note that attachReceipt can be used even if a receipt is already set, no need to call this first
      Parameters:
      expenseReference - the expense from which to remove the receipt
      Returns:
      the updated Expense
    • delete

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