Sha256: c1f1269d0d8e27f15f040cff45446819493dc787c65d39b9567713fd127241c0

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'oxford_dictionary/endpoints/endpoint'

module OxfordDictionary
  module Endpoints
    # Interface for the /entries endpoint
    #
    # API documentation can be found here:
    # https://developer.oxforddictionaries.com/documentation
    class Entries < Endpoint
      ENDPOINT = 'entries'.freeze

      # Return all the entries for a word
      #
      # @param [String] word the word to search for
      # @param [String] dataset the dataset to search in
      # @param [Hash] params the query parameters in the request
      #
      # @example Search for all domains of 'vapid' from the en-gb dataset
      #   entry(word: 'vapid', dataset: 'en-gb', params: { fields: 'domains' })
      #
      # @return [OpenStruct] the JSON response parsed into an OpenStruct
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oxford_dictionary-3.0.0 lib/oxford_dictionary/endpoints/entries.rb