Class: OxfordDictionary::Endpoints::Translations

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

Overview

Interface for the /translations endpoint

API documentation can be found here: developer.oxforddictionaries.com/documentation

Constant Summary collapse

ENDPOINT =
'translations'.freeze

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

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

Instance Method Details

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



12
13
14
15
16
17
18
# File 'lib/oxford_dictionary/endpoints/translations.rb', line 12

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

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