ExpensesAPI

new ExpensesAPI(rest)

This class is used to interact with Expenses in TidyHQ.
Parameters:
NameTypeDescription
restRestThe rest instance to use for requests.

Methods

(async) addPayment(expenseID, optionsopt) → {Promise.<TidyAPI_V1_Payment>}

This function is used to add a payment to an expense.
Parameters:
NameTypeAttributesDescription
expenseIDstringThe ID of the expense.
optionsobject<optional>
The options to create the payment with. At least one option is required that isn't the access_token.
Properties
NameTypeAttributesDescription
access_tokenstring<optional>
The access token to use.
amountnumber<optional>
The amount of the payment expressed as a decimal.
payment_typeTidy_V1_PaymentType<optional>
The type of payment.
datestring<optional>
The date of the payment in ISO 8601 format.
Returns:
- The newly created payment.
Type: 
Promise.<TidyAPI_V1_Payment>

(async) createExpense(expense, optionsopt) → {Promise.<TidyAPI_V1_Expense>}

Create a new expense in TidyHQ.
Parameters:
NameTypeAttributesDefaultDescription
expenseTidy_V1_ExpenseParamsThe expense to create.
optionsobject<optional>
{}The options to create the expense with.
Properties
NameTypeAttributesDescription
access_tokenstring<optional>
The access token to use.
Returns:
- The newly created expense.
Type: 
Promise.<TidyAPI_V1_Expense>

(async) deleteExpense(expenseID, optionsopt) → {Promise.<TidyAPI_Response>}

Delete an expense.
Parameters:
NameTypeAttributesDefaultDescription
expenseIDstringThe ID of the expense.
optionsobject<optional>
{}
Properties
NameTypeAttributesDescription
access_tokenstring<optional>
The access token to use.
Returns:
- Success or failure.
Type: 
Promise.<TidyAPI_Response>

(async) getExpense(expenseID, optionsopt) → {Promise.<TidyAPI_V1_Expense>}

Get a single expense from TidyHQ.
Parameters:
NameTypeAttributesDefaultDescription
expenseIDstringThe ID of the expense to get
optionsobject<optional>
{}
Properties
NameTypeAttributesDescription
access_tokenstring<optional>
The access token to use.
Returns:
- An Expense object.
Type: 
Promise.<TidyAPI_V1_Expense>

(async) getExpenses(optionsopt) → {Promise.<TidyAPI_V1_Expenses>}

Get a list of expenses from TidyHQ.
Parameters:
NameTypeAttributesDefaultDescription
optionsobject<optional>
{}
Properties
NameTypeAttributesDescription
access_tokenstring<optional>
The access token to use.
limitnumber<optional>
The maximum number of expenses to return.
offsetnumber<optional>
The number of expenses to skip.
status"activated" | "cancelled" | "all"<optional>
The status of the expense.
updated_sincestring<optional>
The timestamp of the last update in ISO 8601 format.
Returns:
- An array of expenses.
Type: 
Promise.<TidyAPI_V1_Expenses>