Class: Ticketfly::Events

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

Class Method Summary collapse

Class Method Details

.get_by_id(id) ⇒ Object



69
70
71
72
73
74
# File 'lib/ticketfly.rb', line 69

def self.get_by_id(id)
  base_uri = "http://www.ticketfly.com/api/events/upcoming.json"
  max_results = 1
  result = JSON.parse(open(base_uri + "?eventId=" + id.to_s).read)
  Event.build(result['events'].first)
end

.get_by_venue_id(venue_id) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ticketfly.rb', line 83

def self.get_by_venue_id(venue_id)
  base_uri = "http://www.ticketfly.com/api/events/upcoming.json"
  max_results = 200
  events = []
  total_pages = 1
  page = 1
  begin
    result = JSON.parse(open(base_uri + "?venueId=" + venue_id.to_s).read)
    total_pages = result["totalPages"]
    result['events'].each do |e|
      event = Event.build(e)
      events << event
    end
    page += 1
  end while not page > total_pages
  events
end

.get_next_by_venue_id(venue_id) ⇒ Object



76
77
78
79
80
81
# File 'lib/ticketfly.rb', line 76

def self.get_next_by_venue_id(venue_id)
  base_uri = "http://www.ticketfly.com/api/events/upcoming.json"
  max_results = 1
  result = JSON.parse(open(base_uri + "?venueId=" + venue_id.to_s).read)
  Event.build(result['events'].first)
end

.search(query) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ticketfly.rb', line 101

def self.search(query)
  base_uri = "http://www.ticketfly.com/api/events/upcoming.json"
  max_results = 200
  events = []
  total_pages = 1
  page = 1
  begin
    result = JSON.parse(open(base_uri + "?orgId=1&q=" + query.to_s).read)
    total_pages = result["totalPages"]
    result['events'].each do |e|
      event = Event.build(e)
      events << event
    end
    page += 1
  end while not page > total_pages
  events
end