Skip to content
Open
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
8 changes: 5 additions & 3 deletions lib/oktakit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def get(url, options = {})
if status == 200 && should_paginate
all_objs = [resp]
while next_page
resp, status, next_page = request :get, next_page, **request_options
sleep 1.5
resp, status, next_page = request :get, next_page, uri_encode_url: false, **request_options
break unless status == 200 # Return early if page request fails

all_objs << resp
Expand Down Expand Up @@ -162,14 +163,15 @@ def head(url, options = {})

private

def request(method, path, data:, query:, headers:, accept:, content_type:, paginate: false)
def request(method, path, data:, query:, headers:, accept:, content_type:, paginate: false, uri_encode_url: true)
options = {}
options[:query] = query || {}
options[:headers] = headers || {}
options[:headers][:accept] = accept if accept
options[:headers][:content_type] = content_type if content_type

uri = URI::DEFAULT_PARSER.escape("/api/v1" + path.to_s)
uri = "/api/v1" + path.to_s
uri = URI::DEFAULT_PARSER.escape(uri) if uri_encode_url
@last_response = resp = sawyer_agent.call(method, uri, data, options)

response = [resp.data, resp.status]
Expand Down