algolia 3.0.0.alpha.10 → 3.0.0.alpha.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.openapi-generator/FILES +2 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +4 -4
- data/lib/algolia/models/ingestion/mapping_field_directive.rb +214 -0
- data/lib/algolia/models/ingestion/mapping_input.rb +213 -0
- data/lib/algolia/models/ingestion/mapping_kit_action.rb +235 -0
- data/lib/algolia/models/ingestion/on_demand_date_utils_input.rb +13 -4
- data/lib/algolia/models/ingestion/schedule_date_utils_input.rb +13 -4
- data/lib/algolia/models/recommend/base_search_response.rb +14 -4
- data/lib/algolia/models/recommend/recommendations_results.rb +11 -1
- data/lib/algolia/models/search/api_key_operation.rb +34 -0
- data/lib/algolia/models/search/base_search_response.rb +14 -4
- data/lib/algolia/models/search/browse_response.rb +11 -1
- data/lib/algolia/models/search/search_response.rb +11 -1
- data/lib/algolia/models/search/secured_api_key_restrictions.rb +248 -0
- data/lib/algolia/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83955f794742e28331a6a92d11dd5c3a614bc7f4fbaaa0ddeb15917108b02008
|
4
|
+
data.tar.gz: 3396251b1cf2d5a38401845323c8850c81a002698cba78609161b4a2460fa819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1e35e74fcec5a35a02ab0400214a8a9919a65513c5fb7348edaf9bf9e5da339faa96691e573e8508675380f354c94e9b43b05bedc3065061556d7a54388566d
|
7
|
+
data.tar.gz: 4e22b6da6f089c8141846fa05aff5d0f9d61ecb36c76c39613e9e3a791348673f5cb84974c81bff97cffcbd714ba7e09e38f24a1a8325d2d2eee618565bf1f33
|
data/.openapi-generator/FILES
CHANGED
@@ -6,6 +6,7 @@ lib/algolia/models/search/advanced_syntax_features.rb
|
|
6
6
|
lib/algolia/models/search/alternatives_as_exact.rb
|
7
7
|
lib/algolia/models/search/anchoring.rb
|
8
8
|
lib/algolia/models/search/api_key.rb
|
9
|
+
lib/algolia/models/search/api_key_operation.rb
|
9
10
|
lib/algolia/models/search/around_precision.rb
|
10
11
|
lib/algolia/models/search/around_precision_from_value_inner.rb
|
11
12
|
lib/algolia/models/search/around_radius.rb
|
@@ -140,6 +141,7 @@ lib/algolia/models/search/search_type_default.rb
|
|
140
141
|
lib/algolia/models/search/search_type_facet.rb
|
141
142
|
lib/algolia/models/search/search_user_ids_params.rb
|
142
143
|
lib/algolia/models/search/search_user_ids_response.rb
|
144
|
+
lib/algolia/models/search/secured_api_key_restrictions.rb
|
143
145
|
lib/algolia/models/search/semantic_search.rb
|
144
146
|
lib/algolia/models/search/snippet_result.rb
|
145
147
|
lib/algolia/models/search/snippet_result_option.rb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [3.0.0.alpha.12](https://github.com/algolia/algoliasearch-client-ruby/compare/3.0.0.alpha.11...3.0.0.alpha.12)
|
2
|
+
|
3
|
+
- [234427491](https://github.com/algolia/api-clients-automation/commit/234427491) feat(specs): Add MappingInput to Task Inputs ([#2787](https://github.com/algolia/api-clients-automation/pull/2787)) by [@jsok](https://github.com/jsok/)
|
4
|
+
|
5
|
+
## [3.0.0.alpha.11](https://github.com/algolia/algoliasearch-client-ruby/compare/3.0.0.alpha.10...3.0.0.alpha.11)
|
6
|
+
|
7
|
+
- [a138c2fef](https://github.com/algolia/api-clients-automation/commit/a138c2fef) fix(specs): add `queryID` to search response ([#2801](https://github.com/algolia/api-clients-automation/pull/2801)) by [@aallam](https://github.com/aallam/)
|
8
|
+
- [6f0b00ead](https://github.com/algolia/api-clients-automation/commit/6f0b00ead) chore(specs): remove JSON specs and new worlds logic ([#2794](https://github.com/algolia/api-clients-automation/pull/2794)) by [@shortcuts](https://github.com/shortcuts/)
|
9
|
+
|
1
10
|
## [3.0.0.alpha.10](https://github.com/algolia/algoliasearch-client-ruby/compare/3.0.0.alpha.9...3.0.0.alpha.10)
|
2
11
|
|
3
12
|
- [d48e2f624](https://github.com/algolia/api-clients-automation/commit/d48e2f624) fix(specs): add missing attributes for CT Source update ([#2792](https://github.com/algolia/api-clients-automation/pull/2792)) by [@damcou](https://github.com/damcou/)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
algolia (3.0.0.alpha.
|
4
|
+
algolia (3.0.0.alpha.12)
|
5
5
|
faraday (>= 1.0.1, < 3.0)
|
6
6
|
faraday-net_http_persistent (>= 0.15, < 3)
|
7
7
|
net-http-persistent
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
rake (13.1.0)
|
34
34
|
regexp_parser (2.9.0)
|
35
35
|
rexml (3.2.6)
|
36
|
-
rubocop (1.
|
36
|
+
rubocop (1.61.0)
|
37
37
|
json (~> 2.3)
|
38
38
|
language_server-protocol (>= 3.17.0)
|
39
39
|
parallel (~> 1.10)
|
@@ -44,8 +44,8 @@ GEM
|
|
44
44
|
rubocop-ast (>= 1.30.0, < 2.0)
|
45
45
|
ruby-progressbar (~> 1.7)
|
46
46
|
unicode-display_width (>= 2.4.0, < 3.0)
|
47
|
-
rubocop-ast (1.
|
48
|
-
parser (>= 3.
|
47
|
+
rubocop-ast (1.31.1)
|
48
|
+
parser (>= 3.3.0.4)
|
49
49
|
ruby-progressbar (1.13.0)
|
50
50
|
unicode-display_width (2.5.0)
|
51
51
|
uri (0.13.0)
|
@@ -0,0 +1,214 @@
|
|
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 Ingestion
|
8
|
+
# Describes how a field should be resolved by applying a set of directives.
|
9
|
+
class MappingFieldDirective
|
10
|
+
# Destination field key.
|
11
|
+
attr_accessor :field_key
|
12
|
+
|
13
|
+
# How the destination field should be resolved from the source.
|
14
|
+
attr_accessor :value
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:field_key => :fieldKey,
|
20
|
+
:value => :value
|
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
|
+
:field_key => :String,
|
33
|
+
:value => :'Hash<String, Object>'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# List of attributes with nullable: true
|
38
|
+
def self.openapi_nullable
|
39
|
+
Set.new([])
|
40
|
+
end
|
41
|
+
|
42
|
+
# Initializes the object
|
43
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
44
|
+
def initialize(attributes = {})
|
45
|
+
unless attributes.is_a?(Hash)
|
46
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::MappingFieldDirective` initialize method"
|
47
|
+
end
|
48
|
+
|
49
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
50
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
51
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
52
|
+
raise ArgumentError,
|
53
|
+
"`#{k}` is not a valid attribute in `Algolia::MappingFieldDirective`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
54
|
+
end
|
55
|
+
|
56
|
+
h[k.to_sym] = v
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.key?(:field_key)
|
60
|
+
self.field_key = attributes[:field_key]
|
61
|
+
else
|
62
|
+
self.field_key = nil
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.key?(:value)
|
66
|
+
if (value = attributes[:value]).is_a?(Hash)
|
67
|
+
self.value = value
|
68
|
+
end
|
69
|
+
else
|
70
|
+
self.value = nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Checks equality by comparing each attribute.
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def ==(other)
|
77
|
+
return true if equal?(other)
|
78
|
+
|
79
|
+
self.class == other.class &&
|
80
|
+
field_key == other.field_key &&
|
81
|
+
value == other.value
|
82
|
+
end
|
83
|
+
|
84
|
+
# @see the `==` method
|
85
|
+
# @param [Object] Object to be compared
|
86
|
+
def eql?(other)
|
87
|
+
self == other
|
88
|
+
end
|
89
|
+
|
90
|
+
# Calculates hash code according to all attributes.
|
91
|
+
# @return [Integer] Hash code
|
92
|
+
def hash
|
93
|
+
[field_key, value].hash
|
94
|
+
end
|
95
|
+
|
96
|
+
# Builds the object from hash
|
97
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
98
|
+
# @return [Object] Returns the model itself
|
99
|
+
def self.build_from_hash(attributes)
|
100
|
+
return nil unless attributes.is_a?(Hash)
|
101
|
+
|
102
|
+
attributes = attributes.transform_keys(&:to_sym)
|
103
|
+
transformed_hash = {}
|
104
|
+
types_mapping.each_pair do |key, type|
|
105
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
106
|
+
transformed_hash[key.to_sym] = nil
|
107
|
+
elsif type =~ /\AArray<(.*)>/i
|
108
|
+
# check to ensure the input is an array given that the attribute
|
109
|
+
# is documented as an array but the input is not
|
110
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
111
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
112
|
+
end
|
113
|
+
elsif !attributes[attribute_map[key]].nil?
|
114
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
new(transformed_hash)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Deserializes the data based on type
|
121
|
+
# @param string type Data type
|
122
|
+
# @param string value Value to be deserialized
|
123
|
+
# @return [Object] Deserialized data
|
124
|
+
def self._deserialize(type, value)
|
125
|
+
case type.to_sym
|
126
|
+
when :Time
|
127
|
+
Time.parse(value)
|
128
|
+
when :Date
|
129
|
+
Date.parse(value)
|
130
|
+
when :String
|
131
|
+
value.to_s
|
132
|
+
when :Integer
|
133
|
+
value.to_i
|
134
|
+
when :Float
|
135
|
+
value.to_f
|
136
|
+
when :Boolean
|
137
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
138
|
+
true
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
142
|
+
when :Object
|
143
|
+
# generic object (usually a Hash), return directly
|
144
|
+
value
|
145
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
146
|
+
inner_type = Regexp.last_match[:inner_type]
|
147
|
+
value.map { |v| _deserialize(inner_type, v) }
|
148
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
149
|
+
k_type = Regexp.last_match[:k_type]
|
150
|
+
v_type = Regexp.last_match[:v_type]
|
151
|
+
{}.tap do |hash|
|
152
|
+
value.each do |k, v|
|
153
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
else # model
|
157
|
+
# models (e.g. Pet) or oneOf
|
158
|
+
klass = Algolia::Ingestion.const_get(type)
|
159
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the string representation of the object
|
164
|
+
# @return [String] String presentation of the object
|
165
|
+
def to_s
|
166
|
+
to_hash.to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
# to_body is an alias to to_hash (backward compatibility)
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_body
|
172
|
+
to_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
def to_json(*_args)
|
176
|
+
to_hash.to_json
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the object in the form of hash
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_hash
|
182
|
+
hash = {}
|
183
|
+
self.class.attribute_map.each_pair do |attr, param|
|
184
|
+
value = send(attr)
|
185
|
+
if value.nil?
|
186
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
187
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
188
|
+
end
|
189
|
+
|
190
|
+
hash[param] = _to_hash(value)
|
191
|
+
end
|
192
|
+
hash
|
193
|
+
end
|
194
|
+
|
195
|
+
# Outputs non-array value in the form of hash
|
196
|
+
# For object, use to_hash. Otherwise, just return the value
|
197
|
+
# @param [Object] value Any valid value
|
198
|
+
# @return [Hash] Returns the value in the form of hash
|
199
|
+
def _to_hash(value)
|
200
|
+
if value.is_a?(Array)
|
201
|
+
value.compact.map { |v| _to_hash(v) }
|
202
|
+
elsif value.is_a?(Hash)
|
203
|
+
{}.tap do |hash|
|
204
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
205
|
+
end
|
206
|
+
elsif value.respond_to? :to_hash
|
207
|
+
value.to_hash
|
208
|
+
else
|
209
|
+
value
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,213 @@
|
|
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 Ingestion
|
8
|
+
# Transformations to apply to source, serialized as a JSON string.
|
9
|
+
class MappingInput
|
10
|
+
# Name of the mapping format schema, `mappingkit/v1` is currently the only supported format.
|
11
|
+
attr_accessor :format
|
12
|
+
|
13
|
+
attr_accessor :actions
|
14
|
+
|
15
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
16
|
+
def self.attribute_map
|
17
|
+
{
|
18
|
+
:format => :format,
|
19
|
+
:actions => :actions
|
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
|
+
:format => :String,
|
32
|
+
:actions => :'Array<MappingKitAction>'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# List of attributes with nullable: true
|
37
|
+
def self.openapi_nullable
|
38
|
+
Set.new([])
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initializes the object
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
43
|
+
def initialize(attributes = {})
|
44
|
+
unless attributes.is_a?(Hash)
|
45
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::MappingInput` initialize method"
|
46
|
+
end
|
47
|
+
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
50
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
51
|
+
raise ArgumentError,
|
52
|
+
"`#{k}` is not a valid attribute in `Algolia::MappingInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
53
|
+
end
|
54
|
+
|
55
|
+
h[k.to_sym] = v
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes.key?(:format)
|
59
|
+
self.format = attributes[:format]
|
60
|
+
else
|
61
|
+
self.format = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
if attributes.key?(:actions)
|
65
|
+
if (value = attributes[:actions]).is_a?(Array)
|
66
|
+
self.actions = value
|
67
|
+
end
|
68
|
+
else
|
69
|
+
self.actions = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Checks equality by comparing each attribute.
|
74
|
+
# @param [Object] Object to be compared
|
75
|
+
def ==(other)
|
76
|
+
return true if equal?(other)
|
77
|
+
|
78
|
+
self.class == other.class &&
|
79
|
+
format == other.format &&
|
80
|
+
actions == other.actions
|
81
|
+
end
|
82
|
+
|
83
|
+
# @see the `==` method
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def eql?(other)
|
86
|
+
self == other
|
87
|
+
end
|
88
|
+
|
89
|
+
# Calculates hash code according to all attributes.
|
90
|
+
# @return [Integer] Hash code
|
91
|
+
def hash
|
92
|
+
[format, actions].hash
|
93
|
+
end
|
94
|
+
|
95
|
+
# Builds the object from hash
|
96
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
97
|
+
# @return [Object] Returns the model itself
|
98
|
+
def self.build_from_hash(attributes)
|
99
|
+
return nil unless attributes.is_a?(Hash)
|
100
|
+
|
101
|
+
attributes = attributes.transform_keys(&:to_sym)
|
102
|
+
transformed_hash = {}
|
103
|
+
types_mapping.each_pair do |key, type|
|
104
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
105
|
+
transformed_hash[key.to_sym] = nil
|
106
|
+
elsif type =~ /\AArray<(.*)>/i
|
107
|
+
# check to ensure the input is an array given that the attribute
|
108
|
+
# is documented as an array but the input is not
|
109
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
110
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
111
|
+
end
|
112
|
+
elsif !attributes[attribute_map[key]].nil?
|
113
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
new(transformed_hash)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Deserializes the data based on type
|
120
|
+
# @param string type Data type
|
121
|
+
# @param string value Value to be deserialized
|
122
|
+
# @return [Object] Deserialized data
|
123
|
+
def self._deserialize(type, value)
|
124
|
+
case type.to_sym
|
125
|
+
when :Time
|
126
|
+
Time.parse(value)
|
127
|
+
when :Date
|
128
|
+
Date.parse(value)
|
129
|
+
when :String
|
130
|
+
value.to_s
|
131
|
+
when :Integer
|
132
|
+
value.to_i
|
133
|
+
when :Float
|
134
|
+
value.to_f
|
135
|
+
when :Boolean
|
136
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
137
|
+
true
|
138
|
+
else
|
139
|
+
false
|
140
|
+
end
|
141
|
+
when :Object
|
142
|
+
# generic object (usually a Hash), return directly
|
143
|
+
value
|
144
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
145
|
+
inner_type = Regexp.last_match[:inner_type]
|
146
|
+
value.map { |v| _deserialize(inner_type, v) }
|
147
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
148
|
+
k_type = Regexp.last_match[:k_type]
|
149
|
+
v_type = Regexp.last_match[:v_type]
|
150
|
+
{}.tap do |hash|
|
151
|
+
value.each do |k, v|
|
152
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
else # model
|
156
|
+
# models (e.g. Pet) or oneOf
|
157
|
+
klass = Algolia::Ingestion.const_get(type)
|
158
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the string representation of the object
|
163
|
+
# @return [String] String presentation of the object
|
164
|
+
def to_s
|
165
|
+
to_hash.to_s
|
166
|
+
end
|
167
|
+
|
168
|
+
# to_body is an alias to to_hash (backward compatibility)
|
169
|
+
# @return [Hash] Returns the object in the form of hash
|
170
|
+
def to_body
|
171
|
+
to_hash
|
172
|
+
end
|
173
|
+
|
174
|
+
def to_json(*_args)
|
175
|
+
to_hash.to_json
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns the object in the form of hash
|
179
|
+
# @return [Hash] Returns the object in the form of hash
|
180
|
+
def to_hash
|
181
|
+
hash = {}
|
182
|
+
self.class.attribute_map.each_pair do |attr, param|
|
183
|
+
value = send(attr)
|
184
|
+
if value.nil?
|
185
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
186
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
187
|
+
end
|
188
|
+
|
189
|
+
hash[param] = _to_hash(value)
|
190
|
+
end
|
191
|
+
hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Outputs non-array value in the form of hash
|
195
|
+
# For object, use to_hash. Otherwise, just return the value
|
196
|
+
# @param [Object] value Any valid value
|
197
|
+
# @return [Hash] Returns the value in the form of hash
|
198
|
+
def _to_hash(value)
|
199
|
+
if value.is_a?(Array)
|
200
|
+
value.compact.map { |v| _to_hash(v) }
|
201
|
+
elsif value.is_a?(Hash)
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
204
|
+
end
|
205
|
+
elsif value.respond_to? :to_hash
|
206
|
+
value.to_hash
|
207
|
+
else
|
208
|
+
value
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|