Esempio n. 1
0
        /// <summary>
        /// Update an existing expense on the authenticated account. Makes both a PUT and GET request to the Expenses resource.
        /// </summary>
        /// <param name="expenseId">The ID of the expense to update</param>
        /// <param name="options">The update options for the expense</param>
        public Task <Expense> UpdateExpenseAsync(long expenseId, ExpenseOptions options, long?ofUser = null)
        {
            var request = UpdateRequest(EXPENSES_RESOURCE, expenseId, options);

            if (ofUser != null)
            {
                request.AddParameter("of_user", ofUser.Value);
            }

            return(ExecuteAsync <Expense>(request));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new expense under the authenticated account. Makes a POST and a GET request to the Expenses resource.
        /// </summary>
        /// <param name="options">The options for the new expense to be created</param>
        public Expense CreateExpense(ExpenseOptions options, long?ofUser = null)
        {
            var request = CreateRequest(EXPENSES_RESOURCE, options);

            if (ofUser != null)
            {
                request.AddParameter("of_user", ofUser.Value);
            }

            return(Execute <Expense>(request));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new expense under the authenticated account. Makes a POST and a GET request to the Expenses resource.
        /// </summary>
        /// <param name="options">The options for the new expense to be created</param>
        public Expense CreateExpense(ExpenseOptions options, long?ofUser = null)
        {
            var request = Request("expenses", RestSharp.Method.POST);

            if (ofUser != null)
            {
                request.AddParameter("of_user", ofUser.Value);
            }

            request.AddBody(options);

            return(Execute <Expense>(request));
        }
Esempio n. 4
0
        private IRestRequest UpdateExpenseRequest(long expenseId, ExpenseOptions options, long?ofUser = null)
        {
            var request = Request($"{ExpensesResource}/{expenseId}", RestSharp.Method.PUT);

            if (ofUser != null)
            {
                request.AddParameter(OfUserParameter, ofUser.Value);
            }

            request.AddBody(options);

            return(request);
        }
Esempio n. 5
0
        private IRestRequest CreateExpenseRequest(ExpenseOptions options, long?ofUser = null)
        {
            var request = Request(ExpensesResource, RestSharp.Method.POST);

            if (ofUser != null)
            {
                request.AddParameter(OfUserParameter, ofUser.Value);
            }

            request.AddBody(options);

            return(request);
        }
Esempio n. 6
0
        /// <summary>
        /// Update an existing expense on the authenticated account. Makes both a PUT and GET request to the Expenses resource.
        /// </summary>
        /// <param name="expenseId">The ID of the expense to update</param>
        /// <param name="spentAt">The new date of the expense</param>
        /// <param name="projectId">The new project ID of the expense</param>
        /// <param name="expenseCategoryId">The new expense category ID of the expense</param>
        /// <param name="totalCost">The new total cost of the expense</param>
        /// <param name="units">The new unit count of the expense</param>
        /// <param name="notes">The new notes of the expense</param>
        /// <param name="isBillable">The new billable status of the expense</param>
        public Expense UpdateExpense(long expenseId, DateTime?spentAt = null, long?projectId = null, long?expenseCategoryId = null, decimal?totalCost = null, decimal?units = null, string notes = null, bool?isBillable = null, long?ofUser = null)
        {
            var options = new ExpenseOptions()
            {
                SpentAt           = spentAt,
                ProjectId         = projectId,
                ExpenseCategoryId = expenseCategoryId,
                Notes             = notes,
                Billable          = isBillable,
                TotalCost         = totalCost,
                Units             = units
            };

            return(UpdateExpense(expenseId, options, ofUser));
        }
Esempio n. 7
0
        /// <summary>
        /// Create a new expense for on the authenticated account. Makes both a POST and a GET request to the Expense resource.
        /// </summary>
        /// <param name="spentAt">The date of the expense</param>
        /// <param name="projectId">The project to bill</param>
        /// <param name="expenseCategoryId">The category of the expense</param>
        /// <param name="totalCost">The total expense price</param>
        /// <param name="notes">The notes on the expense</param>
        /// <param name="isBillable">Whether the expense is billable</param>
        public Expense CreateExpense(DateTime spentAt, long projectId, long expenseCategoryId, decimal?totalCost = null, decimal?units = null, string notes = null, bool isBillable = true, long?ofUser = null)
        {
            if (totalCost != null && units != null)
            {
                throw new ArgumentException("You may only set TotalCost OR Units. Not both.");
            }
            else if (totalCost == null && units == null)
            {
                throw new ArgumentException("You must set either TotalCost OR Units.");
            }

            var options = new ExpenseOptions()
            {
                SpentAt           = spentAt,
                ProjectId         = projectId,
                ExpenseCategoryId = expenseCategoryId,
                Notes             = notes,
                Billable          = isBillable,
                TotalCost         = totalCost,
                Units             = units
            };

            return(CreateExpense(options, ofUser));
        }
Esempio n. 8
0
 /// <summary>
 /// Update an existing expense on the authenticated account. Makes both a PUT and GET request to the Expenses resource.
 /// </summary>
 /// <param name="expenseId">The ID of the expense to update</param>
 /// <param name="options">The update options for the expense</param>
 /// <param name="cancellationToken"></param>
 public async Task <Expense> UpdateExpenseAsync(long expenseId, ExpenseOptions options, long?ofUser = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await ExecuteAsync <Expense>(UpdateExpenseRequest(expenseId, options, ofUser), cancellationToken));
 }
Esempio n. 9
0
 /// <summary>
 /// Update an existing expense on the authenticated account. Makes both a PUT and GET request to the Expenses resource.
 /// </summary>
 /// <param name="expenseId">The ID of the expense to update</param>
 /// <param name="options">The update options for the expense</param>
 public Expense UpdateExpense(long expenseId, ExpenseOptions options, long?ofUser = null)
 {
     return(Execute <Expense>(UpdateExpenseRequest(expenseId, options, ofUser)));
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new expense under the authenticated account. Makes a POST and a GET request to the Expenses resource.
 /// </summary>
 /// <param name="options">The options for the new expense to be created</param>
 public Expense CreateExpense(ExpenseOptions options, long?ofUser = null)
 {
     return(Execute <Expense>(CreateExpenseRequest(options, ofUser)));
 }