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,287 @@
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
+ # Writable fields for Create journey. Journeys are always created in the draft state. Server-controlled fields such as state or id are rejected.
17
+ class CreateJourneyRequest
18
+ # Journey name, up to 300 characters.
19
+ attr_accessor :name
20
+
21
+ # Optional journey description, up to 1024 characters.
22
+ attr_accessor :description
23
+
24
+ attr_accessor :audience
25
+
26
+ attr_accessor :early_exit
27
+
28
+ attr_accessor :reentry_rules
29
+
30
+ attr_accessor :schedule
31
+
32
+ # Ordered list of journey nodes. Server-assigned id fields are rejected on create.
33
+ attr_accessor :nodes
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'name' => :'name',
39
+ :'description' => :'description',
40
+ :'audience' => :'audience',
41
+ :'early_exit' => :'early_exit',
42
+ :'reentry_rules' => :'reentry_rules',
43
+ :'schedule' => :'schedule',
44
+ :'nodes' => :'nodes'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'name' => :'String',
57
+ :'description' => :'String',
58
+ :'audience' => :'JourneyAudience',
59
+ :'early_exit' => :'JourneyEarlyExit',
60
+ :'reentry_rules' => :'JourneyReentryRules',
61
+ :'schedule' => :'JourneySchedule',
62
+ :'nodes' => :'Array<JourneyNode>'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ :'description',
70
+ :'early_exit',
71
+ :'reentry_rules',
72
+ :'schedule',
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::CreateJourneyRequest` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::CreateJourneyRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'name')
92
+ self.name = attributes[:'name']
93
+ end
94
+
95
+ if attributes.key?(:'description')
96
+ self.description = attributes[:'description']
97
+ end
98
+
99
+ if attributes.key?(:'audience')
100
+ self.audience = attributes[:'audience']
101
+ end
102
+
103
+ if attributes.key?(:'early_exit')
104
+ self.early_exit = attributes[:'early_exit']
105
+ end
106
+
107
+ if attributes.key?(:'reentry_rules')
108
+ self.reentry_rules = attributes[:'reentry_rules']
109
+ end
110
+
111
+ if attributes.key?(:'schedule')
112
+ self.schedule = attributes[:'schedule']
113
+ end
114
+
115
+ if attributes.key?(:'nodes')
116
+ if (value = attributes[:'nodes']).is_a?(Array)
117
+ self.nodes = value
118
+ end
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ if @name.nil?
127
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
128
+ end
129
+
130
+ invalid_properties
131
+ end
132
+
133
+ # Check to see if the all the properties in the model are valid
134
+ # @return true if the model is valid
135
+ def valid?
136
+ return false if @name.nil?
137
+ true
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
+ name == o.name &&
146
+ description == o.description &&
147
+ audience == o.audience &&
148
+ early_exit == o.early_exit &&
149
+ reentry_rules == o.reentry_rules &&
150
+ schedule == o.schedule &&
151
+ nodes == o.nodes
152
+ end
153
+
154
+ # @see the `==` method
155
+ # @param [Object] Object to be compared
156
+ def eql?(o)
157
+ self == o
158
+ end
159
+
160
+ # Calculates hash code according to all attributes.
161
+ # @return [Integer] Hash code
162
+ def hash
163
+ [name, description, audience, early_exit, reentry_rules, schedule, nodes].hash
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def self.build_from_hash(attributes)
170
+ new.build_from_hash(attributes)
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def build_from_hash(attributes)
177
+ return nil unless attributes.is_a?(Hash)
178
+ attributes = attributes.transform_keys(&:to_sym)
179
+ self.class.openapi_types.each_pair do |key, type|
180
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
181
+ self.send("#{key}=", nil)
182
+ elsif type =~ /\AArray<(.*)>/i
183
+ # check to ensure the input is an array given that the attribute
184
+ # is documented as an array but the input is not
185
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
186
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
187
+ end
188
+ elsif !attributes[self.class.attribute_map[key]].nil?
189
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
190
+ end
191
+ end
192
+
193
+ self
194
+ end
195
+
196
+ # Deserializes the data based on type
197
+ # @param string type Data type
198
+ # @param string value Value to be deserialized
199
+ # @return [Object] Deserialized data
200
+ def _deserialize(type, value)
201
+ case type.to_sym
202
+ when :Time
203
+ Time.parse(value)
204
+ when :Date
205
+ Date.parse(value)
206
+ when :String
207
+ value.to_s
208
+ when :Integer
209
+ value.to_i
210
+ when :Float
211
+ value.to_f
212
+ when :Boolean
213
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
214
+ true
215
+ else
216
+ false
217
+ end
218
+ when :Object
219
+ # generic object (usually a Hash), return directly
220
+ value
221
+ when /\AArray<(?<inner_type>.+)>\z/
222
+ inner_type = Regexp.last_match[:inner_type]
223
+ value.map { |v| _deserialize(inner_type, v) }
224
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
225
+ k_type = Regexp.last_match[:k_type]
226
+ v_type = Regexp.last_match[:v_type]
227
+ {}.tap do |hash|
228
+ value.each do |k, v|
229
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
230
+ end
231
+ end
232
+ else # model
233
+ # models (e.g. Pet) or oneOf
234
+ klass = OneSignal.const_get(type)
235
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
236
+ end
237
+ end
238
+
239
+ # Returns the string representation of the object
240
+ # @return [String] String presentation of the object
241
+ def to_s
242
+ to_hash.to_s
243
+ end
244
+
245
+ # to_body is an alias to to_hash (backward compatibility)
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_body
248
+ to_hash
249
+ end
250
+
251
+ # Returns the object in the form of hash
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_hash
254
+ hash = {}
255
+ self.class.attribute_map.each_pair do |attr, param|
256
+ value = self.send(attr)
257
+ if value.nil?
258
+ is_nullable = self.class.openapi_nullable.include?(attr)
259
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
260
+ end
261
+
262
+ hash[param] = _to_hash(value)
263
+ end
264
+ hash
265
+ end
266
+
267
+ # Outputs non-array value in the form of hash
268
+ # For object, use to_hash. Otherwise, just return the value
269
+ # @param [Object] value Any valid value
270
+ # @return [Hash] Returns the value in the form of hash
271
+ def _to_hash(value)
272
+ if value.is_a?(Array)
273
+ value.compact.map { |v| _to_hash(v) }
274
+ elsif value.is_a?(Hash)
275
+ {}.tap do |hash|
276
+ value.each { |k, v| hash[k] = _to_hash(v) }
277
+ end
278
+ elsif value.respond_to? :to_hash
279
+ value.to_hash
280
+ else
281
+ value
282
+ end
283
+ end
284
+
285
+ end
286
+
287
+ end
@@ -0,0 +1,409 @@
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
+ # Full journey representation returned by the detail, create, and update endpoints.
17
+ class Journey
18
+ # Journey UUID. Read-only.
19
+ attr_accessor :id
20
+
21
+ # UUID of the app the journey belongs to. Read-only.
22
+ attr_accessor :app_id
23
+
24
+ # Journey name, up to 300 characters.
25
+ attr_accessor :name
26
+
27
+ # Journey description, up to 1024 characters. Defaults to an empty string.
28
+ attr_accessor :description
29
+
30
+ # Journey state. New journeys are created as draft. processing is transient while activation is in progress. archived is a journey that has been stopped. Change it through the state field on Update journey.
31
+ attr_accessor :state
32
+
33
+ # ISO 8601 creation time. Read-only.
34
+ attr_accessor :created_at
35
+
36
+ # ISO 8601 last-update time. Read-only.
37
+ attr_accessor :updated_at
38
+
39
+ # ISO 8601 time the journey was activated, or null. Read-only. May stay null briefly after you set state to active: activation is enqueued, and started_at populates once the journey finishes processing.
40
+ attr_accessor :started_at
41
+
42
+ # ISO 8601 time the journey was archived, or null. Read-only.
43
+ attr_accessor :archived_at
44
+
45
+ # Origin of the journey, for example public_api or dashboard. Read-only.
46
+ attr_accessor :created_source
47
+
48
+ attr_accessor :audience
49
+
50
+ attr_accessor :early_exit
51
+
52
+ attr_accessor :reentry_rules
53
+
54
+ attr_accessor :schedule
55
+
56
+ # Ordered list of journey nodes.
57
+ attr_accessor :nodes
58
+
59
+ # Opaque optimistic-concurrency token. Read-only. Pass it back on update to guard against overwriting a concurrent change (409). Send it back exactly as read; do not construct or parse it.
60
+ attr_accessor :concurrency_key
61
+
62
+ class EnumAttributeValidator
63
+ attr_reader :datatype
64
+ attr_reader :allowable_values
65
+
66
+ def initialize(datatype, allowable_values)
67
+ @allowable_values = allowable_values.map do |value|
68
+ case datatype.to_s
69
+ when /Integer/i
70
+ value.to_i
71
+ when /Float/i
72
+ value.to_f
73
+ else
74
+ value
75
+ end
76
+ end
77
+ end
78
+
79
+ def valid?(value)
80
+ !value || allowable_values.include?(value)
81
+ end
82
+ end
83
+
84
+ # Attribute mapping from ruby-style variable name to JSON key.
85
+ def self.attribute_map
86
+ {
87
+ :'id' => :'id',
88
+ :'app_id' => :'app_id',
89
+ :'name' => :'name',
90
+ :'description' => :'description',
91
+ :'state' => :'state',
92
+ :'created_at' => :'created_at',
93
+ :'updated_at' => :'updated_at',
94
+ :'started_at' => :'started_at',
95
+ :'archived_at' => :'archived_at',
96
+ :'created_source' => :'created_source',
97
+ :'audience' => :'audience',
98
+ :'early_exit' => :'early_exit',
99
+ :'reentry_rules' => :'reentry_rules',
100
+ :'schedule' => :'schedule',
101
+ :'nodes' => :'nodes',
102
+ :'concurrency_key' => :'concurrency_key'
103
+ }
104
+ end
105
+
106
+ # Returns all the JSON keys this model knows about
107
+ def self.acceptable_attributes
108
+ attribute_map.values
109
+ end
110
+
111
+ # Attribute type mapping.
112
+ def self.openapi_types
113
+ {
114
+ :'id' => :'String',
115
+ :'app_id' => :'String',
116
+ :'name' => :'String',
117
+ :'description' => :'String',
118
+ :'state' => :'String',
119
+ :'created_at' => :'String',
120
+ :'updated_at' => :'String',
121
+ :'started_at' => :'String',
122
+ :'archived_at' => :'String',
123
+ :'created_source' => :'String',
124
+ :'audience' => :'JourneyAudience',
125
+ :'early_exit' => :'JourneyEarlyExit',
126
+ :'reentry_rules' => :'JourneyReentryRules',
127
+ :'schedule' => :'JourneySchedule',
128
+ :'nodes' => :'Array<JourneyNode>',
129
+ :'concurrency_key' => :'String'
130
+ }
131
+ end
132
+
133
+ # List of attributes with nullable: true
134
+ def self.openapi_nullable
135
+ Set.new([
136
+ :'description',
137
+ :'started_at',
138
+ :'archived_at',
139
+ :'created_source',
140
+ :'early_exit',
141
+ :'reentry_rules',
142
+ :'schedule',
143
+ ])
144
+ end
145
+
146
+ # Initializes the object
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ def initialize(attributes = {})
149
+ if (!attributes.is_a?(Hash))
150
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Journey` initialize method"
151
+ end
152
+
153
+ # check to see if the attribute exists and convert string to symbol for hash key
154
+ attributes = attributes.each_with_object({}) { |(k, v), h|
155
+ if (!self.class.attribute_map.key?(k.to_sym))
156
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Journey`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
157
+ end
158
+ h[k.to_sym] = v
159
+ }
160
+
161
+ if attributes.key?(:'id')
162
+ self.id = attributes[:'id']
163
+ end
164
+
165
+ if attributes.key?(:'app_id')
166
+ self.app_id = attributes[:'app_id']
167
+ end
168
+
169
+ if attributes.key?(:'name')
170
+ self.name = attributes[:'name']
171
+ end
172
+
173
+ if attributes.key?(:'description')
174
+ self.description = attributes[:'description']
175
+ end
176
+
177
+ if attributes.key?(:'state')
178
+ self.state = attributes[:'state']
179
+ end
180
+
181
+ if attributes.key?(:'created_at')
182
+ self.created_at = attributes[:'created_at']
183
+ end
184
+
185
+ if attributes.key?(:'updated_at')
186
+ self.updated_at = attributes[:'updated_at']
187
+ end
188
+
189
+ if attributes.key?(:'started_at')
190
+ self.started_at = attributes[:'started_at']
191
+ end
192
+
193
+ if attributes.key?(:'archived_at')
194
+ self.archived_at = attributes[:'archived_at']
195
+ end
196
+
197
+ if attributes.key?(:'created_source')
198
+ self.created_source = attributes[:'created_source']
199
+ end
200
+
201
+ if attributes.key?(:'audience')
202
+ self.audience = attributes[:'audience']
203
+ end
204
+
205
+ if attributes.key?(:'early_exit')
206
+ self.early_exit = attributes[:'early_exit']
207
+ end
208
+
209
+ if attributes.key?(:'reentry_rules')
210
+ self.reentry_rules = attributes[:'reentry_rules']
211
+ end
212
+
213
+ if attributes.key?(:'schedule')
214
+ self.schedule = attributes[:'schedule']
215
+ end
216
+
217
+ if attributes.key?(:'nodes')
218
+ if (value = attributes[:'nodes']).is_a?(Array)
219
+ self.nodes = value
220
+ end
221
+ end
222
+
223
+ if attributes.key?(:'concurrency_key')
224
+ self.concurrency_key = attributes[:'concurrency_key']
225
+ end
226
+ end
227
+
228
+ # Show invalid properties with the reasons. Usually used together with valid?
229
+ # @return Array for valid properties with the reasons
230
+ def list_invalid_properties
231
+ invalid_properties = Array.new
232
+ invalid_properties
233
+ end
234
+
235
+ # Check to see if the all the properties in the model are valid
236
+ # @return true if the model is valid
237
+ def valid?
238
+ state_validator = EnumAttributeValidator.new('String', ["draft", "scheduled", "processing", "active", "archived"])
239
+ return false unless state_validator.valid?(@state)
240
+ true
241
+ end
242
+
243
+ # Custom attribute writer method checking allowed values (enum).
244
+ # @param [Object] state Object to be assigned
245
+ def state=(state)
246
+ validator = EnumAttributeValidator.new('String', ["draft", "scheduled", "processing", "active", "archived"])
247
+ unless validator.valid?(state)
248
+ fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
249
+ end
250
+ @state = state
251
+ end
252
+
253
+ # Checks equality by comparing each attribute.
254
+ # @param [Object] Object to be compared
255
+ def ==(o)
256
+ return true if self.equal?(o)
257
+ self.class == o.class &&
258
+ id == o.id &&
259
+ app_id == o.app_id &&
260
+ name == o.name &&
261
+ description == o.description &&
262
+ state == o.state &&
263
+ created_at == o.created_at &&
264
+ updated_at == o.updated_at &&
265
+ started_at == o.started_at &&
266
+ archived_at == o.archived_at &&
267
+ created_source == o.created_source &&
268
+ audience == o.audience &&
269
+ early_exit == o.early_exit &&
270
+ reentry_rules == o.reentry_rules &&
271
+ schedule == o.schedule &&
272
+ nodes == o.nodes &&
273
+ concurrency_key == o.concurrency_key
274
+ end
275
+
276
+ # @see the `==` method
277
+ # @param [Object] Object to be compared
278
+ def eql?(o)
279
+ self == o
280
+ end
281
+
282
+ # Calculates hash code according to all attributes.
283
+ # @return [Integer] Hash code
284
+ def hash
285
+ [id, app_id, name, description, state, created_at, updated_at, started_at, archived_at, created_source, audience, early_exit, reentry_rules, schedule, nodes, concurrency_key].hash
286
+ end
287
+
288
+ # Builds the object from hash
289
+ # @param [Hash] attributes Model attributes in the form of hash
290
+ # @return [Object] Returns the model itself
291
+ def self.build_from_hash(attributes)
292
+ new.build_from_hash(attributes)
293
+ end
294
+
295
+ # Builds the object from hash
296
+ # @param [Hash] attributes Model attributes in the form of hash
297
+ # @return [Object] Returns the model itself
298
+ def build_from_hash(attributes)
299
+ return nil unless attributes.is_a?(Hash)
300
+ attributes = attributes.transform_keys(&:to_sym)
301
+ self.class.openapi_types.each_pair do |key, type|
302
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
303
+ self.send("#{key}=", nil)
304
+ elsif type =~ /\AArray<(.*)>/i
305
+ # check to ensure the input is an array given that the attribute
306
+ # is documented as an array but the input is not
307
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
308
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
309
+ end
310
+ elsif !attributes[self.class.attribute_map[key]].nil?
311
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
312
+ end
313
+ end
314
+
315
+ self
316
+ end
317
+
318
+ # Deserializes the data based on type
319
+ # @param string type Data type
320
+ # @param string value Value to be deserialized
321
+ # @return [Object] Deserialized data
322
+ def _deserialize(type, value)
323
+ case type.to_sym
324
+ when :Time
325
+ Time.parse(value)
326
+ when :Date
327
+ Date.parse(value)
328
+ when :String
329
+ value.to_s
330
+ when :Integer
331
+ value.to_i
332
+ when :Float
333
+ value.to_f
334
+ when :Boolean
335
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
336
+ true
337
+ else
338
+ false
339
+ end
340
+ when :Object
341
+ # generic object (usually a Hash), return directly
342
+ value
343
+ when /\AArray<(?<inner_type>.+)>\z/
344
+ inner_type = Regexp.last_match[:inner_type]
345
+ value.map { |v| _deserialize(inner_type, v) }
346
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
347
+ k_type = Regexp.last_match[:k_type]
348
+ v_type = Regexp.last_match[:v_type]
349
+ {}.tap do |hash|
350
+ value.each do |k, v|
351
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
352
+ end
353
+ end
354
+ else # model
355
+ # models (e.g. Pet) or oneOf
356
+ klass = OneSignal.const_get(type)
357
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
358
+ end
359
+ end
360
+
361
+ # Returns the string representation of the object
362
+ # @return [String] String presentation of the object
363
+ def to_s
364
+ to_hash.to_s
365
+ end
366
+
367
+ # to_body is an alias to to_hash (backward compatibility)
368
+ # @return [Hash] Returns the object in the form of hash
369
+ def to_body
370
+ to_hash
371
+ end
372
+
373
+ # Returns the object in the form of hash
374
+ # @return [Hash] Returns the object in the form of hash
375
+ def to_hash
376
+ hash = {}
377
+ self.class.attribute_map.each_pair do |attr, param|
378
+ value = self.send(attr)
379
+ if value.nil?
380
+ is_nullable = self.class.openapi_nullable.include?(attr)
381
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
382
+ end
383
+
384
+ hash[param] = _to_hash(value)
385
+ end
386
+ hash
387
+ end
388
+
389
+ # Outputs non-array value in the form of hash
390
+ # For object, use to_hash. Otherwise, just return the value
391
+ # @param [Object] value Any valid value
392
+ # @return [Hash] Returns the value in the form of hash
393
+ def _to_hash(value)
394
+ if value.is_a?(Array)
395
+ value.compact.map { |v| _to_hash(v) }
396
+ elsif value.is_a?(Hash)
397
+ {}.tap do |hash|
398
+ value.each { |k, v| hash[k] = _to_hash(v) }
399
+ end
400
+ elsif value.respond_to? :to_hash
401
+ value.to_hash
402
+ else
403
+ value
404
+ end
405
+ end
406
+
407
+ end
408
+
409
+ end