class TescoRb::ItemRequester

Public Instance Methods

create_representations(client, hash_args) click to toggle source
# File lib/tesco_rb/item_requester.rb, line 7
def create_representations(client, hash_args)
  response = request(client, update_args(hash_args))
  products = response['uk']['ghs']['products']['results']
  products.map do |json|
    Item.new(json)
  end
rescue => e
  p e
  []
end

Private Instance Methods

request(client, hash_args) click to toggle source
# File lib/tesco_rb/item_requester.rb, line 26
def request(client, hash_args)
  client.get '/grocery/products', query: hash_args
end
update_args(args) click to toggle source
# File lib/tesco_rb/item_requester.rb, line 20
def update_args(args)
  args[:offset] ||= 0
  args[:limit] ||= 1
  args
end