public async Task <ZsCard> CreateAsync(string apiBaseUrl, string authToken, string organizationId, string customerId, ZsCardCreate createInput) { apiBaseUrl.CheckConfigApiBaseUrl(); authToken.CheckConfigAuthToken(); organizationId.CheckConfigOrganizationId(); if (string.IsNullOrWhiteSpace(customerId)) { throw new ArgumentNullException("customerId"); } if (createInput == null) { throw new ArgumentNullException("createInput"); } var validationResult = createInput.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( createInput, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), Encoding.UTF8, "application/json"); var response = await httpClient.PostAsync(string.Format(CultureInfo.InvariantCulture, ApiResources.ZsPostCard, customerId), content); var processResult = await response.ProcessResponse <ZsCardJson>(); if (null != processResult.Error) { throw processResult.Error; } return(processResult.Data.Card); } }
public async Task <ZsCard> CreateAsync(string customerId, ZsCardCreate createInput) { this.client.Configuration.CheckConfig(); return(await this.CreateAsync(this.client.Configuration.ApiBaseUrl, this.client.Configuration.AuthToken, this.client.Configuration.OrganizationId, customerId, createInput)); }