onesignal 5.11.2 → 5.12.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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -3
  5. data/docs/CreateJourneyRequest.md +30 -0
  6. data/docs/DefaultApi.md +563 -0
  7. data/docs/Journey.md +48 -0
  8. data/docs/JourneyAudience.md +28 -0
  9. data/docs/JourneyBranch.md +24 -0
  10. data/docs/JourneyBranchStats.md +18 -0
  11. data/docs/JourneyCondition.md +34 -0
  12. data/docs/JourneyEarlyExit.md +20 -0
  13. data/docs/JourneyEarlyExitRules.md +24 -0
  14. data/docs/JourneyEarlyExitRulesOnEvent.md +18 -0
  15. data/docs/JourneyEarlyExitRulesOnSegment.md +18 -0
  16. data/docs/JourneyEventAttribute.md +22 -0
  17. data/docs/JourneyListAudience.md +18 -0
  18. data/docs/JourneyListItem.md +40 -0
  19. data/docs/JourneyListResponse.md +22 -0
  20. data/docs/JourneyMessageStats.md +18 -0
  21. data/docs/JourneyNode.md +50 -0
  22. data/docs/JourneyNodeStats.md +26 -0
  23. data/docs/JourneyReentryRules.md +18 -0
  24. data/docs/JourneySchedule.md +22 -0
  25. data/docs/JourneyStats.md +28 -0
  26. data/docs/JourneyTimePoint.md +20 -0
  27. data/docs/JourneyTimeWindow.md +22 -0
  28. data/docs/JourneyWaitUntilExpiration.md +20 -0
  29. data/docs/UpdateJourneyNodeRequest.md +48 -0
  30. data/docs/UpdateJourneyRequest.md +34 -0
  31. data/lib/onesignal/api/default_api.rb +524 -0
  32. data/lib/onesignal/api_client.rb +1 -1
  33. data/lib/onesignal/models/create_journey_request.rb +287 -0
  34. data/lib/onesignal/models/journey.rb +409 -0
  35. data/lib/onesignal/models/journey_audience.rb +316 -0
  36. data/lib/onesignal/models/journey_branch.rb +250 -0
  37. data/lib/onesignal/models/journey_branch_stats.rb +220 -0
  38. data/lib/onesignal/models/journey_condition.rb +360 -0
  39. data/lib/onesignal/models/journey_early_exit.rb +231 -0
  40. data/lib/onesignal/models/journey_early_exit_rules.rb +251 -0
  41. data/lib/onesignal/models/journey_early_exit_rules_on_event.rb +224 -0
  42. data/lib/onesignal/models/journey_early_exit_rules_on_segment.rb +221 -0
  43. data/lib/onesignal/models/journey_event_attribute.rb +283 -0
  44. data/lib/onesignal/models/journey_list_audience.rb +254 -0
  45. data/lib/onesignal/models/journey_list_item.rb +366 -0
  46. data/lib/onesignal/models/journey_list_response.rb +241 -0
  47. data/lib/onesignal/models/journey_message_stats.rb +222 -0
  48. data/lib/onesignal/models/journey_node.rb +480 -0
  49. data/lib/onesignal/models/journey_node_stats.rb +293 -0
  50. data/lib/onesignal/models/journey_reentry_rules.rb +236 -0
  51. data/lib/onesignal/models/journey_schedule.rb +243 -0
  52. data/lib/onesignal/models/journey_stats.rb +274 -0
  53. data/lib/onesignal/models/journey_time_point.rb +277 -0
  54. data/lib/onesignal/models/journey_time_window.rb +266 -0
  55. data/lib/onesignal/models/journey_wait_until_expiration.rb +256 -0
  56. data/lib/onesignal/models/update_journey_node_request.rb +454 -0
  57. data/lib/onesignal/models/update_journey_request.rb +337 -0
  58. data/lib/onesignal/version.rb +1 -1
  59. data/lib/onesignal.rb +25 -0
  60. data/spec/api/default_api_spec.rb +95 -0
  61. data/spec/models/create_journey_request_spec.rb +69 -0
  62. data/spec/models/journey_audience_spec.rb +67 -0
  63. data/spec/models/journey_branch_spec.rb +51 -0
  64. data/spec/models/journey_branch_stats_spec.rb +33 -0
  65. data/spec/models/journey_condition_spec.rb +89 -0
  66. data/spec/models/journey_early_exit_rules_on_event_spec.rb +33 -0
  67. data/spec/models/journey_early_exit_rules_on_segment_spec.rb +33 -0
  68. data/spec/models/journey_early_exit_rules_spec.rb +51 -0
  69. data/spec/models/journey_early_exit_spec.rb +39 -0
  70. data/spec/models/journey_event_attribute_spec.rb +49 -0
  71. data/spec/models/journey_list_audience_spec.rb +37 -0
  72. data/spec/models/journey_list_item_spec.rb +103 -0
  73. data/spec/models/journey_list_response_spec.rb +45 -0
  74. data/spec/models/journey_message_stats_spec.rb +33 -0
  75. data/spec/models/journey_node_spec.rb +137 -0
  76. data/spec/models/journey_node_stats_spec.rb +61 -0
  77. data/spec/models/journey_reentry_rules_spec.rb +33 -0
  78. data/spec/models/journey_schedule_spec.rb +45 -0
  79. data/spec/models/journey_spec.rb +127 -0
  80. data/spec/models/journey_stats_spec.rb +63 -0
  81. data/spec/models/journey_time_point_spec.rb +39 -0
  82. data/spec/models/journey_time_window_spec.rb +45 -0
  83. data/spec/models/journey_wait_until_expiration_spec.rb +39 -0
  84. data/spec/models/update_journey_node_request_spec.rb +127 -0
  85. data/spec/models/update_journey_request_spec.rb +85 -0
  86. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
  87. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/gem_make.out +5 -5
  88. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/gem_make.out +5 -5
  89. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/mkmf.log +3 -3
  90. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  91. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.4.0/gem_make.out +5 -5
  92. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  93. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
  94. metadata +102 -2
@@ -0,0 +1,256 @@
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
+ # Optional expiration timer. null waits indefinitely.
17
+ class JourneyWaitUntilExpiration
18
+ # Seconds to wait before the timer fires. Minimum 60, maximum 31556952 (1 year).
19
+ attr_accessor :duration_seconds
20
+
21
+ # When true, the user exits the journey when the timer fires; when false, the user continues to convergence.
22
+ attr_accessor :exits
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'duration_seconds' => :'duration_seconds',
28
+ :'exits' => :'exits'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'duration_seconds' => :'Integer',
41
+ :'exits' => :'Boolean'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ :'duration_seconds',
49
+ :'exits'
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::JourneyWaitUntilExpiration` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::JourneyWaitUntilExpiration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'duration_seconds')
69
+ self.duration_seconds = attributes[:'duration_seconds']
70
+ end
71
+
72
+ if attributes.key?(:'exits')
73
+ self.exits = attributes[:'exits']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ if !@duration_seconds.nil? && @duration_seconds > 31556952
82
+ invalid_properties.push('invalid value for "duration_seconds", must be smaller than or equal to 31556952.')
83
+ end
84
+
85
+ if !@duration_seconds.nil? && @duration_seconds < 60
86
+ invalid_properties.push('invalid value for "duration_seconds", must be greater than or equal to 60.')
87
+ end
88
+
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ return false if !@duration_seconds.nil? && @duration_seconds > 31556952
96
+ return false if !@duration_seconds.nil? && @duration_seconds < 60
97
+ true
98
+ end
99
+
100
+ # Custom attribute writer method with validation
101
+ # @param [Object] duration_seconds Value to be assigned
102
+ def duration_seconds=(duration_seconds)
103
+ if !duration_seconds.nil? && duration_seconds > 31556952
104
+ fail ArgumentError, 'invalid value for "duration_seconds", must be smaller than or equal to 31556952.'
105
+ end
106
+
107
+ if !duration_seconds.nil? && duration_seconds < 60
108
+ fail ArgumentError, 'invalid value for "duration_seconds", must be greater than or equal to 60.'
109
+ end
110
+
111
+ @duration_seconds = duration_seconds
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ duration_seconds == o.duration_seconds &&
120
+ exits == o.exits
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(o)
126
+ self == o
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [duration_seconds, exits].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ new.build_from_hash(attributes)
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ attributes = attributes.transform_keys(&:to_sym)
148
+ self.class.openapi_types.each_pair do |key, type|
149
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
150
+ self.send("#{key}=", nil)
151
+ elsif type =~ /\AArray<(.*)>/i
152
+ # check to ensure the input is an array given that the attribute
153
+ # is documented as an array but the input is not
154
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
155
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
156
+ end
157
+ elsif !attributes[self.class.attribute_map[key]].nil?
158
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
159
+ end
160
+ end
161
+
162
+ self
163
+ end
164
+
165
+ # Deserializes the data based on type
166
+ # @param string type Data type
167
+ # @param string value Value to be deserialized
168
+ # @return [Object] Deserialized data
169
+ def _deserialize(type, value)
170
+ case type.to_sym
171
+ when :Time
172
+ Time.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :Boolean
182
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when :Object
188
+ # generic object (usually a Hash), return directly
189
+ value
190
+ when /\AArray<(?<inner_type>.+)>\z/
191
+ inner_type = Regexp.last_match[:inner_type]
192
+ value.map { |v| _deserialize(inner_type, v) }
193
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
194
+ k_type = Regexp.last_match[:k_type]
195
+ v_type = Regexp.last_match[:v_type]
196
+ {}.tap do |hash|
197
+ value.each do |k, v|
198
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
199
+ end
200
+ end
201
+ else # model
202
+ # models (e.g. Pet) or oneOf
203
+ klass = OneSignal.const_get(type)
204
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ end
@@ -0,0 +1,454 @@
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
+ # Node fields to change, merged onto the current node. Send only the fields you want to change. The node's kind and id cannot be changed. Send null to clear a nullable field. Which other fields apply depends on the node's kind, matching JourneyNode.
17
+ class UpdateJourneyNodeRequest
18
+ # Optional client-assigned identifier, unique within the journey. Use it to reference this node from elsewhere in the same request. Persisted and returned on reads.
19
+ attr_accessor :client_node_id
20
+
21
+ # Optional free-text label, up to 255 characters. Stored and returned as-is with no effect on journey behavior.
22
+ attr_accessor :annotation
23
+
24
+ # wait nodes: seconds to hold the user. Minimum 60, maximum 31556952 (1 year).
25
+ attr_accessor :duration_seconds
26
+
27
+ # time_window nodes: schedule_in_timezone uses the configured windows; last_active_time holds relative to the user's last active time.
28
+ attr_accessor :relative_to
29
+
30
+ # time_window nodes: one or more time windows. A window with no day_of_week applies to every day. Required when relative_to is schedule_in_timezone; omit when it is last_active_time.
31
+ attr_accessor :windows
32
+
33
+ # time_window nodes: IANA timezone identifier used when the user's timezone is unavailable.
34
+ attr_accessor :time_zone
35
+
36
+ # time_window nodes: when true, uses the user's timezone if available.
37
+ attr_accessor :use_user_time_zone
38
+
39
+ # send_push, send_email, and send_sms nodes: UUID of the template to send.
40
+ attr_accessor :template_id
41
+
42
+ # send_iam nodes: UUID of the in-app message to send.
43
+ attr_accessor :iam_id
44
+
45
+ # send_iam nodes: optional time-to-live for the in-app message, in seconds.
46
+ attr_accessor :user_ttl_seconds
47
+
48
+ # send_webhook nodes: UUID of the webhook to send.
49
+ attr_accessor :webhook_id
50
+
51
+ # tag nodes: tag key-value pairs to assign. An empty string value removes the tag. Keys are limited to 255 characters and values to 1024.
52
+ attr_accessor :assignments
53
+
54
+ # split_range nodes: when true, assigns each user to a branch at random on entry. Defaults to false.
55
+ attr_accessor :randomize_on_entry
56
+
57
+ # Branching nodes: nested branches. split_range requires 2-20 weighted branches that sum to 100. yes_no requires exactly 2 branches. wait_until requires 1-10 condition branches.
58
+ attr_accessor :branches
59
+
60
+ attr_accessor :expiration
61
+
62
+ # Optional optimistic-concurrency token. Pass the concurrency_key from a prior fetch to reject the update with 409 if the journey changed. Omit to skip the check. It is not merged onto the node.
63
+ attr_accessor :concurrency_key
64
+
65
+ class EnumAttributeValidator
66
+ attr_reader :datatype
67
+ attr_reader :allowable_values
68
+
69
+ def initialize(datatype, allowable_values)
70
+ @allowable_values = allowable_values.map do |value|
71
+ case datatype.to_s
72
+ when /Integer/i
73
+ value.to_i
74
+ when /Float/i
75
+ value.to_f
76
+ else
77
+ value
78
+ end
79
+ end
80
+ end
81
+
82
+ def valid?(value)
83
+ !value || allowable_values.include?(value)
84
+ end
85
+ end
86
+
87
+ # Attribute mapping from ruby-style variable name to JSON key.
88
+ def self.attribute_map
89
+ {
90
+ :'client_node_id' => :'client_node_id',
91
+ :'annotation' => :'annotation',
92
+ :'duration_seconds' => :'duration_seconds',
93
+ :'relative_to' => :'relative_to',
94
+ :'windows' => :'windows',
95
+ :'time_zone' => :'time_zone',
96
+ :'use_user_time_zone' => :'use_user_time_zone',
97
+ :'template_id' => :'template_id',
98
+ :'iam_id' => :'iam_id',
99
+ :'user_ttl_seconds' => :'user_ttl_seconds',
100
+ :'webhook_id' => :'webhook_id',
101
+ :'assignments' => :'assignments',
102
+ :'randomize_on_entry' => :'randomize_on_entry',
103
+ :'branches' => :'branches',
104
+ :'expiration' => :'expiration',
105
+ :'concurrency_key' => :'concurrency_key'
106
+ }
107
+ end
108
+
109
+ # Returns all the JSON keys this model knows about
110
+ def self.acceptable_attributes
111
+ attribute_map.values
112
+ end
113
+
114
+ # Attribute type mapping.
115
+ def self.openapi_types
116
+ {
117
+ :'client_node_id' => :'String',
118
+ :'annotation' => :'String',
119
+ :'duration_seconds' => :'Integer',
120
+ :'relative_to' => :'String',
121
+ :'windows' => :'Array<JourneyTimeWindow>',
122
+ :'time_zone' => :'String',
123
+ :'use_user_time_zone' => :'Boolean',
124
+ :'template_id' => :'String',
125
+ :'iam_id' => :'String',
126
+ :'user_ttl_seconds' => :'Integer',
127
+ :'webhook_id' => :'String',
128
+ :'assignments' => :'Hash<String, String>',
129
+ :'randomize_on_entry' => :'Boolean',
130
+ :'branches' => :'Array<JourneyBranch>',
131
+ :'expiration' => :'JourneyWaitUntilExpiration',
132
+ :'concurrency_key' => :'String'
133
+ }
134
+ end
135
+
136
+ # List of attributes with nullable: true
137
+ def self.openapi_nullable
138
+ Set.new([
139
+ :'duration_seconds',
140
+ :'use_user_time_zone',
141
+ :'user_ttl_seconds',
142
+ :'randomize_on_entry',
143
+ :'expiration',
144
+ :'concurrency_key'
145
+ ])
146
+ end
147
+
148
+ # Initializes the object
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ def initialize(attributes = {})
151
+ if (!attributes.is_a?(Hash))
152
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::UpdateJourneyNodeRequest` initialize method"
153
+ end
154
+
155
+ # check to see if the attribute exists and convert string to symbol for hash key
156
+ attributes = attributes.each_with_object({}) { |(k, v), h|
157
+ if (!self.class.attribute_map.key?(k.to_sym))
158
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::UpdateJourneyNodeRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
159
+ end
160
+ h[k.to_sym] = v
161
+ }
162
+
163
+ if attributes.key?(:'client_node_id')
164
+ self.client_node_id = attributes[:'client_node_id']
165
+ end
166
+
167
+ if attributes.key?(:'annotation')
168
+ self.annotation = attributes[:'annotation']
169
+ end
170
+
171
+ if attributes.key?(:'duration_seconds')
172
+ self.duration_seconds = attributes[:'duration_seconds']
173
+ end
174
+
175
+ if attributes.key?(:'relative_to')
176
+ self.relative_to = attributes[:'relative_to']
177
+ end
178
+
179
+ if attributes.key?(:'windows')
180
+ if (value = attributes[:'windows']).is_a?(Array)
181
+ self.windows = value
182
+ end
183
+ end
184
+
185
+ if attributes.key?(:'time_zone')
186
+ self.time_zone = attributes[:'time_zone']
187
+ end
188
+
189
+ if attributes.key?(:'use_user_time_zone')
190
+ self.use_user_time_zone = attributes[:'use_user_time_zone']
191
+ end
192
+
193
+ if attributes.key?(:'template_id')
194
+ self.template_id = attributes[:'template_id']
195
+ end
196
+
197
+ if attributes.key?(:'iam_id')
198
+ self.iam_id = attributes[:'iam_id']
199
+ end
200
+
201
+ if attributes.key?(:'user_ttl_seconds')
202
+ self.user_ttl_seconds = attributes[:'user_ttl_seconds']
203
+ end
204
+
205
+ if attributes.key?(:'webhook_id')
206
+ self.webhook_id = attributes[:'webhook_id']
207
+ end
208
+
209
+ if attributes.key?(:'assignments')
210
+ if (value = attributes[:'assignments']).is_a?(Hash)
211
+ self.assignments = value
212
+ end
213
+ end
214
+
215
+ if attributes.key?(:'randomize_on_entry')
216
+ self.randomize_on_entry = attributes[:'randomize_on_entry']
217
+ end
218
+
219
+ if attributes.key?(:'branches')
220
+ if (value = attributes[:'branches']).is_a?(Array)
221
+ self.branches = value
222
+ end
223
+ end
224
+
225
+ if attributes.key?(:'expiration')
226
+ self.expiration = attributes[:'expiration']
227
+ end
228
+
229
+ if attributes.key?(:'concurrency_key')
230
+ self.concurrency_key = attributes[:'concurrency_key']
231
+ end
232
+ end
233
+
234
+ # Show invalid properties with the reasons. Usually used together with valid?
235
+ # @return Array for valid properties with the reasons
236
+ def list_invalid_properties
237
+ invalid_properties = Array.new
238
+ if !@duration_seconds.nil? && @duration_seconds > 31556952
239
+ invalid_properties.push('invalid value for "duration_seconds", must be smaller than or equal to 31556952.')
240
+ end
241
+
242
+ if !@duration_seconds.nil? && @duration_seconds < 60
243
+ invalid_properties.push('invalid value for "duration_seconds", must be greater than or equal to 60.')
244
+ end
245
+
246
+ if !@user_ttl_seconds.nil? && @user_ttl_seconds < 1
247
+ invalid_properties.push('invalid value for "user_ttl_seconds", must be greater than or equal to 1.')
248
+ end
249
+
250
+ invalid_properties
251
+ end
252
+
253
+ # Check to see if the all the properties in the model are valid
254
+ # @return true if the model is valid
255
+ def valid?
256
+ return false if !@duration_seconds.nil? && @duration_seconds > 31556952
257
+ return false if !@duration_seconds.nil? && @duration_seconds < 60
258
+ relative_to_validator = EnumAttributeValidator.new('String', ["schedule_in_timezone", "last_active_time"])
259
+ return false unless relative_to_validator.valid?(@relative_to)
260
+ return false if !@user_ttl_seconds.nil? && @user_ttl_seconds < 1
261
+ true
262
+ end
263
+
264
+ # Custom attribute writer method with validation
265
+ # @param [Object] duration_seconds Value to be assigned
266
+ def duration_seconds=(duration_seconds)
267
+ if !duration_seconds.nil? && duration_seconds > 31556952
268
+ fail ArgumentError, 'invalid value for "duration_seconds", must be smaller than or equal to 31556952.'
269
+ end
270
+
271
+ if !duration_seconds.nil? && duration_seconds < 60
272
+ fail ArgumentError, 'invalid value for "duration_seconds", must be greater than or equal to 60.'
273
+ end
274
+
275
+ @duration_seconds = duration_seconds
276
+ end
277
+
278
+ # Custom attribute writer method checking allowed values (enum).
279
+ # @param [Object] relative_to Object to be assigned
280
+ def relative_to=(relative_to)
281
+ validator = EnumAttributeValidator.new('String', ["schedule_in_timezone", "last_active_time"])
282
+ unless validator.valid?(relative_to)
283
+ fail ArgumentError, "invalid value for \"relative_to\", must be one of #{validator.allowable_values}."
284
+ end
285
+ @relative_to = relative_to
286
+ end
287
+
288
+ # Custom attribute writer method with validation
289
+ # @param [Object] user_ttl_seconds Value to be assigned
290
+ def user_ttl_seconds=(user_ttl_seconds)
291
+ if !user_ttl_seconds.nil? && user_ttl_seconds < 1
292
+ fail ArgumentError, 'invalid value for "user_ttl_seconds", must be greater than or equal to 1.'
293
+ end
294
+
295
+ @user_ttl_seconds = user_ttl_seconds
296
+ end
297
+
298
+ # Checks equality by comparing each attribute.
299
+ # @param [Object] Object to be compared
300
+ def ==(o)
301
+ return true if self.equal?(o)
302
+ self.class == o.class &&
303
+ client_node_id == o.client_node_id &&
304
+ annotation == o.annotation &&
305
+ duration_seconds == o.duration_seconds &&
306
+ relative_to == o.relative_to &&
307
+ windows == o.windows &&
308
+ time_zone == o.time_zone &&
309
+ use_user_time_zone == o.use_user_time_zone &&
310
+ template_id == o.template_id &&
311
+ iam_id == o.iam_id &&
312
+ user_ttl_seconds == o.user_ttl_seconds &&
313
+ webhook_id == o.webhook_id &&
314
+ assignments == o.assignments &&
315
+ randomize_on_entry == o.randomize_on_entry &&
316
+ branches == o.branches &&
317
+ expiration == o.expiration &&
318
+ concurrency_key == o.concurrency_key
319
+ end
320
+
321
+ # @see the `==` method
322
+ # @param [Object] Object to be compared
323
+ def eql?(o)
324
+ self == o
325
+ end
326
+
327
+ # Calculates hash code according to all attributes.
328
+ # @return [Integer] Hash code
329
+ def hash
330
+ [client_node_id, annotation, duration_seconds, relative_to, windows, time_zone, use_user_time_zone, template_id, iam_id, user_ttl_seconds, webhook_id, assignments, randomize_on_entry, branches, expiration, concurrency_key].hash
331
+ end
332
+
333
+ # Builds the object from hash
334
+ # @param [Hash] attributes Model attributes in the form of hash
335
+ # @return [Object] Returns the model itself
336
+ def self.build_from_hash(attributes)
337
+ new.build_from_hash(attributes)
338
+ end
339
+
340
+ # Builds the object from hash
341
+ # @param [Hash] attributes Model attributes in the form of hash
342
+ # @return [Object] Returns the model itself
343
+ def build_from_hash(attributes)
344
+ return nil unless attributes.is_a?(Hash)
345
+ attributes = attributes.transform_keys(&:to_sym)
346
+ self.class.openapi_types.each_pair do |key, type|
347
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
348
+ self.send("#{key}=", nil)
349
+ elsif type =~ /\AArray<(.*)>/i
350
+ # check to ensure the input is an array given that the attribute
351
+ # is documented as an array but the input is not
352
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
353
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
354
+ end
355
+ elsif !attributes[self.class.attribute_map[key]].nil?
356
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
357
+ end
358
+ end
359
+
360
+ self
361
+ end
362
+
363
+ # Deserializes the data based on type
364
+ # @param string type Data type
365
+ # @param string value Value to be deserialized
366
+ # @return [Object] Deserialized data
367
+ def _deserialize(type, value)
368
+ case type.to_sym
369
+ when :Time
370
+ Time.parse(value)
371
+ when :Date
372
+ Date.parse(value)
373
+ when :String
374
+ value.to_s
375
+ when :Integer
376
+ value.to_i
377
+ when :Float
378
+ value.to_f
379
+ when :Boolean
380
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
381
+ true
382
+ else
383
+ false
384
+ end
385
+ when :Object
386
+ # generic object (usually a Hash), return directly
387
+ value
388
+ when /\AArray<(?<inner_type>.+)>\z/
389
+ inner_type = Regexp.last_match[:inner_type]
390
+ value.map { |v| _deserialize(inner_type, v) }
391
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
392
+ k_type = Regexp.last_match[:k_type]
393
+ v_type = Regexp.last_match[:v_type]
394
+ {}.tap do |hash|
395
+ value.each do |k, v|
396
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
397
+ end
398
+ end
399
+ else # model
400
+ # models (e.g. Pet) or oneOf
401
+ klass = OneSignal.const_get(type)
402
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
403
+ end
404
+ end
405
+
406
+ # Returns the string representation of the object
407
+ # @return [String] String presentation of the object
408
+ def to_s
409
+ to_hash.to_s
410
+ end
411
+
412
+ # to_body is an alias to to_hash (backward compatibility)
413
+ # @return [Hash] Returns the object in the form of hash
414
+ def to_body
415
+ to_hash
416
+ end
417
+
418
+ # Returns the object in the form of hash
419
+ # @return [Hash] Returns the object in the form of hash
420
+ def to_hash
421
+ hash = {}
422
+ self.class.attribute_map.each_pair do |attr, param|
423
+ value = self.send(attr)
424
+ if value.nil?
425
+ is_nullable = self.class.openapi_nullable.include?(attr)
426
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
427
+ end
428
+
429
+ hash[param] = _to_hash(value)
430
+ end
431
+ hash
432
+ end
433
+
434
+ # Outputs non-array value in the form of hash
435
+ # For object, use to_hash. Otherwise, just return the value
436
+ # @param [Object] value Any valid value
437
+ # @return [Hash] Returns the value in the form of hash
438
+ def _to_hash(value)
439
+ if value.is_a?(Array)
440
+ value.compact.map { |v| _to_hash(v) }
441
+ elsif value.is_a?(Hash)
442
+ {}.tap do |hash|
443
+ value.each { |k, v| hash[k] = _to_hash(v) }
444
+ end
445
+ elsif value.respond_to? :to_hash
446
+ value.to_hash
447
+ else
448
+ value
449
+ end
450
+ end
451
+
452
+ end
453
+
454
+ end