Module: Twitter::Default
- Defined in:
- lib/twitter/default.rb
Constant Summary collapse
- ENDPOINT =
'https://api.twitter.com'
- CONNECTION_OPTIONS =
{ :headers => { :accept => 'application/json', :user_agent => "Twitter Ruby Gem #{Twitter::Version}" }, :open_timeout => 5, :raw => true, :ssl => {:verify => false}, :timeout => 10, }
- IDENTITY_MAP =
false
- MIDDLEWARE =
Faraday::Builder.new( &Proc.new do |builder| # Convert file uploads to Faraday::UploadIO objects builder.use Twitter::Request::MultipartWithFile # Checks for files in the payload builder.use Faraday::Request::Multipart # Convert request params to "www-form-urlencoded" builder.use Faraday::Request::UrlEncoded # Handle 4xx server responses builder.use Twitter::Response::RaiseError, Twitter::Error::ClientError # Parse JSON response bodies using MultiJson builder.use Twitter::Response::ParseJson # Handle 5xx server responses builder.use Twitter::Response::RaiseError, Twitter::Error::ServerError # Set Faraday's HTTP adapter builder.adapter Faraday.default_adapter end )
Class Method Summary collapse
- .connection_options ⇒ Hash
- .consumer_key ⇒ String
- .consumer_secret ⇒ String
- .endpoint ⇒ String
- .identity_map ⇒ Twitter::IdentityMap
- .middleware ⇒ Faraday::Builder
- .oauth_token ⇒ String
- .oauth_token_secret ⇒ String
- .options ⇒ Hash
Class Method Details
.connection_options ⇒ Hash
82 83 84 |
# File 'lib/twitter/default.rb', line 82 def CONNECTION_OPTIONS end |
.consumer_key ⇒ String
52 53 54 |
# File 'lib/twitter/default.rb', line 52 def consumer_key ENV['TWITTER_CONSUMER_KEY'] end |
.consumer_secret ⇒ String
57 58 59 |
# File 'lib/twitter/default.rb', line 57 def consumer_secret ENV['TWITTER_CONSUMER_SECRET'] end |
.endpoint ⇒ String
Note:
This is configurable in case you want to use HTTP instead of HTTPS or use a Twitter-compatible endpoint.
77 78 79 |
# File 'lib/twitter/default.rb', line 77 def endpoint ENDPOINT end |
.identity_map ⇒ Twitter::IdentityMap
87 88 89 |
# File 'lib/twitter/default.rb', line 87 def identity_map IDENTITY_MAP end |
.middleware ⇒ Faraday::Builder
Note:
Faraday’s middleware stack implementation is comparable to that of Rack middleware. The order of middleware is important: the first middleware on the list wraps all others, while the last middleware is the innermost one.
95 96 97 |
# File 'lib/twitter/default.rb', line 95 def middleware MIDDLEWARE end |
.oauth_token ⇒ String
62 63 64 |
# File 'lib/twitter/default.rb', line 62 def oauth_token ENV['TWITTER_OAUTH_TOKEN'] end |
.oauth_token_secret ⇒ String
67 68 69 |
# File 'lib/twitter/default.rb', line 67 def oauth_token_secret ENV['TWITTER_OAUTH_TOKEN_SECRET'] end |
.options ⇒ Hash
47 48 49 |
# File 'lib/twitter/default.rb', line 47 def Hash[Twitter::Configurable.keys.map{|key| [key, send(key)]}] end |