Class: Yooda::Client
- Inherits:
-
Object
- Object
- Yooda::Client
- Includes:
- Domains, Keywords, Subscriptions
- Defined in:
- lib/yooda/client.rb
Constant Summary collapse
- DEFAULT_CONNECTION_MIDDLEWARE =
[ Faraday::Request::Multipart, Faraday::Request::UrlEncoded, FaradayMiddleware::Mashify, FaradayMiddleware::ParseJson ]
Instance Attribute Summary collapse
-
#apikey ⇒ Object
readonly
Returns the value of attribute apikey.
Instance Method Summary collapse
- #api_url ⇒ Object
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #return_error_or_body(response) ⇒ Object
Methods included from Subscriptions
Methods included from Keywords
#keyword_informations, #keyword_market_kpi, #keywords_market_by_keyword
Methods included from Domains
#domain_informations, #domain_market_kpi, #keywords_market_by_domain
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
26 27 28 29 30 31 |
# File 'lib/yooda/client.rb', line 26 def initialize(={}) @apikey = [:apikey] || Yooda.apikey # @connection_middleware = options[:connection_middleware] || Yooda.connection_middleware || [] @connection_middleware = [] @connection_middleware += DEFAULT_CONNECTION_MIDDLEWARE end |
Instance Attribute Details
#apikey ⇒ Object (readonly)
Returns the value of attribute apikey.
24 25 26 |
# File 'lib/yooda/client.rb', line 24 def apikey @apikey end |
Instance Method Details
#api_url ⇒ Object
44 45 46 |
# File 'lib/yooda/client.rb', line 44 def api_url "https://api.yooda.com" end |
#connection ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yooda/client.rb', line 33 def connection params = {} params[:apikey] = @apikey if @apikey @connection ||= Faraday::Connection.new(:url => api_url, :params => params, :headers => default_headers) do |builder| # @connection_middleware.each do |middleware| # builder.use *middleware # end builder.adapter Faraday.default_adapter end end |