onesignal 5.2.1.pre.beta1 → 5.3.0.pre.beta1

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