Ejemplo n.º 1
0
        public async Task <ZsSubscription> UpdateAsync(string apiBaseUrl, string authToken, string organizationId, string id, ZsSubscriptionUpdate updateInput)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            if (updateInput == null)
            {
                throw new ArgumentNullException("updateInput");
            }

            if (string.IsNullOrEmpty(id) || id == string.Empty)
            {
                throw new ArgumentNullException("id");
            }

            //var validationResult = updateInput.Validate();
            //if (!string.IsNullOrWhiteSpace(validationResult))
            //{
            //    throw new ArgumentException(validationResult);
            //}

            using (var httpClient = new HttpClient())
            {
                httpClient.Configure(apiBaseUrl, organizationId, authToken);
                var jsonContent = JsonConvert.SerializeObject(
                    updateInput,
                    Formatting.None,
                    new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });
                var content  = new StringContent(jsonContent, Encoding.UTF8, "application/json");
                var response = await httpClient.PutAsync(string.Format(CultureInfo.InvariantCulture, ApiResources.ZsPutSubscription, id), content);

                var processResult = await response.ProcessResponse <ZsSubscriptionJson>();

                if (null != processResult.Error)
                {
                    throw processResult.Error;
                }

                return(processResult.Data.Subscription);
            }
        }
Ejemplo n.º 2
0
 public async Task <ZsSubscription> UpdateAsync(string id, ZsSubscriptionUpdate updateInput)
 {
     this.client.Configuration.CheckConfig();
     return(await this.UpdateAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, id, updateInput));
 }