Sha256: cbbdb9525773caf9bae25d280ac20ab773112b2c20cf26e40d19d71fff90f374
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
module MambaNation class HTTPAuth include HTTParty format :plain attr_reader :username, :password, :options def initialize(username, password, options={}) @username, @password = username, password @options = { :ssl => false, :timeout => 100 }.merge(options) options[:api_endpoint] ||= "api.mambanation.com" if options[:api_version] == false version_path = "v2" else options[:api_version] ||= API_VERSION version_path = "v#{options[:api_version]}" end self.class.base_uri "http#{'s' if options[:ssl]}://#{options[:api_endpoint]}/#{version_path}" self.class.default_timeout options[:timeout] if options[:timeout] end def get(uri, headers={}) self.class.get(uri, :headers => headers, :basic_auth => basic_auth) end def post(uri, body={}, headers={}) self.class.post(uri, :body => body, :headers => headers, :basic_auth => basic_auth) end def put(uri, body={}, headers={}) self.class.put(uri, :body => body, :headers => headers, :basic_auth => basic_auth) end def delete(uri, body={}, headers={}) self.class.delete(uri, :body => body, :headers => headers, :basic_auth => basic_auth) end private def basic_auth @basic_auth ||= {:username => @username, :password => @password} end end end
Version data entries
5 entries across 5 versions & 1 rubygems