onesignal 0.3.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +6 -1
  3. data/README.md +126 -111
  4. data/Rakefile +8 -8
  5. data/docs/App.md +76 -0
  6. data/docs/Button.md +22 -0
  7. data/docs/DefaultApi.md +1394 -0
  8. data/docs/DeliveryData.md +26 -0
  9. data/docs/ExportPlayersRequestBody.md +22 -0
  10. data/docs/Filter.md +24 -0
  11. data/docs/FilterExpressions.md +26 -0
  12. data/docs/FilterNotificationTarget.md +40 -0
  13. data/docs/GetNotificationRequestBody.md +22 -0
  14. data/docs/InlineResponse200.md +24 -0
  15. data/docs/InlineResponse2001.md +18 -0
  16. data/docs/InlineResponse2002.md +20 -0
  17. data/docs/InlineResponse2003.md +18 -0
  18. data/docs/InlineResponse2004.md +20 -0
  19. data/docs/InlineResponse2005.md +18 -0
  20. data/docs/InlineResponse201.md +20 -0
  21. data/docs/InlineResponse400.md +18 -0
  22. data/docs/InlineResponse4001.md +20 -0
  23. data/docs/InlineResponse4002.md +18 -0
  24. data/docs/InlineResponse409.md +20 -0
  25. data/docs/Notification.md +240 -0
  26. data/docs/NotificationAllOf.md +192 -0
  27. data/docs/NotificationAllOfAndroidBackgroundLayout.md +22 -0
  28. data/docs/NotificationSlice.md +24 -0
  29. data/docs/NotificationTarget.md +64 -0
  30. data/docs/Operator.md +18 -0
  31. data/docs/OutcomeData.md +22 -0
  32. data/docs/PlatformDeliveryData.md +28 -0
  33. data/docs/Player.md +70 -0
  34. data/docs/PlayerNotificationTarget.md +36 -0
  35. data/docs/PlayerSlice.md +24 -0
  36. data/docs/Purchase.md +22 -0
  37. data/docs/Segment.md +22 -0
  38. data/docs/SegmentNotificationTarget.md +20 -0
  39. data/docs/StringMap.md +102 -0
  40. data/docs/UpdatePlayerTagsRequestBody.md +18 -0
  41. data/git_push.sh +58 -0
  42. data/lib/OneSignal.rb +75 -0
  43. data/lib/onesignal/api/default_api.rb +1338 -0
  44. data/lib/onesignal/api_client.rb +391 -0
  45. data/lib/onesignal/api_error.rb +57 -0
  46. data/lib/onesignal/configuration.rb +242 -0
  47. data/lib/onesignal/models/app.rb +519 -13
  48. data/lib/onesignal/models/button.rb +241 -0
  49. data/lib/onesignal/models/delivery_data.rb +254 -0
  50. data/lib/onesignal/models/export_players_request_body.rb +241 -0
  51. data/lib/onesignal/models/filter.rb +293 -0
  52. data/lib/onesignal/models/filter_expressions.rb +335 -0
  53. data/lib/onesignal/models/filter_notification_target.rb +329 -0
  54. data/lib/onesignal/models/get_notification_request_body.rb +272 -0
  55. data/lib/onesignal/models/inline_response200.rb +256 -0
  56. data/lib/onesignal/models/inline_response2001.rb +218 -0
  57. data/lib/onesignal/models/inline_response2002.rb +227 -0
  58. data/lib/onesignal/models/inline_response2003.rb +218 -0
  59. data/lib/onesignal/models/inline_response2004.rb +227 -0
  60. data/lib/onesignal/models/inline_response2005.rb +218 -0
  61. data/lib/onesignal/models/inline_response201.rb +228 -0
  62. data/lib/onesignal/models/inline_response400.rb +220 -0
  63. data/lib/onesignal/models/inline_response4001.rb +229 -0
  64. data/lib/onesignal/models/inline_response4002.rb +220 -0
  65. data/lib/onesignal/models/inline_response409.rb +229 -0
  66. data/lib/onesignal/models/notification.rb +1395 -5
  67. data/lib/onesignal/models/notification_all_of.rb +1124 -0
  68. data/lib/onesignal/models/notification_all_of_android_background_layout.rb +240 -0
  69. data/lib/onesignal/models/notification_slice.rb +247 -0
  70. data/lib/onesignal/models/notification_target.rb +494 -0
  71. data/lib/onesignal/models/operator.rb +253 -0
  72. data/lib/onesignal/models/outcome_data.rb +285 -0
  73. data/lib/onesignal/models/platform_delivery_data.rb +264 -0
  74. data/lib/onesignal/models/player.rb +483 -9
  75. data/lib/onesignal/models/player_notification_target.rb +329 -0
  76. data/lib/onesignal/models/player_slice.rb +247 -0
  77. data/lib/onesignal/models/purchase.rb +254 -0
  78. data/lib/onesignal/models/segment.rb +251 -0
  79. data/lib/onesignal/models/segment_notification_target.rb +233 -0
  80. data/lib/onesignal/models/string_map.rb +644 -0
  81. data/lib/onesignal/models/update_player_tags_request_body.rb +219 -0
  82. data/lib/onesignal/version.rb +13 -1
  83. data/onesignal.gemspec +36 -27
  84. data/spec/api/default_api_spec.rb +285 -0
  85. data/spec/api_client_spec.rb +226 -0
  86. data/spec/configuration_spec.rb +42 -0
  87. data/spec/models/app_spec.rb +212 -0
  88. data/spec/models/button_spec.rb +46 -0
  89. data/spec/models/delivery_data_spec.rb +58 -0
  90. data/spec/models/export_players_request_body_spec.rb +46 -0
  91. data/spec/models/filter_expressions_spec.rb +66 -0
  92. data/spec/models/filter_notification_target_spec.rb +100 -0
  93. data/spec/models/filter_spec.rb +56 -0
  94. data/spec/models/get_notification_request_body_spec.rb +50 -0
  95. data/spec/models/inline_response2001_spec.rb +34 -0
  96. data/spec/models/inline_response2002_spec.rb +40 -0
  97. data/spec/models/inline_response2003_spec.rb +34 -0
  98. data/spec/models/inline_response2004_spec.rb +40 -0
  99. data/spec/models/inline_response2005_spec.rb +34 -0
  100. data/spec/models/inline_response200_spec.rb +52 -0
  101. data/spec/models/inline_response201_spec.rb +40 -0
  102. data/spec/models/inline_response4001_spec.rb +40 -0
  103. data/spec/models/inline_response4002_spec.rb +34 -0
  104. data/spec/models/inline_response400_spec.rb +34 -0
  105. data/spec/models/inline_response409_spec.rb +40 -0
  106. data/spec/models/notification_all_of_android_background_layout_spec.rb +46 -0
  107. data/spec/models/notification_all_of_spec.rb +560 -0
  108. data/spec/models/notification_slice_spec.rb +52 -0
  109. data/spec/models/notification_spec.rb +704 -0
  110. data/spec/models/notification_target_spec.rb +172 -0
  111. data/spec/models/operator_spec.rb +38 -0
  112. data/spec/models/outcome_data_spec.rb +50 -0
  113. data/spec/models/platform_delivery_data_spec.rb +64 -0
  114. data/spec/models/player_notification_target_spec.rb +88 -0
  115. data/spec/models/player_slice_spec.rb +52 -0
  116. data/spec/models/player_spec.rb +190 -0
  117. data/spec/models/purchase_spec.rb +46 -0
  118. data/spec/models/segment_notification_target_spec.rb +40 -0
  119. data/spec/models/segment_spec.rb +46 -0
  120. data/spec/models/string_map_spec.rb +286 -0
  121. data/spec/models/update_player_tags_request_body_spec.rb +34 -0
  122. data/spec/spec_helper.rb +111 -0
  123. metadata +182 -65
  124. data/.gitignore +0 -10
  125. data/.rubocop.yml +0 -17
  126. data/.travis.yml +0 -16
  127. data/CHANGELOG.md +0 -22
  128. data/CODE_OF_CONDUCT.md +0 -49
  129. data/LICENSE +0 -21
  130. data/bin/console +0 -14
  131. data/bin/setup +0 -8
  132. data/lib/onesignal/app_id_missing_error.rb +0 -7
  133. data/lib/onesignal/client.rb +0 -44
  134. data/lib/onesignal/models/base_model.rb +0 -40
  135. data/lib/onesignal/request.rb +0 -94
  136. data/lib/onesignal/request_error.rb +0 -21
  137. data/lib/onesignal/resources/app_resource.rb +0 -27
  138. data/lib/onesignal/resources/base_resource.rb +0 -35
  139. data/lib/onesignal/resources/notification_resource.rb +0 -33
  140. data/lib/onesignal/resources/player_resource.rb +0 -53
  141. data/lib/onesignal.rb +0 -23
@@ -0,0 +1,254 @@
1
+ =begin
2
+ #OneSignal
3
+
4
+ #A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: devrel@onesignal.com
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 OneSignal
17
+ class Purchase
18
+ # The unique identifier of the purchased item.
19
+ attr_accessor :sku
20
+
21
+ # The amount, in USD, spent purchasing the item.
22
+ attr_accessor :amount
23
+
24
+ # The 3-letter ISO 4217 currency code. Required for correct storage and conversion of amount.
25
+ attr_accessor :iso
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'sku' => :'sku',
31
+ :'amount' => :'amount',
32
+ :'iso' => :'iso'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'sku' => :'String',
45
+ :'amount' => :'Float',
46
+ :'iso' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Purchase` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Purchase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'sku')
72
+ self.sku = attributes[:'sku']
73
+ end
74
+
75
+ if attributes.key?(:'amount')
76
+ self.amount = attributes[:'amount']
77
+ end
78
+
79
+ if attributes.key?(:'iso')
80
+ self.iso = attributes[:'iso']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if @sku.nil?
89
+ invalid_properties.push('invalid value for "sku", sku cannot be nil.')
90
+ end
91
+
92
+ if @amount.nil?
93
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
94
+ end
95
+
96
+ if @iso.nil?
97
+ invalid_properties.push('invalid value for "iso", iso cannot be nil.')
98
+ end
99
+
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
+ return false if @sku.nil?
107
+ return false if @amount.nil?
108
+ return false if @iso.nil?
109
+ true
110
+ end
111
+
112
+ # Checks equality by comparing each attribute.
113
+ # @param [Object] Object to be compared
114
+ def ==(o)
115
+ return true if self.equal?(o)
116
+ self.class == o.class &&
117
+ sku == o.sku &&
118
+ amount == o.amount &&
119
+ iso == o.iso
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [sku, amount, iso].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.openapi_types.each_pair do |key, type|
147
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
148
+ self.send("#{key}=", nil)
149
+ elsif type =~ /\AArray<(.*)>/i
150
+ # check to ensure the input is an array given that the attribute
151
+ # is documented as an array but the input is not
152
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
153
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
154
+ end
155
+ elsif !attributes[self.class.attribute_map[key]].nil?
156
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
157
+ end
158
+ end
159
+
160
+ self
161
+ end
162
+
163
+ # Deserializes the data based on type
164
+ # @param string type Data type
165
+ # @param string value Value to be deserialized
166
+ # @return [Object] Deserialized data
167
+ def _deserialize(type, value)
168
+ case type.to_sym
169
+ when :Time
170
+ Time.parse(value)
171
+ when :Date
172
+ Date.parse(value)
173
+ when :String
174
+ value.to_s
175
+ when :Integer
176
+ value.to_i
177
+ when :Float
178
+ value.to_f
179
+ when :Boolean
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
+ true
182
+ else
183
+ false
184
+ end
185
+ when :Object
186
+ # generic object (usually a Hash), return directly
187
+ value
188
+ when /\AArray<(?<inner_type>.+)>\z/
189
+ inner_type = Regexp.last_match[:inner_type]
190
+ value.map { |v| _deserialize(inner_type, v) }
191
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
+ k_type = Regexp.last_match[:k_type]
193
+ v_type = Regexp.last_match[:v_type]
194
+ {}.tap do |hash|
195
+ value.each do |k, v|
196
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
+ end
198
+ end
199
+ else # model
200
+ # models (e.g. Pet) or oneOf
201
+ klass = OneSignal.const_get(type)
202
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
203
+ end
204
+ end
205
+
206
+ # Returns the string representation of the object
207
+ # @return [String] String presentation of the object
208
+ def to_s
209
+ to_hash.to_s
210
+ end
211
+
212
+ # to_body is an alias to to_hash (backward compatibility)
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_body
215
+ to_hash
216
+ end
217
+
218
+ # Returns the object in the form of hash
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_hash
221
+ hash = {}
222
+ self.class.attribute_map.each_pair do |attr, param|
223
+ value = self.send(attr)
224
+ if value.nil?
225
+ is_nullable = self.class.openapi_nullable.include?(attr)
226
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
227
+ end
228
+
229
+ hash[param] = _to_hash(value)
230
+ end
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to? :to_hash
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+
252
+ end
253
+
254
+ end
@@ -0,0 +1,251 @@
1
+ =begin
2
+ #OneSignal
3
+
4
+ #A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: devrel@onesignal.com
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 OneSignal
17
+ class Segment
18
+ # UUID of the segment. If left empty, it will be assigned automaticaly.
19
+ attr_accessor :id
20
+
21
+ # Name of the segment. You'll see this name on the Web UI.
22
+ attr_accessor :name
23
+
24
+ # Filter or operators the segment will have. For a list of available filters with details, please see Send to Users Based on Filters.
25
+ attr_accessor :filters
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'id' => :'id',
31
+ :'name' => :'name',
32
+ :'filters' => :'filters'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'id' => :'String',
45
+ :'name' => :'String',
46
+ :'filters' => :'Array<FilterExpressions>'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Segment` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Segment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'id')
72
+ self.id = attributes[:'id']
73
+ end
74
+
75
+ if attributes.key?(:'name')
76
+ self.name = attributes[:'name']
77
+ end
78
+
79
+ if attributes.key?(:'filters')
80
+ if (value = attributes[:'filters']).is_a?(Array)
81
+ self.filters = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ if @name.nil?
91
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
92
+ end
93
+
94
+ if @filters.nil?
95
+ invalid_properties.push('invalid value for "filters", filters cannot be nil.')
96
+ end
97
+
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ return false if @name.nil?
105
+ return false if @filters.nil?
106
+ true
107
+ end
108
+
109
+ # Checks equality by comparing each attribute.
110
+ # @param [Object] Object to be compared
111
+ def ==(o)
112
+ return true if self.equal?(o)
113
+ self.class == o.class &&
114
+ id == o.id &&
115
+ name == o.name &&
116
+ filters == o.filters
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [id, name, filters].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ new.build_from_hash(attributes)
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ self.class.openapi_types.each_pair do |key, type|
144
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
145
+ self.send("#{key}=", nil)
146
+ elsif type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :Time
167
+ Time.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ # models (e.g. Pet) or oneOf
198
+ klass = OneSignal.const_get(type)
199
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
200
+ end
201
+ end
202
+
203
+ # Returns the string representation of the object
204
+ # @return [String] String presentation of the object
205
+ def to_s
206
+ to_hash.to_s
207
+ end
208
+
209
+ # to_body is an alias to to_hash (backward compatibility)
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_body
212
+ to_hash
213
+ end
214
+
215
+ # Returns the object in the form of hash
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_hash
218
+ hash = {}
219
+ self.class.attribute_map.each_pair do |attr, param|
220
+ value = self.send(attr)
221
+ if value.nil?
222
+ is_nullable = self.class.openapi_nullable.include?(attr)
223
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
224
+ end
225
+
226
+ hash[param] = _to_hash(value)
227
+ end
228
+ hash
229
+ end
230
+
231
+ # Outputs non-array value in the form of hash
232
+ # For object, use to_hash. Otherwise, just return the value
233
+ # @param [Object] value Any valid value
234
+ # @return [Hash] Returns the value in the form of hash
235
+ def _to_hash(value)
236
+ if value.is_a?(Array)
237
+ value.compact.map { |v| _to_hash(v) }
238
+ elsif value.is_a?(Hash)
239
+ {}.tap do |hash|
240
+ value.each { |k, v| hash[k] = _to_hash(v) }
241
+ end
242
+ elsif value.respond_to? :to_hash
243
+ value.to_hash
244
+ else
245
+ value
246
+ end
247
+ end
248
+
249
+ end
250
+
251
+ end