Sha256: bf5bd62447923cda3b04a2751dd20c475f6890ee73ccbcb36dee49b767c1540a
Contents?: true
Size: 860 Bytes
Versions: 1
Compression:
Stored size: 860 Bytes
Contents
require "api_client/version" require "net/http" module ApiClient autoload :Exceptions, 'api_client/exceptions' def self.get(url = '') response = Net::HTTP.get_response(URI.parse(url)) raise_exception(response.code) response.body end def self.post(url = '', args = {}) response = Net::HTTP.post_form(URI.parse(url), args) raise_exception(response.code) response.body end def self.raise_exception(code) case code when '401' then raise ApiClient::Exceptions::Unauthorized when '403' then raise ApiClient::Exceptions::Forbidden when '404' then raise ApiClient::Exceptions::NotFound when '500' then raise ApiClient::Exceptions::InternalServerError when '502' then raise ApiClient::Exceptions::BadGateway when '503' then raise ApiClient::Exceptions::ServiceUnavailable end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api-client-0.4.0 | lib/api_client.rb |