Sha256: 8417804c8c937d2f79dd4622697f5420c291318901dcca0f1b5dd06cdf2f23b9
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
require 'oxford_dictionary/endpoints/endpoint' require 'plissken' module OxfordDictionary module Endpoints class Entries < Endpoint ENDPOINT = 'entries'.freeze 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oxford_dictionary-1.3.0 | lib/oxford_dictionary/endpoints/entries.rb |