-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Hi there! First off, really appreciate this project. It's shaved days off my timelines.
I'm considering doing a PR against this project for exposing pagination in an easier way. I extended the oktakit client quick and dirty like this for my project, and thought it might be a nice method for this gem (I skimmed open PRs and issues and didn't see anything already in the pipes).
I'd want to clean this up more, but wanted to ask here first to see if some better approach already exists, or if you think this would help:
class OktaClient < Oktakit::Client
# This is copied from https://github.com/Shopify/oktakit/blob/master/lib/oktakit/client.rb#L65, but this just fetches a single page, instead of recursing to fetch every page
def alt_get(url, options = {})
should_paginate = options.delete(:paginate)
request_options = {
query: options.delete(:query),
headers: options.delete(:headers),
accept: options.delete(:accept),
content_type: options.delete(:content_type),
paginate: should_paginate,
data: options
}
resp, status, next_page = request(:get, url, **request_options)
[resp, status, next_page]
end
def get_each_page(url, options = {})
next_page = url
while next_page
resp, status, next_page = alt_get(next_page, options.merge(paginate: true))
raise RequestError, "Error fetching okta #{url}, status=#{status}, response=#{resp}" unless status == 200
yield(resp, status, next_page)
end
end
end
I'm just trying to help though! I'm happy to just keep my extension, so feel free to ignore and close with or without comment :)
sebastiangeiger
Metadata
Metadata
Assignees
Labels
No labels