onesignal_sdk 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +31 -0
  3. data/Gemfile +9 -0
  4. data/LICENSE +24 -0
  5. data/README.md +210 -0
  6. data/RELEASE_INSTRUCTIONS.md +11 -0
  7. data/Rakefile +10 -0
  8. data/docs/App.md +84 -0
  9. data/docs/BasicNotification.md +228 -0
  10. data/docs/BasicNotificationAllOf.md +200 -0
  11. data/docs/BasicNotificationAllOfAndroidBackgroundLayout.md +22 -0
  12. data/docs/BeginLiveActivityRequest.md +20 -0
  13. data/docs/Button.md +22 -0
  14. data/docs/CancelNotificationSuccessResponse.md +18 -0
  15. data/docs/CreateNotificationSuccessResponse.md +24 -0
  16. data/docs/CreatePlayerSuccessResponse.md +20 -0
  17. data/docs/CreateSegmentConflictResponse.md +20 -0
  18. data/docs/CreateSegmentSuccessResponse.md +20 -0
  19. data/docs/CreateSubscriptionRequestBody.md +20 -0
  20. data/docs/CreateUserConflictResponse.md +18 -0
  21. data/docs/CreateUserConflictResponseErrorsInner.md +22 -0
  22. data/docs/CreateUserConflictResponseErrorsItemsMeta.md +18 -0
  23. data/docs/DefaultApi.md +2713 -0
  24. data/docs/DeletePlayerNotFoundResponse.md +18 -0
  25. data/docs/DeletePlayerSuccessResponse.md +18 -0
  26. data/docs/DeleteSegmentNotFoundResponse.md +18 -0
  27. data/docs/DeleteSegmentSuccessResponse.md +18 -0
  28. data/docs/DeliveryData.md +26 -0
  29. data/docs/ExportEventsSuccessResponse.md +18 -0
  30. data/docs/ExportPlayersRequestBody.md +22 -0
  31. data/docs/ExportPlayersSuccessResponse.md +18 -0
  32. data/docs/Filter.md +24 -0
  33. data/docs/FilterExpressions.md +26 -0
  34. data/docs/GenericError.md +18 -0
  35. data/docs/GenericErrorErrorsInner.md +20 -0
  36. data/docs/GetNotificationRequestBody.md +22 -0
  37. data/docs/InlineResponse200.md +18 -0
  38. data/docs/InlineResponse2003.md +18 -0
  39. data/docs/InlineResponse201.md +18 -0
  40. data/docs/InlineResponse202.md +18 -0
  41. data/docs/InvalidIdentifierError.md +20 -0
  42. data/docs/Notification.md +230 -0
  43. data/docs/Notification200Errors.md +49 -0
  44. data/docs/NotificationAllOf.md +18 -0
  45. data/docs/NotificationHistorySuccessResponse.md +20 -0
  46. data/docs/NotificationSlice.md +24 -0
  47. data/docs/NotificationTarget.md +44 -0
  48. data/docs/NotificationWithMeta.md +250 -0
  49. data/docs/NotificationWithMetaAllOf.md +38 -0
  50. data/docs/Operator.md +18 -0
  51. data/docs/OutcomeData.md +22 -0
  52. data/docs/OutcomesData.md +18 -0
  53. data/docs/PlatformDeliveryData.md +32 -0
  54. data/docs/PlatformDeliveryDataEmailAllOf.md +30 -0
  55. data/docs/PlatformDeliveryDataSmsAllOf.md +22 -0
  56. data/docs/Player.md +70 -0
  57. data/docs/PlayerNotificationTarget.md +40 -0
  58. data/docs/PlayerNotificationTargetIncludeAliases.md +18 -0
  59. data/docs/PlayerSlice.md +24 -0
  60. data/docs/PropertiesDeltas.md +22 -0
  61. data/docs/PropertiesObject.md +38 -0
  62. data/docs/Purchase.md +24 -0
  63. data/docs/RateLimiterError.md +18 -0
  64. data/docs/Segment.md +22 -0
  65. data/docs/SegmentNotificationTarget.md +20 -0
  66. data/docs/StringMap.md +102 -0
  67. data/docs/SubscriptionObject.md +50 -0
  68. data/docs/TransferSubscriptionRequestBody.md +18 -0
  69. data/docs/UpdateLiveActivityRequest.md +24 -0
  70. data/docs/UpdateLiveActivitySuccessResponse.md +20 -0
  71. data/docs/UpdatePlayerSuccessResponse.md +18 -0
  72. data/docs/UpdatePlayerTagsRequestBody.md +18 -0
  73. data/docs/UpdatePlayerTagsSuccessResponse.md +18 -0
  74. data/docs/UpdateSubscriptionRequestBody.md +18 -0
  75. data/docs/UpdateUserRequest.md +22 -0
  76. data/docs/User.md +24 -0
  77. data/docs/UserIdentityRequestBody.md +18 -0
  78. data/docs/UserIdentityResponse.md +18 -0
  79. data/docs/UserSubscriptionOptions.md +18 -0
  80. data/lib/onesignal/api/default_api.rb +2727 -0
  81. data/lib/onesignal/api_client.rb +393 -0
  82. data/lib/onesignal/api_error.rb +57 -0
  83. data/lib/onesignal/configuration.rb +245 -0
  84. data/lib/onesignal/models/app.rb +586 -0
  85. data/lib/onesignal/models/basic_notification.rb +1431 -0
  86. data/lib/onesignal/models/basic_notification_all_of.rb +1241 -0
  87. data/lib/onesignal/models/basic_notification_all_of_android_background_layout.rb +241 -0
  88. data/lib/onesignal/models/begin_live_activity_request.rb +238 -0
  89. data/lib/onesignal/models/button.rb +242 -0
  90. data/lib/onesignal/models/cancel_notification_success_response.rb +219 -0
  91. data/lib/onesignal/models/create_notification_success_response.rb +248 -0
  92. data/lib/onesignal/models/create_player_success_response.rb +228 -0
  93. data/lib/onesignal/models/create_segment_conflict_response.rb +230 -0
  94. data/lib/onesignal/models/create_segment_success_response.rb +229 -0
  95. data/lib/onesignal/models/create_subscription_request_body.rb +228 -0
  96. data/lib/onesignal/models/create_user_conflict_response.rb +221 -0
  97. data/lib/onesignal/models/create_user_conflict_response_errors_inner.rb +237 -0
  98. data/lib/onesignal/models/create_user_conflict_response_errors_items_meta.rb +219 -0
  99. data/lib/onesignal/models/delete_player_not_found_response.rb +219 -0
  100. data/lib/onesignal/models/delete_player_success_response.rb +219 -0
  101. data/lib/onesignal/models/delete_segment_not_found_response.rb +219 -0
  102. data/lib/onesignal/models/delete_segment_success_response.rb +219 -0
  103. data/lib/onesignal/models/delivery_data.rb +265 -0
  104. data/lib/onesignal/models/export_events_success_response.rb +219 -0
  105. data/lib/onesignal/models/export_players_request_body.rb +242 -0
  106. data/lib/onesignal/models/export_players_success_response.rb +219 -0
  107. data/lib/onesignal/models/filter.rb +294 -0
  108. data/lib/onesignal/models/filter_expressions.rb +336 -0
  109. data/lib/onesignal/models/generic_error.rb +221 -0
  110. data/lib/onesignal/models/generic_error_errors_inner.rb +228 -0
  111. data/lib/onesignal/models/get_notification_request_body.rb +273 -0
  112. data/lib/onesignal/models/inline_response200.rb +221 -0
  113. data/lib/onesignal/models/inline_response2003.rb +221 -0
  114. data/lib/onesignal/models/inline_response201.rb +219 -0
  115. data/lib/onesignal/models/inline_response202.rb +219 -0
  116. data/lib/onesignal/models/invalid_identifier_error.rb +234 -0
  117. data/lib/onesignal/models/notification.rb +1442 -0
  118. data/lib/onesignal/models/notification200_errors.rb +105 -0
  119. data/lib/onesignal/models/notification_all_of.rb +221 -0
  120. data/lib/onesignal/models/notification_history_success_response.rb +228 -0
  121. data/lib/onesignal/models/notification_slice.rb +248 -0
  122. data/lib/onesignal/models/notification_target.rb +429 -0
  123. data/lib/onesignal/models/notification_with_meta.rb +1546 -0
  124. data/lib/onesignal/models/notification_with_meta_all_of.rb +323 -0
  125. data/lib/onesignal/models/operator.rb +254 -0
  126. data/lib/onesignal/models/outcome_data.rb +286 -0
  127. data/lib/onesignal/models/outcomes_data.rb +221 -0
  128. data/lib/onesignal/models/platform_delivery_data.rb +285 -0
  129. data/lib/onesignal/models/platform_delivery_data_email_all_of.rb +287 -0
  130. data/lib/onesignal/models/platform_delivery_data_sms_all_of.rb +243 -0
  131. data/lib/onesignal/models/player.rb +494 -0
  132. data/lib/onesignal/models/player_notification_target.rb +385 -0
  133. data/lib/onesignal/models/player_notification_target_include_aliases.rb +221 -0
  134. data/lib/onesignal/models/player_slice.rb +248 -0
  135. data/lib/onesignal/models/properties_deltas.rb +239 -0
  136. data/lib/onesignal/models/properties_object.rb +313 -0
  137. data/lib/onesignal/models/purchase.rb +264 -0
  138. data/lib/onesignal/models/rate_limiter_error.rb +221 -0
  139. data/lib/onesignal/models/segment.rb +252 -0
  140. data/lib/onesignal/models/segment_notification_target.rb +234 -0
  141. data/lib/onesignal/models/string_map.rb +640 -0
  142. data/lib/onesignal/models/subscription_object.rb +397 -0
  143. data/lib/onesignal/models/transfer_subscription_request_body.rb +221 -0
  144. data/lib/onesignal/models/update_live_activity_request.rb +309 -0
  145. data/lib/onesignal/models/update_live_activity_success_response.rb +228 -0
  146. data/lib/onesignal/models/update_player_success_response.rb +219 -0
  147. data/lib/onesignal/models/update_player_tags_request_body.rb +220 -0
  148. data/lib/onesignal/models/update_player_tags_success_response.rb +219 -0
  149. data/lib/onesignal/models/update_subscription_request_body.rb +219 -0
  150. data/lib/onesignal/models/update_user_request.rb +239 -0
  151. data/lib/onesignal/models/user.rb +250 -0
  152. data/lib/onesignal/models/user_identity_request_body.rb +221 -0
  153. data/lib/onesignal/models/user_identity_response.rb +221 -0
  154. data/lib/onesignal/models/user_subscription_options.rb +219 -0
  155. data/lib/onesignal/version.rb +15 -0
  156. data/lib/onesignal.rb +111 -0
  157. data/onesignal.gemspec +38 -0
  158. data/spec/api/default_api_spec.rb +522 -0
  159. data/spec/api_client_spec.rb +226 -0
  160. data/spec/configuration_spec.rb +42 -0
  161. data/spec/models/app_spec.rb +236 -0
  162. data/spec/models/basic_notification_all_of_android_background_layout_spec.rb +46 -0
  163. data/spec/models/basic_notification_all_of_spec.rb +584 -0
  164. data/spec/models/basic_notification_spec.rb +672 -0
  165. data/spec/models/begin_live_activity_request_spec.rb +40 -0
  166. data/spec/models/button_spec.rb +46 -0
  167. data/spec/models/cancel_notification_success_response_spec.rb +34 -0
  168. data/spec/models/create_notification_success_response_spec.rb +52 -0
  169. data/spec/models/create_player_success_response_spec.rb +40 -0
  170. data/spec/models/create_segment_conflict_response_spec.rb +40 -0
  171. data/spec/models/create_segment_success_response_spec.rb +40 -0
  172. data/spec/models/create_subscription_request_body_spec.rb +40 -0
  173. data/spec/models/create_user_conflict_response_errors_inner_spec.rb +46 -0
  174. data/spec/models/create_user_conflict_response_errors_items_meta_spec.rb +34 -0
  175. data/spec/models/create_user_conflict_response_spec.rb +34 -0
  176. data/spec/models/delete_player_not_found_response_spec.rb +34 -0
  177. data/spec/models/delete_player_success_response_spec.rb +34 -0
  178. data/spec/models/delete_segment_not_found_response_spec.rb +34 -0
  179. data/spec/models/delete_segment_success_response_spec.rb +34 -0
  180. data/spec/models/delivery_data_spec.rb +58 -0
  181. data/spec/models/export_events_success_response_spec.rb +34 -0
  182. data/spec/models/export_players_request_body_spec.rb +46 -0
  183. data/spec/models/export_players_success_response_spec.rb +34 -0
  184. data/spec/models/filter_expressions_spec.rb +66 -0
  185. data/spec/models/filter_spec.rb +56 -0
  186. data/spec/models/generic_error_errors_inner_spec.rb +40 -0
  187. data/spec/models/generic_error_spec.rb +34 -0
  188. data/spec/models/get_notification_request_body_spec.rb +50 -0
  189. data/spec/models/inline_response2003_spec.rb +34 -0
  190. data/spec/models/inline_response200_spec.rb +34 -0
  191. data/spec/models/inline_response201_spec.rb +34 -0
  192. data/spec/models/inline_response202_spec.rb +34 -0
  193. data/spec/models/invalid_identifier_error_spec.rb +40 -0
  194. data/spec/models/notification200_errors_spec.rb +31 -0
  195. data/spec/models/notification_all_of_spec.rb +34 -0
  196. data/spec/models/notification_history_success_response_spec.rb +40 -0
  197. data/spec/models/notification_slice_spec.rb +52 -0
  198. data/spec/models/notification_spec.rb +678 -0
  199. data/spec/models/notification_target_spec.rb +116 -0
  200. data/spec/models/notification_with_meta_all_of_spec.rb +94 -0
  201. data/spec/models/notification_with_meta_spec.rb +738 -0
  202. data/spec/models/operator_spec.rb +38 -0
  203. data/spec/models/outcome_data_spec.rb +50 -0
  204. data/spec/models/outcomes_data_spec.rb +34 -0
  205. data/spec/models/platform_delivery_data_email_all_of_spec.rb +70 -0
  206. data/spec/models/platform_delivery_data_sms_all_of_spec.rb +46 -0
  207. data/spec/models/platform_delivery_data_spec.rb +76 -0
  208. data/spec/models/player_notification_target_include_aliases_spec.rb +34 -0
  209. data/spec/models/player_notification_target_spec.rb +104 -0
  210. data/spec/models/player_slice_spec.rb +52 -0
  211. data/spec/models/player_spec.rb +190 -0
  212. data/spec/models/properties_deltas_spec.rb +46 -0
  213. data/spec/models/properties_object_spec.rb +94 -0
  214. data/spec/models/purchase_spec.rb +52 -0
  215. data/spec/models/rate_limiter_error_spec.rb +34 -0
  216. data/spec/models/segment_notification_target_spec.rb +40 -0
  217. data/spec/models/segment_spec.rb +46 -0
  218. data/spec/models/string_map_spec.rb +286 -0
  219. data/spec/models/subscription_object_spec.rb +134 -0
  220. data/spec/models/transfer_subscription_request_body_spec.rb +34 -0
  221. data/spec/models/update_live_activity_request_spec.rb +60 -0
  222. data/spec/models/update_live_activity_success_response_spec.rb +40 -0
  223. data/spec/models/update_player_success_response_spec.rb +34 -0
  224. data/spec/models/update_player_tags_request_body_spec.rb +34 -0
  225. data/spec/models/update_player_tags_success_response_spec.rb +34 -0
  226. data/spec/models/update_subscription_request_body_spec.rb +34 -0
  227. data/spec/models/update_user_request_spec.rb +46 -0
  228. data/spec/models/user_identity_request_body_spec.rb +34 -0
  229. data/spec/models/user_identity_response_spec.rb +34 -0
  230. data/spec/models/user_spec.rb +52 -0
  231. data/spec/models/user_subscription_options_spec.rb +34 -0
  232. data/spec/spec_helper.rb +111 -0
  233. metadata +389 -0
@@ -0,0 +1,248 @@
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.2.2
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 NotificationSlice
18
+ attr_accessor :total_count
19
+
20
+ attr_accessor :offset
21
+
22
+ attr_accessor :limit
23
+
24
+ attr_accessor :notifications
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'total_count' => :'total_count',
30
+ :'offset' => :'offset',
31
+ :'limit' => :'limit',
32
+ :'notifications' => :'notifications'
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
+ :'total_count' => :'Integer',
45
+ :'offset' => :'Integer',
46
+ :'limit' => :'Integer',
47
+ :'notifications' => :'Array<NotificationWithMeta>'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::NotificationSlice` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::NotificationSlice`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'total_count')
73
+ self.total_count = attributes[:'total_count']
74
+ end
75
+
76
+ if attributes.key?(:'offset')
77
+ self.offset = attributes[:'offset']
78
+ end
79
+
80
+ if attributes.key?(:'limit')
81
+ self.limit = attributes[:'limit']
82
+ end
83
+
84
+ if attributes.key?(:'notifications')
85
+ if (value = attributes[:'notifications']).is_a?(Array)
86
+ self.notifications = value
87
+ end
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ invalid_properties = Array.new
95
+ invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ true
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ total_count == o.total_count &&
110
+ offset == o.offset &&
111
+ limit == o.limit &&
112
+ notifications == o.notifications
113
+ end
114
+
115
+ # @see the `==` method
116
+ # @param [Object] Object to be compared
117
+ def eql?(o)
118
+ self == o
119
+ end
120
+
121
+ # Calculates hash code according to all attributes.
122
+ # @return [Integer] Hash code
123
+ def hash
124
+ [total_count, offset, limit, notifications].hash
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def self.build_from_hash(attributes)
131
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
138
+ return nil unless attributes.is_a?(Hash)
139
+ attributes = attributes.transform_keys(&:to_sym)
140
+ self.class.openapi_types.each_pair do |key, type|
141
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
142
+ self.send("#{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[self.class.attribute_map[key]].is_a?(Array)
147
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
148
+ end
149
+ elsif !attributes[self.class.attribute_map[key]].nil?
150
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
151
+ end
152
+ end
153
+
154
+ self
155
+ end
156
+
157
+ # Deserializes the data based on type
158
+ # @param string type Data type
159
+ # @param string value Value to be deserialized
160
+ # @return [Object] Deserialized data
161
+ def _deserialize(type, value)
162
+ case type.to_sym
163
+ when :Time
164
+ Time.parse(value)
165
+ when :Date
166
+ Date.parse(value)
167
+ when :String
168
+ value.to_s
169
+ when :Integer
170
+ value.to_i
171
+ when :Float
172
+ value.to_f
173
+ when :Boolean
174
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
175
+ true
176
+ else
177
+ false
178
+ end
179
+ when :Object
180
+ # generic object (usually a Hash), return directly
181
+ value
182
+ when /\AArray<(?<inner_type>.+)>\z/
183
+ inner_type = Regexp.last_match[:inner_type]
184
+ value.map { |v| _deserialize(inner_type, v) }
185
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
186
+ k_type = Regexp.last_match[:k_type]
187
+ v_type = Regexp.last_match[:v_type]
188
+ {}.tap do |hash|
189
+ value.each do |k, v|
190
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
191
+ end
192
+ end
193
+ else # model
194
+ # models (e.g. Pet) or oneOf
195
+ klass = OneSignal.const_get(type)
196
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
197
+ end
198
+ end
199
+
200
+ # Returns the string representation of the object
201
+ # @return [String] String presentation of the object
202
+ def to_s
203
+ to_hash.to_s
204
+ end
205
+
206
+ # to_body is an alias to to_hash (backward compatibility)
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_body
209
+ to_hash
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = self.send(attr)
218
+ if value.nil?
219
+ is_nullable = self.class.openapi_nullable.include?(attr)
220
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
221
+ end
222
+
223
+ hash[param] = _to_hash(value)
224
+ end
225
+ hash
226
+ end
227
+
228
+ # Outputs non-array value in the form of hash
229
+ # For object, use to_hash. Otherwise, just return the value
230
+ # @param [Object] value Any valid value
231
+ # @return [Hash] Returns the value in the form of hash
232
+ def _to_hash(value)
233
+ if value.is_a?(Array)
234
+ value.compact.map { |v| _to_hash(v) }
235
+ elsif value.is_a?(Hash)
236
+ {}.tap do |hash|
237
+ value.each { |k, v| hash[k] = _to_hash(v) }
238
+ end
239
+ elsif value.respond_to? :to_hash
240
+ value.to_hash
241
+ else
242
+ value
243
+ end
244
+ end
245
+
246
+ end
247
+
248
+ end
@@ -0,0 +1,429 @@
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.2.2
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 NotificationTarget
18
+ # The segment names you want to target. Users in these segments will receive a notification. This targeting parameter is only compatible with excluded_segments. Example: [\"Active Users\", \"Inactive Users\"]
19
+ attr_accessor :included_segments
20
+
21
+ # Segment that will be excluded when sending. Users in these segments will not receive a notification, even if they were included in included_segments. This targeting parameter is only compatible with included_segments. Example: [\"Active Users\", \"Inactive Users\"]
22
+ attr_accessor :excluded_segments
23
+
24
+ # Specific playerids to send your notification to. _Does not require API Auth Key. Do not combine with other targeting parameters. Not compatible with any other targeting parameters. Example: [\"1dd608f2-c6a1-11e3-851d-000c2940e62c\"] Limit of 2,000 entries per REST API call
25
+ attr_accessor :include_player_ids
26
+
27
+ # Target specific devices by custom user IDs assigned via API. Not compatible with any other targeting parameters Example: [\"custom-id-assigned-by-api\"] REQUIRED: REST API Key Authentication Limit of 2,000 entries per REST API call. Note: If targeting push, email, or sms subscribers with same ids, use with channel_for_external_user_ids to indicate you are sending a push or email or sms.
28
+ attr_accessor :include_external_user_ids
29
+
30
+ # Recommended for Sending Emails - Target specific email addresses. If an email does not correspond to an existing user, a new user will be created. Example: nick@catfac.ts Limit of 2,000 entries per REST API call
31
+ attr_accessor :include_email_tokens
32
+
33
+ # Recommended for Sending SMS - Target specific phone numbers. The phone number should be in the E.164 format. Phone number should be an existing subscriber on OneSignal. Refer our docs to learn how to add phone numbers to OneSignal. Example phone number: +1999999999 Limit of 2,000 entries per REST API call
34
+ attr_accessor :include_phone_numbers
35
+
36
+ # Not Recommended: Please consider using include_player_ids or include_external_user_ids instead. Target using iOS device tokens. Warning: Only works with Production tokens. All non-alphanumeric characters must be removed from each token. If a token does not correspond to an existing user, a new user will be created. Example: ce777617da7f548fe7a9ab6febb56cf39fba6d38203... Limit of 2,000 entries per REST API call
37
+ attr_accessor :include_ios_tokens
38
+
39
+ # Not Recommended: Please consider using include_player_ids or include_external_user_ids instead. Target using Windows URIs. If a token does not correspond to an existing user, a new user will be created. Example: http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-... Limit of 2,000 entries per REST API call
40
+ attr_accessor :include_wp_wns_uris
41
+
42
+ # Not Recommended: Please consider using include_player_ids or include_external_user_ids instead. Target using Amazon ADM registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: amzn1.adm-registration.v1.XpvSSUk0Rc3hTVVV... Limit of 2,000 entries per REST API call
43
+ attr_accessor :include_amazon_reg_ids
44
+
45
+ # Not Recommended: Please consider using include_player_ids or include_external_user_ids instead. Target using Chrome App registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_... Limit of 2,000 entries per REST API call
46
+ attr_accessor :include_chrome_reg_ids
47
+
48
+ # Not Recommended: Please consider using include_player_ids or include_external_user_ids instead. Target using Chrome Web Push registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_... Limit of 2,000 entries per REST API call
49
+ attr_accessor :include_chrome_web_reg_ids
50
+
51
+ # Not Recommended: Please consider using include_player_ids or include_external_user_ids instead. Target using Android device registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_... Limit of 2,000 entries per REST API call
52
+ attr_accessor :include_android_reg_ids
53
+
54
+ attr_accessor :include_aliases
55
+
56
+ attr_accessor :target_channel
57
+
58
+ class EnumAttributeValidator
59
+ attr_reader :datatype
60
+ attr_reader :allowable_values
61
+
62
+ def initialize(datatype, allowable_values)
63
+ @allowable_values = allowable_values.map do |value|
64
+ case datatype.to_s
65
+ when /Integer/i
66
+ value.to_i
67
+ when /Float/i
68
+ value.to_f
69
+ else
70
+ value
71
+ end
72
+ end
73
+ end
74
+
75
+ def valid?(value)
76
+ !value || allowable_values.include?(value)
77
+ end
78
+ end
79
+
80
+ # Attribute mapping from ruby-style variable name to JSON key.
81
+ def self.attribute_map
82
+ {
83
+ :'included_segments' => :'included_segments',
84
+ :'excluded_segments' => :'excluded_segments',
85
+ :'include_player_ids' => :'include_player_ids',
86
+ :'include_external_user_ids' => :'include_external_user_ids',
87
+ :'include_email_tokens' => :'include_email_tokens',
88
+ :'include_phone_numbers' => :'include_phone_numbers',
89
+ :'include_ios_tokens' => :'include_ios_tokens',
90
+ :'include_wp_wns_uris' => :'include_wp_wns_uris',
91
+ :'include_amazon_reg_ids' => :'include_amazon_reg_ids',
92
+ :'include_chrome_reg_ids' => :'include_chrome_reg_ids',
93
+ :'include_chrome_web_reg_ids' => :'include_chrome_web_reg_ids',
94
+ :'include_android_reg_ids' => :'include_android_reg_ids',
95
+ :'include_aliases' => :'include_aliases',
96
+ :'target_channel' => :'target_channel'
97
+ }
98
+ end
99
+
100
+ # Returns all the JSON keys this model knows about
101
+ def self.acceptable_attributes
102
+ attribute_map.values
103
+ end
104
+
105
+ # Attribute type mapping.
106
+ def self.openapi_types
107
+ {
108
+ :'included_segments' => :'Array<String>',
109
+ :'excluded_segments' => :'Array<String>',
110
+ :'include_player_ids' => :'Array<String>',
111
+ :'include_external_user_ids' => :'Array<String>',
112
+ :'include_email_tokens' => :'Array<String>',
113
+ :'include_phone_numbers' => :'Array<String>',
114
+ :'include_ios_tokens' => :'Array<String>',
115
+ :'include_wp_wns_uris' => :'Array<String>',
116
+ :'include_amazon_reg_ids' => :'Array<String>',
117
+ :'include_chrome_reg_ids' => :'Array<String>',
118
+ :'include_chrome_web_reg_ids' => :'Array<String>',
119
+ :'include_android_reg_ids' => :'Array<String>',
120
+ :'include_aliases' => :'PlayerNotificationTargetIncludeAliases',
121
+ :'target_channel' => :'String'
122
+ }
123
+ end
124
+
125
+ # List of attributes with nullable: true
126
+ def self.openapi_nullable
127
+ Set.new([
128
+ :'include_player_ids',
129
+ :'include_external_user_ids',
130
+ :'include_aliases',
131
+ ])
132
+ end
133
+
134
+ # List of class defined in anyOf (OpenAPI v3)
135
+ def self.openapi_any_of
136
+ [
137
+ :'PlayerNotificationTarget',
138
+ :'SegmentNotificationTarget'
139
+ ]
140
+ end
141
+
142
+ # Initializes the object
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ def initialize(attributes = {})
145
+ if (!attributes.is_a?(Hash))
146
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::NotificationTarget` initialize method"
147
+ end
148
+
149
+ # check to see if the attribute exists and convert string to symbol for hash key
150
+ attributes = attributes.each_with_object({}) { |(k, v), h|
151
+ if (!self.class.attribute_map.key?(k.to_sym))
152
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::NotificationTarget`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
153
+ end
154
+ h[k.to_sym] = v
155
+ }
156
+
157
+ if attributes.key?(:'included_segments')
158
+ if (value = attributes[:'included_segments']).is_a?(Array)
159
+ self.included_segments = value
160
+ end
161
+ end
162
+
163
+ if attributes.key?(:'excluded_segments')
164
+ if (value = attributes[:'excluded_segments']).is_a?(Array)
165
+ self.excluded_segments = value
166
+ end
167
+ end
168
+
169
+ if attributes.key?(:'include_player_ids')
170
+ if (value = attributes[:'include_player_ids']).is_a?(Array)
171
+ self.include_player_ids = value
172
+ end
173
+ end
174
+
175
+ if attributes.key?(:'include_external_user_ids')
176
+ if (value = attributes[:'include_external_user_ids']).is_a?(Array)
177
+ self.include_external_user_ids = value
178
+ end
179
+ end
180
+
181
+ if attributes.key?(:'include_email_tokens')
182
+ if (value = attributes[:'include_email_tokens']).is_a?(Array)
183
+ self.include_email_tokens = value
184
+ end
185
+ end
186
+
187
+ if attributes.key?(:'include_phone_numbers')
188
+ if (value = attributes[:'include_phone_numbers']).is_a?(Array)
189
+ self.include_phone_numbers = value
190
+ end
191
+ end
192
+
193
+ if attributes.key?(:'include_ios_tokens')
194
+ if (value = attributes[:'include_ios_tokens']).is_a?(Array)
195
+ self.include_ios_tokens = value
196
+ end
197
+ end
198
+
199
+ if attributes.key?(:'include_wp_wns_uris')
200
+ if (value = attributes[:'include_wp_wns_uris']).is_a?(Array)
201
+ self.include_wp_wns_uris = value
202
+ end
203
+ end
204
+
205
+ if attributes.key?(:'include_amazon_reg_ids')
206
+ if (value = attributes[:'include_amazon_reg_ids']).is_a?(Array)
207
+ self.include_amazon_reg_ids = value
208
+ end
209
+ end
210
+
211
+ if attributes.key?(:'include_chrome_reg_ids')
212
+ if (value = attributes[:'include_chrome_reg_ids']).is_a?(Array)
213
+ self.include_chrome_reg_ids = value
214
+ end
215
+ end
216
+
217
+ if attributes.key?(:'include_chrome_web_reg_ids')
218
+ if (value = attributes[:'include_chrome_web_reg_ids']).is_a?(Array)
219
+ self.include_chrome_web_reg_ids = value
220
+ end
221
+ end
222
+
223
+ if attributes.key?(:'include_android_reg_ids')
224
+ if (value = attributes[:'include_android_reg_ids']).is_a?(Array)
225
+ self.include_android_reg_ids = value
226
+ end
227
+ end
228
+
229
+ if attributes.key?(:'include_aliases')
230
+ self.include_aliases = attributes[:'include_aliases']
231
+ end
232
+
233
+ if attributes.key?(:'target_channel')
234
+ self.target_channel = attributes[:'target_channel']
235
+ end
236
+ end
237
+
238
+ # Show invalid properties with the reasons. Usually used together with valid?
239
+ # @return Array for valid properties with the reasons
240
+ def list_invalid_properties
241
+ invalid_properties = Array.new
242
+ invalid_properties
243
+ end
244
+
245
+ # Check to see if the all the properties in the model are valid
246
+ # @return true if the model is valid
247
+ def valid?
248
+ target_channel_validator = EnumAttributeValidator.new('String', ["push", "email", "sms"])
249
+ return false unless target_channel_validator.valid?(@target_channel)
250
+ _any_of_found = false
251
+ self.class.openapi_any_of.each do |_class|
252
+ _any_of = OneSignal.const_get(_class).build_from_hash(self.to_hash)
253
+ if _any_of.valid?
254
+ _any_of_found = true
255
+ end
256
+ end
257
+
258
+ if !_any_of_found
259
+ return false
260
+ end
261
+
262
+ true
263
+ end
264
+
265
+ # Custom attribute writer method checking allowed values (enum).
266
+ # @param [Object] target_channel Object to be assigned
267
+ def target_channel=(target_channel)
268
+ validator = EnumAttributeValidator.new('String', ["push", "email", "sms"])
269
+ unless validator.valid?(target_channel)
270
+ fail ArgumentError, "invalid value for \"target_channel\", must be one of #{validator.allowable_values}."
271
+ end
272
+ @target_channel = target_channel
273
+ end
274
+
275
+ # Checks equality by comparing each attribute.
276
+ # @param [Object] Object to be compared
277
+ def ==(o)
278
+ return true if self.equal?(o)
279
+ self.class == o.class &&
280
+ included_segments == o.included_segments &&
281
+ excluded_segments == o.excluded_segments &&
282
+ include_player_ids == o.include_player_ids &&
283
+ include_external_user_ids == o.include_external_user_ids &&
284
+ include_email_tokens == o.include_email_tokens &&
285
+ include_phone_numbers == o.include_phone_numbers &&
286
+ include_ios_tokens == o.include_ios_tokens &&
287
+ include_wp_wns_uris == o.include_wp_wns_uris &&
288
+ include_amazon_reg_ids == o.include_amazon_reg_ids &&
289
+ include_chrome_reg_ids == o.include_chrome_reg_ids &&
290
+ include_chrome_web_reg_ids == o.include_chrome_web_reg_ids &&
291
+ include_android_reg_ids == o.include_android_reg_ids &&
292
+ include_aliases == o.include_aliases &&
293
+ target_channel == o.target_channel
294
+ end
295
+
296
+ # @see the `==` method
297
+ # @param [Object] Object to be compared
298
+ def eql?(o)
299
+ self == o
300
+ end
301
+
302
+ # Calculates hash code according to all attributes.
303
+ # @return [Integer] Hash code
304
+ def hash
305
+ [included_segments, excluded_segments, include_player_ids, include_external_user_ids, include_email_tokens, include_phone_numbers, include_ios_tokens, include_wp_wns_uris, include_amazon_reg_ids, include_chrome_reg_ids, include_chrome_web_reg_ids, include_android_reg_ids, include_aliases, target_channel].hash
306
+ end
307
+
308
+ # Builds the object from hash
309
+ # @param [Hash] attributes Model attributes in the form of hash
310
+ # @return [Object] Returns the model itself
311
+ def self.build_from_hash(attributes)
312
+ new.build_from_hash(attributes)
313
+ end
314
+
315
+ # Builds the object from hash
316
+ # @param [Hash] attributes Model attributes in the form of hash
317
+ # @return [Object] Returns the model itself
318
+ def build_from_hash(attributes)
319
+ return nil unless attributes.is_a?(Hash)
320
+ attributes = attributes.transform_keys(&:to_sym)
321
+ self.class.openapi_types.each_pair do |key, type|
322
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
323
+ self.send("#{key}=", nil)
324
+ elsif type =~ /\AArray<(.*)>/i
325
+ # check to ensure the input is an array given that the attribute
326
+ # is documented as an array but the input is not
327
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
328
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
329
+ end
330
+ elsif !attributes[self.class.attribute_map[key]].nil?
331
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
332
+ end
333
+ end
334
+
335
+ self
336
+ end
337
+
338
+ # Deserializes the data based on type
339
+ # @param string type Data type
340
+ # @param string value Value to be deserialized
341
+ # @return [Object] Deserialized data
342
+ def _deserialize(type, value)
343
+ case type.to_sym
344
+ when :Time
345
+ Time.parse(value)
346
+ when :Date
347
+ Date.parse(value)
348
+ when :String
349
+ value.to_s
350
+ when :Integer
351
+ value.to_i
352
+ when :Float
353
+ value.to_f
354
+ when :Boolean
355
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
356
+ true
357
+ else
358
+ false
359
+ end
360
+ when :Object
361
+ # generic object (usually a Hash), return directly
362
+ value
363
+ when /\AArray<(?<inner_type>.+)>\z/
364
+ inner_type = Regexp.last_match[:inner_type]
365
+ value.map { |v| _deserialize(inner_type, v) }
366
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
367
+ k_type = Regexp.last_match[:k_type]
368
+ v_type = Regexp.last_match[:v_type]
369
+ {}.tap do |hash|
370
+ value.each do |k, v|
371
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
372
+ end
373
+ end
374
+ else # model
375
+ # models (e.g. Pet) or oneOf
376
+ klass = OneSignal.const_get(type)
377
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
378
+ end
379
+ end
380
+
381
+ # Returns the string representation of the object
382
+ # @return [String] String presentation of the object
383
+ def to_s
384
+ to_hash.to_s
385
+ end
386
+
387
+ # to_body is an alias to to_hash (backward compatibility)
388
+ # @return [Hash] Returns the object in the form of hash
389
+ def to_body
390
+ to_hash
391
+ end
392
+
393
+ # Returns the object in the form of hash
394
+ # @return [Hash] Returns the object in the form of hash
395
+ def to_hash
396
+ hash = {}
397
+ self.class.attribute_map.each_pair do |attr, param|
398
+ value = self.send(attr)
399
+ if value.nil?
400
+ is_nullable = self.class.openapi_nullable.include?(attr)
401
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
402
+ end
403
+
404
+ hash[param] = _to_hash(value)
405
+ end
406
+ hash
407
+ end
408
+
409
+ # Outputs non-array value in the form of hash
410
+ # For object, use to_hash. Otherwise, just return the value
411
+ # @param [Object] value Any valid value
412
+ # @return [Hash] Returns the value in the form of hash
413
+ def _to_hash(value)
414
+ if value.is_a?(Array)
415
+ value.compact.map { |v| _to_hash(v) }
416
+ elsif value.is_a?(Hash)
417
+ {}.tap do |hash|
418
+ value.each { |k, v| hash[k] = _to_hash(v) }
419
+ end
420
+ elsif value.respond_to? :to_hash
421
+ value.to_hash
422
+ else
423
+ value
424
+ end
425
+ end
426
+
427
+ end
428
+
429
+ end