algolia 3.15.4 → 3.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52cb63e14d4759337c66f9f2459f752ee03af7b7944b338783ee8797e989ddb6
4
- data.tar.gz: 7b01e70ae34a17388540ae743ff93a5da87646c79f32fe811e38c9cc3e61f2ec
3
+ metadata.gz: 866c3b0ca3aeefdf7eac97bc971e746f161b53ac53807083a28223a933e27a49
4
+ data.tar.gz: f1b7931dfcee757ea5bf242f5a89df2b613bb2e27f1ebdd318197589e632a920
5
5
  SHA512:
6
- metadata.gz: c98515c4ba5726fb4bb5871765ced01b3a7a9d92a85ddeab588a279d6bb68d4991c05b8d0eef5ba59f3be2a47d0c50ba75713f4d7eb165d5c000e9d0a89cfc07
7
- data.tar.gz: a4ee881c2a812f5c0e9d643a109042ec8c7cda54d1766adab36f25c65d770fa84b93d862352db5f109f2a9c14bbc64080c6f96bb3afbb56423ac22558a2fc591
6
+ metadata.gz: 46aeb23ea063e85a8ed25baec6910c3099c1bbd31d46d0393fbcad90acc33bc3f4c62b8e5f891f9ae870e3bed301fb7509314e796cf1950775f27656a5c36d58
7
+ data.tar.gz: f74c062ec55982f8fd360bd60aacdc65b72e2646bdc76392b75353f5b833df335548dfbe24465091ab2cf7f9fd1bd9dee45c4cdf7da199d8498a869abd7a984b
@@ -21,7 +21,7 @@ jobs:
21
21
  - name: Install Ruby
22
22
  uses: ruby/setup-ruby@v1
23
23
  with:
24
- ruby-version: 3.4.2
24
+ ruby-version: 3.4.3
25
25
  bundler-cache: true
26
26
 
27
27
  - uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [3.15.5](https://github.com/algolia/algoliasearch-client-ruby/compare/3.15.4...3.15.5)
2
+
3
+ - [efec6baf1c](https://github.com/algolia/api-clients-automation/commit/efec6baf1c) chore(deps): dependencies 2025-04-21 ([#4762](https://github.com/algolia/api-clients-automation/pull/4762)) by [@algolia-bot](https://github.com/algolia-bot/)
4
+ - [53ac749807](https://github.com/algolia/api-clients-automation/commit/53ac749807) chore(deps): dependencies 2025-04-28 ([#4785](https://github.com/algolia/api-clients-automation/pull/4785)) by [@algolia-bot](https://github.com/algolia-bot/)
5
+
1
6
  ## [3.15.4](https://github.com/algolia/algoliasearch-client-ruby/compare/3.15.3...3.15.4)
2
7
 
3
8
  - [369c14232](https://github.com/algolia/api-clients-automation/commit/369c14232) fix(specs): condition cant be numeric filter ([#4726](https://github.com/algolia/api-clients-automation/pull/4726)) by [@kai687](https://github.com/kai687/)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- algolia (3.15.4)
4
+ algolia (3.15.5)
5
5
  base64 (>= 0.2.0, < 1)
6
6
  faraday (>= 1.0.1, < 3.0)
7
7
  faraday-net_http_persistent (>= 0.15, < 3)
@@ -11,8 +11,8 @@ GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
13
  base64 (0.2.0)
14
- connection_pool (2.5.0)
15
- faraday (2.12.2)
14
+ connection_pool (2.5.2)
15
+ faraday (2.13.1)
16
16
  faraday-net_http (>= 2.0, < 3.5)
17
17
  json
18
18
  logger
@@ -21,8 +21,8 @@ GEM
21
21
  faraday-net_http_persistent (2.3.0)
22
22
  faraday (~> 2.5)
23
23
  net-http-persistent (>= 4.0.4, < 5)
24
- json (2.10.1)
25
- logger (1.6.6)
24
+ json (2.11.3)
25
+ logger (1.7.0)
26
26
  net-http (0.6.0)
27
27
  uri
28
28
  net-http-persistent (4.0.5)
@@ -7,101 +7,225 @@ require "time"
7
7
 
8
8
  module Algolia
9
9
  module Ingestion
10
- module DestinationInput
11
- class << self
12
- # List of class defined in oneOf (OpenAPI v3)
13
- def openapi_one_of
14
- [
15
- :"DestinationIndexName"
16
- ]
10
+ class DestinationInput
11
+ # Algolia index name (case-sensitive).
12
+ attr_accessor :index_name
13
+
14
+ attr_accessor :record_type
15
+
16
+ # Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array.
17
+ attr_accessor :attributes_to_exclude
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :index_name => :indexName,
23
+ :record_type => :recordType,
24
+ :attributes_to_exclude => :attributesToExclude
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.types_mapping
30
+ {
31
+ :index_name => :"String",
32
+ :record_type => :"RecordType",
33
+ :attributes_to_exclude => :"Array<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::DestinationInput` initialize method"
51
+ )
17
52
  end
18
53
 
19
- # Builds the object
20
- # @param [Mixed] Data to be matched against the list of oneOf items
21
- # @return [Object] Returns the model or the data itself
22
- def build(data)
23
- # Go through the list of oneOf items and attempt to identify the appropriate one.
24
- # Note:
25
- # - We do not attempt to check whether exactly one item matches.
26
- # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
27
- # due to the way the deserialization is made in the base_object template (it just casts without verifying).
28
- # - TODO: scalar values are de facto behaving as if they were nullable.
29
- # - TODO: logging when debugging is set.
30
- openapi_one_of.each do |klass|
31
- begin
32
- # "nullable: true"
33
- next if klass == :AnyType
34
- typed_data = find_and_cast_into_type(klass, data)
35
- return typed_data if typed_data
36
- # rescue all errors so we keep iterating even if the current item lookup raises
37
- rescue
38
- end
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::DestinationInput`. Please check the name to make sure it's valid. List of attributes: " +
60
+ self.class.attribute_map.keys.inspect
61
+ )
39
62
  end
40
63
 
41
- openapi_one_of.include?(:AnyType) ? data : nil
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:index_name)
68
+ self.index_name = attributes[:index_name]
69
+ else
70
+ self.index_name = nil
42
71
  end
43
72
 
44
- private
45
-
46
- SchemaMismatchError = Class.new(StandardError)
47
-
48
- def find_and_cast_into_type(klass, data)
49
- return if data.nil?
50
-
51
- case klass.to_s
52
- when "Boolean"
53
- return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
54
- when "Float"
55
- return data if data.instance_of?(Float)
56
- when "Integer"
57
- return data if data.instance_of?(Integer)
58
- when "Time"
59
- return Time.parse(data)
60
- when "Date"
61
- return Date.parse(data)
62
- when "String"
63
- return data if data.instance_of?(String)
64
- # "type: object"
65
- when "Object"
66
- return data if data.instance_of?(Hash)
67
- # "type: array"
68
- when /\AArray<(?<sub_type>.+)>\z/
69
- if data.instance_of?(Array)
70
- sub_type = Regexp.last_match[:sub_type]
71
- return data.map { |item| find_and_cast_into_type(sub_type, item) }
72
- end
73
- # "type: object" with "additionalProperties: { ... }"
74
- when /\AHash<String, (?<sub_type>.+)>\z/
75
- if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
76
- sub_type = Regexp.last_match[:sub_type]
77
- return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
73
+ if attributes.key?(:record_type)
74
+ self.record_type = attributes[:record_type]
75
+ end
76
+
77
+ if attributes.key?(:attributes_to_exclude)
78
+ if (value = attributes[:attributes_to_exclude]).is_a?(Array)
79
+ self.attributes_to_exclude = value
80
+ end
81
+ end
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(other)
87
+ return true if self.equal?(other)
88
+ self.class == other.class &&
89
+ index_name == other.index_name &&
90
+ record_type == other.record_type &&
91
+ attributes_to_exclude == other.attributes_to_exclude
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(other)
97
+ self == other
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Integer] Hash code
102
+ def hash
103
+ [index_name, record_type, attributes_to_exclude].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def self.build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ transformed_hash = {}
113
+ types_mapping.each_pair do |key, type|
114
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
115
+ transformed_hash[key.to_sym] = nil
116
+ elsif type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[attribute_map[key]].is_a?(Array)
120
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
121
+ _deserialize(::Regexp.last_match(1), v)
122
+ }
78
123
  end
79
- # model
124
+ elsif !attributes[attribute_map[key]].nil?
125
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
126
+ end
127
+ end
128
+
129
+ new(transformed_hash)
130
+ end
131
+
132
+ # Deserializes the data based on type
133
+ # @param string type Data type
134
+ # @param string value Value to be deserialized
135
+ # @return [Object] Deserialized data
136
+ def self._deserialize(type, value)
137
+ case type.to_sym
138
+ when :Time
139
+ Time.parse(value)
140
+ when :Date
141
+ Date.parse(value)
142
+ when :String
143
+ value.to_s
144
+ when :Integer
145
+ value.to_i
146
+ when :Float
147
+ value.to_f
148
+ when :Boolean
149
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
150
+ true
80
151
  else
81
- const = Algolia::Ingestion.const_get(klass)
82
- if const
83
- if const.respond_to?(:openapi_one_of)
84
- # nested oneOf model
85
- model = const.build(data)
86
- elsif const.respond_to?(:discriminator_attributes)
87
- if const.discriminator_attributes.all? { |attr| data.key?(attr) }
88
- model = const.build_from_hash(data)
89
- end
90
- else
91
- # maybe it's an enum, or doens't have discriminators
92
- model = const.build_from_hash(data)
93
- end
94
-
95
- return model if model
152
+ false
153
+ end
154
+
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
96
167
  end
97
168
  end
169
+ # model
170
+ else
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Algolia::Ingestion.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
174
+ .build_from_hash(value)
175
+ end
176
+ end
98
177
 
99
- # if no match by now, raise
100
- raise
101
- rescue
102
- raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
178
+ # Returns the string representation of the object
179
+ # @return [String] String presentation of the object
180
+ def to_s
181
+ to_hash.to_s
182
+ end
183
+
184
+ # to_body is an alias to to_hash (backward compatibility)
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_body
187
+ to_hash
188
+ end
189
+
190
+ def to_json(*_args)
191
+ to_hash.to_json
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = send(attr)
200
+ if value.nil?
201
+ is_nullable = self.class.openapi_nullable.include?(attr)
202
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
+ end
204
+
205
+ hash[param] = _to_hash(value)
103
206
  end
207
+
208
+ hash
104
209
  end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value)
216
+ if value.is_a?(Array)
217
+ value.compact.map { |v| _to_hash(v) }
218
+ elsif value.is_a?(Hash)
219
+ {}.tap do |hash|
220
+ value.each { |k, v| hash[k] = _to_hash(v) }
221
+ end
222
+ elsif value.respond_to?(:to_hash)
223
+ value.to_hash
224
+ else
225
+ value
226
+ end
227
+ end
228
+
105
229
  end
106
230
 
107
231
  end
@@ -3,5 +3,5 @@
3
3
  # 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.
4
4
 
5
5
  module Algolia
6
- VERSION = "3.15.4"
6
+ VERSION = "3.15.5"
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algolia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.4
4
+ version: 3.15.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://alg.li/support
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday
@@ -307,7 +307,6 @@ files:
307
307
  - lib/algolia/models/ingestion/destination.rb
308
308
  - lib/algolia/models/ingestion/destination_create.rb
309
309
  - lib/algolia/models/ingestion/destination_create_response.rb
310
- - lib/algolia/models/ingestion/destination_index_name.rb
311
310
  - lib/algolia/models/ingestion/destination_input.rb
312
311
  - lib/algolia/models/ingestion/destination_search.rb
313
312
  - lib/algolia/models/ingestion/destination_sort_keys.rb
@@ -765,7 +764,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
765
764
  - !ruby/object:Gem::Version
766
765
  version: '0'
767
766
  requirements: []
768
- rubygems_version: 3.6.2
767
+ rubygems_version: 3.6.7
769
768
  specification_version: 4
770
769
  summary: A simple Ruby client for the algolia.com REST API
771
770
  test_files: []
@@ -1,232 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # 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.
4
-
5
- require "date"
6
- require "time"
7
-
8
- module Algolia
9
- module Ingestion
10
- class DestinationIndexName
11
- # Algolia index name (case-sensitive).
12
- attr_accessor :index_name
13
-
14
- attr_accessor :record_type
15
-
16
- # Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array.
17
- attr_accessor :attributes_to_exclude
18
-
19
- # Attribute mapping from ruby-style variable name to JSON key.
20
- def self.attribute_map
21
- {
22
- :index_name => :indexName,
23
- :record_type => :recordType,
24
- :attributes_to_exclude => :attributesToExclude
25
- }
26
- end
27
-
28
- # Attribute type mapping.
29
- def self.types_mapping
30
- {
31
- :index_name => :"String",
32
- :record_type => :"RecordType",
33
- :attributes_to_exclude => :"Array<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::DestinationIndexName` 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::DestinationIndexName`. 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?(:index_name)
68
- self.index_name = attributes[:index_name]
69
- else
70
- self.index_name = nil
71
- end
72
-
73
- if attributes.key?(:record_type)
74
- self.record_type = attributes[:record_type]
75
- end
76
-
77
- if attributes.key?(:attributes_to_exclude)
78
- if (value = attributes[:attributes_to_exclude]).is_a?(Array)
79
- self.attributes_to_exclude = value
80
- end
81
- end
82
- end
83
-
84
- # Checks equality by comparing each attribute.
85
- # @param [Object] Object to be compared
86
- def ==(other)
87
- return true if self.equal?(other)
88
- self.class == other.class &&
89
- index_name == other.index_name &&
90
- record_type == other.record_type &&
91
- attributes_to_exclude == other.attributes_to_exclude
92
- end
93
-
94
- # @see the `==` method
95
- # @param [Object] Object to be compared
96
- def eql?(other)
97
- self == other
98
- end
99
-
100
- # Calculates hash code according to all attributes.
101
- # @return [Integer] Hash code
102
- def hash
103
- [index_name, record_type, attributes_to_exclude].hash
104
- end
105
-
106
- # Builds the object from hash
107
- # @param [Hash] attributes Model attributes in the form of hash
108
- # @return [Object] Returns the model itself
109
- def self.build_from_hash(attributes)
110
- return nil unless attributes.is_a?(Hash)
111
- attributes = attributes.transform_keys(&:to_sym)
112
- transformed_hash = {}
113
- types_mapping.each_pair do |key, type|
114
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
115
- transformed_hash[key.to_sym] = nil
116
- elsif type =~ /\AArray<(.*)>/i
117
- # check to ensure the input is an array given that the attribute
118
- # is documented as an array but the input is not
119
- if attributes[attribute_map[key]].is_a?(Array)
120
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
121
- _deserialize(::Regexp.last_match(1), v)
122
- }
123
- end
124
- elsif !attributes[attribute_map[key]].nil?
125
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
126
- end
127
- end
128
-
129
- new(transformed_hash)
130
- end
131
-
132
- # Deserializes the data based on type
133
- # @param string type Data type
134
- # @param string value Value to be deserialized
135
- # @return [Object] Deserialized data
136
- def self._deserialize(type, value)
137
- case type.to_sym
138
- when :Time
139
- Time.parse(value)
140
- when :Date
141
- Date.parse(value)
142
- when :String
143
- value.to_s
144
- when :Integer
145
- value.to_i
146
- when :Float
147
- value.to_f
148
- when :Boolean
149
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
150
- true
151
- else
152
- false
153
- end
154
-
155
- when :Object
156
- # generic object (usually a Hash), return directly
157
- value
158
- when /\AArray<(?<inner_type>.+)>\z/
159
- inner_type = Regexp.last_match[:inner_type]
160
- value.map { |v| _deserialize(inner_type, v) }
161
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
- k_type = Regexp.last_match[:k_type]
163
- v_type = Regexp.last_match[:v_type]
164
- {}.tap do |hash|
165
- value.each do |k, v|
166
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
- end
168
- end
169
- # model
170
- else
171
- # models (e.g. Pet) or oneOf
172
- klass = Algolia::Ingestion.const_get(type)
173
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
174
- .build_from_hash(value)
175
- end
176
- end
177
-
178
- # Returns the string representation of the object
179
- # @return [String] String presentation of the object
180
- def to_s
181
- to_hash.to_s
182
- end
183
-
184
- # to_body is an alias to to_hash (backward compatibility)
185
- # @return [Hash] Returns the object in the form of hash
186
- def to_body
187
- to_hash
188
- end
189
-
190
- def to_json(*_args)
191
- to_hash.to_json
192
- end
193
-
194
- # Returns the object in the form of hash
195
- # @return [Hash] Returns the object in the form of hash
196
- def to_hash
197
- hash = {}
198
- self.class.attribute_map.each_pair do |attr, param|
199
- value = send(attr)
200
- if value.nil?
201
- is_nullable = self.class.openapi_nullable.include?(attr)
202
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
- end
204
-
205
- hash[param] = _to_hash(value)
206
- end
207
-
208
- hash
209
- end
210
-
211
- # Outputs non-array value in the form of hash
212
- # For object, use to_hash. Otherwise, just return the value
213
- # @param [Object] value Any valid value
214
- # @return [Hash] Returns the value in the form of hash
215
- def _to_hash(value)
216
- if value.is_a?(Array)
217
- value.compact.map { |v| _to_hash(v) }
218
- elsif value.is_a?(Hash)
219
- {}.tap do |hash|
220
- value.each { |k, v| hash[k] = _to_hash(v) }
221
- end
222
- elsif value.respond_to?(:to_hash)
223
- value.to_hash
224
- else
225
- value
226
- end
227
- end
228
-
229
- end
230
-
231
- end
232
- end