Class: LeaflyApiWrapper::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/leafly_api_wrapper/location.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Location

Returns a new instance of Location.



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
# File 'lib/leafly_api_wrapper/location.rb', line 16

def initialize(data)
  @id = data['id']
  @slug = data['slug']
  @name = data['name']
  @atm = data['atm']
  @creditCards = data['creditCards']
  @veteranDiscount = data['veteranDiscount']
  @ada = data['ada']
  @delivery = data['delivery']
  @retail = data['retail']
  @medical = data['medical']
  @storefront = data['storefront']
  @logo = data['logo']
  @address = data['address']
  @city = data['city']
  @state = data['state']
  @zip = data['zip']
  @phone = data['phone']
  @hours = data['hours']
  @website = data['website']
  @desription = data['desription']
  @latitude = data['latitude']
  @longitude = data['longitude']
  @photos = data['photos']
  @permalink = data['permalink']
  @canadaLP = data['canadaLP']
  @tagLine = data['tagLine']
  @tagLineBlurb = data['tagLineBlurb']
  @facebookUrl = data['facebookUrl']
  @twitterUrl = data['twitterUrl']
  @googlePlusUrl = data['googlePlusUrl']
  @pinterestUrl = data['pinterestUrl']
  @tumblrUrl = data['tumblrUrl']
  @instagramUrl = data['instagramUrl']
  @specials = data['specials']
end

Instance Attribute Details

#adaObject (readonly)

Returns the value of attribute ada.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def ada
  @ada
end

#addressObject (readonly)

Returns the value of attribute address.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def address
  @address
end

#atmObject (readonly)

Returns the value of attribute atm.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def atm
  @atm
end

#canadaLPObject (readonly)

Returns the value of attribute canadaLP.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def canadaLP
  @canadaLP
end

#cityObject (readonly)

Returns the value of attribute city.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def city
  @city
end

#creditCardsObject (readonly)

Returns the value of attribute creditCards.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def creditCards
  @creditCards
end

#deliveryObject (readonly)

Returns the value of attribute delivery.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def delivery
  @delivery
end

#desriptionObject (readonly)

Returns the value of attribute desription.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def desription
  @desription
end

#facebookUrlObject (readonly)

Returns the value of attribute facebookUrl.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def facebookUrl
  @facebookUrl
end

#googlePlusUrlObject (readonly)

Returns the value of attribute googlePlusUrl.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def googlePlusUrl
  @googlePlusUrl
end

#hoursObject (readonly)

Returns the value of attribute hours.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def hours
  @hours
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def id
  @id
end

#instagramUrlObject (readonly)

Returns the value of attribute instagramUrl.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def instagramUrl
  @instagramUrl
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def latitude
  @latitude
end

#logoObject (readonly)

Returns the value of attribute logo.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def 
  @logo
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def longitude
  @longitude
end

#medicalObject (readonly)

Returns the value of attribute medical.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def medical
  @medical
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def name
  @name
end

Returns the value of attribute permalink.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def permalink
  @permalink
end

#phoneObject (readonly)

Returns the value of attribute phone.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def phone
  @phone
end

#photosObject (readonly)

Returns the value of attribute photos.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def photos
  @photos
end

#pinterestUrlObject (readonly)

Returns the value of attribute pinterestUrl.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def pinterestUrl
  @pinterestUrl
end

#retailObject (readonly)

Returns the value of attribute retail.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def retail
  @retail
end

#slugObject (readonly)

Returns the value of attribute slug.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def slug
  @slug
end

#specialsObject (readonly)

Returns the value of attribute specials.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def specials
  @specials
end

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def state
  @state
end

#storefrontObject (readonly)

Returns the value of attribute storefront.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def storefront
  @storefront
end

#tagLineObject (readonly)

Returns the value of attribute tagLine.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def tagLine
  @tagLine
end

#tagLineBlurbObject (readonly)

Returns the value of attribute tagLineBlurb.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def tagLineBlurb
  @tagLineBlurb
end

#tumblrUrlObject (readonly)

Returns the value of attribute tumblrUrl.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def tumblrUrl
  @tumblrUrl
end

#twitterUrlObject (readonly)

Returns the value of attribute twitterUrl.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def twitterUrl
  @twitterUrl
end

#veteranDiscountObject (readonly)

Returns the value of attribute veteranDiscount.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def veteranDiscount
  @veteranDiscount
end

#websiteObject (readonly)

Returns the value of attribute website.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def website
  @website
end

#zipObject (readonly)

Returns the value of attribute zip.



7
8
9
# File 'lib/leafly_api_wrapper/location.rb', line 7

def zip
  @zip
end

Class Method Details

.get(slug) ⇒ Object



67
68
69
70
71
72
# File 'lib/leafly_api_wrapper/location.rb', line 67

def self.get(slug)
  res = connection.get "/locations/#{slug}"
  raw_data = JSON.parse(res.body)
  data = LeaflyApiWrapper::Mapper.new(raw_data, 'location_detail').mapped
  new(data)
end

.near(lat, lon, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/leafly_api_wrapper/location.rb', line 53

def self.near(lat, lon, options = {})
  response = connection.post '/locations', {
    page:      0,
    take:      50,
    latitude:  lat,
    longitude: lon
  }.merge(options)

  JSON.parse(response.body)['stores'].collect do |raw_data|
    data = LeaflyApiWrapper::Mapper.new(raw_data, 'location_search').mapped
    new(data)
  end
end