Class: Tuiter::Client
- Inherits:
-
Object
- Object
- Tuiter::Client
- Includes:
- AccountMethods, DirectMessageMethods, FriendshipMethods, SocialGraphMethods, StatusMethods, UserMethods
- Defined in:
- lib/tuiter/client.rb
Instance Method Summary collapse
- #authorize(token, secret) ⇒ Object
- #authorized? ⇒ Boolean
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #request_token ⇒ Object
- #username ⇒ Object
Methods included from AccountMethods
#account_rate_limit_status, #account_verify_credentials?
Methods included from SocialGraphMethods
Methods included from FriendshipMethods
#friendships_create, #friendships_destroy, #friendships_exists?
Methods included from DirectMessageMethods
#direct_messages, #direct_messages_new, #direct_messages_sent
Methods included from UserMethods
#statuses_followers, #statuses_friends, #users_show
Methods included from StatusMethods
#statuses_mentions, #statuses_show, #statuses_update
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tuiter/client.rb', line 11 def initialize( = {}) @pid = Process.pid @logger = [:logger] || Logger.new('tuiter.log') begin authentication_type = .delete(:authentication) authentication_type = :basic if authentication_type.nil? @request_handler = Tuiter::Request.new(authentication_type, ) rescue return nil end log("initialize()") end |
Instance Method Details
#authorize(token, secret) ⇒ Object
28 29 30 |
# File 'lib/tuiter/client.rb', line 28 def (token, secret) @request_handler.(token, secret) end |
#authorized? ⇒ Boolean
32 33 34 35 36 37 38 39 40 |
# File 'lib/tuiter/client.rb', line 32 def oauth_response = @request_handler.get('/account/verify_credentials.json') if oauth_response.class == Net::HTTPOK @username = JSON.parse(oauth_response.body)[:username] true else false end end |
#request_token ⇒ Object
24 25 26 |
# File 'lib/tuiter/client.rb', line 24 def request_token @request_handler.request_token end |
#username ⇒ Object
42 43 44 |
# File 'lib/tuiter/client.rb', line 42 def username @username ||= account_verify_credentials?.screen_name end |