public async Task <bool> EmailInvoice(string apiBaseUrl, string authToken, string organizationId, string id, ZsInvoiceEmailInput emailInput) { apiBaseUrl.CheckConfigApiBaseUrl(); authToken.CheckConfigAuthToken(); organizationId.CheckConfigOrganizationId(); if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("Invoice id is required"); } if (emailInput == null) { throw new ArgumentNullException("emailInput"); } var validationResult = emailInput.Validate(); if (!string.IsNullOrWhiteSpace(validationResult)) { throw new ArgumentException(validationResult); } using (var httpClient = new HttpClient()) { httpClient.Configure(apiBaseUrl, organizationId, authToken); var content = new StringContent( JsonConvert.SerializeObject( emailInput, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), Encoding.UTF8, "application/json"); var response = await httpClient.PostAsync(string.Format(CultureInfo.InvariantCulture, ApiResources.ZsPostInvoiceEmail, id), content); var processResult = await response.ProcessResponse <bool>(); if (null != processResult.Error) { throw processResult.Error; } return(processResult.Data); } }
public async Task <bool> EmailInvoice(string id, ZsInvoiceEmailInput emailInput) { this.client.Configuration.CheckConfig(); return(await this.EmailInvoice(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, id, emailInput)); }