public async Task <List <SeatDetails> > GetSeats( ProductKey productKey, int maxResults = 25) { var results = new List <SeatDetails>(); Func <string, Task <SeatDetailsResultSet> > function = async(token) => { var query = QueryString.Create(); query.AddParameter("continuationToken", token); query.AddParameter("maxResults", maxResults); var url = $"{baseUri}/Inventory/{productKey.ProductId}/{productKey.SkuId}/Seats?{query.ToString()}"; var response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsAsync <SeatDetailsResultSet>(); return(result); }; string continuationtoken = null; do { var output = await Task.Run(() => function(continuationtoken)); results.AddRange(output.Seats); continuationtoken = output.ContinuationToken; } while (continuationtoken != null); return(results); }
public async Task <ProductPackageDetails> GetProductPackage( ProductKey productKey, string packageId) { var url = $"{baseUri}/Products/{productKey.ProductId}/{productKey.SkuId}/Packages/{packageId}"; var response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsAsync <ProductPackageDetails>(); return(result); }
public async Task <LocalizedProductDetail> GetLocalizedProductDetails( ProductKey productKey, string language) { var url = $"{baseUri}/Products/{productKey.ProductId}/{productKey.SkuId}/LocalizedDetails/{language}"; var response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsAsync <LocalizedProductDetail>(); return(result); }
public async Task <SeatDetails> GetSeat( ProductKey productKey, string username) { var url = $"{baseUri}/Inventory/{productKey.ProductId}/{productKey.SkuId}/Seats/{username}"; var response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsAsync <SeatDetails>(); return(result); }
public async Task <BulkSeatOperationResultSet> ChangeSeats( ProductKey productKey, SeatAction action, params string[] userNames ) { var url = $"{baseUri}/Inventory/{productKey.ProductId}/{productKey.SkuId}/Seats"; var json = new { UserNames = userNames, seatAction = action }; var response = await client.PostAsJsonAsync(url, json); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsAsync <BulkSeatOperationResultSet>(); return(result); }