Module: StartupStats::Default
- Defined in:
- lib/startupstats/default.rb
Constant Summary collapse
- ENDPOINT =
'https://api.startupstats.com'
- CONNECTION_OPTIONS =
{ :headers => { :accept => 'application/json', :user_agent => "StartupStats Ruby Gem #{StartupStats::VERSION}" }, :open_timeout => 5, :raw => true, :ssl => {:verify => false}, :timeout => 10, }
- MIDDLEWARE =
Faraday::Builder.new do |builder| # Convert request params to "www-form-urlencoded" builder.use Faraday::Request::UrlEncoded # Handle 4xx server responses builder.use StartupStats::Response::RaiseError, StartupStats::Error::ClientError # Parse JSON response bodies using MultiJson builder.use StartupStats::Response::ParseJson # Handle 5xx server responses builder.use StartupStats::Response::RaiseError, StartupStats::Error::ServerError # Set Faraday's HTTP adapter builder.adapter Faraday.default_adapter #:typhoeus end
Class Method Summary collapse
- .access_token ⇒ String
- .access_token_key ⇒ String
- .connection_options ⇒ Object
- .endpoint ⇒ String
- .middleware ⇒ Faraday::Builder
- .options ⇒ Hash
Class Method Details
.access_token ⇒ String
45 46 47 |
# File 'lib/startupstats/default.rb', line 45 def access_token ENV['FORMD_ACCESS_TOKEN'] end |
.access_token_key ⇒ String
50 51 52 |
# File 'lib/startupstats/default.rb', line 50 def access_token_key ENV['FORMD_ACCESS_TOKEN_KEY'] || "access_token" end |
.connection_options ⇒ Object
64 65 66 |
# File 'lib/startupstats/default.rb', line 64 def CONNECTION_OPTIONS end |
.endpoint ⇒ String
Note:
This is configurable in case you want to use a Twitter-compatible endpoint.
60 61 62 |
# File 'lib/startupstats/default.rb', line 60 def endpoint ENDPOINT 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.
72 73 74 |
# File 'lib/startupstats/default.rb', line 72 def middleware MIDDLEWARE end |
.options ⇒ Hash
40 41 42 |
# File 'lib/startupstats/default.rb', line 40 def Hash[StartupStats::Configurable.keys.map{|key| [key, send(key)]}] end |