Class: TangaServices::HTTP

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

Defined Under Namespace

Classes: Exception

Instance Method Summary collapse

Constructor Details

#initialize(method, *args) ⇒ HTTP

Returns a new instance of HTTP.



25
26
27
28
# File 'lib/tanga_services/http.rb', line 25

def initialize(method, *args)
  @method = method
  @args   = *args
end

Instance Method Details

#callObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tanga_services/http.rb', line 30

def call
  begin
    Http::Exceptions.wrap_and_check do
      response = HTTParty.send(@method, *@args)
      response.parsed_response # See that the response can be accessed
      response
    end
  rescue Http::Exceptions::HttpException, JSON::ParserError
    fail TangaServices::HTTP::Exception
  end
end