algolia 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/search_client.rb +4 -4
- data/lib/algolia/models/abtesting/error_base.rb +212 -0
- data/lib/algolia/models/analytics/error_base.rb +212 -0
- data/lib/algolia/models/ingestion/error_base.rb +212 -0
- data/lib/algolia/models/insights/error_base.rb +212 -0
- data/lib/algolia/models/monitoring/error_base.rb +212 -0
- data/lib/algolia/models/personalization/error_base.rb +212 -0
- data/lib/algolia/models/query-suggestions/error_base.rb +212 -0
- data/lib/algolia/models/recommend/error_base.rb +212 -0
- data/lib/algolia/models/search/error_base.rb +212 -0
- data/lib/algolia/models/usage/error_base.rb +212 -0
- data/lib/algolia/version.rb +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 404b7dfdccd5dd7e5fdc335e2a9aa51df6e25db69090bfab3d26d78de2d5627b
|
4
|
+
data.tar.gz: 6d12601db49e7a0c3148699c91e2b529532ecb7b2dd7accd5acc73b7b7281d8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9a195272c834ace42d3afc0d432dff8c231f3bfd0bd72fec215ca2869ece8c288e227ee5e31fc17b450569d5a35dd131fefde1feb11643744d523ee19a3057
|
7
|
+
data.tar.gz: aa37dd5dec384ece1fbbb04a6e584eeecc6b3b48e2815be424c5920aec116717559a8b3313f061a73e70a1d3292c5466e3d8783ad6d1d37424cd150aa25c5d4c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [3.2.1](https://github.com/algolia/algoliasearch-client-ruby/compare/3.2.0...3.2.1)
|
2
|
+
|
3
|
+
- [41f849e41](https://github.com/algolia/api-clients-automation/commit/41f849e41) fix(specs): partial update operation ([#3486](https://github.com/algolia/api-clients-automation/pull/3486)) by [@kai687](https://github.com/kai687/)
|
4
|
+
|
1
5
|
## [3.2.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.1.1...3.2.0)
|
2
6
|
|
3
7
|
- [23a799f0e](https://github.com/algolia/api-clients-automation/commit/23a799f0e) feat(specs): push source type ([#3600](https://github.com/algolia/api-clients-automation/pull/3600)) by [@shortcuts](https://github.com/shortcuts/)
|
data/Gemfile.lock
CHANGED
@@ -2072,13 +2072,13 @@ module Algolia
|
|
2072
2072
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
|
2073
2073
|
end
|
2074
2074
|
|
2075
|
-
# Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor.
|
2075
|
+
# Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don't have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an IncrementSet value that's greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
|
2076
2076
|
#
|
2077
2077
|
# Required API Key ACLs:
|
2078
2078
|
# - addObject
|
2079
2079
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
2080
2080
|
# @param object_id [String] Unique record identifier. (required)
|
2081
|
-
# @param attributes_to_update [
|
2081
|
+
# @param attributes_to_update [Object] Attributes with their values. (required)
|
2082
2082
|
# @param create_if_not_exists [Boolean] Whether to create a new record if it doesn't exist. (default to true)
|
2083
2083
|
# @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)
|
2084
2084
|
# @return [Http::Response] the response
|
@@ -2124,13 +2124,13 @@ module Algolia
|
|
2124
2124
|
@api_client.call_api(:POST, path, new_options)
|
2125
2125
|
end
|
2126
2126
|
|
2127
|
-
# Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor.
|
2127
|
+
# Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don't have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an IncrementSet value that's greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
|
2128
2128
|
#
|
2129
2129
|
# Required API Key ACLs:
|
2130
2130
|
# - addObject
|
2131
2131
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
2132
2132
|
# @param object_id [String] Unique record identifier. (required)
|
2133
|
-
# @param attributes_to_update [
|
2133
|
+
# @param attributes_to_update [Object] Attributes with their values. (required)
|
2134
2134
|
# @param create_if_not_exists [Boolean] Whether to create a new record if it doesn't exist. (default to true)
|
2135
2135
|
# @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)
|
2136
2136
|
# @return [UpdatedAtWithObjectIdResponse]
|
@@ -0,0 +1,212 @@
|
|
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 Abtesting
|
8
|
+
# Error.
|
9
|
+
class ErrorBase
|
10
|
+
attr_accessor :message
|
11
|
+
|
12
|
+
attr_accessor :additional_properties
|
13
|
+
|
14
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
15
|
+
def self.attribute_map
|
16
|
+
{
|
17
|
+
:message => :message
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns all the JSON keys this model knows about
|
22
|
+
def self.acceptable_attributes
|
23
|
+
attribute_map.values
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.types_mapping
|
28
|
+
{
|
29
|
+
:message => :"String"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# List of attributes with nullable: true
|
34
|
+
def self.openapi_nullable
|
35
|
+
Set.new(
|
36
|
+
[]
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Initializes the object
|
41
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
42
|
+
def initialize(attributes = {})
|
43
|
+
if (!attributes.is_a?(Hash))
|
44
|
+
raise(
|
45
|
+
ArgumentError,
|
46
|
+
"The input argument (attributes) must be a hash in `Algolia::ErrorBase` initialize method"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes.key?(:message)
|
51
|
+
self.message = attributes[:message]
|
52
|
+
end
|
53
|
+
|
54
|
+
# add extra attribute to additional_properties
|
55
|
+
self.additional_properties ||= {}
|
56
|
+
self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
|
57
|
+
end
|
58
|
+
|
59
|
+
# Checks equality by comparing each attribute.
|
60
|
+
# @param [Object] Object to be compared
|
61
|
+
def ==(other)
|
62
|
+
return true if self.equal?(other)
|
63
|
+
self.class == other.class &&
|
64
|
+
message == other.message
|
65
|
+
end
|
66
|
+
|
67
|
+
# @see the `==` method
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def eql?(other)
|
70
|
+
self == other
|
71
|
+
end
|
72
|
+
|
73
|
+
# Calculates hash code according to all attributes.
|
74
|
+
# @return [Integer] Hash code
|
75
|
+
def hash
|
76
|
+
[message].hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# Builds the object from hash
|
80
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
81
|
+
# @return [Object] Returns the model itself
|
82
|
+
def self.build_from_hash(attributes)
|
83
|
+
return nil unless attributes.is_a?(Hash)
|
84
|
+
attributes = attributes.transform_keys(&:to_sym)
|
85
|
+
transformed_hash = {}
|
86
|
+
types_mapping.each_pair do |key, type|
|
87
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
88
|
+
transformed_hash[key.to_sym] = nil
|
89
|
+
elsif type =~ /\AArray<(.*)>/i
|
90
|
+
# check to ensure the input is an array given that the attribute
|
91
|
+
# is documented as an array but the input is not
|
92
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
93
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
94
|
+
_deserialize(::Regexp.last_match(1), v)
|
95
|
+
}
|
96
|
+
end
|
97
|
+
elsif !attributes[attribute_map[key]].nil?
|
98
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# add extra attribute to transformed_hash
|
103
|
+
transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
|
104
|
+
new(transformed_hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Deserializes the data based on type
|
108
|
+
# @param string type Data type
|
109
|
+
# @param string value Value to be deserialized
|
110
|
+
# @return [Object] Deserialized data
|
111
|
+
def self._deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :Time
|
114
|
+
Time.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :Boolean
|
124
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
|
130
|
+
when :Object
|
131
|
+
# generic object (usually a Hash), return directly
|
132
|
+
value
|
133
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
134
|
+
inner_type = Regexp.last_match[:inner_type]
|
135
|
+
value.map { |v| _deserialize(inner_type, v) }
|
136
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
137
|
+
k_type = Regexp.last_match[:k_type]
|
138
|
+
v_type = Regexp.last_match[:v_type]
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each do |k, v|
|
141
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
# model
|
145
|
+
else
|
146
|
+
# models (e.g. Pet) or oneOf
|
147
|
+
klass = Algolia::Abtesting.const_get(type)
|
148
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
149
|
+
.build_from_hash(value)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Returns the string representation of the object
|
154
|
+
# @return [String] String presentation of the object
|
155
|
+
def to_s
|
156
|
+
to_hash.to_s
|
157
|
+
end
|
158
|
+
|
159
|
+
# to_body is an alias to to_hash (backward compatibility)
|
160
|
+
# @return [Hash] Returns the object in the form of hash
|
161
|
+
def to_body
|
162
|
+
to_hash
|
163
|
+
end
|
164
|
+
|
165
|
+
def to_json(*_args)
|
166
|
+
to_hash.to_json
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the object in the form of hash
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_hash
|
172
|
+
hash = {}
|
173
|
+
self.class.attribute_map.each_pair do |attr, param|
|
174
|
+
value = send(attr)
|
175
|
+
if value.nil?
|
176
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
177
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
178
|
+
end
|
179
|
+
|
180
|
+
hash[param] = _to_hash(value)
|
181
|
+
end
|
182
|
+
|
183
|
+
# also add attributes from additional_properties to hash
|
184
|
+
self.additional_properties&.each_pair do |k, v|
|
185
|
+
hash[k.to_sym] = _to_hash(v)
|
186
|
+
end
|
187
|
+
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to?(:to_hash)
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,212 @@
|
|
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 Analytics
|
8
|
+
# Error.
|
9
|
+
class ErrorBase
|
10
|
+
attr_accessor :message
|
11
|
+
|
12
|
+
attr_accessor :additional_properties
|
13
|
+
|
14
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
15
|
+
def self.attribute_map
|
16
|
+
{
|
17
|
+
:message => :message
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns all the JSON keys this model knows about
|
22
|
+
def self.acceptable_attributes
|
23
|
+
attribute_map.values
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.types_mapping
|
28
|
+
{
|
29
|
+
:message => :"String"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# List of attributes with nullable: true
|
34
|
+
def self.openapi_nullable
|
35
|
+
Set.new(
|
36
|
+
[]
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Initializes the object
|
41
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
42
|
+
def initialize(attributes = {})
|
43
|
+
if (!attributes.is_a?(Hash))
|
44
|
+
raise(
|
45
|
+
ArgumentError,
|
46
|
+
"The input argument (attributes) must be a hash in `Algolia::ErrorBase` initialize method"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes.key?(:message)
|
51
|
+
self.message = attributes[:message]
|
52
|
+
end
|
53
|
+
|
54
|
+
# add extra attribute to additional_properties
|
55
|
+
self.additional_properties ||= {}
|
56
|
+
self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
|
57
|
+
end
|
58
|
+
|
59
|
+
# Checks equality by comparing each attribute.
|
60
|
+
# @param [Object] Object to be compared
|
61
|
+
def ==(other)
|
62
|
+
return true if self.equal?(other)
|
63
|
+
self.class == other.class &&
|
64
|
+
message == other.message
|
65
|
+
end
|
66
|
+
|
67
|
+
# @see the `==` method
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def eql?(other)
|
70
|
+
self == other
|
71
|
+
end
|
72
|
+
|
73
|
+
# Calculates hash code according to all attributes.
|
74
|
+
# @return [Integer] Hash code
|
75
|
+
def hash
|
76
|
+
[message].hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# Builds the object from hash
|
80
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
81
|
+
# @return [Object] Returns the model itself
|
82
|
+
def self.build_from_hash(attributes)
|
83
|
+
return nil unless attributes.is_a?(Hash)
|
84
|
+
attributes = attributes.transform_keys(&:to_sym)
|
85
|
+
transformed_hash = {}
|
86
|
+
types_mapping.each_pair do |key, type|
|
87
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
88
|
+
transformed_hash[key.to_sym] = nil
|
89
|
+
elsif type =~ /\AArray<(.*)>/i
|
90
|
+
# check to ensure the input is an array given that the attribute
|
91
|
+
# is documented as an array but the input is not
|
92
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
93
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
94
|
+
_deserialize(::Regexp.last_match(1), v)
|
95
|
+
}
|
96
|
+
end
|
97
|
+
elsif !attributes[attribute_map[key]].nil?
|
98
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# add extra attribute to transformed_hash
|
103
|
+
transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
|
104
|
+
new(transformed_hash)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Deserializes the data based on type
|
108
|
+
# @param string type Data type
|
109
|
+
# @param string value Value to be deserialized
|
110
|
+
# @return [Object] Deserialized data
|
111
|
+
def self._deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :Time
|
114
|
+
Time.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :Boolean
|
124
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
|
130
|
+
when :Object
|
131
|
+
# generic object (usually a Hash), return directly
|
132
|
+
value
|
133
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
134
|
+
inner_type = Regexp.last_match[:inner_type]
|
135
|
+
value.map { |v| _deserialize(inner_type, v) }
|
136
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
137
|
+
k_type = Regexp.last_match[:k_type]
|
138
|
+
v_type = Regexp.last_match[:v_type]
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each do |k, v|
|
141
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
# model
|
145
|
+
else
|
146
|
+
# models (e.g. Pet) or oneOf
|
147
|
+
klass = Algolia::Analytics.const_get(type)
|
148
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
149
|
+
.build_from_hash(value)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Returns the string representation of the object
|
154
|
+
# @return [String] String presentation of the object
|
155
|
+
def to_s
|
156
|
+
to_hash.to_s
|
157
|
+
end
|
158
|
+
|
159
|
+
# to_body is an alias to to_hash (backward compatibility)
|
160
|
+
# @return [Hash] Returns the object in the form of hash
|
161
|
+
def to_body
|
162
|
+
to_hash
|
163
|
+
end
|
164
|
+
|
165
|
+
def to_json(*_args)
|
166
|
+
to_hash.to_json
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the object in the form of hash
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_hash
|
172
|
+
hash = {}
|
173
|
+
self.class.attribute_map.each_pair do |attr, param|
|
174
|
+
value = send(attr)
|
175
|
+
if value.nil?
|
176
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
177
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
178
|
+
end
|
179
|
+
|
180
|
+
hash[param] = _to_hash(value)
|
181
|
+
end
|
182
|
+
|
183
|
+
# also add attributes from additional_properties to hash
|
184
|
+
self.additional_properties&.each_pair do |k, v|
|
185
|
+
hash[k.to_sym] = _to_hash(v)
|
186
|
+
end
|
187
|
+
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to?(:to_hash)
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|