public async Task <ZsAddon> UpdateAsync(string apiBaseUrl, string authToken, string organizationId, string code, ZsAddonUpdate updateInput) { apiBaseUrl.CheckConfigApiBaseUrl(); authToken.CheckConfigAuthToken(); organizationId.CheckConfigOrganizationId(); if (updateInput == null) { throw new ArgumentNullException("updateInput"); } if (string.IsNullOrWhiteSpace(code)) { throw new ArgumentNullException("Addon code 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.ZsPutAddon, code), content); var processResult = await response.ProcessResponse <ZsAddonJson>(); if (null != processResult.Error) { throw processResult.Error; } return(processResult.Data.Addon); } }
public async Task <ZsAddon> UpdateAsync(string code, ZsAddonUpdate updateInput) { this.client.Configuration.CheckConfig(); return(await this.UpdateAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, code, updateInput)); }