Class: OxfordDictionary::Endpoints::Entries

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

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: {}) ⇒ Object



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

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

#entry_snake_case(word:, dataset:, params: {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/oxford_dictionary/endpoints/entries.rb', line 17

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

  response = @request_client.get(uri: uri)
  snake_keys = JSON.parse(response.body).to_snake_keys
  deserialize.call(JSON.generate(snake_keys))
end