|
| 1 | +# |
| 2 | +# This file is auto-generated, do not edit |
| 3 | +# |
| 4 | + |
| 5 | +module RecombeeApiClient |
| 6 | + require_relative 'request' |
| 7 | + require_relative '../errors' |
| 8 | + |
| 9 | + ## |
| 10 | + #Adds a new synonym for the [Search items](https://docs.recombee.com/api.html#search-items). |
| 11 | + # |
| 12 | + #When the `term` is used in the search query, the `synonym` is also used for the full-text search. |
| 13 | + #Unless `oneWay=true`, it works also in the opposite way (`synonym` -> `term`). |
| 14 | + # |
| 15 | + #An example of a synonym can be `science fiction` for the term `sci-fi`. |
| 16 | + # |
| 17 | + class AddSearchSynonym < ApiRequest |
| 18 | + attr_reader :term, :synonym, :one_way |
| 19 | + attr_accessor :timeout |
| 20 | + attr_accessor :ensure_https |
| 21 | + |
| 22 | + ## |
| 23 | + # * *Required arguments* |
| 24 | + # - +term+ -> A word to which the `synonym` is specified. |
| 25 | + # - +synonym+ -> A word that should be considered equal to the `term` by the full-text search engine. |
| 26 | + # |
| 27 | + # * *Optional arguments (given as hash optional)* |
| 28 | + # - +oneWay+ -> If set to `true`, only `term` -> `synonym` is considered. If set to `false`, also `synonym` -> `term` works. |
| 29 | + # |
| 30 | + #Default: `false`. |
| 31 | + # |
| 32 | + # |
| 33 | + def initialize(term, synonym, optional = {}) |
| 34 | + @term = term |
| 35 | + @synonym = synonym |
| 36 | + optional = normalize_optional(optional) |
| 37 | + @one_way = optional['oneWay'] |
| 38 | + @optional = optional |
| 39 | + @timeout = 10000 |
| 40 | + @ensure_https = false |
| 41 | + @optional.each do |par, _| |
| 42 | + fail UnknownOptionalParameter.new(par) unless ["oneWay"].include? par |
| 43 | + end |
| 44 | + end |
| 45 | + |
| 46 | + # HTTP method |
| 47 | + def method |
| 48 | + :post |
| 49 | + end |
| 50 | + |
| 51 | + # Values of body parameters as a Hash |
| 52 | + def body_parameters |
| 53 | + p = Hash.new |
| 54 | + p['term'] = @term |
| 55 | + p['synonym'] = @synonym |
| 56 | + p['oneWay'] = @optional['oneWay'] if @optional.include? 'oneWay' |
| 57 | + p |
| 58 | + end |
| 59 | + |
| 60 | + # Values of query parameters as a Hash. |
| 61 | + # name of parameter => value of the parameter |
| 62 | + def query_parameters |
| 63 | + params = {} |
| 64 | + params |
| 65 | + end |
| 66 | + |
| 67 | + # Relative path to the endpoint |
| 68 | + def path |
| 69 | + "/{databaseId}/synonyms/items/" |
| 70 | + end |
| 71 | + end |
| 72 | +end |
0 commit comments