Class: TicketflyApi::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Events
Defined in:
lib/ticketfly-api/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Events

#event_show

Constructor Details

#initializeBase

Returns a new instance of Base.



15
16
17
# File 'lib/ticketfly-api/base.rb', line 15

def initialize
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



13
14
15
# File 'lib/ticketfly-api/base.rb', line 13

def errors
  @errors
end

Instance Method Details

#call(command, options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ticketfly-api/base.rb', line 19

def call(command, options)
  begin
    result = self.class.get("/#{command}", :query => options)
  rescue HTTParty::UnsupportedFormat, HTTParty::UnsupportedURIScheme, HTTParty::ResponseError, HTTParty::RedirectionTooDeep
    raise NetworkError.new
  end

  if result && result.parsed_response == "<html><body><h1>500 Internal Server Error</h1></body></html>"
    @errors << "Ticketfly returned a 500 error"
    raise CommandError.new 
  end

  @errors << result["error"] if result && result["error"]
  raise InvalidResponseError.new if result.nil? || !result["error"].blank?
  result
end