Sha256: 850bad5207db980a94c5219553962a8adafb7054c591ee8fd32c0fec34b78b55
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
module Animoto module HTTPEngines extend Support::DynamicClassLoader(File.expand_path(File.dirname(__FILE__))) # @abstract Override {#request} to subclass. class Base # Make a request. # # @abstract # @param [Symbol] method the HTTP method to use, should be lower-case (that is, :get # instead of :GET) # @param [String] url the URL to request # @param [String,nil] body the request body # @param [Hash<String,String>] headers request headers to send; names will be sent as-is # (for example, use keys like "Content-Type" and not :content_type) # @param [Hash<Symbol,Object>] options # @option options [Integer] :timeout set a timeout # @option options [String] :username the authentication username # @option options [String] :password the authentication password # @return [String] the response body # @raise [NotImplementedError] if called on the abstract class def request method, url, body = nil, headers = {}, options = {} raise NotImplementedError end private # Checks the response and raises an error if the status isn't success. # # @param [Fixnum] code the HTTP status code # @param [String] body the HTTP response body # @return [void] # @raise [Animoto::Error] if the status isn't between 200 and 299 def check_response code, body throw(:fail, [code,body]) unless (200..299).include?(code) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
animoto-0.1.1.beta1 | ./lib/animoto/http_engines/base.rb |
animoto-0.1.0.beta1 | ./lib/animoto/http_engines/base.rb |
animoto-0.1.0.beta0 | ./lib/animoto/http_engines/base.rb |