Sha256: e44e29ca962390af4ed99d6e0272284c6c5e7ea19ad036a689b5a7e26bc2327a
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
require 'oxford_dictionary/deprecated_request' require 'oxford_dictionary/api_objects/list_response' module OxfordDictionary module Endpoints # Interface to '/wordlist' endpoint module WordlistEndpoint extend Gem::Deprecate include OxfordDictionary::DeprecatedRequest ENDPOINT = 'wordlist'.freeze ADVANCED_FILTERS = [:exact, :exclude, :exclude_senses, :exclude_prime_senses, :limit, :offset, :prefix, :word_length].freeze def wordlist(params = {}) # Check first so that we don't waste an API call if too_many_filter_values(params) raise(Error.new(400), 'Do not use more than 5 values for a filter') end ListResponse.new(request(ENDPOINT, nil, params)) end deprecate :wordlist, :none, 2019, 6 private def too_many_filter_values(params) params.each do |k, v| return true if v.size > 5 && !ADVANCED_FILTERS.include?(k) end false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems