onesignal 5.13.0 → 5.15.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -3
  5. data/docs/BasicNotification.md +6 -2
  6. data/docs/BasicNotificationAllOf.md +5 -1
  7. data/docs/DefaultApi.md +77 -0
  8. data/docs/EmailWarmUp.md +24 -0
  9. data/docs/EmailWarmUpRequest.md +20 -0
  10. data/docs/EmailWarmUpStage.md +24 -0
  11. data/docs/EstimateNotificationRecipientsRequest.md +28 -0
  12. data/docs/EstimateNotificationRecipientsRequestAllOf.md +24 -0
  13. data/docs/EstimateNotificationRecipientsSuccessResponse.md +26 -0
  14. data/docs/Notification.md +6 -2
  15. data/docs/NotificationTarget.md +1 -1
  16. data/docs/NotificationWithMeta.md +6 -2
  17. data/docs/NotificationWithMetaAllOf.md +3 -1
  18. data/docs/SegmentNotificationTarget.md +1 -1
  19. data/lib/onesignal/api/default_api.rb +68 -0
  20. data/lib/onesignal/api_client.rb +1 -1
  21. data/lib/onesignal/models/basic_notification.rb +36 -3
  22. data/lib/onesignal/models/basic_notification_all_of.rb +35 -2
  23. data/lib/onesignal/models/email_warm_up.rb +298 -0
  24. data/lib/onesignal/models/email_warm_up_request.rb +272 -0
  25. data/lib/onesignal/models/email_warm_up_stage.rb +284 -0
  26. data/lib/onesignal/models/estimate_notification_recipients_request.rb +326 -0
  27. data/lib/onesignal/models/estimate_notification_recipients_request_all_of.rb +288 -0
  28. data/lib/onesignal/models/estimate_notification_recipients_success_response.rb +260 -0
  29. data/lib/onesignal/models/notification.rb +36 -3
  30. data/lib/onesignal/models/notification_target.rb +1 -1
  31. data/lib/onesignal/models/notification_with_meta.rb +35 -3
  32. data/lib/onesignal/models/notification_with_meta_all_of.rb +14 -5
  33. data/lib/onesignal/models/segment_notification_target.rb +1 -1
  34. data/lib/onesignal/version.rb +1 -1
  35. data/lib/onesignal.rb +6 -0
  36. data/spec/api/default_api_spec.rb +12 -0
  37. data/spec/models/basic_notification_all_of_spec.rb +16 -0
  38. data/spec/models/basic_notification_spec.rb +16 -0
  39. data/spec/models/email_warm_up_request_spec.rb +43 -0
  40. data/spec/models/email_warm_up_spec.rb +59 -0
  41. data/spec/models/email_warm_up_stage_spec.rb +51 -0
  42. data/spec/models/estimate_notification_recipients_request_all_of_spec.rb +55 -0
  43. data/spec/models/estimate_notification_recipients_request_spec.rb +67 -0
  44. data/spec/models/estimate_notification_recipients_success_response_spec.rb +57 -0
  45. data/spec/models/notification_spec.rb +16 -0
  46. data/spec/models/notification_with_meta_all_of_spec.rb +6 -0
  47. data/spec/models/notification_with_meta_spec.rb +16 -0
  48. metadata +26 -2
@@ -14,7 +14,7 @@ require 'time'
14
14
 
15
15
  module OneSignal
16
16
  class BasicNotification
17
- # 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\"]
17
+ # 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\"] `\"All\"` is a shorthand for every subscribed user: if the array includes the string `\"All\"` and the app has no segment actually named `All`, it targets all subscribers instead of a literal segment lookup.
18
18
  attr_accessor :included_segments
19
19
 
20
20
  # 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\"]
@@ -303,7 +303,7 @@ module OneSignal
303
303
  # Channel: Push Notifications Platform: iOS 15+ Focus Modes and Interruption Levels indicate the priority and delivery timing of a notification, to \"interrupt\" the user. Can choose from options: ['active', 'passive', 'time_sensitive', 'critical']. Default is active.
304
304
  attr_accessor :ios_interruption_level
305
305
 
306
- # Channel: Email Required. The subject of the email.
306
+ # Channel: Email Required. The subject of the email.
307
307
  attr_accessor :email_subject
308
308
 
309
309
  # Channel: Email Required unless template_id is set. HTML suported The body of the email you wish to send. Typically, customers include their own HTML templates here. Must include [unsubscribe_url] in an <a> tag somewhere in the email. Note: any malformed HTML content will be sent to users. Please double-check your HTML is valid.
@@ -333,6 +333,11 @@ module OneSignal
333
333
  # Channel: Email Sender domain to use for the email message. Overrides the default sender domain configured for the app. Only supported when the email service provider is OneSignal Email.
334
334
  attr_accessor :email_sender_domain
335
335
 
336
+ # Channel: Email Set to \"warmup\" to send this as an Auto Warm Up campaign: a single campaign delivered gradually to your audience over several days, so you don't have to pace sends manually. OneSignal generates a sending schedule based on your past delivery volumes, scheduled Auto Warm Up emails, and the size of your current audience. When set, `email_warm_up` is required and describes the campaign's stages and (optionally) its scheduling strategy. `send_after` cannot be combined with `kind: \"warmup\"`. The campaign will be scheduled to begin at its first stage's `start` time. Only supported for Email notifications.
337
+ attr_accessor :kind
338
+
339
+ attr_accessor :email_warm_up
340
+
336
341
  # Channel: SMS Phone Number used to send SMS. Should be a registered Twilio phone number in E.164 format.
337
342
  attr_accessor :sms_from
338
343
 
@@ -493,6 +498,8 @@ module OneSignal
493
498
  :'include_unsubscribed' => :'include_unsubscribed',
494
499
  :'email_bcc' => :'email_bcc',
495
500
  :'email_sender_domain' => :'email_sender_domain',
501
+ :'kind' => :'kind',
502
+ :'email_warm_up' => :'email_warm_up',
496
503
  :'sms_from' => :'sms_from',
497
504
  :'sms_media_urls' => :'sms_media_urls',
498
505
  :'filters' => :'filters',
@@ -622,6 +629,8 @@ module OneSignal
622
629
  :'include_unsubscribed' => :'Boolean',
623
630
  :'email_bcc' => :'Array<String>',
624
631
  :'email_sender_domain' => :'String',
632
+ :'kind' => :'String',
633
+ :'email_warm_up' => :'EmailWarmUpRequest',
625
634
  :'sms_from' => :'String',
626
635
  :'sms_media_urls' => :'Array<String>',
627
636
  :'filters' => :'Array<FilterExpression>',
@@ -723,6 +732,8 @@ module OneSignal
723
732
  :'include_unsubscribed',
724
733
  :'email_bcc',
725
734
  :'email_sender_domain',
735
+ :'kind',
736
+ :'email_warm_up',
726
737
  :'sms_from',
727
738
  :'sms_media_urls',
728
739
  :'filters',
@@ -1226,6 +1237,14 @@ module OneSignal
1226
1237
  self.email_sender_domain = attributes[:'email_sender_domain']
1227
1238
  end
1228
1239
 
1240
+ if attributes.key?(:'kind')
1241
+ self.kind = attributes[:'kind']
1242
+ end
1243
+
1244
+ if attributes.key?(:'email_warm_up')
1245
+ self.email_warm_up = attributes[:'email_warm_up']
1246
+ end
1247
+
1229
1248
  if attributes.key?(:'sms_from')
1230
1249
  self.sms_from = attributes[:'sms_from']
1231
1250
  end
@@ -1291,6 +1310,8 @@ module OneSignal
1291
1310
  return false unless aggregation_validator.valid?(@aggregation)
1292
1311
  return false if @app_id.nil?
1293
1312
  return false if !@email_bcc.nil? && @email_bcc.length > 5
1313
+ kind_validator = EnumAttributeValidator.new('String', ["warmup"])
1314
+ return false unless kind_validator.valid?(@kind)
1294
1315
  huawei_category_validator = EnumAttributeValidator.new('String', ["IM", "VOIP", "SUBSCRIPTION", "TRAVEL", "HEALTH", "WORK", "ACCOUNT", "EXPRESS", "FINANCE", "DEVICE_REMINDER", "MAIL", "MARKETING"])
1295
1316
  return false unless huawei_category_validator.valid?(@huawei_category)
1296
1317
  true
@@ -1326,6 +1347,16 @@ module OneSignal
1326
1347
  @email_bcc = email_bcc
1327
1348
  end
1328
1349
 
1350
+ # Custom attribute writer method checking allowed values (enum).
1351
+ # @param [Object] kind Object to be assigned
1352
+ def kind=(kind)
1353
+ validator = EnumAttributeValidator.new('String', ["warmup"])
1354
+ unless validator.valid?(kind)
1355
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{validator.allowable_values}."
1356
+ end
1357
+ @kind = kind
1358
+ end
1359
+
1329
1360
  # Custom attribute writer method checking allowed values (enum).
1330
1361
  # @param [Object] huawei_category Object to be assigned
1331
1362
  def huawei_category=(huawei_category)
@@ -1450,6 +1481,8 @@ module OneSignal
1450
1481
  include_unsubscribed == o.include_unsubscribed &&
1451
1482
  email_bcc == o.email_bcc &&
1452
1483
  email_sender_domain == o.email_sender_domain &&
1484
+ kind == o.kind &&
1485
+ email_warm_up == o.email_warm_up &&
1453
1486
  sms_from == o.sms_from &&
1454
1487
  sms_media_urls == o.sms_media_urls &&
1455
1488
  filters == o.filters &&
@@ -1470,7 +1503,7 @@ module OneSignal
1470
1503
  # Calculates hash code according to all attributes.
1471
1504
  # @return [Integer] Hash code
1472
1505
  def hash
1473
- [included_segments, excluded_segments, include_subscription_ids, include_email_tokens, email_to, 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, id, value, name, aggregation, is_ios, is_android, is_huawei, is_any_web, is_chrome_web, is_firefox, is_safari, is_wp_wns, is_adm, is_chrome, app_id, external_id, idempotency_key, contents, headings, subtitle, data, huawei_msg_type, url, web_url, app_url, ios_attachments, template_id, content_available, mutable_content, target_content_identifier, big_picture, global_image, huawei_big_picture, adm_big_picture, chrome_big_picture, chrome_web_image, buttons, web_buttons, ios_category, android_channel_id, huawei_channel_id, existing_android_channel_id, huawei_existing_channel_id, android_background_layout, small_icon, huawei_small_icon, large_icon, huawei_large_icon, adm_small_icon, adm_large_icon, chrome_web_icon, chrome_web_badge, firefox_icon, chrome_icon, ios_sound, android_sound, huawei_sound, adm_sound, wp_wns_sound, android_led_color, huawei_led_color, android_accent_color, huawei_accent_color, android_visibility, huawei_visibility, ios_badge_type, ios_badge_count, collapse_id, web_push_topic, apns_alert, delayed_option, delivery_time_of_day, ttl, priority, apns_push_type_override, throttle_rate_per_minute, android_group, android_group_message, adm_group, adm_group_message, thread_id, summary_arg, summary_arg_count, ios_relevance_score, ios_interruption_level, email_subject, email_body, email_from_name, email_from_address, email_reply_to_address, email_preheader, disable_email_click_tracking, include_unsubscribed, email_bcc, email_sender_domain, sms_from, sms_media_urls, filters, custom_data, huawei_badge_class, huawei_badge_add_num, huawei_badge_set_num, huawei_category, huawei_bi_tag].hash
1506
+ [included_segments, excluded_segments, include_subscription_ids, include_email_tokens, email_to, 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, id, value, name, aggregation, is_ios, is_android, is_huawei, is_any_web, is_chrome_web, is_firefox, is_safari, is_wp_wns, is_adm, is_chrome, app_id, external_id, idempotency_key, contents, headings, subtitle, data, huawei_msg_type, url, web_url, app_url, ios_attachments, template_id, content_available, mutable_content, target_content_identifier, big_picture, global_image, huawei_big_picture, adm_big_picture, chrome_big_picture, chrome_web_image, buttons, web_buttons, ios_category, android_channel_id, huawei_channel_id, existing_android_channel_id, huawei_existing_channel_id, android_background_layout, small_icon, huawei_small_icon, large_icon, huawei_large_icon, adm_small_icon, adm_large_icon, chrome_web_icon, chrome_web_badge, firefox_icon, chrome_icon, ios_sound, android_sound, huawei_sound, adm_sound, wp_wns_sound, android_led_color, huawei_led_color, android_accent_color, huawei_accent_color, android_visibility, huawei_visibility, ios_badge_type, ios_badge_count, collapse_id, web_push_topic, apns_alert, delayed_option, delivery_time_of_day, ttl, priority, apns_push_type_override, throttle_rate_per_minute, android_group, android_group_message, adm_group, adm_group_message, thread_id, summary_arg, summary_arg_count, ios_relevance_score, ios_interruption_level, email_subject, email_body, email_from_name, email_from_address, email_reply_to_address, email_preheader, disable_email_click_tracking, include_unsubscribed, email_bcc, email_sender_domain, kind, email_warm_up, sms_from, sms_media_urls, filters, custom_data, huawei_badge_class, huawei_badge_add_num, huawei_badge_set_num, huawei_category, huawei_bi_tag].hash
1474
1507
  end
1475
1508
 
1476
1509
  # Builds the object from hash
@@ -262,7 +262,7 @@ module OneSignal
262
262
  # Channel: Push Notifications Platform: iOS 15+ Focus Modes and Interruption Levels indicate the priority and delivery timing of a notification, to \"interrupt\" the user. Can choose from options: ['active', 'passive', 'time_sensitive', 'critical']. Default is active.
263
263
  attr_accessor :ios_interruption_level
264
264
 
265
- # Channel: Email Required. The subject of the email.
265
+ # Channel: Email Required. The subject of the email.
266
266
  attr_accessor :email_subject
267
267
 
268
268
  # Channel: Email Required unless template_id is set. HTML suported The body of the email you wish to send. Typically, customers include their own HTML templates here. Must include [unsubscribe_url] in an <a> tag somewhere in the email. Note: any malformed HTML content will be sent to users. Please double-check your HTML is valid.
@@ -292,6 +292,11 @@ module OneSignal
292
292
  # Channel: Email Sender domain to use for the email message. Overrides the default sender domain configured for the app. Only supported when the email service provider is OneSignal Email.
293
293
  attr_accessor :email_sender_domain
294
294
 
295
+ # Channel: Email Set to \"warmup\" to send this as an Auto Warm Up campaign: a single campaign delivered gradually to your audience over several days, so you don't have to pace sends manually. OneSignal generates a sending schedule based on your past delivery volumes, scheduled Auto Warm Up emails, and the size of your current audience. When set, `email_warm_up` is required and describes the campaign's stages and (optionally) its scheduling strategy. `send_after` cannot be combined with `kind: \"warmup\"`. The campaign will be scheduled to begin at its first stage's `start` time. Only supported for Email notifications.
296
+ attr_accessor :kind
297
+
298
+ attr_accessor :email_warm_up
299
+
295
300
  # Channel: SMS Phone Number used to send SMS. Should be a registered Twilio phone number in E.164 format.
296
301
  attr_accessor :sms_from
297
302
 
@@ -438,6 +443,8 @@ module OneSignal
438
443
  :'include_unsubscribed' => :'include_unsubscribed',
439
444
  :'email_bcc' => :'email_bcc',
440
445
  :'email_sender_domain' => :'email_sender_domain',
446
+ :'kind' => :'kind',
447
+ :'email_warm_up' => :'email_warm_up',
441
448
  :'sms_from' => :'sms_from',
442
449
  :'sms_media_urls' => :'sms_media_urls',
443
450
  :'filters' => :'filters',
@@ -553,6 +560,8 @@ module OneSignal
553
560
  :'include_unsubscribed' => :'Boolean',
554
561
  :'email_bcc' => :'Array<String>',
555
562
  :'email_sender_domain' => :'String',
563
+ :'kind' => :'String',
564
+ :'email_warm_up' => :'EmailWarmUpRequest',
556
565
  :'sms_from' => :'String',
557
566
  :'sms_media_urls' => :'Array<String>',
558
567
  :'filters' => :'Array<FilterExpression>',
@@ -652,6 +661,8 @@ module OneSignal
652
661
  :'include_unsubscribed',
653
662
  :'email_bcc',
654
663
  :'email_sender_domain',
664
+ :'kind',
665
+ :'email_warm_up',
655
666
  :'sms_from',
656
667
  :'sms_media_urls',
657
668
  :'filters',
@@ -1065,6 +1076,14 @@ module OneSignal
1065
1076
  self.email_sender_domain = attributes[:'email_sender_domain']
1066
1077
  end
1067
1078
 
1079
+ if attributes.key?(:'kind')
1080
+ self.kind = attributes[:'kind']
1081
+ end
1082
+
1083
+ if attributes.key?(:'email_warm_up')
1084
+ self.email_warm_up = attributes[:'email_warm_up']
1085
+ end
1086
+
1068
1087
  if attributes.key?(:'sms_from')
1069
1088
  self.sms_from = attributes[:'sms_from']
1070
1089
  end
@@ -1123,6 +1142,8 @@ module OneSignal
1123
1142
  aggregation_validator = EnumAttributeValidator.new('String', ["sum", "count"])
1124
1143
  return false unless aggregation_validator.valid?(@aggregation)
1125
1144
  return false if !@email_bcc.nil? && @email_bcc.length > 5
1145
+ kind_validator = EnumAttributeValidator.new('String', ["warmup"])
1146
+ return false unless kind_validator.valid?(@kind)
1126
1147
  huawei_category_validator = EnumAttributeValidator.new('String', ["IM", "VOIP", "SUBSCRIPTION", "TRAVEL", "HEALTH", "WORK", "ACCOUNT", "EXPRESS", "FINANCE", "DEVICE_REMINDER", "MAIL", "MARKETING"])
1127
1148
  return false unless huawei_category_validator.valid?(@huawei_category)
1128
1149
  true
@@ -1148,6 +1169,16 @@ module OneSignal
1148
1169
  @email_bcc = email_bcc
1149
1170
  end
1150
1171
 
1172
+ # Custom attribute writer method checking allowed values (enum).
1173
+ # @param [Object] kind Object to be assigned
1174
+ def kind=(kind)
1175
+ validator = EnumAttributeValidator.new('String', ["warmup"])
1176
+ unless validator.valid?(kind)
1177
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{validator.allowable_values}."
1178
+ end
1179
+ @kind = kind
1180
+ end
1181
+
1151
1182
  # Custom attribute writer method checking allowed values (enum).
1152
1183
  # @param [Object] huawei_category Object to be assigned
1153
1184
  def huawei_category=(huawei_category)
@@ -1258,6 +1289,8 @@ module OneSignal
1258
1289
  include_unsubscribed == o.include_unsubscribed &&
1259
1290
  email_bcc == o.email_bcc &&
1260
1291
  email_sender_domain == o.email_sender_domain &&
1292
+ kind == o.kind &&
1293
+ email_warm_up == o.email_warm_up &&
1261
1294
  sms_from == o.sms_from &&
1262
1295
  sms_media_urls == o.sms_media_urls &&
1263
1296
  filters == o.filters &&
@@ -1278,7 +1311,7 @@ module OneSignal
1278
1311
  # Calculates hash code according to all attributes.
1279
1312
  # @return [Integer] Hash code
1280
1313
  def hash
1281
- [id, value, name, aggregation, is_ios, is_android, is_huawei, is_any_web, is_chrome_web, is_firefox, is_safari, is_wp_wns, is_adm, is_chrome, app_id, external_id, idempotency_key, contents, headings, subtitle, data, huawei_msg_type, url, web_url, app_url, ios_attachments, template_id, content_available, mutable_content, target_content_identifier, big_picture, global_image, huawei_big_picture, adm_big_picture, chrome_big_picture, chrome_web_image, buttons, web_buttons, ios_category, android_channel_id, huawei_channel_id, existing_android_channel_id, huawei_existing_channel_id, android_background_layout, small_icon, huawei_small_icon, large_icon, huawei_large_icon, adm_small_icon, adm_large_icon, chrome_web_icon, chrome_web_badge, firefox_icon, chrome_icon, ios_sound, android_sound, huawei_sound, adm_sound, wp_wns_sound, android_led_color, huawei_led_color, android_accent_color, huawei_accent_color, android_visibility, huawei_visibility, ios_badge_type, ios_badge_count, collapse_id, web_push_topic, apns_alert, delayed_option, delivery_time_of_day, ttl, priority, apns_push_type_override, throttle_rate_per_minute, android_group, android_group_message, adm_group, adm_group_message, thread_id, summary_arg, summary_arg_count, ios_relevance_score, ios_interruption_level, email_subject, email_body, email_from_name, email_from_address, email_reply_to_address, email_preheader, disable_email_click_tracking, include_unsubscribed, email_bcc, email_sender_domain, sms_from, sms_media_urls, filters, custom_data, huawei_badge_class, huawei_badge_add_num, huawei_badge_set_num, huawei_category, huawei_bi_tag].hash
1314
+ [id, value, name, aggregation, is_ios, is_android, is_huawei, is_any_web, is_chrome_web, is_firefox, is_safari, is_wp_wns, is_adm, is_chrome, app_id, external_id, idempotency_key, contents, headings, subtitle, data, huawei_msg_type, url, web_url, app_url, ios_attachments, template_id, content_available, mutable_content, target_content_identifier, big_picture, global_image, huawei_big_picture, adm_big_picture, chrome_big_picture, chrome_web_image, buttons, web_buttons, ios_category, android_channel_id, huawei_channel_id, existing_android_channel_id, huawei_existing_channel_id, android_background_layout, small_icon, huawei_small_icon, large_icon, huawei_large_icon, adm_small_icon, adm_large_icon, chrome_web_icon, chrome_web_badge, firefox_icon, chrome_icon, ios_sound, android_sound, huawei_sound, adm_sound, wp_wns_sound, android_led_color, huawei_led_color, android_accent_color, huawei_accent_color, android_visibility, huawei_visibility, ios_badge_type, ios_badge_count, collapse_id, web_push_topic, apns_alert, delayed_option, delivery_time_of_day, ttl, priority, apns_push_type_override, throttle_rate_per_minute, android_group, android_group_message, adm_group, adm_group_message, thread_id, summary_arg, summary_arg_count, ios_relevance_score, ios_interruption_level, email_subject, email_body, email_from_name, email_from_address, email_reply_to_address, email_preheader, disable_email_click_tracking, include_unsubscribed, email_bcc, email_sender_domain, kind, email_warm_up, sms_from, sms_media_urls, filters, custom_data, huawei_badge_class, huawei_badge_add_num, huawei_badge_set_num, huawei_category, huawei_bi_tag].hash
1282
1315
  end
1283
1316
 
1284
1317
  # Builds the object from hash
@@ -0,0 +1,298 @@
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
+ Contact: devrel@onesignal.com
7
+ Generated by: https://openapi-generator.tech
8
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
9
+
10
+ =end
11
+
12
+ require 'date'
13
+ require 'time'
14
+
15
+ module OneSignal
16
+ # Channel: Email Present only when this notification's `kind` is \"warmup\". The Auto Warm Up campaign's stage schedule, scheduling strategy, and live status.
17
+ class EmailWarmUp
18
+ # The campaign's sending schedule, stage by stage.
19
+ attr_accessor :stages
20
+
21
+ # How the stage schedule was produced: * `recommended` - OneSignal generated (and may still adjust) the schedule based on past delivery volumes, scheduled Auto Warm Up emails, and the size of the current audience. * `custom` - The stages were provided as-is in the create request.
22
+ attr_accessor :strategy
23
+
24
+ # Current status of the campaign: * `initializing` - The stages have been submitted and the schedule is being set up. * `draft` - The campaign has been created but has not started sending. * `active` - The campaign is currently working through its stages. * `finished` - All stages have completed. * `canceled` - The campaign was canceled before finishing.
25
+ attr_accessor :status
26
+
27
+ # Whether the campaign is currently live (actively sending).
28
+ attr_accessor :is_live
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'stages' => :'stages',
56
+ :'strategy' => :'strategy',
57
+ :'status' => :'status',
58
+ :'is_live' => :'is_live'
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.openapi_types
69
+ {
70
+ :'stages' => :'Array<EmailWarmUpStage>',
71
+ :'strategy' => :'String',
72
+ :'status' => :'String',
73
+ :'is_live' => :'Boolean'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
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::EmailWarmUp` 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::EmailWarmUp`. 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?(:'stages')
99
+ if (value = attributes[:'stages']).is_a?(Array)
100
+ self.stages = value
101
+ end
102
+ end
103
+
104
+ if attributes.key?(:'strategy')
105
+ self.strategy = attributes[:'strategy']
106
+ end
107
+
108
+ if attributes.key?(:'status')
109
+ self.status = attributes[:'status']
110
+ end
111
+
112
+ if attributes.key?(:'is_live')
113
+ self.is_live = attributes[:'is_live']
114
+ end
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def list_invalid_properties
120
+ invalid_properties = Array.new
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ strategy_validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
128
+ return false unless strategy_validator.valid?(@strategy)
129
+ status_validator = EnumAttributeValidator.new('String', ["initializing", "draft", "active", "finished", "canceled"])
130
+ return false unless status_validator.valid?(@status)
131
+ true
132
+ end
133
+
134
+ # Custom attribute writer method checking allowed values (enum).
135
+ # @param [Object] strategy Object to be assigned
136
+ def strategy=(strategy)
137
+ validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
138
+ unless validator.valid?(strategy)
139
+ fail ArgumentError, "invalid value for \"strategy\", must be one of #{validator.allowable_values}."
140
+ end
141
+ @strategy = strategy
142
+ end
143
+
144
+ # Custom attribute writer method checking allowed values (enum).
145
+ # @param [Object] status Object to be assigned
146
+ def status=(status)
147
+ validator = EnumAttributeValidator.new('String', ["initializing", "draft", "active", "finished", "canceled"])
148
+ unless validator.valid?(status)
149
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
150
+ end
151
+ @status = status
152
+ end
153
+
154
+ # Checks equality by comparing each attribute.
155
+ # @param [Object] Object to be compared
156
+ def ==(o)
157
+ return true if self.equal?(o)
158
+ self.class == o.class &&
159
+ stages == o.stages &&
160
+ strategy == o.strategy &&
161
+ status == o.status &&
162
+ is_live == o.is_live
163
+ end
164
+
165
+ # @see the `==` method
166
+ # @param [Object] Object to be compared
167
+ def eql?(o)
168
+ self == o
169
+ end
170
+
171
+ # Calculates hash code according to all attributes.
172
+ # @return [Integer] Hash code
173
+ def hash
174
+ [stages, strategy, status, is_live].hash
175
+ end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def self.build_from_hash(attributes)
181
+ new.build_from_hash(attributes)
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ attributes = attributes.transform_keys(&:to_sym)
190
+ self.class.openapi_types.each_pair do |key, type|
191
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
192
+ self.send("#{key}=", nil)
193
+ elsif type =~ /\AArray<(.*)>/i
194
+ # check to ensure the input is an array given that the attribute
195
+ # is documented as an array but the input is not
196
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
197
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
198
+ end
199
+ elsif !attributes[self.class.attribute_map[key]].nil?
200
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
201
+ end
202
+ end
203
+
204
+ self
205
+ end
206
+
207
+ # Deserializes the data based on type
208
+ # @param string type Data type
209
+ # @param string value Value to be deserialized
210
+ # @return [Object] Deserialized data
211
+ def _deserialize(type, value)
212
+ case type.to_sym
213
+ when :Time
214
+ Time.parse(value)
215
+ when :Date
216
+ Date.parse(value)
217
+ when :String
218
+ value.to_s
219
+ when :Integer
220
+ value.to_i
221
+ when :Float
222
+ value.to_f
223
+ when :Boolean
224
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
225
+ true
226
+ else
227
+ false
228
+ end
229
+ when :Object
230
+ # generic object (usually a Hash), return directly
231
+ value
232
+ when /\AArray<(?<inner_type>.+)>\z/
233
+ inner_type = Regexp.last_match[:inner_type]
234
+ value.map { |v| _deserialize(inner_type, v) }
235
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
236
+ k_type = Regexp.last_match[:k_type]
237
+ v_type = Regexp.last_match[:v_type]
238
+ {}.tap do |hash|
239
+ value.each do |k, v|
240
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
241
+ end
242
+ end
243
+ else # model
244
+ # models (e.g. Pet) or oneOf
245
+ klass = OneSignal.const_get(type)
246
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
247
+ end
248
+ end
249
+
250
+ # Returns the string representation of the object
251
+ # @return [String] String presentation of the object
252
+ def to_s
253
+ to_hash.to_s
254
+ end
255
+
256
+ # to_body is an alias to to_hash (backward compatibility)
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_body
259
+ to_hash
260
+ end
261
+
262
+ # Returns the object in the form of hash
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_hash
265
+ hash = {}
266
+ self.class.attribute_map.each_pair do |attr, param|
267
+ value = self.send(attr)
268
+ if value.nil?
269
+ is_nullable = self.class.openapi_nullable.include?(attr)
270
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
271
+ end
272
+
273
+ hash[param] = _to_hash(value)
274
+ end
275
+ hash
276
+ end
277
+
278
+ # Outputs non-array value in the form of hash
279
+ # For object, use to_hash. Otherwise, just return the value
280
+ # @param [Object] value Any valid value
281
+ # @return [Hash] Returns the value in the form of hash
282
+ def _to_hash(value)
283
+ if value.is_a?(Array)
284
+ value.compact.map { |v| _to_hash(v) }
285
+ elsif value.is_a?(Hash)
286
+ {}.tap do |hash|
287
+ value.each { |k, v| hash[k] = _to_hash(v) }
288
+ end
289
+ elsif value.respond_to? :to_hash
290
+ value.to_hash
291
+ else
292
+ value
293
+ end
294
+ end
295
+
296
+ end
297
+
298
+ end