zyphr 0.1.3 → 0.1.6

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/docs/Category.md +4 -2
  4. data/docs/Device.md +10 -12
  5. data/docs/DeviceStats.md +3 -1
  6. data/docs/DevicesApi.md +3 -3
  7. data/docs/PushApi.md +3 -3
  8. data/docs/PushMessage.md +13 -7
  9. data/docs/PushMessageDetail.md +17 -15
  10. data/docs/PushMessageDetailAllOfActionButtons.md +24 -0
  11. data/docs/RegisterDeviceRequest.md +4 -14
  12. data/docs/SMSApi.md +4 -4
  13. data/docs/SendPushRequest.md +35 -15
  14. data/docs/SendPushRequestActionButtonsInner.md +24 -0
  15. data/docs/TemplatesApi.md +2 -2
  16. data/docs/TopicsApi.md +2 -2
  17. data/docs/WaaSApplication.md +4 -2
  18. data/docs/WaaSApplicationsApi.md +1 -1
  19. data/docs/{WebhookWorkspaceMetricsResponse.md → WebhookAccountMetricsResponse.md} +3 -3
  20. data/docs/WebhooksApi.md +70 -70
  21. data/lib/zyphr/api/devices_api.rb +4 -4
  22. data/lib/zyphr/api/push_api.rb +4 -4
  23. data/lib/zyphr/api/sms_api.rb +8 -8
  24. data/lib/zyphr/api/templates_api.rb +4 -4
  25. data/lib/zyphr/api/topics_api.rb +4 -4
  26. data/lib/zyphr/api/waa_s_applications_api.rb +2 -2
  27. data/lib/zyphr/api/webhooks_api.rb +59 -59
  28. data/lib/zyphr/models/category.rb +16 -7
  29. data/lib/zyphr/models/device.rb +34 -57
  30. data/lib/zyphr/models/device_stats.rb +13 -4
  31. data/lib/zyphr/models/push_message.rb +67 -36
  32. data/lib/zyphr/models/push_message_detail.rb +88 -75
  33. data/lib/zyphr/models/push_message_detail_all_of_action_buttons.rb +247 -0
  34. data/lib/zyphr/models/register_device_request.rb +43 -59
  35. data/lib/zyphr/models/send_push_request.rb +278 -91
  36. data/lib/zyphr/models/{push_payload.rb → send_push_request_action_buttons_inner.rb} +72 -73
  37. data/lib/zyphr/models/waa_s_application.rb +16 -7
  38. data/lib/zyphr/models/{webhook_workspace_metrics_response.rb → webhook_account_metrics_response.rb} +4 -4
  39. data/lib/zyphr.rb +3 -2
  40. data/spec/api/devices_api_spec.rb +2 -2
  41. data/spec/api/push_api_spec.rb +2 -2
  42. data/spec/api/sms_api_spec.rb +4 -4
  43. data/spec/api/templates_api_spec.rb +2 -2
  44. data/spec/api/topics_api_spec.rb +2 -2
  45. data/spec/api/waa_s_applications_api_spec.rb +1 -1
  46. data/spec/api/webhooks_api_spec.rb +12 -12
  47. data/spec/models/category_spec.rb +7 -1
  48. data/spec/models/device_spec.rb +5 -15
  49. data/spec/models/device_stats_spec.rb +6 -0
  50. data/spec/models/{push_payload_spec.rb → push_message_detail_all_of_action_buttons_spec.rb} +10 -34
  51. data/spec/models/push_message_detail_spec.rb +26 -20
  52. data/spec/models/push_message_spec.rb +26 -8
  53. data/spec/models/register_device_request_spec.rb +2 -32
  54. data/spec/models/send_push_request_action_buttons_inner_spec.rb +54 -0
  55. data/spec/models/send_push_request_spec.rb +67 -11
  56. data/spec/models/waa_s_application_spec.rb +7 -1
  57. data/spec/models/{webhook_workspace_metrics_response_spec.rb → webhook_account_metrics_response_spec.rb} +6 -6
  58. data/zyphr.gemspec +1 -1
  59. metadata +328 -324
  60. data/docs/PushPayload.md +0 -32
@@ -19,27 +19,29 @@ module Zyphr
19
19
 
20
20
  attr_accessor :device_id
21
21
 
22
- attr_accessor :subscriber_id
22
+ attr_accessor :user_id
23
+
24
+ attr_accessor :platform
23
25
 
24
26
  attr_accessor :title
25
27
 
26
28
  attr_accessor :body
27
29
 
30
+ attr_accessor :data
31
+
28
32
  attr_accessor :status
29
33
 
30
- attr_accessor :platform
34
+ attr_accessor :tags
31
35
 
32
- attr_accessor :created_at
36
+ attr_accessor :queued_at
33
37
 
34
38
  attr_accessor :sent_at
35
39
 
36
40
  attr_accessor :delivered_at
37
41
 
38
- attr_accessor :batch_id
39
-
40
- attr_accessor :user_id
42
+ attr_accessor :created_at
41
43
 
42
- attr_accessor :data
44
+ attr_accessor :batch_id
43
45
 
44
46
  attr_accessor :badge
45
47
 
@@ -47,16 +49,16 @@ module Zyphr
47
49
 
48
50
  attr_accessor :image_url
49
51
 
52
+ attr_accessor :content_available
53
+
54
+ attr_accessor :action_buttons
55
+
50
56
  attr_accessor :status_reason
51
57
 
52
58
  attr_accessor :provider_message_id
53
59
 
54
- attr_accessor :tags
55
-
56
60
  attr_accessor :metadata
57
61
 
58
- attr_accessor :queued_at
59
-
60
62
  attr_accessor :failed_at
61
63
 
62
64
  attr_accessor :events
@@ -88,25 +90,26 @@ module Zyphr
88
90
  {
89
91
  :'id' => :'id',
90
92
  :'device_id' => :'device_id',
91
- :'subscriber_id' => :'subscriber_id',
93
+ :'user_id' => :'user_id',
94
+ :'platform' => :'platform',
92
95
  :'title' => :'title',
93
96
  :'body' => :'body',
97
+ :'data' => :'data',
94
98
  :'status' => :'status',
95
- :'platform' => :'platform',
96
- :'created_at' => :'created_at',
99
+ :'tags' => :'tags',
100
+ :'queued_at' => :'queued_at',
97
101
  :'sent_at' => :'sent_at',
98
102
  :'delivered_at' => :'delivered_at',
103
+ :'created_at' => :'created_at',
99
104
  :'batch_id' => :'batch_id',
100
- :'user_id' => :'user_id',
101
- :'data' => :'data',
102
105
  :'badge' => :'badge',
103
106
  :'sound' => :'sound',
104
107
  :'image_url' => :'image_url',
108
+ :'content_available' => :'content_available',
109
+ :'action_buttons' => :'action_buttons',
105
110
  :'status_reason' => :'status_reason',
106
111
  :'provider_message_id' => :'provider_message_id',
107
- :'tags' => :'tags',
108
112
  :'metadata' => :'metadata',
109
- :'queued_at' => :'queued_at',
110
113
  :'failed_at' => :'failed_at',
111
114
  :'events' => :'events'
112
115
  }
@@ -127,25 +130,26 @@ module Zyphr
127
130
  {
128
131
  :'id' => :'String',
129
132
  :'device_id' => :'String',
130
- :'subscriber_id' => :'String',
133
+ :'user_id' => :'String',
134
+ :'platform' => :'String',
131
135
  :'title' => :'String',
132
136
  :'body' => :'String',
137
+ :'data' => :'Hash<String, Object>',
133
138
  :'status' => :'String',
134
- :'platform' => :'String',
135
- :'created_at' => :'Time',
139
+ :'tags' => :'Array<String>',
140
+ :'queued_at' => :'Time',
136
141
  :'sent_at' => :'Time',
137
142
  :'delivered_at' => :'Time',
143
+ :'created_at' => :'Time',
138
144
  :'batch_id' => :'String',
139
- :'user_id' => :'String',
140
- :'data' => :'Hash<String, Object>',
141
- :'badge' => :'String',
145
+ :'badge' => :'Integer',
142
146
  :'sound' => :'String',
143
147
  :'image_url' => :'String',
148
+ :'content_available' => :'Boolean',
149
+ :'action_buttons' => :'Array<PushMessageDetailAllOfActionButtons>',
144
150
  :'status_reason' => :'String',
145
151
  :'provider_message_id' => :'String',
146
- :'tags' => :'Array<String>',
147
152
  :'metadata' => :'Hash<String, Object>',
148
- :'queued_at' => :'Time',
149
153
  :'failed_at' => :'Time',
150
154
  :'events' => :'Array<PushEvent>'
151
155
  }
@@ -154,14 +158,16 @@ module Zyphr
154
158
  # List of attributes with nullable: true
155
159
  def self.openapi_nullable
156
160
  Set.new([
157
- :'subscriber_id',
161
+ :'queued_at',
158
162
  :'sent_at',
159
163
  :'delivered_at',
160
164
  :'batch_id',
161
- :'user_id',
165
+ :'badge',
166
+ :'sound',
167
+ :'image_url',
168
+ :'action_buttons',
162
169
  :'status_reason',
163
170
  :'provider_message_id',
164
- :'queued_at',
165
171
  :'failed_at',
166
172
  ])
167
173
  end
@@ -197,8 +203,12 @@ module Zyphr
197
203
  self.device_id = attributes[:'device_id']
198
204
  end
199
205
 
200
- if attributes.key?(:'subscriber_id')
201
- self.subscriber_id = attributes[:'subscriber_id']
206
+ if attributes.key?(:'user_id')
207
+ self.user_id = attributes[:'user_id']
208
+ end
209
+
210
+ if attributes.key?(:'platform')
211
+ self.platform = attributes[:'platform']
202
212
  end
203
213
 
204
214
  if attributes.key?(:'title')
@@ -209,16 +219,24 @@ module Zyphr
209
219
  self.body = attributes[:'body']
210
220
  end
211
221
 
222
+ if attributes.key?(:'data')
223
+ if (value = attributes[:'data']).is_a?(Hash)
224
+ self.data = value
225
+ end
226
+ end
227
+
212
228
  if attributes.key?(:'status')
213
229
  self.status = attributes[:'status']
214
230
  end
215
231
 
216
- if attributes.key?(:'platform')
217
- self.platform = attributes[:'platform']
232
+ if attributes.key?(:'tags')
233
+ if (value = attributes[:'tags']).is_a?(Array)
234
+ self.tags = value
235
+ end
218
236
  end
219
237
 
220
- if attributes.key?(:'created_at')
221
- self.created_at = attributes[:'created_at']
238
+ if attributes.key?(:'queued_at')
239
+ self.queued_at = attributes[:'queued_at']
222
240
  end
223
241
 
224
242
  if attributes.key?(:'sent_at')
@@ -229,18 +247,12 @@ module Zyphr
229
247
  self.delivered_at = attributes[:'delivered_at']
230
248
  end
231
249
 
232
- if attributes.key?(:'batch_id')
233
- self.batch_id = attributes[:'batch_id']
234
- end
235
-
236
- if attributes.key?(:'user_id')
237
- self.user_id = attributes[:'user_id']
250
+ if attributes.key?(:'created_at')
251
+ self.created_at = attributes[:'created_at']
238
252
  end
239
253
 
240
- if attributes.key?(:'data')
241
- if (value = attributes[:'data']).is_a?(Hash)
242
- self.data = value
243
- end
254
+ if attributes.key?(:'batch_id')
255
+ self.batch_id = attributes[:'batch_id']
244
256
  end
245
257
 
246
258
  if attributes.key?(:'badge')
@@ -255,6 +267,16 @@ module Zyphr
255
267
  self.image_url = attributes[:'image_url']
256
268
  end
257
269
 
270
+ if attributes.key?(:'content_available')
271
+ self.content_available = attributes[:'content_available']
272
+ end
273
+
274
+ if attributes.key?(:'action_buttons')
275
+ if (value = attributes[:'action_buttons']).is_a?(Array)
276
+ self.action_buttons = value
277
+ end
278
+ end
279
+
258
280
  if attributes.key?(:'status_reason')
259
281
  self.status_reason = attributes[:'status_reason']
260
282
  end
@@ -263,22 +285,12 @@ module Zyphr
263
285
  self.provider_message_id = attributes[:'provider_message_id']
264
286
  end
265
287
 
266
- if attributes.key?(:'tags')
267
- if (value = attributes[:'tags']).is_a?(Array)
268
- self.tags = value
269
- end
270
- end
271
-
272
288
  if attributes.key?(:'metadata')
273
289
  if (value = attributes[:'metadata']).is_a?(Hash)
274
290
  self.metadata = value
275
291
  end
276
292
  end
277
293
 
278
- if attributes.key?(:'queued_at')
279
- self.queued_at = attributes[:'queued_at']
280
- end
281
-
282
294
  if attributes.key?(:'failed_at')
283
295
  self.failed_at = attributes[:'failed_at']
284
296
  end
@@ -302,23 +314,13 @@ module Zyphr
302
314
  # @return true if the model is valid
303
315
  def valid?
304
316
  warn '[DEPRECATED] the `valid?` method is obsolete'
305
- status_validator = EnumAttributeValidator.new('String', ["pending", "queued", "sent", "delivered", "failed"])
306
- return false unless status_validator.valid?(@status)
307
317
  platform_validator = EnumAttributeValidator.new('String', ["ios", "android", "web"])
308
318
  return false unless platform_validator.valid?(@platform)
319
+ status_validator = EnumAttributeValidator.new('String', ["queued", "sending", "sent", "delivered", "failed", "expired"])
320
+ return false unless status_validator.valid?(@status)
309
321
  true
310
322
  end
311
323
 
312
- # Custom attribute writer method checking allowed values (enum).
313
- # @param [Object] status Object to be assigned
314
- def status=(status)
315
- validator = EnumAttributeValidator.new('String', ["pending", "queued", "sent", "delivered", "failed"])
316
- unless validator.valid?(status)
317
- fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
318
- end
319
- @status = status
320
- end
321
-
322
324
  # Custom attribute writer method checking allowed values (enum).
323
325
  # @param [Object] platform Object to be assigned
324
326
  def platform=(platform)
@@ -329,6 +331,16 @@ module Zyphr
329
331
  @platform = platform
330
332
  end
331
333
 
334
+ # Custom attribute writer method checking allowed values (enum).
335
+ # @param [Object] status Object to be assigned
336
+ def status=(status)
337
+ validator = EnumAttributeValidator.new('String', ["queued", "sending", "sent", "delivered", "failed", "expired"])
338
+ unless validator.valid?(status)
339
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
340
+ end
341
+ @status = status
342
+ end
343
+
332
344
  # Checks equality by comparing each attribute.
333
345
  # @param [Object] Object to be compared
334
346
  def ==(o)
@@ -336,25 +348,26 @@ module Zyphr
336
348
  self.class == o.class &&
337
349
  id == o.id &&
338
350
  device_id == o.device_id &&
339
- subscriber_id == o.subscriber_id &&
351
+ user_id == o.user_id &&
352
+ platform == o.platform &&
340
353
  title == o.title &&
341
354
  body == o.body &&
355
+ data == o.data &&
342
356
  status == o.status &&
343
- platform == o.platform &&
344
- created_at == o.created_at &&
357
+ tags == o.tags &&
358
+ queued_at == o.queued_at &&
345
359
  sent_at == o.sent_at &&
346
360
  delivered_at == o.delivered_at &&
361
+ created_at == o.created_at &&
347
362
  batch_id == o.batch_id &&
348
- user_id == o.user_id &&
349
- data == o.data &&
350
363
  badge == o.badge &&
351
364
  sound == o.sound &&
352
365
  image_url == o.image_url &&
366
+ content_available == o.content_available &&
367
+ action_buttons == o.action_buttons &&
353
368
  status_reason == o.status_reason &&
354
369
  provider_message_id == o.provider_message_id &&
355
- tags == o.tags &&
356
370
  metadata == o.metadata &&
357
- queued_at == o.queued_at &&
358
371
  failed_at == o.failed_at &&
359
372
  events == o.events
360
373
  end
@@ -368,7 +381,7 @@ module Zyphr
368
381
  # Calculates hash code according to all attributes.
369
382
  # @return [Integer] Hash code
370
383
  def hash
371
- [id, device_id, subscriber_id, title, body, status, platform, created_at, sent_at, delivered_at, batch_id, user_id, data, badge, sound, image_url, status_reason, provider_message_id, tags, metadata, queued_at, failed_at, events].hash
384
+ [id, device_id, user_id, platform, title, body, data, status, tags, queued_at, sent_at, delivered_at, created_at, batch_id, badge, sound, image_url, content_available, action_buttons, status_reason, provider_message_id, metadata, failed_at, events].hash
372
385
  end
373
386
 
374
387
  # Builds the object from hash
@@ -0,0 +1,247 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class PushMessageDetailAllOfActionButtons
18
+ attr_accessor :id
19
+
20
+ attr_accessor :title
21
+
22
+ attr_accessor :action
23
+
24
+ attr_accessor :deep_link
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'id' => :'id',
30
+ :'title' => :'title',
31
+ :'action' => :'action',
32
+ :'deep_link' => :'deep_link'
33
+ }
34
+ end
35
+
36
+ # Returns attribute mapping this model knows about
37
+ def self.acceptable_attribute_map
38
+ attribute_map
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ acceptable_attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'id' => :'String',
50
+ :'title' => :'String',
51
+ :'action' => :'String',
52
+ :'deep_link' => :'String'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::PushMessageDetailAllOfActionButtons` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ acceptable_attribute_map = self.class.acceptable_attribute_map
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!acceptable_attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::PushMessageDetailAllOfActionButtons`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'id')
79
+ self.id = attributes[:'id']
80
+ end
81
+
82
+ if attributes.key?(:'title')
83
+ self.title = attributes[:'title']
84
+ end
85
+
86
+ if attributes.key?(:'action')
87
+ self.action = attributes[:'action']
88
+ end
89
+
90
+ if attributes.key?(:'deep_link')
91
+ self.deep_link = attributes[:'deep_link']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
99
+ invalid_properties = Array.new
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ warn '[DEPRECATED] the `valid?` method is obsolete'
107
+ true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(o)
113
+ return true if self.equal?(o)
114
+ self.class == o.class &&
115
+ id == o.id &&
116
+ title == o.title &&
117
+ action == o.action &&
118
+ deep_link == o.deep_link
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Integer] Hash code
129
+ def hash
130
+ [id, title, action, deep_link].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def self.build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ attributes = attributes.transform_keys(&:to_sym)
139
+ transformed_hash = {}
140
+ openapi_types.each_pair do |key, type|
141
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
142
+ transformed_hash["#{key}"] = nil
143
+ elsif type =~ /\AArray<(.*)>/i
144
+ # check to ensure the input is an array given that the attribute
145
+ # is documented as an array but the input is not
146
+ if attributes[attribute_map[key]].is_a?(Array)
147
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
148
+ end
149
+ elsif !attributes[attribute_map[key]].nil?
150
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
151
+ end
152
+ end
153
+ new(transformed_hash)
154
+ end
155
+
156
+ # Deserializes the data based on type
157
+ # @param string type Data type
158
+ # @param string value Value to be deserialized
159
+ # @return [Object] Deserialized data
160
+ def self._deserialize(type, value)
161
+ case type.to_sym
162
+ when :Time
163
+ Time.parse(value)
164
+ when :Date
165
+ Date.parse(value)
166
+ when :String
167
+ value.to_s
168
+ when :Integer
169
+ value.to_i
170
+ when :Float
171
+ value.to_f
172
+ when :Boolean
173
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
174
+ true
175
+ else
176
+ false
177
+ end
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ else # model
193
+ # models (e.g. Pet) or oneOf
194
+ klass = Zyphr.const_get(type)
195
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
196
+ end
197
+ end
198
+
199
+ # Returns the string representation of the object
200
+ # @return [String] String presentation of the object
201
+ def to_s
202
+ to_hash.to_s
203
+ end
204
+
205
+ # to_body is an alias to to_hash (backward compatibility)
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_body
208
+ to_hash
209
+ end
210
+
211
+ # Returns the object in the form of hash
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_hash
214
+ hash = {}
215
+ self.class.attribute_map.each_pair do |attr, param|
216
+ value = self.send(attr)
217
+ if value.nil?
218
+ is_nullable = self.class.openapi_nullable.include?(attr)
219
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
220
+ end
221
+
222
+ hash[param] = _to_hash(value)
223
+ end
224
+ hash
225
+ end
226
+
227
+ # Outputs non-array value in the form of hash
228
+ # For object, use to_hash. Otherwise, just return the value
229
+ # @param [Object] value Any valid value
230
+ # @return [Hash] Returns the value in the form of hash
231
+ def _to_hash(value)
232
+ if value.is_a?(Array)
233
+ value.compact.map { |v| _to_hash(v) }
234
+ elsif value.is_a?(Hash)
235
+ {}.tap do |hash|
236
+ value.each { |k, v| hash[k] = _to_hash(v) }
237
+ end
238
+ elsif value.respond_to? :to_hash
239
+ value.to_hash
240
+ else
241
+ value
242
+ end
243
+ end
244
+
245
+ end
246
+
247
+ end