Class: PQSDK::Store
- Inherits:
-
RemoteObject
- Object
- RemoteObject
- PQSDK::Store
- Defined in:
- lib/pqsdk/store.rb
Overview
The Store class provides an interface for crawlers to the v1/stores api endpoint.
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#city_id ⇒ Object
Returns the value of attribute city_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#name ⇒ Object
Returns the value of attribute name.
-
#opening_hours ⇒ Object
Returns the value of attribute opening_hours.
-
#opening_hours_text ⇒ Object
Returns the value of attribute opening_hours_text.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#region ⇒ Object
Returns the value of attribute region.
-
#zipcode ⇒ Object
Returns the value of attribute zipcode.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from RemoteObject
all, #create, #create!, get, #persisted?, #save, #save!, #update, #update!
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def city @city end |
#city_id ⇒ Object
Returns the value of attribute city_id.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def city_id @city_id end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def id @id end |
#latitude ⇒ Object
Returns the value of attribute latitude.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def longitude @longitude end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def name @name end |
#opening_hours ⇒ Object
Returns the value of attribute opening_hours.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def opening_hours @opening_hours end |
#opening_hours_text ⇒ Object
Returns the value of attribute opening_hours_text.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def opening_hours_text @opening_hours_text end |
#origin ⇒ Object
Returns the value of attribute origin.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def origin @origin end |
#phone ⇒ Object
Returns the value of attribute phone.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def phone @phone end |
#region ⇒ Object
Returns the value of attribute region.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def region @region end |
#zipcode ⇒ Object
Returns the value of attribute zipcode.
9 10 11 |
# File 'lib/pqsdk/store.rb', line 9 def zipcode @zipcode end |
Class Method Details
.find(address, zipcode, retailer = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pqsdk/store.rb', line 27 def self.find(address, zipcode, retailer = nil) res = RestLayer.get(@endpoint, { address: address, zipcode: zipcode, retailer: retailer }, 'Authorization' => "Bearer #{Token.access_token}") if res[0] == 200 from_hash res[1] elsif res[0] == 404 nil else raise "Unexpected HTTP status code #{res[0]}, #{res[1]}" end end |
.from_hash(json) ⇒ Object
38 39 40 |
# File 'lib/pqsdk/store.rb', line 38 def self.from_hash(json) super(json.stringify_keys.except('city')) end |
Instance Method Details
#attributes ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/pqsdk/store.rb', line 15 def attributes { 'origin' => nil, 'name' => nil, 'address' => nil, 'latitude' => nil, 'longitude' => nil, 'city' => nil, 'city_id' => nil, 'zipcode' => nil, 'phone' => nil, 'opening_hours' => nil, 'opening_hours_text' => nil, 'region' => nil } end |