pluralkit-api 1.0.0

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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +136 -0
  4. data/Rakefile +10 -0
  5. data/docs/AccountsApi.md +72 -0
  6. data/docs/FullSwitch.md +20 -0
  7. data/docs/Member.md +58 -0
  8. data/docs/MembersApi.md +353 -0
  9. data/docs/Message.md +30 -0
  10. data/docs/PrivacySetting.md +15 -0
  11. data/docs/ProxyTag.md +20 -0
  12. data/docs/ProxyingApi.md +70 -0
  13. data/docs/Switch.md +20 -0
  14. data/docs/SwitchesApi.md +208 -0
  15. data/docs/System.md +40 -0
  16. data/docs/SystemsApi.md +475 -0
  17. data/git_push.sh +58 -0
  18. data/lib/pluralkit-api.rb +51 -0
  19. data/lib/pluralkit-api/api/accounts_api.rb +98 -0
  20. data/lib/pluralkit-api/api/members_api.rb +389 -0
  21. data/lib/pluralkit-api/api/proxying_api.rb +96 -0
  22. data/lib/pluralkit-api/api/switches_api.rb +236 -0
  23. data/lib/pluralkit-api/api/systems_api.rb +525 -0
  24. data/lib/pluralkit-api/api_client.rb +390 -0
  25. data/lib/pluralkit-api/api_error.rb +57 -0
  26. data/lib/pluralkit-api/configuration.rb +277 -0
  27. data/lib/pluralkit-api/models/full_switch.rb +231 -0
  28. data/lib/pluralkit-api/models/member.rb +568 -0
  29. data/lib/pluralkit-api/models/message.rb +274 -0
  30. data/lib/pluralkit-api/models/privacy_setting.rb +37 -0
  31. data/lib/pluralkit-api/models/proxy_tag.rb +262 -0
  32. data/lib/pluralkit-api/models/switch.rb +231 -0
  33. data/lib/pluralkit-api/models/system.rb +417 -0
  34. data/lib/pluralkit-api/version.rb +15 -0
  35. data/pluralkit-api.gemspec +38 -0
  36. data/spec/api/accounts_api_spec.rb +47 -0
  37. data/spec/api/members_api_spec.rb +92 -0
  38. data/spec/api/proxying_api_spec.rb +46 -0
  39. data/spec/api/switches_api_spec.rb +70 -0
  40. data/spec/api/systems_api_spec.rb +118 -0
  41. data/spec/api_client_spec.rb +226 -0
  42. data/spec/configuration_spec.rb +42 -0
  43. data/spec/models/full_switch_spec.rb +40 -0
  44. data/spec/models/member_spec.rb +154 -0
  45. data/spec/models/message_spec.rb +70 -0
  46. data/spec/models/privacy_setting_spec.rb +28 -0
  47. data/spec/models/proxy_tag_spec.rb +40 -0
  48. data/spec/models/switch_spec.rb +40 -0
  49. data/spec/models/system_spec.rb +94 -0
  50. data/spec/spec_helper.rb +111 -0
  51. metadata +147 -0
@@ -0,0 +1,274 @@
1
+ =begin
2
+ #PluralKit
3
+
4
+ #This is the API for [PluralKit](https://pluralkit.me/)! :) The API itself is stable, but this document (the OpenAPI description) is still subject to change, and may be updated, corrected or restructured in the future (as long as it's still coherent with the real API). # Authentication Authentication is handled using a \"system token\". At the moment, the only way to obtain a system token is to use the `pk;token` command through the Discord bot. This will generate an opaque string you must pass as the `Authorization` header to API requests. Many API endpoints are available anonymously, but most of them will hide information from unauthenticated requests to align with the relevant privacy settings. # Errors Errors are just returned as HTTP response codes. Most error responses include a human-readable error message as the body, but this should not be relied on. Just read the response codes :) # OpenAPI version history - **1.1**: Granular member privacy - **1.0**: (initial definition version)
5
+
6
+ The version of the OpenAPI document: 1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PluralKitAPI
17
+ # An object containing information about a proxied message, including message, user and channel IDs, as well as the system and member it's related to. For privacy and performance reasons, this endpoint does not return the *contents* of the original message. This data isn't stored in the database either way - but given the channel and message ID, it can be fetched from Discord's own API.
18
+ class Message
19
+ # The time the message was proxied.
20
+ attr_accessor :timestamp
21
+
22
+ attr_accessor :id
23
+
24
+ attr_accessor :original
25
+
26
+ attr_accessor :sender
27
+
28
+ attr_accessor :channel
29
+
30
+ attr_accessor :system
31
+
32
+ attr_accessor :member
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'timestamp' => :'timestamp',
38
+ :'id' => :'id',
39
+ :'original' => :'original',
40
+ :'sender' => :'sender',
41
+ :'channel' => :'channel',
42
+ :'system' => :'system',
43
+ :'member' => :'member'
44
+ }
45
+ end
46
+
47
+ # Returns all the JSON keys this model knows about
48
+ def self.acceptable_attributes
49
+ attribute_map.values
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'timestamp' => :'Time',
56
+ :'id' => :'String',
57
+ :'original' => :'String',
58
+ :'sender' => :'String',
59
+ :'channel' => :'String',
60
+ :'system' => :'System',
61
+ :'member' => :'Member'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::Message` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PluralKitAPI::Message`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'timestamp')
87
+ self.timestamp = attributes[:'timestamp']
88
+ end
89
+
90
+ if attributes.key?(:'id')
91
+ self.id = attributes[:'id']
92
+ end
93
+
94
+ if attributes.key?(:'original')
95
+ self.original = attributes[:'original']
96
+ end
97
+
98
+ if attributes.key?(:'sender')
99
+ self.sender = attributes[:'sender']
100
+ end
101
+
102
+ if attributes.key?(:'channel')
103
+ self.channel = attributes[:'channel']
104
+ end
105
+
106
+ if attributes.key?(:'system')
107
+ self.system = attributes[:'system']
108
+ end
109
+
110
+ if attributes.key?(:'member')
111
+ self.member = attributes[:'member']
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ true
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ timestamp == o.timestamp &&
134
+ id == o.id &&
135
+ original == o.original &&
136
+ sender == o.sender &&
137
+ channel == o.channel &&
138
+ system == o.system &&
139
+ member == o.member
140
+ end
141
+
142
+ # @see the `==` method
143
+ # @param [Object] Object to be compared
144
+ def eql?(o)
145
+ self == o
146
+ end
147
+
148
+ # Calculates hash code according to all attributes.
149
+ # @return [Integer] Hash code
150
+ def hash
151
+ [timestamp, id, original, sender, channel, system, member].hash
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def self.build_from_hash(attributes)
158
+ new.build_from_hash(attributes)
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ self.class.openapi_types.each_pair do |key, type|
167
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
168
+ self.send("#{key}=", nil)
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
173
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ end
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :Time
190
+ Time.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ # models (e.g. Pet) or oneOf
221
+ klass = PluralKitAPI.const_get(type)
222
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+
272
+ end
273
+
274
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ #PluralKit
3
+
4
+ #This is the API for [PluralKit](https://pluralkit.me/)! :) The API itself is stable, but this document (the OpenAPI description) is still subject to change, and may be updated, corrected or restructured in the future (as long as it's still coherent with the real API). # Authentication Authentication is handled using a \"system token\". At the moment, the only way to obtain a system token is to use the `pk;token` command through the Discord bot. This will generate an opaque string you must pass as the `Authorization` header to API requests. Many API endpoints are available anonymously, but most of them will hide information from unauthenticated requests to align with the relevant privacy settings. # Errors Errors are just returned as HTTP response codes. Most error responses include a human-readable error message as the body, but this should not be relied on. Just read the response codes :) # OpenAPI version history - **1.1**: Granular member privacy - **1.0**: (initial definition version)
5
+
6
+ The version of the OpenAPI document: 1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PluralKitAPI
17
+ class PrivacySetting
18
+ PUBLIC = "public".freeze
19
+ PRIVATE = "private".freeze
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ constantValues = PrivacySetting.constants.select { |c| PrivacySetting::const_get(c) == value }
33
+ raise "Invalid ENUM value #{value} for class #PrivacySetting" if constantValues.empty?
34
+ value
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,262 @@
1
+ =begin
2
+ #PluralKit
3
+
4
+ #This is the API for [PluralKit](https://pluralkit.me/)! :) The API itself is stable, but this document (the OpenAPI description) is still subject to change, and may be updated, corrected or restructured in the future (as long as it's still coherent with the real API). # Authentication Authentication is handled using a \"system token\". At the moment, the only way to obtain a system token is to use the `pk;token` command through the Discord bot. This will generate an opaque string you must pass as the `Authorization` header to API requests. Many API endpoints are available anonymously, but most of them will hide information from unauthenticated requests to align with the relevant privacy settings. # Errors Errors are just returned as HTTP response codes. Most error responses include a human-readable error message as the body, but this should not be relied on. Just read the response codes :) # OpenAPI version history - **1.1**: Granular member privacy - **1.0**: (initial definition version)
5
+
6
+ The version of the OpenAPI document: 1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PluralKitAPI
17
+ # Represents a proxy tag to match messages on. A \"proxy tag\" consists of a prefix and a suffix, and a given proxy tag set matches a string if that string begins with the prefix and ends with the suffix. It's often represented to the user with the word `text` between them, eg. `[text]`, `{{text`, and so on. For example, the proxy tag pair \"[\" and \"]\" will match any string \\[in square brackets\\]. Either the prefix or the suffix may be missing (or both may be present), but it is invalid for both values to be null.
18
+ class ProxyTag
19
+ # The proxy tag prefix. This is the string that goes *before* the inner text. An empty prefix is represented as `null` and an empty string will be converted as such.
20
+ attr_accessor :prefix
21
+
22
+ # The proxy tag suffix. This is the string that goes *after* the inner text. An empty suffix is represented as `null` and an empty string will be converted as such.
23
+ attr_accessor :suffix
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'prefix' => :'prefix',
29
+ :'suffix' => :'suffix'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'prefix' => :'String',
42
+ :'suffix' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ :'prefix',
50
+ :'suffix'
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::ProxyTag` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PluralKitAPI::ProxyTag`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'prefix')
70
+ self.prefix = attributes[:'prefix']
71
+ end
72
+
73
+ if attributes.key?(:'suffix')
74
+ self.suffix = attributes[:'suffix']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ if !@prefix.nil? && @prefix.to_s.length > 100
83
+ invalid_properties.push('invalid value for "prefix", the character length must be smaller than or equal to 100.')
84
+ end
85
+
86
+ if !@suffix.nil? && @suffix.to_s.length > 100
87
+ invalid_properties.push('invalid value for "suffix", the character length must be smaller than or equal to 100.')
88
+ end
89
+
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ return false if !@prefix.nil? && @prefix.to_s.length > 100
97
+ return false if !@suffix.nil? && @suffix.to_s.length > 100
98
+ true
99
+ end
100
+
101
+ # Custom attribute writer method with validation
102
+ # @param [Object] prefix Value to be assigned
103
+ def prefix=(prefix)
104
+ if !prefix.nil? && prefix.to_s.length > 100
105
+ fail ArgumentError, 'invalid value for "prefix", the character length must be smaller than or equal to 100.'
106
+ end
107
+
108
+ @prefix = prefix
109
+ end
110
+
111
+ # Custom attribute writer method with validation
112
+ # @param [Object] suffix Value to be assigned
113
+ def suffix=(suffix)
114
+ if !suffix.nil? && suffix.to_s.length > 100
115
+ fail ArgumentError, 'invalid value for "suffix", the character length must be smaller than or equal to 100.'
116
+ end
117
+
118
+ @suffix = suffix
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ prefix == o.prefix &&
127
+ suffix == o.suffix
128
+ end
129
+
130
+ # @see the `==` method
131
+ # @param [Object] Object to be compared
132
+ def eql?(o)
133
+ self == o
134
+ end
135
+
136
+ # Calculates hash code according to all attributes.
137
+ # @return [Integer] Hash code
138
+ def hash
139
+ [prefix, suffix].hash
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def self.build_from_hash(attributes)
146
+ new.build_from_hash(attributes)
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ self.class.openapi_types.each_pair do |key, type|
155
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
156
+ self.send("#{key}=", nil)
157
+ elsif type =~ /\AArray<(.*)>/i
158
+ # check to ensure the input is an array given that the attribute
159
+ # is documented as an array but the input is not
160
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
161
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
162
+ end
163
+ elsif !attributes[self.class.attribute_map[key]].nil?
164
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
165
+ end
166
+ end
167
+
168
+ self
169
+ end
170
+
171
+ # Deserializes the data based on type
172
+ # @param string type Data type
173
+ # @param string value Value to be deserialized
174
+ # @return [Object] Deserialized data
175
+ def _deserialize(type, value)
176
+ case type.to_sym
177
+ when :Time
178
+ Time.parse(value)
179
+ when :Date
180
+ Date.parse(value)
181
+ when :String
182
+ value.to_s
183
+ when :Integer
184
+ value.to_i
185
+ when :Float
186
+ value.to_f
187
+ when :Boolean
188
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
+ true
190
+ else
191
+ false
192
+ end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
196
+ when /\AArray<(?<inner_type>.+)>\z/
197
+ inner_type = Regexp.last_match[:inner_type]
198
+ value.map { |v| _deserialize(inner_type, v) }
199
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
+ k_type = Regexp.last_match[:k_type]
201
+ v_type = Regexp.last_match[:v_type]
202
+ {}.tap do |hash|
203
+ value.each do |k, v|
204
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
+ end
206
+ end
207
+ else # model
208
+ # models (e.g. Pet) or oneOf
209
+ klass = PluralKitAPI.const_get(type)
210
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
211
+ end
212
+ end
213
+
214
+ # Returns the string representation of the object
215
+ # @return [String] String presentation of the object
216
+ def to_s
217
+ to_hash.to_s
218
+ end
219
+
220
+ # to_body is an alias to to_hash (backward compatibility)
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_body
223
+ to_hash
224
+ end
225
+
226
+ # Returns the object in the form of hash
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_hash
229
+ hash = {}
230
+ self.class.attribute_map.each_pair do |attr, param|
231
+ value = self.send(attr)
232
+ if value.nil?
233
+ is_nullable = self.class.openapi_nullable.include?(attr)
234
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
235
+ end
236
+
237
+ hash[param] = _to_hash(value)
238
+ end
239
+ hash
240
+ end
241
+
242
+ # Outputs non-array value in the form of hash
243
+ # For object, use to_hash. Otherwise, just return the value
244
+ # @param [Object] value Any valid value
245
+ # @return [Hash] Returns the value in the form of hash
246
+ def _to_hash(value)
247
+ if value.is_a?(Array)
248
+ value.compact.map { |v| _to_hash(v) }
249
+ elsif value.is_a?(Hash)
250
+ {}.tap do |hash|
251
+ value.each { |k, v| hash[k] = _to_hash(v) }
252
+ end
253
+ elsif value.respond_to? :to_hash
254
+ value.to_hash
255
+ else
256
+ value
257
+ end
258
+ end
259
+
260
+ end
261
+
262
+ end