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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcff709eff851b88df22d6cc9624d5eae18a604e
4
- data.tar.gz: 4e04e3a4673b7a745e349d12a346e8e6f5225a92
3
+ metadata.gz: 864370413f5c959a91d3013c2bbd89418211b8fc
4
+ data.tar.gz: 889d9b0e0749aa56cfe5c66a839852afb68a646d
5
5
  SHA512:
6
- metadata.gz: 43fd8bd7d29e112fcb4b86db4e1617ce60faa35c24c9f824a6bcd240c3713d312b55eb8cdcad08b90f0c1087a9e765ee14ed0585581f2414edf2f0336ce08c45
7
- data.tar.gz: 52d4822369f269367f5cc0461c5f15a6b16de1f59602fb79296be4b669299b52267e1e95db29ef2c816fc7eac6613865c09fe2cfa5db67abd36048380f2aa589
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.item.search('bananas')
13
- client.item.search('bananas', limit: 10)
14
- client.item.search('bananas', limit: 10, offset: 10)
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
@@ -23,6 +23,10 @@ module TescoRb
23
23
  ItemRequester.new.create_representations(self, options)
24
24
  end
25
25
 
26
+ def search(item_name)
27
+ item(query: item_name, limit: 10)
28
+ end
29
+
26
30
  def get(url, options = {})
27
31
  self.class.get(url, options.merge(default_options))
28
32
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TescoRb
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
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
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tesco_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Clarke