onesignal 5.2.1.pre.beta1 → 5.3.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 (168) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +33 -5
  4. data/docs/ApiKeyToken.md +28 -0
  5. data/docs/ApiKeyTokensListResponse.md +18 -0
  6. data/docs/BasicNotification.md +13 -1
  7. data/docs/BasicNotificationAllOf.md +13 -1
  8. data/docs/CopyTemplateRequest.md +18 -0
  9. data/docs/CreateApiKeyRequest.md +22 -0
  10. data/docs/CreateApiKeyResponse.md +20 -0
  11. data/docs/CreateTemplateRequest.md +32 -0
  12. data/docs/CustomEvent.md +26 -0
  13. data/docs/CustomEventsRequest.md +18 -0
  14. data/docs/DefaultApi.md +1132 -110
  15. data/docs/Notification.md +12 -0
  16. data/docs/NotificationWithMeta.md +12 -0
  17. data/docs/StartLiveActivityRequest.md +48 -0
  18. data/docs/StartLiveActivitySuccessResponse.md +18 -0
  19. data/docs/TemplateResource.md +28 -0
  20. data/docs/TemplatesListResponse.md +18 -0
  21. data/docs/UpdateApiKeyRequest.md +22 -0
  22. data/docs/UpdateTemplateRequest.md +30 -0
  23. data/lib/onesignal/api/default_api.rb +1043 -1
  24. data/lib/onesignal/api_client.rb +2 -2
  25. data/lib/onesignal/api_error.rb +1 -1
  26. data/lib/onesignal/configuration.rb +1 -1
  27. data/lib/onesignal/models/api_key_token.rb +300 -0
  28. data/lib/onesignal/models/api_key_tokens_list_response.rb +221 -0
  29. data/lib/onesignal/models/app.rb +1 -1
  30. data/lib/onesignal/models/basic_notification.rb +84 -6
  31. data/lib/onesignal/models/basic_notification_all_of.rb +84 -6
  32. data/lib/onesignal/models/basic_notification_all_of_android_background_layout.rb +1 -1
  33. data/lib/onesignal/models/button.rb +1 -1
  34. data/lib/onesignal/models/copy_template_request.rb +225 -0
  35. data/lib/onesignal/models/create_api_key_request.rb +273 -0
  36. data/lib/onesignal/models/create_api_key_response.rb +228 -0
  37. data/lib/onesignal/models/create_notification_success_response.rb +1 -1
  38. data/lib/onesignal/models/create_segment_conflict_response.rb +1 -1
  39. data/lib/onesignal/models/create_segment_success_response.rb +1 -1
  40. data/lib/onesignal/models/create_template_request.rb +307 -0
  41. data/lib/onesignal/models/create_user_conflict_response.rb +1 -1
  42. data/lib/onesignal/models/create_user_conflict_response_errors_inner.rb +1 -1
  43. data/lib/onesignal/models/create_user_conflict_response_errors_items_meta.rb +1 -1
  44. data/lib/onesignal/models/custom_event.rb +269 -0
  45. data/lib/onesignal/models/custom_events_request.rb +226 -0
  46. data/lib/onesignal/models/delivery_data.rb +1 -1
  47. data/lib/onesignal/models/export_events_success_response.rb +1 -1
  48. data/lib/onesignal/models/export_subscriptions_request_body.rb +1 -1
  49. data/lib/onesignal/models/export_subscriptions_success_response.rb +1 -1
  50. data/lib/onesignal/models/filter.rb +1 -1
  51. data/lib/onesignal/models/filter_expression.rb +1 -1
  52. data/lib/onesignal/models/generic_error.rb +1 -1
  53. data/lib/onesignal/models/generic_success_bool_response.rb +1 -1
  54. data/lib/onesignal/models/get_notification_history_request_body.rb +1 -1
  55. data/lib/onesignal/models/get_segments_success_response.rb +1 -1
  56. data/lib/onesignal/models/language_string_map.rb +1 -1
  57. data/lib/onesignal/models/notification.rb +80 -2
  58. data/lib/onesignal/models/notification_all_of.rb +1 -1
  59. data/lib/onesignal/models/notification_history_success_response.rb +1 -1
  60. data/lib/onesignal/models/notification_slice.rb +1 -1
  61. data/lib/onesignal/models/notification_target.rb +1 -1
  62. data/lib/onesignal/models/notification_with_meta.rb +80 -2
  63. data/lib/onesignal/models/notification_with_meta_all_of.rb +1 -1
  64. data/lib/onesignal/models/operator.rb +1 -1
  65. data/lib/onesignal/models/outcome_data.rb +1 -1
  66. data/lib/onesignal/models/outcomes_data.rb +1 -1
  67. data/lib/onesignal/models/platform_delivery_data.rb +1 -1
  68. data/lib/onesignal/models/platform_delivery_data_email_all_of.rb +1 -1
  69. data/lib/onesignal/models/platform_delivery_data_sms_all_of.rb +1 -1
  70. data/lib/onesignal/models/properties_body.rb +1 -1
  71. data/lib/onesignal/models/properties_deltas.rb +1 -1
  72. data/lib/onesignal/models/properties_object.rb +1 -1
  73. data/lib/onesignal/models/purchase.rb +1 -1
  74. data/lib/onesignal/models/rate_limit_error.rb +1 -1
  75. data/lib/onesignal/models/segment.rb +1 -1
  76. data/lib/onesignal/models/segment_data.rb +1 -1
  77. data/lib/onesignal/models/segment_notification_target.rb +1 -1
  78. data/lib/onesignal/models/start_live_activity_request.rb +454 -0
  79. data/lib/onesignal/models/start_live_activity_success_response.rb +219 -0
  80. data/lib/onesignal/models/subscription.rb +1 -1
  81. data/lib/onesignal/models/subscription_body.rb +1 -1
  82. data/lib/onesignal/models/subscription_notification_target.rb +1 -1
  83. data/lib/onesignal/models/template_resource.rb +302 -0
  84. data/lib/onesignal/models/templates_list_response.rb +221 -0
  85. data/lib/onesignal/models/transfer_subscription_request_body.rb +1 -1
  86. data/lib/onesignal/models/update_api_key_request.rb +273 -0
  87. data/lib/onesignal/models/update_live_activity_request.rb +1 -1
  88. data/lib/onesignal/models/update_live_activity_success_response.rb +1 -1
  89. data/lib/onesignal/models/update_template_request.rb +282 -0
  90. data/lib/onesignal/models/update_user_request.rb +1 -1
  91. data/lib/onesignal/models/user.rb +1 -1
  92. data/lib/onesignal/models/user_identity_body.rb +1 -1
  93. data/lib/onesignal/models/web_button.rb +1 -1
  94. data/lib/onesignal/version.rb +2 -2
  95. data/lib/onesignal.rb +15 -1
  96. data/onesignal.gemspec +1 -1
  97. data/spec/api/default_api_spec.rb +189 -1
  98. data/spec/api_client_spec.rb +1 -1
  99. data/spec/configuration_spec.rb +1 -1
  100. data/spec/models/api_key_token_spec.rb +68 -0
  101. data/spec/models/api_key_tokens_list_response_spec.rb +34 -0
  102. data/spec/models/app_spec.rb +1 -1
  103. data/spec/models/basic_notification_all_of_android_background_layout_spec.rb +1 -1
  104. data/spec/models/basic_notification_all_of_spec.rb +41 -1
  105. data/spec/models/basic_notification_spec.rb +41 -1
  106. data/spec/models/button_spec.rb +1 -1
  107. data/spec/models/copy_template_request_spec.rb +34 -0
  108. data/spec/models/create_api_key_request_spec.rb +50 -0
  109. data/spec/models/create_api_key_response_spec.rb +40 -0
  110. data/spec/models/create_notification_success_response_spec.rb +1 -1
  111. data/spec/models/create_segment_conflict_response_spec.rb +1 -1
  112. data/spec/models/create_segment_success_response_spec.rb +1 -1
  113. data/spec/models/create_template_request_spec.rb +76 -0
  114. data/spec/models/create_user_conflict_response_errors_inner_spec.rb +1 -1
  115. data/spec/models/create_user_conflict_response_errors_items_meta_spec.rb +1 -1
  116. data/spec/models/create_user_conflict_response_spec.rb +1 -1
  117. data/spec/models/custom_event_spec.rb +58 -0
  118. data/spec/models/custom_events_request_spec.rb +34 -0
  119. data/spec/models/delivery_data_spec.rb +1 -1
  120. data/spec/models/export_events_success_response_spec.rb +1 -1
  121. data/spec/models/export_subscriptions_request_body_spec.rb +1 -1
  122. data/spec/models/export_subscriptions_success_response_spec.rb +1 -1
  123. data/spec/models/filter_expression_spec.rb +1 -1
  124. data/spec/models/filter_spec.rb +1 -1
  125. data/spec/models/generic_error_spec.rb +1 -1
  126. data/spec/models/generic_success_bool_response_spec.rb +1 -1
  127. data/spec/models/get_notification_history_request_body_spec.rb +1 -1
  128. data/spec/models/get_segments_success_response_spec.rb +1 -1
  129. data/spec/models/language_string_map_spec.rb +1 -1
  130. data/spec/models/notification_all_of_spec.rb +1 -1
  131. data/spec/models/notification_history_success_response_spec.rb +1 -1
  132. data/spec/models/notification_slice_spec.rb +1 -1
  133. data/spec/models/notification_spec.rb +41 -1
  134. data/spec/models/notification_target_spec.rb +1 -1
  135. data/spec/models/notification_with_meta_all_of_spec.rb +1 -1
  136. data/spec/models/notification_with_meta_spec.rb +41 -1
  137. data/spec/models/operator_spec.rb +1 -1
  138. data/spec/models/outcome_data_spec.rb +1 -1
  139. data/spec/models/outcomes_data_spec.rb +1 -1
  140. data/spec/models/platform_delivery_data_email_all_of_spec.rb +1 -1
  141. data/spec/models/platform_delivery_data_sms_all_of_spec.rb +1 -1
  142. data/spec/models/platform_delivery_data_spec.rb +1 -1
  143. data/spec/models/properties_body_spec.rb +1 -1
  144. data/spec/models/properties_deltas_spec.rb +1 -1
  145. data/spec/models/properties_object_spec.rb +1 -1
  146. data/spec/models/purchase_spec.rb +1 -1
  147. data/spec/models/rate_limit_error_spec.rb +1 -1
  148. data/spec/models/segment_data_spec.rb +1 -1
  149. data/spec/models/segment_notification_target_spec.rb +1 -1
  150. data/spec/models/segment_spec.rb +1 -1
  151. data/spec/models/start_live_activity_request_spec.rb +128 -0
  152. data/spec/models/start_live_activity_success_response_spec.rb +34 -0
  153. data/spec/models/subscription_body_spec.rb +1 -1
  154. data/spec/models/subscription_notification_target_spec.rb +1 -1
  155. data/spec/models/subscription_spec.rb +1 -1
  156. data/spec/models/template_resource_spec.rb +68 -0
  157. data/spec/models/templates_list_response_spec.rb +34 -0
  158. data/spec/models/transfer_subscription_request_body_spec.rb +1 -1
  159. data/spec/models/update_api_key_request_spec.rb +50 -0
  160. data/spec/models/update_live_activity_request_spec.rb +1 -1
  161. data/spec/models/update_live_activity_success_response_spec.rb +1 -1
  162. data/spec/models/update_template_request_spec.rb +70 -0
  163. data/spec/models/update_user_request_spec.rb +1 -1
  164. data/spec/models/user_identity_body_spec.rb +1 -1
  165. data/spec/models/user_spec.rb +1 -1
  166. data/spec/models/web_button_spec.rb +1 -1
  167. data/spec/spec_helper.rb +1 -1
  168. metadata +58 -2
@@ -0,0 +1,307 @@
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: 5.3.0
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OneSignal
17
+ class CreateTemplateRequest
18
+ # Your OneSignal App ID in UUID v4 format.
19
+ attr_accessor :app_id
20
+
21
+ # Name of the template.
22
+ attr_accessor :name
23
+
24
+ attr_accessor :contents
25
+
26
+ # Set true for an Email template.
27
+ attr_accessor :is_email
28
+
29
+ # Subject of the email.
30
+ attr_accessor :email_subject
31
+
32
+ # Body of the email (HTML supported).
33
+ attr_accessor :email_body
34
+
35
+ # Set true for an SMS template.
36
+ attr_accessor :is_sms
37
+
38
+ # JSON string for dynamic content personalization.
39
+ attr_accessor :dynamic_content
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'app_id' => :'app_id',
45
+ :'name' => :'name',
46
+ :'contents' => :'contents',
47
+ :'is_email' => :'isEmail',
48
+ :'email_subject' => :'email_subject',
49
+ :'email_body' => :'email_body',
50
+ :'is_sms' => :'isSMS',
51
+ :'dynamic_content' => :'dynamic_content'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'app_id' => :'String',
64
+ :'name' => :'String',
65
+ :'contents' => :'LanguageStringMap',
66
+ :'is_email' => :'Boolean',
67
+ :'email_subject' => :'String',
68
+ :'email_body' => :'String',
69
+ :'is_sms' => :'Boolean',
70
+ :'dynamic_content' => :'String'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ :'email_subject',
78
+ :'email_body',
79
+ :'dynamic_content'
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::CreateTemplateRequest` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::CreateTemplateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'app_id')
99
+ self.app_id = attributes[:'app_id']
100
+ end
101
+
102
+ if attributes.key?(:'name')
103
+ self.name = attributes[:'name']
104
+ end
105
+
106
+ if attributes.key?(:'contents')
107
+ self.contents = attributes[:'contents']
108
+ end
109
+
110
+ if attributes.key?(:'is_email')
111
+ self.is_email = attributes[:'is_email']
112
+ end
113
+
114
+ if attributes.key?(:'email_subject')
115
+ self.email_subject = attributes[:'email_subject']
116
+ end
117
+
118
+ if attributes.key?(:'email_body')
119
+ self.email_body = attributes[:'email_body']
120
+ end
121
+
122
+ if attributes.key?(:'is_sms')
123
+ self.is_sms = attributes[:'is_sms']
124
+ end
125
+
126
+ if attributes.key?(:'dynamic_content')
127
+ self.dynamic_content = attributes[:'dynamic_content']
128
+ end
129
+ end
130
+
131
+ # Show invalid properties with the reasons. Usually used together with valid?
132
+ # @return Array for valid properties with the reasons
133
+ def list_invalid_properties
134
+ invalid_properties = Array.new
135
+ if @app_id.nil?
136
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
137
+ end
138
+
139
+ if @name.nil?
140
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
141
+ end
142
+
143
+ if @contents.nil?
144
+ invalid_properties.push('invalid value for "contents", contents cannot be nil.')
145
+ end
146
+
147
+ invalid_properties
148
+ end
149
+
150
+ # Check to see if the all the properties in the model are valid
151
+ # @return true if the model is valid
152
+ def valid?
153
+ return false if @app_id.nil?
154
+ return false if @name.nil?
155
+ return false if @contents.nil?
156
+ true
157
+ end
158
+
159
+ # Checks equality by comparing each attribute.
160
+ # @param [Object] Object to be compared
161
+ def ==(o)
162
+ return true if self.equal?(o)
163
+ self.class == o.class &&
164
+ app_id == o.app_id &&
165
+ name == o.name &&
166
+ contents == o.contents &&
167
+ is_email == o.is_email &&
168
+ email_subject == o.email_subject &&
169
+ email_body == o.email_body &&
170
+ is_sms == o.is_sms &&
171
+ dynamic_content == o.dynamic_content
172
+ end
173
+
174
+ # @see the `==` method
175
+ # @param [Object] Object to be compared
176
+ def eql?(o)
177
+ self == o
178
+ end
179
+
180
+ # Calculates hash code according to all attributes.
181
+ # @return [Integer] Hash code
182
+ def hash
183
+ [app_id, name, contents, is_email, email_subject, email_body, is_sms, dynamic_content].hash
184
+ end
185
+
186
+ # Builds the object from hash
187
+ # @param [Hash] attributes Model attributes in the form of hash
188
+ # @return [Object] Returns the model itself
189
+ def self.build_from_hash(attributes)
190
+ new.build_from_hash(attributes)
191
+ end
192
+
193
+ # Builds the object from hash
194
+ # @param [Hash] attributes Model attributes in the form of hash
195
+ # @return [Object] Returns the model itself
196
+ def build_from_hash(attributes)
197
+ return nil unless attributes.is_a?(Hash)
198
+ attributes = attributes.transform_keys(&:to_sym)
199
+ self.class.openapi_types.each_pair do |key, type|
200
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
201
+ self.send("#{key}=", nil)
202
+ elsif type =~ /\AArray<(.*)>/i
203
+ # check to ensure the input is an array given that the attribute
204
+ # is documented as an array but the input is not
205
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
206
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
207
+ end
208
+ elsif !attributes[self.class.attribute_map[key]].nil?
209
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
210
+ end
211
+ end
212
+
213
+ self
214
+ end
215
+
216
+ # Deserializes the data based on type
217
+ # @param string type Data type
218
+ # @param string value Value to be deserialized
219
+ # @return [Object] Deserialized data
220
+ def _deserialize(type, value)
221
+ case type.to_sym
222
+ when :Time
223
+ Time.parse(value)
224
+ when :Date
225
+ Date.parse(value)
226
+ when :String
227
+ value.to_s
228
+ when :Integer
229
+ value.to_i
230
+ when :Float
231
+ value.to_f
232
+ when :Boolean
233
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
234
+ true
235
+ else
236
+ false
237
+ end
238
+ when :Object
239
+ # generic object (usually a Hash), return directly
240
+ value
241
+ when /\AArray<(?<inner_type>.+)>\z/
242
+ inner_type = Regexp.last_match[:inner_type]
243
+ value.map { |v| _deserialize(inner_type, v) }
244
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
245
+ k_type = Regexp.last_match[:k_type]
246
+ v_type = Regexp.last_match[:v_type]
247
+ {}.tap do |hash|
248
+ value.each do |k, v|
249
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
250
+ end
251
+ end
252
+ else # model
253
+ # models (e.g. Pet) or oneOf
254
+ klass = OneSignal.const_get(type)
255
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
256
+ end
257
+ end
258
+
259
+ # Returns the string representation of the object
260
+ # @return [String] String presentation of the object
261
+ def to_s
262
+ to_hash.to_s
263
+ end
264
+
265
+ # to_body is an alias to to_hash (backward compatibility)
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_body
268
+ to_hash
269
+ end
270
+
271
+ # Returns the object in the form of hash
272
+ # @return [Hash] Returns the object in the form of hash
273
+ def to_hash
274
+ hash = {}
275
+ self.class.attribute_map.each_pair do |attr, param|
276
+ value = self.send(attr)
277
+ if value.nil?
278
+ is_nullable = self.class.openapi_nullable.include?(attr)
279
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
280
+ end
281
+
282
+ hash[param] = _to_hash(value)
283
+ end
284
+ hash
285
+ end
286
+
287
+ # Outputs non-array value in the form of hash
288
+ # For object, use to_hash. Otherwise, just return the value
289
+ # @param [Object] value Any valid value
290
+ # @return [Hash] Returns the value in the form of hash
291
+ def _to_hash(value)
292
+ if value.is_a?(Array)
293
+ value.compact.map { |v| _to_hash(v) }
294
+ elsif value.is_a?(Hash)
295
+ {}.tap do |hash|
296
+ value.each { |k, v| hash[k] = _to_hash(v) }
297
+ end
298
+ elsif value.respond_to? :to_hash
299
+ value.to_hash
300
+ else
301
+ value
302
+ end
303
+ end
304
+
305
+ end
306
+
307
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  #A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
5
5
 
6
- The version of the OpenAPI document: 5.2.1
6
+ The version of the OpenAPI document: 5.3.0
7
7
  Contact: devrel@onesignal.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 6.0.0-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
4
  #A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
5
5
 
6
- The version of the OpenAPI document: 5.2.1
6
+ The version of the OpenAPI document: 5.3.0
7
7
  Contact: devrel@onesignal.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 6.0.0-SNAPSHOT
@@ -3,7 +3,7 @@
3
3
 
4
4
  #A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
5
5
 
6
- The version of the OpenAPI document: 5.2.1
6
+ The version of the OpenAPI document: 5.3.0
7
7
  Contact: devrel@onesignal.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 6.0.0-SNAPSHOT
@@ -0,0 +1,269 @@
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: 5.3.0
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OneSignal
17
+ class CustomEvent
18
+ # The identifier or name of the event. Maximum 128 characters.
19
+ attr_accessor :name
20
+
21
+ # The external ID of the user targeted for the event. Either the user's External ID or OneSignal ID is required.
22
+ attr_accessor :external_id
23
+
24
+ # The OneSignal ID of the user targeted for the event. Either the user's External ID or OneSignal ID is required.
25
+ attr_accessor :onesignal_id
26
+
27
+ # Time the event occurred as an ISO8601 formatted string. Defaults to now if not included or past date provided.
28
+ attr_accessor :timestamp
29
+
30
+ # Properties or data related to the event, like {\"geography\": \"USA\"}
31
+ attr_accessor :payload
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'name' => :'name',
37
+ :'external_id' => :'external_id',
38
+ :'onesignal_id' => :'onesignal_id',
39
+ :'timestamp' => :'timestamp',
40
+ :'payload' => :'payload'
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ :'name' => :'String',
53
+ :'external_id' => :'String',
54
+ :'onesignal_id' => :'String',
55
+ :'timestamp' => :'Time',
56
+ :'payload' => :'Hash<String, Object>'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ :'external_id',
64
+ :'onesignal_id',
65
+ ])
66
+ end
67
+
68
+ # Initializes the object
69
+ # @param [Hash] attributes Model attributes in the form of hash
70
+ def initialize(attributes = {})
71
+ if (!attributes.is_a?(Hash))
72
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::CustomEvent` initialize method"
73
+ end
74
+
75
+ # check to see if the attribute exists and convert string to symbol for hash key
76
+ attributes = attributes.each_with_object({}) { |(k, v), h|
77
+ if (!self.class.attribute_map.key?(k.to_sym))
78
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::CustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
79
+ end
80
+ h[k.to_sym] = v
81
+ }
82
+
83
+ if attributes.key?(:'name')
84
+ self.name = attributes[:'name']
85
+ end
86
+
87
+ if attributes.key?(:'external_id')
88
+ self.external_id = attributes[:'external_id']
89
+ end
90
+
91
+ if attributes.key?(:'onesignal_id')
92
+ self.onesignal_id = attributes[:'onesignal_id']
93
+ end
94
+
95
+ if attributes.key?(:'timestamp')
96
+ self.timestamp = attributes[:'timestamp']
97
+ end
98
+
99
+ if attributes.key?(:'payload')
100
+ if (value = attributes[:'payload']).is_a?(Hash)
101
+ self.payload = value
102
+ end
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if @name.nil?
111
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
112
+ end
113
+
114
+ invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+ return false if @name.nil?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ name == o.name &&
130
+ external_id == o.external_id &&
131
+ onesignal_id == o.onesignal_id &&
132
+ timestamp == o.timestamp &&
133
+ payload == o.payload
134
+ end
135
+
136
+ # @see the `==` method
137
+ # @param [Object] Object to be compared
138
+ def eql?(o)
139
+ self == o
140
+ end
141
+
142
+ # Calculates hash code according to all attributes.
143
+ # @return [Integer] Hash code
144
+ def hash
145
+ [name, external_id, onesignal_id, timestamp, payload].hash
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def self.build_from_hash(attributes)
152
+ new.build_from_hash(attributes)
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ attributes = attributes.transform_keys(&:to_sym)
161
+ self.class.openapi_types.each_pair do |key, type|
162
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
163
+ self.send("#{key}=", nil)
164
+ elsif type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
166
+ # is documented as an array but the input is not
167
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
168
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
169
+ end
170
+ elsif !attributes[self.class.attribute_map[key]].nil?
171
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
172
+ end
173
+ end
174
+
175
+ self
176
+ end
177
+
178
+ # Deserializes the data based on type
179
+ # @param string type Data type
180
+ # @param string value Value to be deserialized
181
+ # @return [Object] Deserialized data
182
+ def _deserialize(type, value)
183
+ case type.to_sym
184
+ when :Time
185
+ Time.parse(value)
186
+ when :Date
187
+ Date.parse(value)
188
+ when :String
189
+ value.to_s
190
+ when :Integer
191
+ value.to_i
192
+ when :Float
193
+ value.to_f
194
+ when :Boolean
195
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
+ true
197
+ else
198
+ false
199
+ end
200
+ when :Object
201
+ # generic object (usually a Hash), return directly
202
+ value
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ # models (e.g. Pet) or oneOf
216
+ klass = OneSignal.const_get(type)
217
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
218
+ end
219
+ end
220
+
221
+ # Returns the string representation of the object
222
+ # @return [String] String presentation of the object
223
+ def to_s
224
+ to_hash.to_s
225
+ end
226
+
227
+ # to_body is an alias to to_hash (backward compatibility)
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_body
230
+ to_hash
231
+ end
232
+
233
+ # Returns the object in the form of hash
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_hash
236
+ hash = {}
237
+ self.class.attribute_map.each_pair do |attr, param|
238
+ value = self.send(attr)
239
+ if value.nil?
240
+ is_nullable = self.class.openapi_nullable.include?(attr)
241
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
242
+ end
243
+
244
+ hash[param] = _to_hash(value)
245
+ end
246
+ hash
247
+ end
248
+
249
+ # Outputs non-array value in the form of hash
250
+ # For object, use to_hash. Otherwise, just return the value
251
+ # @param [Object] value Any valid value
252
+ # @return [Hash] Returns the value in the form of hash
253
+ def _to_hash(value)
254
+ if value.is_a?(Array)
255
+ value.compact.map { |v| _to_hash(v) }
256
+ elsif value.is_a?(Hash)
257
+ {}.tap do |hash|
258
+ value.each { |k, v| hash[k] = _to_hash(v) }
259
+ end
260
+ elsif value.respond_to? :to_hash
261
+ value.to_hash
262
+ else
263
+ value
264
+ end
265
+ end
266
+
267
+ end
268
+
269
+ end