Class: LeaflyApiWrapper::Location
- Inherits:
-
Object
- Object
- LeaflyApiWrapper::Location
- Defined in:
- lib/leafly_api_wrapper/location.rb
Instance Attribute Summary collapse
-
#ada ⇒ Object
readonly
Returns the value of attribute ada.
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#atm ⇒ Object
readonly
Returns the value of attribute atm.
-
#canadaLP ⇒ Object
readonly
Returns the value of attribute canadaLP.
-
#coverPhoto ⇒ Object
readonly
Returns the value of attribute coverPhoto.
-
#creditCards ⇒ Object
readonly
Returns the value of attribute creditCards.
-
#customMarker ⇒ Object
readonly
Returns the value of attribute customMarker.
-
#customMarker2x ⇒ Object
readonly
Returns the value of attribute customMarker2x.
-
#delivery ⇒ Object
readonly
Returns the value of attribute delivery.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lastMenuUpdate ⇒ Object
readonly
Returns the value of attribute lastMenuUpdate.
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#locationLabel ⇒ Object
readonly
Returns the value of attribute locationLabel.
-
#logo ⇒ Object
readonly
Returns the value of attribute logo.
-
#logoId ⇒ Object
readonly
Returns the value of attribute logoId.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
-
#mapMarker ⇒ Object
readonly
Returns the value of attribute mapMarker.
-
#mapMarkerLevel ⇒ Object
readonly
Returns the value of attribute mapMarkerLevel.
-
#marquee ⇒ Object
readonly
Returns the value of attribute marquee.
-
#medical ⇒ Object
readonly
Returns the value of attribute medical.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#numReviews ⇒ Object
readonly
Returns the value of attribute numReviews.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#price1 ⇒ Object
readonly
Returns the value of attribute price1.
-
#price2 ⇒ Object
readonly
Returns the value of attribute price2.
-
#price3 ⇒ Object
readonly
Returns the value of attribute price3.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#retail ⇒ Object
readonly
Returns the value of attribute retail.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#specials ⇒ Object
readonly
Returns the value of attribute specials.
-
#sponsor ⇒ Object
readonly
Returns the value of attribute sponsor.
-
#starImage ⇒ Object
readonly
Returns the value of attribute starImage.
-
#storefront ⇒ Object
readonly
Returns the value of attribute storefront.
-
#tagLine ⇒ Object
readonly
Returns the value of attribute tagLine.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Location
constructor
A new instance of Location.
Constructor Details
#initialize(data) ⇒ Location
Returns a new instance of Location.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/leafly_api_wrapper/location.rb', line 14 def initialize(data) @id = data['id'] @name = data['name'] @slug = data['slug'] @address = "#{data['address1']} #{data['address2']}".strip @address = "#{data['address']} #{data['locationLabel']}".strip if @address.empty? @hours = data['hours'] @phone = data['phone'] @locationLabel = data['locationLabel'] @delivery = data['delivery'] @storefront = data['storefront'] @lastMenuUpdate = data['lastMenuUpdate'] @latitude = data['latitude'] @longitude = data['longitude'] = data['rating'] @numReviews = data['numReviews'] @sponsor = data['sponsor'] @ada = data['ada'] @creditCards = data['creditCards'] @atm = data['atm'] @marquee = data['marquee'] @coverPhoto = data['coverPhoto'] @logoId = data['logoId'] @logo = data['logo'] @medical = data['medical'] @retail = data['retail'] @price1 = data['price1'] @price2 = data['price2'] @price3 = data['price3'] @mapMarkerLevel = data['mapMarkerLevel'] @canadaLP = data['canadaLP'] @tagLine = data['tagLine'] @permalink = data['permalink'] @starImage = data['starImage'] @customMarker = data['customMarker'] @customMarker2x = data['customMarker2x'] @mapMarker = data['mapMarker'] @specials = data['specials'] end |
Instance Attribute Details
#ada ⇒ Object (readonly)
Returns the value of attribute ada.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def ada @ada end |
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def address @address end |
#atm ⇒ Object (readonly)
Returns the value of attribute atm.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def atm @atm end |
#canadaLP ⇒ Object (readonly)
Returns the value of attribute canadaLP.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def canadaLP @canadaLP end |
#coverPhoto ⇒ Object (readonly)
Returns the value of attribute coverPhoto.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def coverPhoto @coverPhoto end |
#creditCards ⇒ Object (readonly)
Returns the value of attribute creditCards.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def creditCards @creditCards end |
#customMarker ⇒ Object (readonly)
Returns the value of attribute customMarker.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def customMarker @customMarker end |
#customMarker2x ⇒ Object (readonly)
Returns the value of attribute customMarker2x.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def customMarker2x @customMarker2x end |
#delivery ⇒ Object (readonly)
Returns the value of attribute delivery.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def delivery @delivery end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def hours @hours end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def id @id end |
#lastMenuUpdate ⇒ Object (readonly)
Returns the value of attribute lastMenuUpdate.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def lastMenuUpdate @lastMenuUpdate end |
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def latitude @latitude end |
#locationLabel ⇒ Object (readonly)
Returns the value of attribute locationLabel.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def locationLabel @locationLabel end |
#logo ⇒ Object (readonly)
Returns the value of attribute logo.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def logo @logo end |
#logoId ⇒ Object (readonly)
Returns the value of attribute logoId.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def logoId @logoId end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def longitude @longitude end |
#mapMarker ⇒ Object (readonly)
Returns the value of attribute mapMarker.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def mapMarker @mapMarker end |
#mapMarkerLevel ⇒ Object (readonly)
Returns the value of attribute mapMarkerLevel.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def mapMarkerLevel @mapMarkerLevel end |
#marquee ⇒ Object (readonly)
Returns the value of attribute marquee.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def marquee @marquee end |
#medical ⇒ Object (readonly)
Returns the value of attribute medical.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def medical @medical end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def name @name end |
#numReviews ⇒ Object (readonly)
Returns the value of attribute numReviews.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def numReviews @numReviews end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def permalink @permalink end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def phone @phone end |
#price1 ⇒ Object (readonly)
Returns the value of attribute price1.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def price1 @price1 end |
#price2 ⇒ Object (readonly)
Returns the value of attribute price2.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def price2 @price2 end |
#price3 ⇒ Object (readonly)
Returns the value of attribute price3.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def price3 @price3 end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def end |
#retail ⇒ Object (readonly)
Returns the value of attribute retail.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def retail @retail end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def slug @slug end |
#specials ⇒ Object (readonly)
Returns the value of attribute specials.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def specials @specials end |
#sponsor ⇒ Object (readonly)
Returns the value of attribute sponsor.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def sponsor @sponsor end |
#starImage ⇒ Object (readonly)
Returns the value of attribute starImage.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def starImage @starImage end |
#storefront ⇒ Object (readonly)
Returns the value of attribute storefront.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def storefront @storefront end |
#tagLine ⇒ Object (readonly)
Returns the value of attribute tagLine.
7 8 9 |
# File 'lib/leafly_api_wrapper/location.rb', line 7 def tagLine @tagLine end |
Class Method Details
.connection ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/leafly_api_wrapper/location.rb', line 75 def self.connection api_id = LeaflyApiWrapper.configuration.api_id api_key = LeaflyApiWrapper.configuration.api_key base_url = LeaflyApiWrapper.configuration.base_url conn = Faraday.new(url: base_url) do |req| req.headers = { 'app_key' => api_key, 'app_id' => api_id } req.request :url_encoded req.response :logger req.adapter Faraday.default_adapter end end |
.get(slug) ⇒ Object
68 69 70 71 |
# File 'lib/leafly_api_wrapper/location.rb', line 68 def self.get(slug) res = connection.get "/locations/#{slug}" new(JSON.parse(res.body)) end |
.near(lat, lon, options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/leafly_api_wrapper/location.rb', line 55 def self.near(lat, lon, = {}) response = connection.post '/locations', { page: 0, take: 50, latitude: lat, longitude: lon }.merge() JSON.parse(response.body)['stores'].collect do |data| new(data) end end |