Class: OxfordDictionary::Endpoints::Entries

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

Overview

Interface for the /entries endpoint

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

Constant Summary collapse

ENDPOINT =
'entries'.freeze

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

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

Instance Method Details

#entry(word:, dataset:, params: {}) ⇒ OpenStruct

Return all the entries for a word

Examples:

Search for all domains of ‘vapid’ from the en-gb dataset

entry(word: 'vapid', dataset: 'en-gb', params: { fields: 'domains' })

Parameters:

  • word (String)

    the word to search for

  • dataset (String)

    the dataset to search in

  • params (Hash) (defaults to: {})

    the query parameters in the request

Returns:

  • (OpenStruct)

    the JSON response parsed into an OpenStruct



22
23
24
25
26
27
28
# File 'lib/oxford_dictionary/endpoints/entries.rb', line 22

def entry(word:, dataset:, params: {})
  path = "#{ENDPOINT}/#{dataset}/#{word}"
  uri = request_uri(path: path, params: params)

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