/// <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 = GetInvoiceOptions(kind, clientId, issuedAt, dueAt, currency, subject, notes, number, projectIds, lineItems); return(CreateInvoice(invoice)); }
private InvoiceOptions CreateInvoiceOptions(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(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="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 async Task <Invoice> CreateInvoiceAsync(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, CancellationToken cancellationToken = default(CancellationToken)) { return(await CreateInvoiceAsync(CreateInvoiceOptions(kind, clientId, issuedAt, dueAt, currency, subject, notes, number, projectIds, lineItems), cancellationToken)); }
/// <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); }