public static Task <HttpResponseMessage> GetAsync(this HttpClient client, string requestUri, CursorPager pager, CancellationToken cancellationToken = default(CancellationToken)) { if (pager == null) { pager = new CursorPager(); } if (!string.IsNullOrEmpty(pager.Cursor)) { var encodedCursor = Uri.EscapeDataString(pager.Cursor); if (requestUri.Contains("?")) { requestUri += $"&cursor={encodedCursor}"; } else { requestUri += $"?cursor={encodedCursor}"; } } if (requestUri.Contains("?")) { requestUri += $"&limit={pager.ResultsLimit}"; } else { requestUri += $"?limit={pager.ResultsLimit}"; } return(client.GetAsync(requestUri, cancellationToken)); }
public async Task <TicketAuditResponse> GetAllAsync(CursorPager pager = null, CancellationToken cancellationToken = default(CancellationToken)) { return(await GetAsyncWithCursor <TicketAuditResponse>( ResourceUri, "list-all-ticket-audits", "GetAllAsync", pager, cancellationToken)); }
protected async Task <T> GetAsyncWithCursor <T>(string resource, string docs, string scope, CursorPager pager, CancellationToken cancellationToken = default(CancellationToken)) where T : class { return(await ExecuteRequest(async (client, token) => await client.GetAsync(resource, pager, token).ConfigureAwait(false), scope, cancellationToken) .ThrowIfUnsuccessful($"{DocsResource}#{docs}") .ReadContentAsAsync <T>()); }