Sha256: 9d7ad73cddbe95a17f8ec1d1083fc9c72bef4688ee8f9a9a5aea588e1bb81117
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'oxford_dictionary/deserialize' require 'plissken' module OxfordDictionary module Endpoints class Entries ENDPOINT = 'entries'.freeze def initialize(request_client:) @request_client = request_client end def entry(word:, dataset:, params: {}) query_string = "#{ENDPOINT}/#{dataset}/#{word}" uri = URI(query_string) unless params.empty? uri.query = URI.encode_www_form(params) end response = @request_client.get(uri: uri) deserialize.call(response.body) end def entry_snake_case(word:, dataset:, params: {}) query_string = "#{ENDPOINT}/#{dataset}/#{word}" uri = URI(query_string) unless params.empty? uri.query = URI.encode_www_form(params) end response = @request_client.get(uri: uri) snake_keys = JSON.parse(response.body).to_snake_keys deserialize.call(JSON.generate(snake_keys)) end private def deserialize @deserialize ||= OxfordDictionary::Deserialize.new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
oxford_dictionary-1.2.0 | lib/oxford_dictionary/endpoints/entries.rb |
oxford_dictionary-1.1.0 | lib/oxford_dictionary/endpoints/entries.rb |