Skip to content
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

Add support for sending remaining options with query #592

Merged
merged 1 commit into from
Jun 20, 2023
Merged
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: 6 additions & 2 deletions lib/quickbooks/service/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ def url_for_query(query = nil, start_position = 1, max_results = 20, options = {
query ||= default_model_query
query = "#{query} STARTPOSITION #{start_position} MAXRESULTS #{max_results}"

"#{url_for_base}/query?query=#{CGI.escape(query)}"
URI("#{url_for_base}/query").tap do |uri|
params = Faraday::Utils::ParamsHash.new
params.update(options.merge(query: query))
uri.query = params.to_query
end.to_s
end

private
Expand Down Expand Up @@ -116,7 +120,7 @@ def fetch_collection(query, model, options = {})
start_position = ((page - 1) * per_page) + 1 # page=2, per_page=10 then we want to start at 11
max_results = per_page

response = do_http_get(url_for_query(query, start_position, max_results))
response = do_http_get(url_for_query(query, start_position, max_results, options.except(:page, :per_page)))

parse_collection(response, model)
end
Expand Down