Class: MambaNation::HTTPAuth
- Inherits:
-
Object
- Object
- MambaNation::HTTPAuth
- Includes:
- HTTParty
- Defined in:
- lib/mambanation/httpauth.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #delete(uri, body = {}, headers = {}) ⇒ Object
- #get(uri, headers = {}) ⇒ Object
-
#initialize(username, password, options = {}) ⇒ HTTPAuth
constructor
A new instance of HTTPAuth.
- #post(uri, body = {}, headers = {}) ⇒ Object
- #put(uri, body = {}, headers = {}) ⇒ Object
Constructor Details
#initialize(username, password, options = {}) ⇒ HTTPAuth
Returns a new instance of HTTPAuth.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mambanation/httpauth.rb', line 9 def initialize(username, password, ={}) @username, @password = username, password @options = { :ssl => false, :timeout => 100 }.merge() [:api_endpoint] ||= "api.mambanation.com" if [:api_version] == false version_path = "2" else [:api_version] ||= API_VERSION version_path = "#{[:api_version]}" end self.class.base_uri "http#{'s' if [:ssl]}://#{[:api_endpoint]}/v#{version_path}" self.class.default_timeout [:timeout] if [:timeout] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/mambanation/httpauth.rb', line 7 def @options end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
7 8 9 |
# File 'lib/mambanation/httpauth.rb', line 7 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
7 8 9 |
# File 'lib/mambanation/httpauth.rb', line 7 def username @username end |
Instance Method Details
#delete(uri, body = {}, headers = {}) ⇒ Object
38 39 40 |
# File 'lib/mambanation/httpauth.rb', line 38 def delete(uri, body={}, headers={}) self.class.delete(uri, :body => body, :headers => headers, :basic_auth => basic_auth) end |
#get(uri, headers = {}) ⇒ Object
26 27 28 |
# File 'lib/mambanation/httpauth.rb', line 26 def get(uri, headers={}) self.class.get(uri, :headers => headers, :basic_auth => basic_auth) end |
#post(uri, body = {}, headers = {}) ⇒ Object
30 31 32 |
# File 'lib/mambanation/httpauth.rb', line 30 def post(uri, body={}, headers={}) self.class.post(uri, :body => body, :headers => headers, :basic_auth => basic_auth) end |
#put(uri, body = {}, headers = {}) ⇒ Object
34 35 36 |
# File 'lib/mambanation/httpauth.rb', line 34 def put(uri, body={}, headers={}) self.class.put(uri, :body => body, :headers => headers, :basic_auth => basic_auth) end |