public async Task <ICollection <Voucher> > GenerateVouchersAsync(NewVoucherParams voucherParams, string cloudControllerId = null) { cloudControllerId = CheckCloudControllerId(cloudControllerId); //Generate Vouchers { var response = await client.PostAsync(GenerateVoucherEndpoint + cloudControllerId, new StringContent(voucherParams.ToJson())); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); var json = JsonConvert.DeserializeObject <BaseResponse>(responseText); json.EnsureSuccessStatusCode(); } //Query Vouchers { var response = await client.PostAsync(QueryVoucherEndpoint + cloudControllerId, new StringContent(voucherParams.ToQueryVouchersParams().ToJson())); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); var json = JsonConvert.DeserializeObject <BaseResponse <QueryVouchersResult> >(responseText); json.EnsureSuccessStatusCode(); return(json.Result.Vouchers); } }
public async Task <ICollection <Voucher> > GenerateVouchersAsync(NewVoucherParams voucherParams) { if (string.IsNullOrEmpty(DefaultCloudControllerId)) { throw new ArgumentException("DefaultCloudControllerId is null"); } return(await GenerateVouchersAsync(voucherParams, DefaultCloudControllerId)); }