Skip to content

feat: Add new methods to retrieve paginated data #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "onelogin"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

require "irb"
IRB.start(__FILE__)
21 changes: 20 additions & 1 deletion lib/onelogin/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,30 @@ def authorazation
end

DefaultApi.public_instance_methods(false)
.reject { |m| m =~ /api_client|generate_token|_with_http_info/ }
.reject { |m| m =~ /api_client|generate_token|list_|_with_http_info/ }
.each do |name|
define_method(name) do |*args|
@client.send(name, authorazation, *args)
end
end

DefaultApi.public_instance_methods(false)
.select { |m| m =~ /list_/ }
.reject { |m| m =~ /_with_http_info/ }
.each do |name|
define_method(name) do |opts = {}|
result = []
cursor = ""
loop do
data, status, header = @client.send("#{name}_with_http_info", authorazation, opts.merge(cursor: cursor))
result += data

cursor = header['after-cursor']
break if status != 200 || cursor.nil?
end

result
end
end
end
end