Module: Echowrap::Default
- Defined in:
- lib/echowrap/default.rb
Constant Summary collapse
- ENDPOINT =
'http://developer.echonest.com'
- CONNECTION_OPTIONS =
{ :headers => { :accept => 'application/json', :user_agent => "Echowrap Ruby Gem #{Echowrap::Version}", }, :request => { :open_timeout => 5, :timeout => 10, :params_encoder => Faraday::FlatParamsEncoder }, :ssl => { :verify => false }, }
- IDENTITY_MAP =
false
- MIDDLEWARE =
Faraday::RackBuilder.new do |builder| # Convert file uploads to Faraday::UploadIO objects builder.use Echowrap::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 Echowrap::Response::RaiseError, Echowrap::Error::ClientError # Parse JSON response bodies using MultiJson builder.use Echowrap::Response::ParseJson # Handle 5xx server responses builder.use Echowrap::Response::RaiseError, Echowrap::Error::ServerError # Set Faraday's HTTP adapter builder.adapter Faraday.default_adapter end
Class Method Summary collapse
- .api_key ⇒ String
- .connection_options ⇒ Object
- .consumer_key ⇒ String
- .endpoint ⇒ String
- .middleware ⇒ Faraday::RackBuilder
- .options ⇒ Hash
- .shared_secret ⇒ String
Class Method Details
.api_key ⇒ String
54 55 56 |
# File 'lib/echowrap/default.rb', line 54 def api_key ENV['ECHONEST_API_KEY'] end |
.connection_options ⇒ Object
74 75 76 |
# File 'lib/echowrap/default.rb', line 74 def CONNECTION_OPTIONS end |
.consumer_key ⇒ String
59 60 61 |
# File 'lib/echowrap/default.rb', line 59 def consumer_key ENV['ECHONEST_CONSUMER_KEY'] end |
.endpoint ⇒ String
Note:
This is configurable in case you want to use a Echowrap-compatible endpoint.
70 71 72 |
# File 'lib/echowrap/default.rb', line 70 def endpoint ENDPOINT end |
.middleware ⇒ Faraday::RackBuilder
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.
82 83 84 |
# File 'lib/echowrap/default.rb', line 82 def middleware MIDDLEWARE end |
.options ⇒ Hash
49 50 51 |
# File 'lib/echowrap/default.rb', line 49 def Hash[Echowrap::Configurable.keys.map{|key| [key, send(key)]}] end |
.shared_secret ⇒ String
64 65 66 |
# File 'lib/echowrap/default.rb', line 64 def shared_secret ENV['ECHONEST_SHARED_SECRET'] end |