tesco_rb 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.org +34 -4
- data/lib/tesco_rb/client.rb +4 -0
- data/lib/tesco_rb/item_requester.rb +4 -0
- data/lib/tesco_rb/version.rb +1 -1
- data/tesco_rb.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 864370413f5c959a91d3013c2bbd89418211b8fc
|
|
4
|
+
data.tar.gz: 889d9b0e0749aa56cfe5c66a839852afb68a646d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 329bebb51663f4e98febdaf0f13df7e939e245c86245ae2403affbdfe4b4c6937c5034bc161823295e19f76ccbc1c89ec540ed6b74af81a2cec909b6d348f8d5
|
|
7
|
+
data.tar.gz: f35088360d515cbd29951eeedd33ae24b81d276c88c1f0fad2f0f9ad24f89b3c09c3a4fef831085fc4d0ed3a844acdfcca329b481855f7605bb7b06616c69497
|
data/README.org
CHANGED
|
@@ -2,21 +2,50 @@
|
|
|
2
2
|
A ruby gem for interacting with the [[https://devportal.tescolabs.com/docs/services/][Tesco Api]].
|
|
3
3
|
Currently it supports [[https://devportal.tescolabs.com/docs/services/56c73b1bf205fd0ed81dbe7a][Grocery]] & [[https://devportal.tescolabs.com/docs/services/5731ed21611a4b2968547c5f][Store Location]] end points.
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
** Usage Examples:
|
|
7
6
|
|
|
8
7
|
#+BEGIN_SRC ruby
|
|
9
8
|
client = TescoRb.new(YOUR_API_KEY)
|
|
10
9
|
|
|
11
10
|
# To search for items:
|
|
12
|
-
client.
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
client.search('bananas')
|
|
12
|
+
# => [#<TescoRb::Item:0x007fae80828fa8
|
|
13
|
+
# @AverageSellingUnitWeight=2.402,
|
|
14
|
+
# @ContentsMeasureType="KG",
|
|
15
|
+
# @ContentsQuantity=1.0,
|
|
16
|
+
# @PromotionDescription="25 extra points on any bananas",
|
|
17
|
+
# @UnitOfSale=3,
|
|
18
|
+
# @UnitQuantity="KG",
|
|
19
|
+
# @image="http://img.tesco.com/Groceries/pi/000/0261480000000/IDShot_90x90.jpg",
|
|
20
|
+
# @name="Tesco Bananas Loose",
|
|
21
|
+
# @price=0.68,
|
|
22
|
+
# @tpnb=50502269,
|
|
23
|
+
# @unitprice=0.68>
|
|
24
|
+
# ..... ]
|
|
25
|
+
|
|
26
|
+
# Another way to search for items:
|
|
27
|
+
client.item(query: 'bananas', limit: 10) # page 1
|
|
28
|
+
client.item(query: 'bananas', limit: 10, offset: 10) # page 2
|
|
15
29
|
|
|
16
30
|
# To search for Shops:
|
|
17
31
|
client.store(near: 'SW5 4YY')
|
|
18
32
|
client.store(near: 'SW5 4YY', limit: 5)
|
|
19
33
|
client.store(filter: 'isoCountryCode:GB AND category:Store AND facilities:DBT')
|
|
34
|
+
|
|
35
|
+
# An example shop:
|
|
36
|
+
# <TescoRb::Store:0x007fae80ca1ad0
|
|
37
|
+
# @address=
|
|
38
|
+
# #<TescoRb::Address:0x007fae80ca1300
|
|
39
|
+
# @lines=
|
|
40
|
+
# [{"lineNumber"=>1, "text"=>"87-93 Gloucester Rd"},
|
|
41
|
+
# {"lineNumber"=>2, "text"=>"South Kensington"}],
|
|
42
|
+
# @postcode="SW7 4SS",
|
|
43
|
+
# @town="London">,
|
|
44
|
+
# @altIds={"branchNumber"=>2745},
|
|
45
|
+
# @classification={"type"=>"Express", "category"=>"Store"},
|
|
46
|
+
# @facilities=[]
|
|
47
|
+
# @region={"isoCountryCode"=>"GB"},
|
|
48
|
+
# @status={"currentStatus"=>"Trading"}>
|
|
20
49
|
#+END_SRC
|
|
21
50
|
|
|
22
51
|
** Installation
|
|
@@ -49,3 +78,4 @@ $ gem install tesco_rb
|
|
|
49
78
|
- GeoLocation Object
|
|
50
79
|
- Get rid of linting errors
|
|
51
80
|
- Think about exceptions / error handling
|
|
81
|
+
- Pagination
|
data/lib/tesco_rb/client.rb
CHANGED
|
@@ -2,6 +2,7 @@ require_relative 'item'
|
|
|
2
2
|
|
|
3
3
|
# TODO: subclass these requesters as they share loads of logic.
|
|
4
4
|
module TescoRb
|
|
5
|
+
|
|
5
6
|
class ItemRequester
|
|
6
7
|
def create_representations(client, hash_args)
|
|
7
8
|
response = request(client, update_args(hash_args))
|
|
@@ -9,6 +10,9 @@ module TescoRb
|
|
|
9
10
|
products.map do |json|
|
|
10
11
|
Item.new(json)
|
|
11
12
|
end
|
|
13
|
+
rescue => e
|
|
14
|
+
p e
|
|
15
|
+
[]
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
private
|
data/lib/tesco_rb/version.rb
CHANGED
data/tesco_rb.gemspec
CHANGED
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
if spec.respond_to?(:metadata)
|
|
19
19
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
20
20
|
else
|
|
21
|
-
|
|
21
|
+
fail 'RubyGems 2.0 or newer is required'
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|