예제 #1
0
        public async Task <ZsCard> UpdateAsync(string apiBaseUrl, string authToken, string organizationId, string customerId, string cardId, ZsCardUpdate updateInput)
        {
            apiBaseUrl.CheckConfigApiBaseUrl();
            authToken.CheckConfigAuthToken();
            organizationId.CheckConfigOrganizationId();

            if (string.IsNullOrWhiteSpace(customerId))
            {
                throw new ArgumentNullException("customerId");
            }

            if (string.IsNullOrWhiteSpace(cardId))
            {
                throw new ArgumentNullException("cardId");
            }

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

            var validationResult = updateInput.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(updateInput), Encoding.UTF8, "application/json");
                var response = await httpClient.PutAsync(string.Format(CultureInfo.InvariantCulture, ApiResources.ZsPutCard, customerId, cardId), content);

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

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

                return(processResult.Data.Card);
            }
        }
예제 #2
0
 public async Task <ZsCard> UpdateAsync(string customerId, string cardId, ZsCardUpdate updateInput)
 {
     this.client.Configuration.CheckConfig();
     return(await this.UpdateAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, customerId, cardId, updateInput));
 }