/// <summary> /// Create a new invoice on the authenticated account. Makes both a POST and a GET request to the Invoices resource. /// </summary> /// <param name="kind">The kind of invoice to create</param> /// <param name="clientId">The client the new invoice is for</param> /// <param name="issuedAt">The date the invoice should be issued</param> /// <param name="dueAt">The date the invoice should be due</param> /// <param name="currency">The currency of the invoice</param> /// <param name="subject">The invoice subject</param> /// <param name="notes">Notes to include on the invoice</param> /// <param name="number">The number for the invoice</param> /// <param name="projectIds">The IDs of projects to include in the invoice (useless for FreeForm invoices)</param> /// <param name="lineItems">A collection of line items for the invoice (only for FreeForm invoices)</param> public Invoice CreateInvoice(InvoiceKind kind, long clientId, DateTime issuedAt, DateTime? dueAt = null, Currency? currency = null, string subject = null, string notes = null, string number = null, long[] projectIds = null, List<InvoiceItem> lineItems = null) { var invoice = new InvoiceOptions() { Kind = kind, ClientId = clientId, IssuedAt = issuedAt, DueAt = dueAt, Currency = currency, Subject = subject, Notes = notes, Number = number, }; if (projectIds != null) invoice.ProjectsToInvoice = string.Join(",", projectIds.Select(id => id.ToString())); invoice.SetInvoiceItems(lineItems); return CreateInvoice(invoice); }
/// <summary> /// Create a new invoice on the authenticated account. Makes both a POST and a GET request to the Invoices resource. /// </summary> /// <param name="options">The options for the new invoice to create</param> public Invoice CreateInvoice(InvoiceOptions options) { var request = Request("invoices", RestSharp.Method.POST); request.AddBody(options); return Execute<Invoice>(request); }
/// <summary> /// Update an existing invoice on the authenticated account. Makes both a PUT and a GET request to the Invoices resource. /// </summary> /// <param name="invoiceId">The ID of the invoice to update</param> /// <param name="options">The fields to be updated</param> public Invoice UpdateInvoice(long invoiceId, InvoiceOptions options) { var request = Request("invoices/" + invoiceId, RestSharp.Method.PUT); request.AddBody(options); return Execute<Invoice>(request); }
public void CreateInvoice_WithItemsContainsItems() { var client = Api.ListClients().First(); var options = new InvoiceOptions() { ClientId = client.Id, Subject = "Test Items Invoice", Kind = InvoiceKind.FreeForm }; options.SetInvoiceItems(new List<InvoiceItem>() { new InvoiceItem() { Kind = "Product", Description = "Description 1", Quantity = 1, Amount = 10 }, new InvoiceItem() { Kind = "Product", Description = "Description 2", Quantity = 2, Amount = 10 } }); _toDelete = Api.CreateInvoice(options); Assert.Equal(2, _toDelete.ListLineItems().Count()); }