Sha256: e08c11480c38714393c7882188c2b655d8feeb195e0429b939368f2a66fc9a6a

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

require 'oxford_dictionary/endpoints/endpoint'
require 'plissken'

module OxfordDictionary
  module Endpoints
    class Entries < Endpoint
      ENDPOINT = 'entries'.freeze

      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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oxford_dictionary-2.0.1 lib/oxford_dictionary/endpoints/entries.rb
oxford_dictionary-2.0.0 lib/oxford_dictionary/endpoints/entries.rb
oxford_dictionary-1.3.1 lib/oxford_dictionary/endpoints/entries.rb