/// <summary> /// Returns a [cursor-paginated](#api-usage-cursor-pagination) list of /// your webhooks. /// </summary> /// <param name="request">An optional `WebhookListRequest` representing the query parameters for this list request.</param> /// <param name="customiseRequestMessage">An optional `RequestSettings` allowing you to configure the request</param> /// <returns>A set of webhook resources</returns> public Task <WebhookListResponse> ListAsync(WebhookListRequest request = null, RequestSettings customiseRequestMessage = null) { request = request ?? new WebhookListRequest(); var urlParams = new List <KeyValuePair <string, object> > { }; return(_goCardlessClient.ExecuteAsync <WebhookListResponse>("GET", "/webhooks", urlParams, request, null, null, customiseRequestMessage)); }
/// <summary> /// Get a lazily enumerated list of webhooks. /// This acts like the #list method, but paginates for you automatically. /// </summary> public IEnumerable <Task <IReadOnlyList <Webhook> > > AllAsync(WebhookListRequest request = null, RequestSettings customiseRequestMessage = null) { request = request ?? new WebhookListRequest(); return(new TaskEnumerable <IReadOnlyList <Webhook>, string>(async after => { request.After = after; var list = await this.ListAsync(request, customiseRequestMessage); return Tuple.Create(list.Webhooks, list.Meta?.Cursors?.After); })); }
/// <summary> /// Get a lazily enumerated list of webhooks. /// This acts like the #list method, but paginates for you automatically. /// </summary> public IEnumerable <Webhook> All(WebhookListRequest request = null, RequestSettings customiseRequestMessage = null) { request = request ?? new WebhookListRequest(); string cursor = null; do { request.After = cursor; var result = Task.Run(() => ListAsync(request, customiseRequestMessage)).Result; foreach (var item in result.Webhooks) { yield return(item); } cursor = result.Meta?.Cursors?.After; } while (cursor != null); }