-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support endpoints for handling search synonyms
- Loading branch information
1 parent
01e40fc
commit 31255d7
Showing
14 changed files
with
350 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RecombeeApiClient | ||
VERSION = '3.1.0' | ||
VERSION = '3.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |