Class: OxfordDictionary::Endpoints::Search

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/oxford_dictionary/endpoints/search.rb

Constant Summary collapse

ENDPOINT =
'search'.freeze

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

This class inherits a constructor from OxfordDictionary::Endpoints::Endpoint

Instance Method Details

#search(language:, params: {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/oxford_dictionary/endpoints/search.rb', line 8

def search(language:, params: {})
  path = "#{ENDPOINT}/#{language}"
  uri = request_uri(path: path, params: params)

  response = @request_client.get(uri: uri)
  deserialize.call(response.body)
end

#search_translation(source_language:, target_language:, params: {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/oxford_dictionary/endpoints/search.rb', line 16

def search_translation(source_language:, target_language:, params: {})
  path = "#{ENDPOINT}/translations/#{source_language}/#{target_language}"
  uri = request_uri(path: path, params: params)

  response = @request_client.get(uri: uri)
  deserialize.call(response.body)
end