diff --git a/lib/oxford_dictionary/client.rb b/lib/oxford_dictionary/client.rb index f9443eb..7f2057d 100644 --- a/lib/oxford_dictionary/client.rb +++ b/lib/oxford_dictionary/client.rb @@ -7,6 +7,7 @@ require 'oxford_dictionary/endpoints/lemmas' require 'oxford_dictionary/endpoints/translations' require 'oxford_dictionary/endpoints/sentences' +require 'oxford_dictionary/endpoints/thesaurus' module OxfordDictionary # The client object to interact with @@ -71,6 +72,14 @@ def sentence(word:, language:, params: {}) sentence_endpoint.sentence(word: word, language: language, params: params) end + def thesaurus(word:, language:, params: {}) + thesaurus_endpoint.thesaurus( + word: word, + language: language, + params: params + ) + end + private def lemma_endpoint @@ -95,6 +104,12 @@ def sentence_endpoint ) end + def thesaurus_endpoint + @thesaurus_endpoint ||= OxfordDictionary::Endpoints::Thesaurus.new( + request_client: request_client + ) + end + def request_client @request_client ||= OxfordDictionary::Request.new(app_id: @app_id, app_key: @app_key) diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 1398d7c..6281afb 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -94,6 +94,21 @@ end end + describe '#thesaurus' do + subject { client.thesaurus(word: word, language: language, params: params) } + let(:word) { 'ace' } + let(:language) { 'en' } + let(:params) { {} } + + it 'calls the Thesaurus endpoint with correct arguments' do + expect_any_instance_of(OxfordDictionary::Endpoints::Thesaurus). + to receive(:thesaurus). + with(word: word, language: language, params: params) + + subject + end + end + describe '#entry_snake_case' do let(:client) { described_class.new(app_id: app_id, app_key: app_key) } subject do