Class: Eventify::Provider::Livenation

Inherits:
Base
  • Object
show all
Defined in:
lib/eventify/provider/livenation.rb

Constant Summary collapse

URL =
"https://www.livenation.ee/api/search/events?IncludePostponed=true&IncludeCancelled=false&Url=%2Fevent%2Fallevents&PageSize=200&Page=1&CountryIds=68"

Constants inherited from Base

Base::MissingAttributeError

Instance Attribute Summary

Attributes inherited from Base

#date, #id, #link, #title

Class Method Summary collapse

Methods inherited from Base

#<=>, #==, #exists?, #hash, #initialize, #provider, #save

Constructor Details

This class inherits a constructor from Eventify::Provider::Base

Class Method Details

.fetchObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/eventify/provider/livenation.rb', line 10

def fetch
  json = JSON.parse(URI.open(URL).read)
  entries = json["documents"]
  entries.map do |entry|
    localization = entry["localizations"][0]
    url = URI.parse(localization["url"])
    url = URI.parse("https://www.livenation.ee#{url}") unless url.host
    new id: entry["id"], title: localization["name"], link: url.to_s, date: Time.parse(entry["eventDate"])
  end
end