Skip to content

Commit 40bf4b3

Browse files
committed
Fix bugs in client code where next cursor param is sent in request body instead of as query param
1 parent 801fc03 commit 40bf4b3

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

.fernignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ test/
66
.github/workflows
77
README.md
88
lib/square/file_param.rb
9-
custom.gemfile.rb
9+
custom.gemfile.rb
10+
11+
# Pagination is currently broken for endpoints where the page token is not submitted via a query param
12+
# Manually fixed pagination bugs in:
13+
lib/square/inventory/client.rb
14+
lib/square/transfer_orders/client.rb

lib/square/inventory/client.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ def batch_get_changes(request_options: {}, **params)
173173
Square::Internal::CursorItemIterator.new(
174174
cursor_field: :cursor,
175175
item_field: :changes,
176-
initial_cursor: _query[:cursor]
176+
initial_cursor: params[:cursor]
177177
) do |next_cursor|
178-
_query[:cursor] = next_cursor
178+
params[:cursor] = next_cursor
179179
_request = Square::Internal::JSON::Request.new(
180180
base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
181181
method: "POST",
@@ -214,9 +214,9 @@ def batch_get_counts(request_options: {}, **params)
214214
Square::Internal::CursorItemIterator.new(
215215
cursor_field: :cursor,
216216
item_field: :counts,
217-
initial_cursor: _query[:cursor]
217+
initial_cursor: params[:cursor]
218218
) do |next_cursor|
219-
_query[:cursor] = next_cursor
219+
params[:cursor] = next_cursor
220220
_request = Square::Internal::JSON::Request.new(
221221
base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
222222
method: "POST",

lib/square/transfer_orders/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def search(request_options: {}, **params)
6464
Square::Internal::CursorItemIterator.new(
6565
cursor_field: :cursor,
6666
item_field: :transfer_orders,
67-
initial_cursor: _query[:cursor]
67+
initial_cursor: params[:cursor]
6868
) do |next_cursor|
69-
_query[:cursor] = next_cursor
69+
params[:cursor] = next_cursor
7070
_request = Square::Internal::JSON::Request.new(
7171
base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
7272
method: "POST",

0 commit comments

Comments
 (0)