Sha256: 419095ac4ad9c66cc046def0fe4d80b235939028791b8dc2b29f66263c759db0

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

require 'oxford_dictionary/endpoints/endpoint'

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

      def search(language:, params: {})
        path = "#{ENDPOINT}/#{language}"
        uri = request_uri(path: path, params: params)

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

      def search_translation(source_language:, target_language:, params: {})
        path = "#{ENDPOINT}/translations/#{source_language}/#{target_language}"
        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/search.rb