public async Task <ZsCustomer> UpdateAsync(string apiBaseUrl, string authToken, string organizationId, string id, ZsCustomerInput updateInput) { apiBaseUrl.CheckConfigApiBaseUrl(); authToken.CheckConfigAuthToken(); organizationId.CheckConfigOrganizationId(); if (updateInput == null) { throw new ArgumentNullException("updateInput"); } if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("Customer id is required"); } var validationResult = updateInput.Validate(); if (!string.IsNullOrWhiteSpace(validationResult)) { throw new ArgumentException(validationResult); } using (var httpClient = new HttpClient()) { httpClient.Configure(apiBaseUrl, organizationId, authToken); var updateJson = JsonConvert.SerializeObject( updateInput, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var content = new StringContent( updateJson, Encoding.UTF8, "application/json"); var response = await httpClient.PutAsync(string.Format(CultureInfo.InvariantCulture, ApiResources.ZsPutCustomer, id), content); var processResult = await response.ProcessResponse <ZsCustomerJson>(); if (null != processResult.Error) { throw processResult.Error; } return(processResult.Data.Customer); } }
public async Task <ZsCustomer> CreateAsync(ZsCustomerInput createInput) { this.client.Configuration.CheckConfig(); return(await this.CreateAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, createInput)); }
public async Task <ZsCustomer> UpdateAsync(string id, ZsCustomerInput updateInput) { this.client.Configuration.CheckConfig(); return(await this.UpdateAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, id, updateInput)); }