Class: TicketflyApi::Base
- Inherits:
-
Object
- Object
- TicketflyApi::Base
- Includes:
- HTTParty, Events
- Defined in:
- lib/ticketfly-api/base.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #call(command, options) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
Methods included from Events
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
15 16 17 |
# File 'lib/ticketfly-api/base.rb', line 15 def initialize @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (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, ) begin result = self.class.get("/#{command}", :query => ) 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 |