/// <summary> /// Sends asynchronously e-mail message for the specified invoice. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="messageType">Type of the message.</param> /// <exception cref="System.ArgumentOutOfRangeException">id;Value must be greater than zero.</exception> public async Task SendMessageAsync(int id, InvoiceMessageType messageType) { if (id < 1) { throw new ArgumentOutOfRangeException(nameof(id), "Value must be greater than zero."); } // Get name of event string eventName; switch (messageType) { case InvoiceMessageType.InvoiceMessage: eventName = "deliver"; break; case InvoiceMessageType.PaymentReminderMessage: eventName = "deliver_reminder"; break; default: eventName = "mark_as_sent"; break; } var c = this.Context.GetHttpClient(); var r = await c.PostAsync(string.Format("invoices/{0}/fire.json?event={1}", id, eventName), new StringContent(string.Empty)); r.EnsureFakturoidSuccess(); }
/// <summary> /// Sends e-mail message for the specified invoice. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="messageType">Type of the message.</param> /// <exception cref="System.ArgumentOutOfRangeException">id;Value must be greater than zero.</exception> public void SendMessage(int id, InvoiceMessageType messageType) { try { this.SendMessageAsync(id, messageType).Wait(); } catch (AggregateException aex) { throw aex.InnerException; } }
/// <summary> /// Sends e-mail message for the specified invoice. /// </summary> /// <param name="id">The invoice id.</param> /// <param name="messageType">Type of the message.</param> /// <exception cref="System.ArgumentOutOfRangeException">id;Value must be greater than zero.</exception> public void SendMessage(int id, InvoiceMessageType messageType) { if (id < 1) throw new ArgumentOutOfRangeException("id", "Value must be greater than zero."); // Get name of event string eventName; switch (messageType) { case InvoiceMessageType.InvoiceMessage: eventName = "deliver"; break; case InvoiceMessageType.PaymentReminderMessage: eventName = "deliver_reminder"; break; default: eventName = "mark_as_sent"; break; } var c = this.Context.GetHttpClient(); var r = c.PostAsync(string.Format("invoices/{0}/fire.json?event={1}", id, eventName), new StringContent(string.Empty)).Result; r.EnsureFakturoidSuccess(); }