Class: Weibo::HTTPAuth

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/weibo/httpauth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, options = {}) ⇒ HTTPAuth

Returns a new instance of HTTPAuth.



8
9
10
11
12
13
14
# File 'lib/weibo/httpauth.rb', line 8

def initialize(username, password, options={})
  @username, @password = username, password
  @options = {:ssl => false}.merge(options)
  options[:api_endpoint] ||= "api.t.sina.com.cn"
  
  self.class.base_uri "http#{'s' if options[:ssl]}://#{options[:api_endpoint]}"
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/weibo/httpauth.rb', line 6

def options
  @options
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/weibo/httpauth.rb', line 6

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



6
7
8
# File 'lib/weibo/httpauth.rb', line 6

def username
  @username
end

Instance Method Details

#delete(uri, body = {}, headers = {}) ⇒ Object



28
29
30
# File 'lib/weibo/httpauth.rb', line 28

def delete(uri, body={}, headers={})
  self.class.delete(uri, :body => body, :headers => headers, :basic_auth => basic_auth)
end

#get(uri, headers = {}) ⇒ Object



16
17
18
# File 'lib/weibo/httpauth.rb', line 16

def get(uri, headers={})
  self.class.get(uri, :headers => headers, :basic_auth => basic_auth)
end

#post(uri, body = {}, headers = {}) ⇒ Object



20
21
22
# File 'lib/weibo/httpauth.rb', line 20

def post(uri, body={}, headers={})
  self.class.post(uri, :body => body, :headers => headers, :basic_auth => basic_auth)
end

#put(uri, body = {}, headers = {}) ⇒ Object



24
25
26
# File 'lib/weibo/httpauth.rb', line 24

def put(uri, body={}, headers={})
  self.class.put(uri, :body => body, :headers => headers, :basic_auth => basic_auth)
end