Method: Tidal::ClientV1#get_search

Defined in:
lib/tidal/client_v1.rb

#get_search(query, country_code, type = nil, popularity = nil, offset = nil, limit = nil) ⇒ Hash

Search for content

Parameters:

  • query (String)

    The search query

  • country_code (String)

    The country code

  • type (String, nil) (defaults to: nil)

    The type of content to search for

  • popularity (String, nil) (defaults to: nil)

    The popularity filter

  • offset (Integer, nil) (defaults to: nil)

    The offset for pagination

  • limit (Integer, nil) (defaults to: nil)

    The limit for pagination

Returns:

  • (Hash)

    The search results



285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/tidal/client_v1.rb', line 285

def get_search(query, country_code, type = nil, popularity = nil, offset = nil, limit = nil)
  uri = URI("#{BASE_URL}/search")
  params = { query: query, countryCode: country_code }
  params[:type] = type if type
  params[:popularity] = popularity if popularity
  params[:offset] = offset if offset
  params[:limit] = limit if limit
  uri.query = URI.encode_www_form(params)

  response = @client.request(:get, uri.to_s, headers: default_headers)
  JSON.parse(response.body)
end