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
@@ -0,0 +1,272 @@
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 Required when `kind` is \"warmup\". The gradual sending schedule for the Auto Warm Up campaign.
17
+ class EmailWarmUpRequest
18
+ # Required. The ordered stages that make up the campaign's sending schedule.
19
+ attr_accessor :stages
20
+
21
+ # How the stage schedule should be treated: * `recommended` - (Default) OneSignal may adjust the provided stages based on past delivery volumes, scheduled Auto Warm Up emails, and the size of the current audience. * `custom` - The stages provided are sent as-is.
22
+ attr_accessor :strategy
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'stages' => :'stages',
50
+ :'strategy' => :'strategy'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'stages' => :'Array<EmailWarmUpStage>',
63
+ :'strategy' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ :'strategy'
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailWarmUpRequest` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailWarmUpRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'stages')
90
+ if (value = attributes[:'stages']).is_a?(Array)
91
+ self.stages = value
92
+ end
93
+ end
94
+
95
+ if attributes.key?(:'strategy')
96
+ self.strategy = attributes[:'strategy']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ invalid_properties = Array.new
104
+ if @stages.nil?
105
+ invalid_properties.push('invalid value for "stages", stages cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ return false if @stages.nil?
115
+ strategy_validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
116
+ return false unless strategy_validator.valid?(@strategy)
117
+ true
118
+ end
119
+
120
+ # Custom attribute writer method checking allowed values (enum).
121
+ # @param [Object] strategy Object to be assigned
122
+ def strategy=(strategy)
123
+ validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
124
+ unless validator.valid?(strategy)
125
+ fail ArgumentError, "invalid value for \"strategy\", must be one of #{validator.allowable_values}."
126
+ end
127
+ @strategy = strategy
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ stages == o.stages &&
136
+ strategy == o.strategy
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Integer] Hash code
147
+ def hash
148
+ [stages, strategy].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def self.build_from_hash(attributes)
155
+ new.build_from_hash(attributes)
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ attributes = attributes.transform_keys(&:to_sym)
164
+ self.class.openapi_types.each_pair do |key, type|
165
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
166
+ self.send("#{key}=", nil)
167
+ elsif type =~ /\AArray<(.*)>/i
168
+ # check to ensure the input is an array given that the attribute
169
+ # is documented as an array but the input is not
170
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
171
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
172
+ end
173
+ elsif !attributes[self.class.attribute_map[key]].nil?
174
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
175
+ end
176
+ end
177
+
178
+ self
179
+ end
180
+
181
+ # Deserializes the data based on type
182
+ # @param string type Data type
183
+ # @param string value Value to be deserialized
184
+ # @return [Object] Deserialized data
185
+ def _deserialize(type, value)
186
+ case type.to_sym
187
+ when :Time
188
+ Time.parse(value)
189
+ when :Date
190
+ Date.parse(value)
191
+ when :String
192
+ value.to_s
193
+ when :Integer
194
+ value.to_i
195
+ when :Float
196
+ value.to_f
197
+ when :Boolean
198
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
199
+ true
200
+ else
201
+ false
202
+ end
203
+ when :Object
204
+ # generic object (usually a Hash), return directly
205
+ value
206
+ when /\AArray<(?<inner_type>.+)>\z/
207
+ inner_type = Regexp.last_match[:inner_type]
208
+ value.map { |v| _deserialize(inner_type, v) }
209
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
210
+ k_type = Regexp.last_match[:k_type]
211
+ v_type = Regexp.last_match[:v_type]
212
+ {}.tap do |hash|
213
+ value.each do |k, v|
214
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
215
+ end
216
+ end
217
+ else # model
218
+ # models (e.g. Pet) or oneOf
219
+ klass = OneSignal.const_get(type)
220
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
221
+ end
222
+ end
223
+
224
+ # Returns the string representation of the object
225
+ # @return [String] String presentation of the object
226
+ def to_s
227
+ to_hash.to_s
228
+ end
229
+
230
+ # to_body is an alias to to_hash (backward compatibility)
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_body
233
+ to_hash
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = self.send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+
270
+ end
271
+
272
+ end
@@ -0,0 +1,284 @@
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 One stage of an Auto Warm Up campaign's sending schedule.
17
+ class EmailWarmUpStage
18
+ # ISO 8601 timestamp for the start of this stage. Sending for this stage will not begin before this time.
19
+ attr_accessor :start
20
+
21
+ # ISO 8601 timestamp for the end of this stage. This stage's quota is expected to be sent by this time.
22
+ attr_accessor :_end
23
+
24
+ # Number of emails to send during this stage.
25
+ attr_accessor :quota
26
+
27
+ # Whether this stage has been picked up and acknowledged by the warm-up scheduler. Not accepted on create. This is only present when reading back a campaign.
28
+ attr_accessor :acked
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'start' => :'start',
34
+ :'_end' => :'end',
35
+ :'quota' => :'quota',
36
+ :'acked' => :'acked'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'start' => :'Time',
49
+ :'_end' => :'Time',
50
+ :'quota' => :'Integer',
51
+ :'acked' => :'Boolean'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailWarmUpStage` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailWarmUpStage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'start')
77
+ self.start = attributes[:'start']
78
+ end
79
+
80
+ if attributes.key?(:'_end')
81
+ self._end = attributes[:'_end']
82
+ end
83
+
84
+ if attributes.key?(:'quota')
85
+ self.quota = attributes[:'quota']
86
+ end
87
+
88
+ if attributes.key?(:'acked')
89
+ self.acked = attributes[:'acked']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ if @start.nil?
98
+ invalid_properties.push('invalid value for "start", start cannot be nil.')
99
+ end
100
+
101
+ if @_end.nil?
102
+ invalid_properties.push('invalid value for "_end", _end cannot be nil.')
103
+ end
104
+
105
+ if @quota.nil?
106
+ invalid_properties.push('invalid value for "quota", quota cannot be nil.')
107
+ end
108
+
109
+ if @quota < 0
110
+ invalid_properties.push('invalid value for "quota", must be greater than or equal to 0.')
111
+ end
112
+
113
+ invalid_properties
114
+ end
115
+
116
+ # Check to see if the all the properties in the model are valid
117
+ # @return true if the model is valid
118
+ def valid?
119
+ return false if @start.nil?
120
+ return false if @_end.nil?
121
+ return false if @quota.nil?
122
+ return false if @quota < 0
123
+ true
124
+ end
125
+
126
+ # Custom attribute writer method with validation
127
+ # @param [Object] quota Value to be assigned
128
+ def quota=(quota)
129
+ if quota.nil?
130
+ fail ArgumentError, 'quota cannot be nil'
131
+ end
132
+
133
+ if quota < 0
134
+ fail ArgumentError, 'invalid value for "quota", must be greater than or equal to 0.'
135
+ end
136
+
137
+ @quota = quota
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ start == o.start &&
146
+ _end == o._end &&
147
+ quota == o.quota &&
148
+ acked == o.acked
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [start, _end, quota, acked].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ new.build_from_hash(attributes)
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+ attributes = attributes.transform_keys(&:to_sym)
176
+ self.class.openapi_types.each_pair do |key, type|
177
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
178
+ self.send("#{key}=", nil)
179
+ elsif type =~ /\AArray<(.*)>/i
180
+ # check to ensure the input is an array given that the attribute
181
+ # is documented as an array but the input is not
182
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
183
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
184
+ end
185
+ elsif !attributes[self.class.attribute_map[key]].nil?
186
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
187
+ end
188
+ end
189
+
190
+ self
191
+ end
192
+
193
+ # Deserializes the data based on type
194
+ # @param string type Data type
195
+ # @param string value Value to be deserialized
196
+ # @return [Object] Deserialized data
197
+ def _deserialize(type, value)
198
+ case type.to_sym
199
+ when :Time
200
+ Time.parse(value)
201
+ when :Date
202
+ Date.parse(value)
203
+ when :String
204
+ value.to_s
205
+ when :Integer
206
+ value.to_i
207
+ when :Float
208
+ value.to_f
209
+ when :Boolean
210
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
211
+ true
212
+ else
213
+ false
214
+ end
215
+ when :Object
216
+ # generic object (usually a Hash), return directly
217
+ value
218
+ when /\AArray<(?<inner_type>.+)>\z/
219
+ inner_type = Regexp.last_match[:inner_type]
220
+ value.map { |v| _deserialize(inner_type, v) }
221
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
222
+ k_type = Regexp.last_match[:k_type]
223
+ v_type = Regexp.last_match[:v_type]
224
+ {}.tap do |hash|
225
+ value.each do |k, v|
226
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
227
+ end
228
+ end
229
+ else # model
230
+ # models (e.g. Pet) or oneOf
231
+ klass = OneSignal.const_get(type)
232
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ if value.nil?
255
+ is_nullable = self.class.openapi_nullable.include?(attr)
256
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
257
+ end
258
+
259
+ hash[param] = _to_hash(value)
260
+ end
261
+ hash
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value)
269
+ if value.is_a?(Array)
270
+ value.compact.map { |v| _to_hash(v) }
271
+ elsif value.is_a?(Hash)
272
+ {}.tap do |hash|
273
+ value.each { |k, v| hash[k] = _to_hash(v) }
274
+ end
275
+ elsif value.respond_to? :to_hash
276
+ value.to_hash
277
+ else
278
+ value
279
+ end
280
+ end
281
+
282
+ end
283
+
284
+ end