TescoRb
A ruby gem for interacting with the Tesco Api. Currently it supports Grocery & Store Location end points.
Usage Examples:
client = TescoRb.new(YOUR_API_KEY)
# To search for items:
client.search('bananas')
# => [#<TescoRb::Item:0x007fae80828fa8
# @AverageSellingUnitWeight=2.402,
# @ContentsMeasureType="KG",
# @ContentsQuantity=1.0,
# @PromotionDescription="25 extra points on any bananas",
# @UnitOfSale=3,
# @UnitQuantity="KG",
# @image="http://img.tesco.com/Groceries/pi/000/0261480000000/IDShot_90x90.jpg",
# @name="Tesco Bananas Loose",
# @price=0.68,
# @tpnb=50502269,
# @unitprice=0.68>
# ..... ]
# Another way to search for items:
client.item(query: 'bananas', limit: 10) # page 1
client.item(query: 'bananas', limit: 10, offset: 10) # page 2
# To search for Shops:
client.store(near: 'SW5 4YY')
client.store(near: 'SW5 4YY', limit: 5)
client.store(filter: 'isoCountryCode:GB AND category:Store AND facilities:DBT')
# An example shop:
# <TescoRb::Store:0x007fae80ca1ad0
# @address=
# #<TescoRb::Address:0x007fae80ca1300
# @lines=
# [{"lineNumber"=>1, "text"=>"87-93 Gloucester Rd"},
# {"lineNumber"=>2, "text"=>"South Kensington"}],
# @postcode="SW7 4SS",
# @town="London">,
# @altIds={"branchNumber"=>2745},
# @classification={"type"=>"Express", "category"=>"Store"},
# @facilities=[]
# @region={"isoCountryCode"=>"GB"},
# @status={"currentStatus"=>"Trading"}>
Installation
Add this line to your application’s Gemfile:
gem 'tesco_rb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tesco_rb
Todo
- DRY / subclass requesters
- OpeningHours Object
- GeoLocation Object
- Get rid of linting errors
- Think about exceptions / error handling
- Pagination