algolia 3.3.4 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/do-not-edit-this-repository.yml +24 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/recommend_client.rb +57 -0
- data/lib/algolia/api/search_client.rb +2 -2
- data/lib/algolia/models/recommend/recommend_rule.rb +16 -4
- data/lib/algolia/models/recommend/recommend_updated_at_response.rb +227 -0
- data/lib/algolia/models/recommend/time_range.rb +226 -0
- data/lib/algolia/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9faf3750eb1a9ce64b6901f3e112776847b50317c804adf7ccc30f76a6392bc
|
4
|
+
data.tar.gz: a5c4e70c12e4530f1b61b79cfca6d5c2962c3b4ea7d45db28d07e21615a213fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4794af9dcf6a949e2d8c1da6cfe92098745b4cd8f271a48317347390bafc0872ce518178873b37daf11cc902b5c5e1ede033733804be141d9beafd49304b1aae
|
7
|
+
data.tar.gz: 162393a051eaec3b087b1651038fd9aa296524cfc335a76cbc2cadec3affeab3f87c3846c9decd2d7cdb7473617dd1af8ac96e3be668271f3f5a549f59184815
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Do not edit files in this repository
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types:
|
6
|
+
- opened
|
7
|
+
- synchronize
|
8
|
+
- reopen
|
9
|
+
branches:
|
10
|
+
- 'main'
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
auto_close_pr:
|
14
|
+
name: Close PR
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v4
|
18
|
+
|
19
|
+
- name: Close PR
|
20
|
+
env:
|
21
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
22
|
+
PR_NUMBER: ${{ github.event.pull_request.number }}
|
23
|
+
run: |
|
24
|
+
gh pr close "${PR_NUMBER}" -d -c "Thanks for contributing to our API clients! Sorry to close your PR, but this repository is fully generated, you can port your changes to [the API Clients Automation repository](https://github.com/algolia/api-clients-automation). If you need some guidance, feel free to [open an issue](https://github.com/algolia/api-clients-automation/issues) or [read our contribution guide](https://api-clients-automation.netlify.app/docs/introduction)."
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [3.4.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.3.4...3.4.0)
|
2
|
+
|
3
|
+
- [788483537](https://github.com/algolia/api-clients-automation/commit/788483537) chore(clients): add workflow to auto-close PR ([#3834](https://github.com/algolia/api-clients-automation/pull/3834)) by [@shortcuts](https://github.com/shortcuts/)
|
4
|
+
- [e59dd41d5](https://github.com/algolia/api-clients-automation/commit/e59dd41d5) fix(specs): API key description will be obfuscated ([#3840](https://github.com/algolia/api-clients-automation/pull/3840)) by [@kai687](https://github.com/kai687/)
|
5
|
+
- [dc28c0268](https://github.com/algolia/api-clients-automation/commit/dc28c0268) feat(specs): add recommend batch rules endpoint ([#3782](https://github.com/algolia/api-clients-automation/pull/3782)) by [@raed667](https://github.com/raed667/)
|
6
|
+
|
1
7
|
## [3.3.4](https://github.com/algolia/algoliasearch-client-ruby/compare/3.3.3...3.3.4)
|
2
8
|
|
3
9
|
- [022131871](https://github.com/algolia/api-clients-automation/commit/022131871) fix(specs): correct query params for ingestion [skip-bc] ([#3830](https://github.com/algolia/api-clients-automation/pull/3830)) by [@millotp](https://github.com/millotp/)
|
data/Gemfile.lock
CHANGED
@@ -40,6 +40,63 @@ module Algolia
|
|
40
40
|
@api_client.set_client_api_key(api_key)
|
41
41
|
end
|
42
42
|
|
43
|
+
# Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to match the data source item's attributes instead).
|
44
|
+
#
|
45
|
+
# Required API Key ACLs:
|
46
|
+
# - editSettings
|
47
|
+
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
48
|
+
# @param model [RecommendModels] [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). (required)
|
49
|
+
# @param recommend_rule [Array<RecommendRule>]
|
50
|
+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
51
|
+
# @return [Http::Response] the response
|
52
|
+
def batch_recommend_rules_with_http_info(index_name, model, recommend_rule = nil, request_options = {})
|
53
|
+
# verify the required parameter 'index_name' is set
|
54
|
+
if @api_client.config.client_side_validation && index_name.nil?
|
55
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `batch_recommend_rules`."
|
56
|
+
end
|
57
|
+
# verify the required parameter 'model' is set
|
58
|
+
if @api_client.config.client_side_validation && model.nil?
|
59
|
+
raise ArgumentError, "Parameter `model` is required when calling `batch_recommend_rules`."
|
60
|
+
end
|
61
|
+
|
62
|
+
path = "/1/indexes/{indexName}/{model}/recommend/rules/batch"
|
63
|
+
.sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
64
|
+
.sub("{" + "model" + "}", Transport.encode_uri(model.to_s))
|
65
|
+
query_params = {}
|
66
|
+
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
|
67
|
+
header_params = {}
|
68
|
+
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
|
69
|
+
|
70
|
+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(recommend_rule)
|
71
|
+
|
72
|
+
new_options = request_options.merge(
|
73
|
+
:operation => :"RecommendClient.batch_recommend_rules",
|
74
|
+
:header_params => header_params,
|
75
|
+
:query_params => query_params,
|
76
|
+
:body => post_body,
|
77
|
+
:use_read_transporter => false
|
78
|
+
)
|
79
|
+
|
80
|
+
@api_client.call_api(:POST, path, new_options)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to match the data source item's attributes instead).
|
84
|
+
#
|
85
|
+
# Required API Key ACLs:
|
86
|
+
# - editSettings
|
87
|
+
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
88
|
+
# @param model [RecommendModels] [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). (required)
|
89
|
+
# @param recommend_rule [Array<RecommendRule>]
|
90
|
+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
91
|
+
# @return [RecommendUpdatedAtResponse]
|
92
|
+
def batch_recommend_rules(index_name, model, recommend_rule = nil, request_options = {})
|
93
|
+
response = batch_recommend_rules_with_http_info(index_name, model, recommend_rule, request_options)
|
94
|
+
@api_client.deserialize(
|
95
|
+
response.body,
|
96
|
+
request_options[:debug_return_type] || "Recommend::RecommendUpdatedAtResponse"
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
43
100
|
# This method allow you to send requests to the Algolia REST API.
|
44
101
|
|
45
102
|
# @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required)
|
@@ -1127,7 +1127,7 @@ module Algolia
|
|
1127
1127
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::DeletedAtResponse")
|
1128
1128
|
end
|
1129
1129
|
|
1130
|
-
# Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key
|
1130
|
+
# Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key, with the description replaced by `<redacted>`.
|
1131
1131
|
|
1132
1132
|
# @param key [String] API key. (required)
|
1133
1133
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
@@ -1157,7 +1157,7 @@ module Algolia
|
|
1157
1157
|
@api_client.call_api(:GET, path, new_options)
|
1158
1158
|
end
|
1159
1159
|
|
1160
|
-
# Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key
|
1160
|
+
# Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key, with the description replaced by `<redacted>`.
|
1161
1161
|
|
1162
1162
|
# @param key [String] API key. (required)
|
1163
1163
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
@@ -22,6 +22,9 @@ module Algolia
|
|
22
22
|
# Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time.
|
23
23
|
attr_accessor :enabled
|
24
24
|
|
25
|
+
# Time periods when the rule is active.
|
26
|
+
attr_accessor :validity
|
27
|
+
|
25
28
|
# Attribute mapping from ruby-style variable name to JSON key.
|
26
29
|
def self.attribute_map
|
27
30
|
{
|
@@ -30,7 +33,8 @@ module Algolia
|
|
30
33
|
:condition => :condition,
|
31
34
|
:consequence => :consequence,
|
32
35
|
:description => :description,
|
33
|
-
:enabled => :enabled
|
36
|
+
:enabled => :enabled,
|
37
|
+
:validity => :validity
|
34
38
|
}
|
35
39
|
end
|
36
40
|
|
@@ -47,7 +51,8 @@ module Algolia
|
|
47
51
|
:condition => :"Condition",
|
48
52
|
:consequence => :"Consequence",
|
49
53
|
:description => :"String",
|
50
|
-
:enabled => :"Boolean"
|
54
|
+
:enabled => :"Boolean",
|
55
|
+
:validity => :"Array<TimeRange>"
|
51
56
|
}
|
52
57
|
end
|
53
58
|
|
@@ -104,6 +109,12 @@ module Algolia
|
|
104
109
|
if attributes.key?(:enabled)
|
105
110
|
self.enabled = attributes[:enabled]
|
106
111
|
end
|
112
|
+
|
113
|
+
if attributes.key?(:validity)
|
114
|
+
if (value = attributes[:validity]).is_a?(Array)
|
115
|
+
self.validity = value
|
116
|
+
end
|
117
|
+
end
|
107
118
|
end
|
108
119
|
|
109
120
|
# Checks equality by comparing each attribute.
|
@@ -116,7 +127,8 @@ module Algolia
|
|
116
127
|
condition == other.condition &&
|
117
128
|
consequence == other.consequence &&
|
118
129
|
description == other.description &&
|
119
|
-
enabled == other.enabled
|
130
|
+
enabled == other.enabled &&
|
131
|
+
validity == other.validity
|
120
132
|
end
|
121
133
|
|
122
134
|
# @see the `==` method
|
@@ -128,7 +140,7 @@ module Algolia
|
|
128
140
|
# Calculates hash code according to all attributes.
|
129
141
|
# @return [Integer] Hash code
|
130
142
|
def hash
|
131
|
-
[_metadata, object_id, condition, consequence, description, enabled].hash
|
143
|
+
[_metadata, object_id, condition, consequence, description, enabled, validity].hash
|
132
144
|
end
|
133
145
|
|
134
146
|
# Builds the object from hash
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Recommend
|
8
|
+
# Response, taskID, and update timestamp.
|
9
|
+
class RecommendUpdatedAtResponse
|
10
|
+
# Unique identifier of a task. A successful API response means that a task was added to a queue. It might not run immediately. You can check the task's progress with the [`task` operation](#tag/Indices/operation/getTask) and this `taskID`.
|
11
|
+
attr_accessor :task_id
|
12
|
+
|
13
|
+
# Date and time when the object was updated, in RFC 3339 format.
|
14
|
+
attr_accessor :updated_at
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:task_id => :taskID,
|
20
|
+
:updated_at => :updatedAt
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns all the JSON keys this model knows about
|
25
|
+
def self.acceptable_attributes
|
26
|
+
attribute_map.values
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.types_mapping
|
31
|
+
{
|
32
|
+
:task_id => :"Integer",
|
33
|
+
:updated_at => :"String"
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# List of attributes with nullable: true
|
38
|
+
def self.openapi_nullable
|
39
|
+
Set.new(
|
40
|
+
[]
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
if (!attributes.is_a?(Hash))
|
48
|
+
raise(
|
49
|
+
ArgumentError,
|
50
|
+
"The input argument (attributes) must be a hash in `Algolia::RecommendUpdatedAtResponse` initialize method"
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
55
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
56
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
57
|
+
raise(
|
58
|
+
ArgumentError,
|
59
|
+
"`#{k}` is not a valid attribute in `Algolia::RecommendUpdatedAtResponse`. Please check the name to make sure it's valid. List of attributes: " +
|
60
|
+
self.class.attribute_map.keys.inspect
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
h[k.to_sym] = v
|
65
|
+
}
|
66
|
+
|
67
|
+
if attributes.key?(:task_id)
|
68
|
+
self.task_id = attributes[:task_id]
|
69
|
+
else
|
70
|
+
self.task_id = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.key?(:updated_at)
|
74
|
+
self.updated_at = attributes[:updated_at]
|
75
|
+
else
|
76
|
+
self.updated_at = nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Checks equality by comparing each attribute.
|
81
|
+
# @param [Object] Object to be compared
|
82
|
+
def ==(other)
|
83
|
+
return true if self.equal?(other)
|
84
|
+
self.class == other.class &&
|
85
|
+
task_id == other.task_id &&
|
86
|
+
updated_at == other.updated_at
|
87
|
+
end
|
88
|
+
|
89
|
+
# @see the `==` method
|
90
|
+
# @param [Object] Object to be compared
|
91
|
+
def eql?(other)
|
92
|
+
self == other
|
93
|
+
end
|
94
|
+
|
95
|
+
# Calculates hash code according to all attributes.
|
96
|
+
# @return [Integer] Hash code
|
97
|
+
def hash
|
98
|
+
[task_id, updated_at].hash
|
99
|
+
end
|
100
|
+
|
101
|
+
# Builds the object from hash
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
# @return [Object] Returns the model itself
|
104
|
+
def self.build_from_hash(attributes)
|
105
|
+
return nil unless attributes.is_a?(Hash)
|
106
|
+
attributes = attributes.transform_keys(&:to_sym)
|
107
|
+
transformed_hash = {}
|
108
|
+
types_mapping.each_pair do |key, type|
|
109
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
110
|
+
transformed_hash[key.to_sym] = nil
|
111
|
+
elsif type =~ /\AArray<(.*)>/i
|
112
|
+
# check to ensure the input is an array given that the attribute
|
113
|
+
# is documented as an array but the input is not
|
114
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
115
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
116
|
+
_deserialize(::Regexp.last_match(1), v)
|
117
|
+
}
|
118
|
+
end
|
119
|
+
elsif !attributes[attribute_map[key]].nil?
|
120
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
new(transformed_hash)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Deserializes the data based on type
|
128
|
+
# @param string type Data type
|
129
|
+
# @param string value Value to be deserialized
|
130
|
+
# @return [Object] Deserialized data
|
131
|
+
def self._deserialize(type, value)
|
132
|
+
case type.to_sym
|
133
|
+
when :Time
|
134
|
+
Time.parse(value)
|
135
|
+
when :Date
|
136
|
+
Date.parse(value)
|
137
|
+
when :String
|
138
|
+
value.to_s
|
139
|
+
when :Integer
|
140
|
+
value.to_i
|
141
|
+
when :Float
|
142
|
+
value.to_f
|
143
|
+
when :Boolean
|
144
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
145
|
+
true
|
146
|
+
else
|
147
|
+
false
|
148
|
+
end
|
149
|
+
|
150
|
+
when :Object
|
151
|
+
# generic object (usually a Hash), return directly
|
152
|
+
value
|
153
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
154
|
+
inner_type = Regexp.last_match[:inner_type]
|
155
|
+
value.map { |v| _deserialize(inner_type, v) }
|
156
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
157
|
+
k_type = Regexp.last_match[:k_type]
|
158
|
+
v_type = Regexp.last_match[:v_type]
|
159
|
+
{}.tap do |hash|
|
160
|
+
value.each do |k, v|
|
161
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
# model
|
165
|
+
else
|
166
|
+
# models (e.g. Pet) or oneOf
|
167
|
+
klass = Algolia::Recommend.const_get(type)
|
168
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
169
|
+
.build_from_hash(value)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# Returns the string representation of the object
|
174
|
+
# @return [String] String presentation of the object
|
175
|
+
def to_s
|
176
|
+
to_hash.to_s
|
177
|
+
end
|
178
|
+
|
179
|
+
# to_body is an alias to to_hash (backward compatibility)
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_body
|
182
|
+
to_hash
|
183
|
+
end
|
184
|
+
|
185
|
+
def to_json(*_args)
|
186
|
+
to_hash.to_json
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns the object in the form of hash
|
190
|
+
# @return [Hash] Returns the object in the form of hash
|
191
|
+
def to_hash
|
192
|
+
hash = {}
|
193
|
+
self.class.attribute_map.each_pair do |attr, param|
|
194
|
+
value = send(attr)
|
195
|
+
if value.nil?
|
196
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
197
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
198
|
+
end
|
199
|
+
|
200
|
+
hash[param] = _to_hash(value)
|
201
|
+
end
|
202
|
+
|
203
|
+
hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Outputs non-array value in the form of hash
|
207
|
+
# For object, use to_hash. Otherwise, just return the value
|
208
|
+
# @param [Object] value Any valid value
|
209
|
+
# @return [Hash] Returns the value in the form of hash
|
210
|
+
def _to_hash(value)
|
211
|
+
if value.is_a?(Array)
|
212
|
+
value.compact.map { |v| _to_hash(v) }
|
213
|
+
elsif value.is_a?(Hash)
|
214
|
+
{}.tap do |hash|
|
215
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
216
|
+
end
|
217
|
+
elsif value.respond_to?(:to_hash)
|
218
|
+
value.to_hash
|
219
|
+
else
|
220
|
+
value
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Recommend
|
8
|
+
class TimeRange
|
9
|
+
# When the rule should start to be active, in Unix epoch time.
|
10
|
+
attr_accessor :from
|
11
|
+
|
12
|
+
# When the rule should stop to be active, in Unix epoch time.
|
13
|
+
attr_accessor :_until
|
14
|
+
|
15
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
16
|
+
def self.attribute_map
|
17
|
+
{
|
18
|
+
:from => :from,
|
19
|
+
:_until => :until
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns all the JSON keys this model knows about
|
24
|
+
def self.acceptable_attributes
|
25
|
+
attribute_map.values
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.types_mapping
|
30
|
+
{
|
31
|
+
:from => :"Integer",
|
32
|
+
:_until => :"Integer"
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# List of attributes with nullable: true
|
37
|
+
def self.openapi_nullable
|
38
|
+
Set.new(
|
39
|
+
[]
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
if (!attributes.is_a?(Hash))
|
47
|
+
raise(
|
48
|
+
ArgumentError,
|
49
|
+
"The input argument (attributes) must be a hash in `Algolia::TimeRange` initialize method"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
55
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
56
|
+
raise(
|
57
|
+
ArgumentError,
|
58
|
+
"`#{k}` is not a valid attribute in `Algolia::TimeRange`. Please check the name to make sure it's valid. List of attributes: " +
|
59
|
+
self.class.attribute_map.keys.inspect
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
h[k.to_sym] = v
|
64
|
+
}
|
65
|
+
|
66
|
+
if attributes.key?(:from)
|
67
|
+
self.from = attributes[:from]
|
68
|
+
else
|
69
|
+
self.from = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
if attributes.key?(:_until)
|
73
|
+
self._until = attributes[:_until]
|
74
|
+
else
|
75
|
+
self._until = nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks equality by comparing each attribute.
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def ==(other)
|
82
|
+
return true if self.equal?(other)
|
83
|
+
self.class == other.class &&
|
84
|
+
from == other.from &&
|
85
|
+
_until == other._until
|
86
|
+
end
|
87
|
+
|
88
|
+
# @see the `==` method
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def eql?(other)
|
91
|
+
self == other
|
92
|
+
end
|
93
|
+
|
94
|
+
# Calculates hash code according to all attributes.
|
95
|
+
# @return [Integer] Hash code
|
96
|
+
def hash
|
97
|
+
[from, _until].hash
|
98
|
+
end
|
99
|
+
|
100
|
+
# Builds the object from hash
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
# @return [Object] Returns the model itself
|
103
|
+
def self.build_from_hash(attributes)
|
104
|
+
return nil unless attributes.is_a?(Hash)
|
105
|
+
attributes = attributes.transform_keys(&:to_sym)
|
106
|
+
transformed_hash = {}
|
107
|
+
types_mapping.each_pair do |key, type|
|
108
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
109
|
+
transformed_hash[key.to_sym] = nil
|
110
|
+
elsif type =~ /\AArray<(.*)>/i
|
111
|
+
# check to ensure the input is an array given that the attribute
|
112
|
+
# is documented as an array but the input is not
|
113
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
114
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
115
|
+
_deserialize(::Regexp.last_match(1), v)
|
116
|
+
}
|
117
|
+
end
|
118
|
+
elsif !attributes[attribute_map[key]].nil?
|
119
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
new(transformed_hash)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Deserializes the data based on type
|
127
|
+
# @param string type Data type
|
128
|
+
# @param string value Value to be deserialized
|
129
|
+
# @return [Object] Deserialized data
|
130
|
+
def self._deserialize(type, value)
|
131
|
+
case type.to_sym
|
132
|
+
when :Time
|
133
|
+
Time.parse(value)
|
134
|
+
when :Date
|
135
|
+
Date.parse(value)
|
136
|
+
when :String
|
137
|
+
value.to_s
|
138
|
+
when :Integer
|
139
|
+
value.to_i
|
140
|
+
when :Float
|
141
|
+
value.to_f
|
142
|
+
when :Boolean
|
143
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
144
|
+
true
|
145
|
+
else
|
146
|
+
false
|
147
|
+
end
|
148
|
+
|
149
|
+
when :Object
|
150
|
+
# generic object (usually a Hash), return directly
|
151
|
+
value
|
152
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
153
|
+
inner_type = Regexp.last_match[:inner_type]
|
154
|
+
value.map { |v| _deserialize(inner_type, v) }
|
155
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
156
|
+
k_type = Regexp.last_match[:k_type]
|
157
|
+
v_type = Regexp.last_match[:v_type]
|
158
|
+
{}.tap do |hash|
|
159
|
+
value.each do |k, v|
|
160
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
# model
|
164
|
+
else
|
165
|
+
# models (e.g. Pet) or oneOf
|
166
|
+
klass = Algolia::Recommend.const_get(type)
|
167
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
168
|
+
.build_from_hash(value)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the string representation of the object
|
173
|
+
# @return [String] String presentation of the object
|
174
|
+
def to_s
|
175
|
+
to_hash.to_s
|
176
|
+
end
|
177
|
+
|
178
|
+
# to_body is an alias to to_hash (backward compatibility)
|
179
|
+
# @return [Hash] Returns the object in the form of hash
|
180
|
+
def to_body
|
181
|
+
to_hash
|
182
|
+
end
|
183
|
+
|
184
|
+
def to_json(*_args)
|
185
|
+
to_hash.to_json
|
186
|
+
end
|
187
|
+
|
188
|
+
# Returns the object in the form of hash
|
189
|
+
# @return [Hash] Returns the object in the form of hash
|
190
|
+
def to_hash
|
191
|
+
hash = {}
|
192
|
+
self.class.attribute_map.each_pair do |attr, param|
|
193
|
+
value = send(attr)
|
194
|
+
if value.nil?
|
195
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
196
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
197
|
+
end
|
198
|
+
|
199
|
+
hash[param] = _to_hash(value)
|
200
|
+
end
|
201
|
+
|
202
|
+
hash
|
203
|
+
end
|
204
|
+
|
205
|
+
# Outputs non-array value in the form of hash
|
206
|
+
# For object, use to_hash. Otherwise, just return the value
|
207
|
+
# @param [Object] value Any valid value
|
208
|
+
# @return [Hash] Returns the value in the form of hash
|
209
|
+
def _to_hash(value)
|
210
|
+
if value.is_a?(Array)
|
211
|
+
value.compact.map { |v| _to_hash(v) }
|
212
|
+
elsif value.is_a?(Hash)
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
215
|
+
end
|
216
|
+
elsif value.respond_to?(:to_hash)
|
217
|
+
value.to_hash
|
218
|
+
else
|
219
|
+
value
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
data/lib/algolia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://alg.li/support
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -119,6 +119,7 @@ extensions: []
|
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
121
|
- ".github/ISSUE_TEMPLATE/Bug_report.yml"
|
122
|
+
- ".github/workflows/do-not-edit-this-repository.yml"
|
122
123
|
- ".github/workflows/issue.yml"
|
123
124
|
- ".github/workflows/release.yml"
|
124
125
|
- ".gitignore"
|
@@ -481,6 +482,7 @@ files:
|
|
481
482
|
- lib/algolia/models/recommend/recommend_models.rb
|
482
483
|
- lib/algolia/models/recommend/recommend_rule.rb
|
483
484
|
- lib/algolia/models/recommend/recommend_search_params.rb
|
485
|
+
- lib/algolia/models/recommend/recommend_updated_at_response.rb
|
484
486
|
- lib/algolia/models/recommend/recommendations_hit.rb
|
485
487
|
- lib/algolia/models/recommend/recommendations_request.rb
|
486
488
|
- lib/algolia/models/recommend/recommendations_results.rb
|
@@ -504,6 +506,7 @@ files:
|
|
504
506
|
- lib/algolia/models/recommend/supported_language.rb
|
505
507
|
- lib/algolia/models/recommend/tag_filters.rb
|
506
508
|
- lib/algolia/models/recommend/task_status.rb
|
509
|
+
- lib/algolia/models/recommend/time_range.rb
|
507
510
|
- lib/algolia/models/recommend/trending_facet_hit.rb
|
508
511
|
- lib/algolia/models/recommend/trending_facets_model.rb
|
509
512
|
- lib/algolia/models/recommend/trending_facets_query.rb
|