Package ch.aaap.harvestclient.impl
Class ExpensesApiImpl
Object
ch.aaap.harvestclient.impl.ExpensesApiImpl
- All Implemented Interfaces:
Api.Create<Expense>
,Api.Delete<Expense>
,Api.Get<Expense>
,Api.Simple<Expense>
,ExpensesApi
-
Constructor Summary
-
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.void
Delete an existing Expense.Return an existing Expense.list
(ExpenseFilter filter) list
(ExpenseFilter filter, int page, int perPage) update
(Reference<Expense> expenseReference, ExpenseUpdateInfo toChange) Updates the specific expense by setting the values of the parameters passed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.aaap.harvestclient.api.ExpensesApi
removeReceipt
-
Constructor Details
-
ExpensesApiImpl
-
-
Method Details
-
list
- Specified by:
list
in interfaceExpensesApi
- 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
- Specified by:
list
in interfaceExpensesApi
- 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
Description copied from interface:ExpensesApi
Return an existing Expense.- Specified by:
get
in interfaceApi.Get<Expense>
- Specified by:
get
in interfaceExpensesApi
- Parameters:
expenseReference
- a reference to an existing Expense- Returns:
- the full Expense object
-
create
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 interfaceApi.Create<Expense>
- Specified by:
create
in interfaceExpensesApi
- Parameters:
creationInfo
- creation information- Returns:
- the created Expense
-
update
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 interfaceExpensesApi
- Parameters:
expenseReference
- An existing Expense to be updatedtoChange
- 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 interfaceExpensesApi
- 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
Description copied from interface:ExpensesApi
Attach a file as a receipt for an Expense- Specified by:
attachReceipt
in interfaceExpensesApi
- Parameters:
expenseReference
- An existing Expense to be updatedfile
- a receipt file (allowed extensions: png, gif, pdf, jpeg, jpg)- Returns:
- the updated Expense
-
delete
Description copied from interface:ExpensesApi
Delete an existing Expense. Only possible if no time entries are associated with it- Specified by:
delete
in interfaceApi.Delete<Expense>
- Specified by:
delete
in interfaceExpensesApi
- Parameters:
expenseReference
- a reference to the Expense to be deleted
-