Package ch.aaap.harvestclient.api
Interface ExpensesApi
- All Superinterfaces:
Api.Create<Expense>,Api.Delete<Expense>,Api.Get<Expense>,Api.Simple<Expense>
- All Known Implementing Classes:
ExpensesApiImpl
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionattachReceipt(Reference<Expense> expenseReference, File file) Attach a file as a receipt for an ExpenseattachReceipt(Reference<Expense> expenseReference, InputStream inputStream, String fileName) Attach a file as a receipt for an ExpenseCreate a new Expense.voidDelete an existing Expense.Return an existing Expense.list(ExpenseFilter filter) list(ExpenseFilter filter, int page, int perPage) default ExpenseremoveReceipt(Reference<Expense> expenseReference) Remove a receipt from an Expense, if one is currently present.update(Reference<Expense> expenseReference, ExpenseUpdateInfo toChange) Updates the specific expense by setting the values of the parameters passed.
-
Method Details
-
list
- 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
- Parameters:
filter- filtering optionspage- the page numberperPage- 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
Return an existing Expense. -
create
Create a new Expense. Example:Expense expense = harvest.expenses().create(ImmutableExpense.builder() .name("expense name") .build());- Specified by:
createin interfaceApi.Create<Expense>- Parameters:
creationInfo- creation information- Returns:
- the created Expense
-
update
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 updatedtoChange- 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 updatedinputStream- a receipt inputstream (allowed filetypes: png, gif, pdf, jpeg, jpg). Calling code is responsible for closing the streamfileName- a filename for Harvest- Returns:
- the updated Expense
- Throws:
IOException- if there is a problem reading the inputStream
-
attachReceipt
Attach a file as a receipt for an Expense- Parameters:
expenseReference- An existing Expense to be updatedfile- a receipt file (allowed extensions: png, gif, pdf, jpeg, jpg)- Returns:
- the updated Expense
-
removeReceipt
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
Delete an existing Expense. Only possible if no time entries are associated with it- Specified by:
deletein interfaceApi.Delete<Expense>- Parameters:
expenseReference- a reference to the Expense to be deleted
-