Module: Request

Included in:
Musixmatch
Defined in:
lib/musixmatch/request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.base_url(url = 'https://api.musixmatch.com') ⇒ Object



7
8
9
# File 'lib/musixmatch/request.rb', line 7

def base_url(url = 'https://api.musixmatch.com')
  url
end

Instance Method Details

#httpObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/musixmatch/request.rb', line 11

def http
  Faraday.new(url: base_url) do |f|
    f.response :mashify
    f.response :json
    f.request :url_encoded
    f.request :retry, max: 5, interval: 1.0
    f.options[:open_timeout] = 2
    f.options[:timeout] = 5
    f.headers['Accept'] = 'application/json'
    f.headers['User-Agent'] = "ruby-musixmatch/#{version}"
    f.adapter :net_http
  end
end