class TicketflyApi::Base

Attributes

errors[R]

Public Class Methods

new() click to toggle source
# File lib/ticketfly-api/base.rb, line 15
def initialize
  @errors = []
end

Public Instance Methods

call(command, options) click to toggle source
# 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