Class: Twitter::Client
Overview
Base client class for Twitter API authentication
Direct Known Subclasses
Instance Attribute Summary collapse
-
#access_token ⇒ String
The OAuth access token.
-
#access_token_secret ⇒ String
The OAuth access token secret.
-
#consumer_key ⇒ String
The OAuth consumer key.
-
#consumer_secret ⇒ String
The OAuth consumer secret.
-
#dev_environment ⇒ String
The development environment name for Premium API endpoints.
-
#proxy ⇒ String
The proxy server URI.
-
#timeouts ⇒ Hash
The HTTP request timeouts.
-
#user_agent ⇒ String
The user agent string sent with requests.
Instance Method Summary collapse
-
#credentials ⇒ Hash
The OAuth credentials hash.
-
#credentials? ⇒ Boolean
Check if all credentials are present.
-
#initialize(options = {}) {|_self| ... } ⇒ Twitter::Client
constructor
Initializes a new Client object.
-
#user_token? ⇒ Boolean
Check if user token credentials are present.
Methods included from Utils
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Twitter::Client
Initializes a new Client object
81 82 83 84 85 86 |
# File 'lib/twitter/client.rb', line 81 def initialize( = {}) .each do |key, value| instance_variable_set(:"@#{key}", value) end yield(self) if block_given? end |
Instance Attribute Details
#access_token ⇒ String
The OAuth access token
16 17 18 |
# File 'lib/twitter/client.rb', line 16 def access_token @access_token end |
#access_token_secret ⇒ String
The OAuth access token secret
24 25 26 |
# File 'lib/twitter/client.rb', line 24 def access_token_secret @access_token_secret end |
#consumer_key ⇒ String
The OAuth consumer key
32 33 34 |
# File 'lib/twitter/client.rb', line 32 def consumer_key @consumer_key end |
#consumer_secret ⇒ String
The OAuth consumer secret
40 41 42 |
# File 'lib/twitter/client.rb', line 40 def consumer_secret @consumer_secret end |
#dev_environment ⇒ String
The development environment name for Premium API endpoints
64 65 66 |
# File 'lib/twitter/client.rb', line 64 def dev_environment @dev_environment end |
#proxy ⇒ String
The proxy server URI
48 49 50 |
# File 'lib/twitter/client.rb', line 48 def proxy @proxy end |
#timeouts ⇒ Hash
The HTTP request timeouts
56 57 58 |
# File 'lib/twitter/client.rb', line 56 def timeouts @timeouts end |
Instance Method Details
#credentials ⇒ Hash
The OAuth credentials hash
114 115 116 117 118 119 120 121 |
# File 'lib/twitter/client.rb', line 114 def credentials { consumer_key:, consumer_secret:, token: access_token, token_secret: access_token_secret } end |
#credentials? ⇒ Boolean
Check if all credentials are present
129 130 131 |
# File 'lib/twitter/client.rb', line 129 def credentials? credentials.values.none? { |v| blank_string?(v) } end |
#user_token? ⇒ Boolean
Check if user token credentials are present
94 95 96 |
# File 'lib/twitter/client.rb', line 94 def user_token? !(blank_string?(access_token) || blank_string?(access_token_secret)) end |