diff --git a/lib/recombee_api_client.rb b/lib/recombee_api_client.rb index 979678b..582f3de 100644 --- a/lib/recombee_api_client.rb +++ b/lib/recombee_api_client.rb @@ -18,7 +18,7 @@ class RecombeeClient include HTTParty BATCH_MAX_SIZE = 10000 - USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/3.1.0'} + USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/3.2.0'} ## # - +account+ -> Name of your account at Recombee diff --git a/lib/recombee_api_client/api/add_search_synonym.rb b/lib/recombee_api_client/api/add_search_synonym.rb new file mode 100644 index 0000000..505a77b --- /dev/null +++ b/lib/recombee_api_client/api/add_search_synonym.rb @@ -0,0 +1,72 @@ +# +# This file is auto-generated, do not edit +# + +module RecombeeApiClient + require_relative 'request' + require_relative '../errors' + + ## + #Adds a new synonym for the [Search items](https://docs.recombee.com/api.html#search-items). + # + #When the `term` is used in the search query, the `synonym` is also used for the full-text search. + #Unless `oneWay=true`, it works also in the opposite way (`synonym` -> `term`). + # + #An example of a synonym can be `science fiction` for the term `sci-fi`. + # + class AddSearchSynonym < ApiRequest + attr_reader :term, :synonym, :one_way + attr_accessor :timeout + attr_accessor :ensure_https + + ## + # * *Required arguments* + # - +term+ -> A word to which the `synonym` is specified. + # - +synonym+ -> A word that should be considered equal to the `term` by the full-text search engine. + # + # * *Optional arguments (given as hash optional)* + # - +oneWay+ -> If set to `true`, only `term` -> `synonym` is considered. If set to `false`, also `synonym` -> `term` works. + # + #Default: `false`. + # + # + def initialize(term, synonym, optional = {}) + @term = term + @synonym = synonym + optional = normalize_optional(optional) + @one_way = optional['oneWay'] + @optional = optional + @timeout = 10000 + @ensure_https = false + @optional.each do |par, _| + fail UnknownOptionalParameter.new(par) unless ["oneWay"].include? par + end + end + + # HTTP method + def method + :post + end + + # Values of body parameters as a Hash + def body_parameters + p = Hash.new + p['term'] = @term + p['synonym'] = @synonym + p['oneWay'] = @optional['oneWay'] if @optional.include? 'oneWay' + p + end + + # Values of query parameters as a Hash. + # name of parameter => value of the parameter + def query_parameters + params = {} + params + end + + # Relative path to the endpoint + def path + "/{databaseId}/synonyms/items/" + end + end +end diff --git a/lib/recombee_api_client/api/delete_all_search_synonyms.rb b/lib/recombee_api_client/api/delete_all_search_synonyms.rb new file mode 100644 index 0000000..5c4bc74 --- /dev/null +++ b/lib/recombee_api_client/api/delete_all_search_synonyms.rb @@ -0,0 +1,47 @@ +# +# This file is auto-generated, do not edit +# + +module RecombeeApiClient + require_relative 'request' + require_relative '../errors' + + ## + #Deletes all synonyms defined in the database. + # + class DeleteAllSearchSynonyms < ApiRequest + + attr_accessor :timeout + attr_accessor :ensure_https + + ## + # + def initialize() + @timeout = 10000 + @ensure_https = false + end + + # HTTP method + def method + :delete + end + + # Values of body parameters as a Hash + def body_parameters + p = Hash.new + p + end + + # Values of query parameters as a Hash. + # name of parameter => value of the parameter + def query_parameters + params = {} + params + end + + # Relative path to the endpoint + def path + "/{databaseId}/synonyms/items/" + end + end +end diff --git a/lib/recombee_api_client/api/delete_search_synonym.rb b/lib/recombee_api_client/api/delete_search_synonym.rb new file mode 100644 index 0000000..634aeec --- /dev/null +++ b/lib/recombee_api_client/api/delete_search_synonym.rb @@ -0,0 +1,50 @@ +# +# This file is auto-generated, do not edit +# + +module RecombeeApiClient + require_relative 'request' + require_relative '../errors' + + ## + #Deletes synonym of given `id` and this synonym is no longer taken into account in the [Search items](https://docs.recombee.com/api.html#search-items). + # + class DeleteSearchSynonym < ApiRequest + attr_reader :id + attr_accessor :timeout + attr_accessor :ensure_https + + ## + # * *Required arguments* + # - +id+ -> ID of the synonym that should be deleted. + # + def initialize(id) + @id = id + @timeout = 10000 + @ensure_https = false + end + + # HTTP method + def method + :delete + end + + # Values of body parameters as a Hash + def body_parameters + p = Hash.new + p + end + + # Values of query parameters as a Hash. + # name of parameter => value of the parameter + def query_parameters + params = {} + params + end + + # Relative path to the endpoint + def path + "/{databaseId}/synonyms/items/#{@id}" + end + end +end diff --git a/lib/recombee_api_client/api/list_search_synonyms.rb b/lib/recombee_api_client/api/list_search_synonyms.rb new file mode 100644 index 0000000..e08dc8f --- /dev/null +++ b/lib/recombee_api_client/api/list_search_synonyms.rb @@ -0,0 +1,59 @@ +# +# This file is auto-generated, do not edit +# + +module RecombeeApiClient + require_relative 'request' + require_relative '../errors' + + ## + #Gives the list of synonyms defined in the database. + class ListSearchSynonyms < ApiRequest + attr_reader :count, :offset + attr_accessor :timeout + attr_accessor :ensure_https + + ## + # + # * *Optional arguments (given as hash optional)* + # - +count+ -> The number of synonyms to be listed. + # - +offset+ -> Specifies the number of synonyms to skip (ordered by `term`). + # + def initialize(optional = {}) + optional = normalize_optional(optional) + @count = optional['count'] + @offset = optional['offset'] + @optional = optional + @timeout = 100000 + @ensure_https = false + @optional.each do |par, _| + fail UnknownOptionalParameter.new(par) unless ["count","offset"].include? par + end + end + + # HTTP method + def method + :get + end + + # Values of body parameters as a Hash + def body_parameters + p = Hash.new + p + end + + # Values of query parameters as a Hash. + # name of parameter => value of the parameter + def query_parameters + params = {} + params['count'] = @optional['count'] if @optional['count'] + params['offset'] = @optional['offset'] if @optional['offset'] + params + end + + # Relative path to the endpoint + def path + "/{databaseId}/synonyms/items/" + end + end +end diff --git a/lib/recombee_api_client/version.rb b/lib/recombee_api_client/version.rb index 1207f30..76f05d2 100644 --- a/lib/recombee_api_client/version.rb +++ b/lib/recombee_api_client/version.rb @@ -1,3 +1,3 @@ module RecombeeApiClient - VERSION = '3.1.0' + VERSION = '3.2.0' end diff --git a/spec/api/add_search_synonym.rb b/spec/api/add_search_synonym.rb new file mode 100644 index 0000000..101e77e --- /dev/null +++ b/spec/api/add_search_synonym.rb @@ -0,0 +1,22 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative 'set_environment' +shared_examples 'add search synonym' do +include_context 'set environment' + + it 'adds search synonym' do + req = described_class.new('sci-fi','science fiction',{'oneWay' => true}) + resp = @client.send(req) + expect(resp['term']).to eq 'sci-fi' + expect(resp['synonym']).to eq 'science fiction' + req = described_class.new('sci-fi','science fiction',{'oneWay' => true}) + expect { @client.send(req) }.to raise_exception { |exception| + expect(exception).to be_a(RecombeeApiClient::ResponseError) + expect(exception.status_code).to eq 409 + } + end + +end diff --git a/spec/api/add_search_synonym_spec.rb b/spec/api/add_search_synonym_spec.rb new file mode 100644 index 0000000..0c4c4bd --- /dev/null +++ b/spec/api/add_search_synonym_spec.rb @@ -0,0 +1,10 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative "add_search_synonym" + +describe RecombeeApiClient::AddSearchSynonym do + it_behaves_like "add search synonym" +end \ No newline at end of file diff --git a/spec/api/delete_all_search_synonyms.rb b/spec/api/delete_all_search_synonyms.rb new file mode 100644 index 0000000..5ab9419 --- /dev/null +++ b/spec/api/delete_all_search_synonyms.rb @@ -0,0 +1,15 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative 'set_environment' +shared_examples 'delete all search synonyms' do +include_context 'set environment' + + it 'deletes all search synonyms' do + req = described_class.new() + resp = @client.send(req) + end + +end diff --git a/spec/api/delete_all_search_synonyms_spec.rb b/spec/api/delete_all_search_synonyms_spec.rb new file mode 100644 index 0000000..9a6f995 --- /dev/null +++ b/spec/api/delete_all_search_synonyms_spec.rb @@ -0,0 +1,10 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative "delete_all_search_synonyms" + +describe RecombeeApiClient::DeleteAllSearchSynonyms do + it_behaves_like "delete all search synonyms" +end \ No newline at end of file diff --git a/spec/api/delete_search_synonym.rb b/spec/api/delete_search_synonym.rb new file mode 100644 index 0000000..a635318 --- /dev/null +++ b/spec/api/delete_search_synonym.rb @@ -0,0 +1,22 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative 'set_environment' +shared_examples 'delete search synonym' do +include_context 'set environment' + + it 'deletes search synonym' do + req = AddSearchSynonym.new('sci-fi','science fiction') + resp = @client.send(req) + req = described_class.new(resp['id']) + resp = @client.send(req) + req = described_class.new('a968271b-d666-4dfb-8a30-f459e564ba7b') + expect { @client.send(req) }.to raise_exception { |exception| + expect(exception).to be_a(RecombeeApiClient::ResponseError) + expect(exception.status_code).to eq 404 + } + end + +end diff --git a/spec/api/delete_search_synonym_spec.rb b/spec/api/delete_search_synonym_spec.rb new file mode 100644 index 0000000..4157d27 --- /dev/null +++ b/spec/api/delete_search_synonym_spec.rb @@ -0,0 +1,10 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative "delete_search_synonym" + +describe RecombeeApiClient::DeleteSearchSynonym do + it_behaves_like "delete search synonym" +end \ No newline at end of file diff --git a/spec/api/list_search_synonyms.rb b/spec/api/list_search_synonyms.rb new file mode 100644 index 0000000..1a9e71a --- /dev/null +++ b/spec/api/list_search_synonyms.rb @@ -0,0 +1,21 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative 'set_environment' +shared_examples 'list search synonyms' do +include_context 'set environment' + + it 'lists search synonyms' do + req = AddSearchSynonym.new('sci-fi','science fiction') + resp = @client.send(req) + req = described_class.new() + resp = @client.send(req) + expect(resp['synonyms'].size).to eq 1 + req = described_class.new({'count' => 10,'offset' => 1}) + resp = @client.send(req) + expect(resp['synonyms'].size).to eq 0 + end + +end diff --git a/spec/api/list_search_synonyms_spec.rb b/spec/api/list_search_synonyms_spec.rb new file mode 100644 index 0000000..24e1a3b --- /dev/null +++ b/spec/api/list_search_synonyms_spec.rb @@ -0,0 +1,10 @@ +# +# This file is auto-generated, do not edit +# + +require 'spec_helper' +require_relative "list_search_synonyms" + +describe RecombeeApiClient::ListSearchSynonyms do + it_behaves_like "list search synonyms" +end \ No newline at end of file