Class: VividSeats::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/vivid_seats/api.rb

Constant Summary collapse

Error =
Class.new(StandardError)
Timeout =
Class.new(Error)
Unauthorized =
Class.new(Error)

Class Method Summary collapse

Class Method Details

.categories(query = {}) ⇒ Object



21
22
23
# File 'lib/vivid_seats/api.rb', line 21

def categories(query={})
  get('/getCategories', :query => query)
end

.events(query = {}) ⇒ Object



29
30
31
# File 'lib/vivid_seats/api.rb', line 29

def events(query={})
  get('/getEvents', :query => query)
end

.get(*args) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vivid_seats/api.rb', line 45

def get(*args)
  response = super

  case response.code
    when 412
      raise Unauthorized.new(response.body)
    else
      response
  end
rescue Errno::ECONNRESET
  raise Error.new($!.message)
rescue Errno::ETIMEDOUT
  raise Timeout.new($!.message)
end

.performances(query = {}) ⇒ Object



25
26
27
# File 'lib/vivid_seats/api.rb', line 25

def performances(query={})
  get('/getEventPerformers', :query => query)
end

.performers(query = {}) ⇒ Object



33
34
35
# File 'lib/vivid_seats/api.rb', line 33

def performers(query={})
  get('/getPerformers', :query => query)
end

.regions(query = {}) ⇒ Object



37
38
39
# File 'lib/vivid_seats/api.rb', line 37

def regions(query={})
  get('/getRegions', :query => query)
end

.venues(query = {}) ⇒ Object



41
42
43
# File 'lib/vivid_seats/api.rb', line 41

def venues(query={})
  get('/getVenues', :query => query)
end