Skip to content

Instantly share code, notes, and snippets.

@duckinator
Last active March 23, 2016 20:11
Show Gist options
  • Select an option

  • Save duckinator/ef08acbe04aef940a2b1 to your computer and use it in GitHub Desktop.

Select an option

Save duckinator/ef08acbe04aef940a2b1 to your computer and use it in GitHub Desktop.
def fetch_items(options={})
limit = options.fetch(:limit)
timestamp = options.fetch(:timestamp)
paged_helper = PagedHelper
client = OurHttpClient
responses = paged_helper.
new(limit, timestamp).
fetch_pages { |params| client.get(params) }
responses.
map { |r| JSON.parse(r) }.
map { |h| ItemCollection.new(h) }.
map { |ic| ic.items }.
flatten
end
def fetch_items(options={})
limit = options.fetch(:limit)
timestamp = options.fetch(:timestamp)
paged_helper = PagedHelper
client = OurHttpClient
responses = paged_helper.
new(limit, timestamp).
fetch_pages { |params| client.get(params) }
responses.
map { |r|
h = JSON.parse(r)
ic = ItemCollection.new(h)
ic.items
}.
flatten
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment