Skip to content

Commit

Permalink
fix get_all
Browse files Browse the repository at this point in the history
  • Loading branch information
haukot committed Jul 8, 2023
1 parent 1c23526 commit 12db9dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ecwid_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_all(path, params={}, &block)
# TODO: здесь не обрабатываются failure?
# Но и падать не надо, поидее? Т.к. может быть много уже загруженных данных.
# Надо ретраить?
PagedEcwidResponse.new(client, path, params, &block)
PagedEcwidResponse.new(self, path, params, &block)
end

def post(*args, &block)
Expand Down
4 changes: 2 additions & 2 deletions lib/ecwid_api/paged_ecwid_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def each

begin
response = @client.get(@path, params)
items = response.with_indifferent_access.body["items"] || []
items = response.with_indifferent_access["items"] || []
items.each do |item|
yield(@block ? @block.call(item) : item)
end
count, offset, total = %w(count offset total).map do |i|
response.body[i].to_i
response[i].to_i
end

params = params.merge(offset: offset + count)
Expand Down

0 comments on commit 12db9dd

Please sign in to comment.