onesignal 5.11.2 → 5.13.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 (163) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile.lock +2 -2
  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/StartLiveActivityRequest.md +1 -1
  30. data/docs/UpdateJourneyNodeRequest.md +48 -0
  31. data/docs/UpdateJourneyRequest.md +34 -0
  32. data/docs/UpdateLiveActivityRequest.md +7 -3
  33. data/lib/onesignal/api/default_api.rb +524 -0
  34. data/lib/onesignal/api_client.rb +1 -1
  35. data/lib/onesignal/models/create_journey_request.rb +287 -0
  36. data/lib/onesignal/models/journey.rb +409 -0
  37. data/lib/onesignal/models/journey_audience.rb +316 -0
  38. data/lib/onesignal/models/journey_branch.rb +250 -0
  39. data/lib/onesignal/models/journey_branch_stats.rb +220 -0
  40. data/lib/onesignal/models/journey_condition.rb +360 -0
  41. data/lib/onesignal/models/journey_early_exit.rb +231 -0
  42. data/lib/onesignal/models/journey_early_exit_rules.rb +251 -0
  43. data/lib/onesignal/models/journey_early_exit_rules_on_event.rb +224 -0
  44. data/lib/onesignal/models/journey_early_exit_rules_on_segment.rb +221 -0
  45. data/lib/onesignal/models/journey_event_attribute.rb +283 -0
  46. data/lib/onesignal/models/journey_list_audience.rb +254 -0
  47. data/lib/onesignal/models/journey_list_item.rb +366 -0
  48. data/lib/onesignal/models/journey_list_response.rb +241 -0
  49. data/lib/onesignal/models/journey_message_stats.rb +222 -0
  50. data/lib/onesignal/models/journey_node.rb +480 -0
  51. data/lib/onesignal/models/journey_node_stats.rb +293 -0
  52. data/lib/onesignal/models/journey_reentry_rules.rb +236 -0
  53. data/lib/onesignal/models/journey_schedule.rb +243 -0
  54. data/lib/onesignal/models/journey_stats.rb +274 -0
  55. data/lib/onesignal/models/journey_time_point.rb +277 -0
  56. data/lib/onesignal/models/journey_time_window.rb +266 -0
  57. data/lib/onesignal/models/journey_wait_until_expiration.rb +256 -0
  58. data/lib/onesignal/models/start_live_activity_request.rb +1 -1
  59. data/lib/onesignal/models/update_journey_node_request.rb +454 -0
  60. data/lib/onesignal/models/update_journey_request.rb +337 -0
  61. data/lib/onesignal/models/update_live_activity_request.rb +27 -6
  62. data/lib/onesignal/version.rb +1 -1
  63. data/lib/onesignal.rb +25 -0
  64. data/spec/api/default_api_spec.rb +95 -0
  65. data/spec/models/create_journey_request_spec.rb +69 -0
  66. data/spec/models/journey_audience_spec.rb +67 -0
  67. data/spec/models/journey_branch_spec.rb +51 -0
  68. data/spec/models/journey_branch_stats_spec.rb +33 -0
  69. data/spec/models/journey_condition_spec.rb +89 -0
  70. data/spec/models/journey_early_exit_rules_on_event_spec.rb +33 -0
  71. data/spec/models/journey_early_exit_rules_on_segment_spec.rb +33 -0
  72. data/spec/models/journey_early_exit_rules_spec.rb +51 -0
  73. data/spec/models/journey_early_exit_spec.rb +39 -0
  74. data/spec/models/journey_event_attribute_spec.rb +49 -0
  75. data/spec/models/journey_list_audience_spec.rb +37 -0
  76. data/spec/models/journey_list_item_spec.rb +103 -0
  77. data/spec/models/journey_list_response_spec.rb +45 -0
  78. data/spec/models/journey_message_stats_spec.rb +33 -0
  79. data/spec/models/journey_node_spec.rb +137 -0
  80. data/spec/models/journey_node_stats_spec.rb +61 -0
  81. data/spec/models/journey_reentry_rules_spec.rb +33 -0
  82. data/spec/models/journey_schedule_spec.rb +45 -0
  83. data/spec/models/journey_spec.rb +127 -0
  84. data/spec/models/journey_stats_spec.rb +63 -0
  85. data/spec/models/journey_time_point_spec.rb +39 -0
  86. data/spec/models/journey_time_window_spec.rb +45 -0
  87. data/spec/models/journey_wait_until_expiration_spec.rb +39 -0
  88. data/spec/models/update_journey_node_request_spec.rb +127 -0
  89. data/spec/models/update_journey_request_spec.rb +85 -0
  90. data/spec/models/update_live_activity_request_spec.rb +12 -0
  91. data/vendor/bundle/ruby/3.2.0/cache/psych-5.5.0.gem +0 -0
  92. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
  93. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/gem_make.out +5 -5
  94. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/gem_make.out +5 -5
  95. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/mkmf.log +3 -3
  96. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  97. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.5.0/gem_make.out +28 -0
  98. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.5.0/psych.so +0 -0
  99. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  100. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
  101. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/README.md +53 -0
  102. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/extconf.rb +22 -0
  103. data/vendor/bundle/ruby/3.2.0/gems/psych-5.5.0/ext/psych/psych.c +68 -0
  104. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych.h +4 -0
  105. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_emitter.c +4 -0
  106. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_parser.c +79 -18
  107. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/class_loader.rb +1 -0
  108. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/parser.rb +40 -1
  109. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/scalar_scanner.rb +15 -3
  110. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/versions.rb +1 -1
  111. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors/to_ruby.rb +20 -9
  112. data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors/yaml_tree.rb +0 -3
  113. data/vendor/bundle/ruby/3.2.0/gems/psych-5.5.0/lib/psych.so +0 -0
  114. data/vendor/bundle/ruby/3.2.0/specifications/{psych-5.4.0.gemspec → psych-5.5.0.gemspec} +2 -2
  115. metadata +162 -62
  116. data/vendor/bundle/ruby/3.2.0/cache/psych-5.4.0.gem +0 -0
  117. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.4.0/gem_make.out +0 -28
  118. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.4.0/psych.so +0 -0
  119. data/vendor/bundle/ruby/3.2.0/gems/psych-5.4.0/ext/psych/psych.c +0 -36
  120. data/vendor/bundle/ruby/3.2.0/gems/psych-5.4.0/lib/psych.so +0 -0
  121. /data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{psych-5.4.0 → psych-5.5.0}/gem.build_complete +0 -0
  122. /data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{psych-5.4.0 → psych-5.5.0}/mkmf.log +0 -0
  123. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/CONTRIBUTING.md +0 -0
  124. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/LICENSE +0 -0
  125. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/Makefile +0 -0
  126. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/depend +0 -0
  127. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_emitter.h +0 -0
  128. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_parser.h +0 -0
  129. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_to_ruby.c +0 -0
  130. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_to_ruby.h +0 -0
  131. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_yaml_tree.c +0 -0
  132. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/ext/psych/psych_yaml_tree.h +0 -0
  133. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/coder.rb +0 -0
  134. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/core_ext.rb +0 -0
  135. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/exception.rb +0 -0
  136. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/handler.rb +0 -0
  137. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/handlers/document_stream.rb +0 -0
  138. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/handlers/recorder.rb +0 -0
  139. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/json/ruby_events.rb +0 -0
  140. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/json/stream.rb +0 -0
  141. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/json/tree_builder.rb +0 -0
  142. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/json/yaml_events.rb +0 -0
  143. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/alias.rb +0 -0
  144. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/document.rb +0 -0
  145. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/mapping.rb +0 -0
  146. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/node.rb +0 -0
  147. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/scalar.rb +0 -0
  148. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/sequence.rb +0 -0
  149. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes/stream.rb +0 -0
  150. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/nodes.rb +0 -0
  151. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/omap.rb +0 -0
  152. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/set.rb +0 -0
  153. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/stream.rb +0 -0
  154. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/streaming.rb +0 -0
  155. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/syntax_error.rb +0 -0
  156. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/tree_builder.rb +0 -0
  157. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors/depth_first.rb +0 -0
  158. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors/emitter.rb +0 -0
  159. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors/json_tree.rb +0 -0
  160. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors/visitor.rb +0 -0
  161. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/visitors.rb +0 -0
  162. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych/y.rb +0 -0
  163. /data/vendor/bundle/ruby/3.2.0/gems/{psych-5.4.0 → psych-5.5.0}/lib/psych.rb +0 -0
@@ -0,0 +1,220 @@
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
+ # Stats for a single branch of a branching node. Keyed in the response by the branch's server-assigned id.
17
+ class JourneyBranchStats
18
+ # Users who took this branch.
19
+ attr_accessor :completed
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'completed' => :'completed'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'completed' => :'Integer'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::JourneyBranchStats` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::JourneyBranchStats`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'completed')
62
+ self.completed = attributes[:'completed']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ completed == o.completed
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [completed].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
+ self.send("#{key}=", nil)
115
+ elsif type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = OneSignal.const_get(type)
168
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -0,0 +1,360 @@
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
+ # A branch condition. The kind field selects which other fields apply.
17
+ class JourneyCondition
18
+ # Condition kind. Selects which other fields apply.
19
+ attr_accessor :kind
20
+
21
+ # segment_membership conditions: Segment UUIDs the user must belong to.
22
+ attr_accessor :included_segment_ids
23
+
24
+ # segment_membership conditions: Segment UUIDs the user must not belong to.
25
+ attr_accessor :excluded_segment_ids
26
+
27
+ # on_notification_action conditions: the notification action to branch on. Which actions apply depends on the sending node's channel.
28
+ attr_accessor :action
29
+
30
+ # on_notification_action conditions: id of the sending node this action refers to. Returned on reads; accepted on write.
31
+ attr_accessor :sending_node_id
32
+
33
+ # on_notification_action conditions: write-only alternative to sending_node_id. References the sending node by its client_node_id.
34
+ attr_accessor :client_node_id
35
+
36
+ # event_trigger conditions: event name, up to 255 characters.
37
+ attr_accessor :name
38
+
39
+ # Event attribute matchers, as a list of condition groups. Send a single group whose conditions are AND'd together. More than one group is rejected.
40
+ attr_accessor :attributes
41
+
42
+ # event_trigger conditions: match incoming event properties against the journey's entry event. Only valid on event-triggered journeys.
43
+ attr_accessor :entry_event_match_attributes
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'kind' => :'kind',
71
+ :'included_segment_ids' => :'included_segment_ids',
72
+ :'excluded_segment_ids' => :'excluded_segment_ids',
73
+ :'action' => :'action',
74
+ :'sending_node_id' => :'sending_node_id',
75
+ :'client_node_id' => :'client_node_id',
76
+ :'name' => :'name',
77
+ :'attributes' => :'attributes',
78
+ :'entry_event_match_attributes' => :'entry_event_match_attributes'
79
+ }
80
+ end
81
+
82
+ # Returns all the JSON keys this model knows about
83
+ def self.acceptable_attributes
84
+ attribute_map.values
85
+ end
86
+
87
+ # Attribute type mapping.
88
+ def self.openapi_types
89
+ {
90
+ :'kind' => :'String',
91
+ :'included_segment_ids' => :'Array<String>',
92
+ :'excluded_segment_ids' => :'Array<String>',
93
+ :'action' => :'String',
94
+ :'sending_node_id' => :'String',
95
+ :'client_node_id' => :'String',
96
+ :'name' => :'String',
97
+ :'attributes' => :'Array<Array<JourneyEventAttribute>>',
98
+ :'entry_event_match_attributes' => :'Array<Object>'
99
+ }
100
+ end
101
+
102
+ # List of attributes with nullable: true
103
+ def self.openapi_nullable
104
+ Set.new([
105
+ :'entry_event_match_attributes'
106
+ ])
107
+ end
108
+
109
+ # Initializes the object
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ def initialize(attributes = {})
112
+ if (!attributes.is_a?(Hash))
113
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::JourneyCondition` initialize method"
114
+ end
115
+
116
+ # check to see if the attribute exists and convert string to symbol for hash key
117
+ attributes = attributes.each_with_object({}) { |(k, v), h|
118
+ if (!self.class.attribute_map.key?(k.to_sym))
119
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::JourneyCondition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
120
+ end
121
+ h[k.to_sym] = v
122
+ }
123
+
124
+ if attributes.key?(:'kind')
125
+ self.kind = attributes[:'kind']
126
+ end
127
+
128
+ if attributes.key?(:'included_segment_ids')
129
+ if (value = attributes[:'included_segment_ids']).is_a?(Array)
130
+ self.included_segment_ids = value
131
+ end
132
+ end
133
+
134
+ if attributes.key?(:'excluded_segment_ids')
135
+ if (value = attributes[:'excluded_segment_ids']).is_a?(Array)
136
+ self.excluded_segment_ids = value
137
+ end
138
+ end
139
+
140
+ if attributes.key?(:'action')
141
+ self.action = attributes[:'action']
142
+ end
143
+
144
+ if attributes.key?(:'sending_node_id')
145
+ self.sending_node_id = attributes[:'sending_node_id']
146
+ end
147
+
148
+ if attributes.key?(:'client_node_id')
149
+ self.client_node_id = attributes[:'client_node_id']
150
+ end
151
+
152
+ if attributes.key?(:'name')
153
+ self.name = attributes[:'name']
154
+ end
155
+
156
+ if attributes.key?(:'attributes')
157
+ if (value = attributes[:'attributes']).is_a?(Array)
158
+ self.attributes = value
159
+ end
160
+ end
161
+
162
+ if attributes.key?(:'entry_event_match_attributes')
163
+ if (value = attributes[:'entry_event_match_attributes']).is_a?(Array)
164
+ self.entry_event_match_attributes = value
165
+ end
166
+ end
167
+ end
168
+
169
+ # Show invalid properties with the reasons. Usually used together with valid?
170
+ # @return Array for valid properties with the reasons
171
+ def list_invalid_properties
172
+ invalid_properties = Array.new
173
+ if @kind.nil?
174
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
175
+ end
176
+
177
+ invalid_properties
178
+ end
179
+
180
+ # Check to see if the all the properties in the model are valid
181
+ # @return true if the model is valid
182
+ def valid?
183
+ return false if @kind.nil?
184
+ kind_validator = EnumAttributeValidator.new('String', ["segment_membership", "on_notification_action", "event_trigger"])
185
+ return false unless kind_validator.valid?(@kind)
186
+ action_validator = EnumAttributeValidator.new('String', ["received", "clicked", "opened"])
187
+ return false unless action_validator.valid?(@action)
188
+ true
189
+ end
190
+
191
+ # Custom attribute writer method checking allowed values (enum).
192
+ # @param [Object] kind Object to be assigned
193
+ def kind=(kind)
194
+ validator = EnumAttributeValidator.new('String', ["segment_membership", "on_notification_action", "event_trigger"])
195
+ unless validator.valid?(kind)
196
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{validator.allowable_values}."
197
+ end
198
+ @kind = kind
199
+ end
200
+
201
+ # Custom attribute writer method checking allowed values (enum).
202
+ # @param [Object] action Object to be assigned
203
+ def action=(action)
204
+ validator = EnumAttributeValidator.new('String', ["received", "clicked", "opened"])
205
+ unless validator.valid?(action)
206
+ fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
207
+ end
208
+ @action = action
209
+ end
210
+
211
+ # Checks equality by comparing each attribute.
212
+ # @param [Object] Object to be compared
213
+ def ==(o)
214
+ return true if self.equal?(o)
215
+ self.class == o.class &&
216
+ kind == o.kind &&
217
+ included_segment_ids == o.included_segment_ids &&
218
+ excluded_segment_ids == o.excluded_segment_ids &&
219
+ action == o.action &&
220
+ sending_node_id == o.sending_node_id &&
221
+ client_node_id == o.client_node_id &&
222
+ name == o.name &&
223
+ attributes == o.attributes &&
224
+ entry_event_match_attributes == o.entry_event_match_attributes
225
+ end
226
+
227
+ # @see the `==` method
228
+ # @param [Object] Object to be compared
229
+ def eql?(o)
230
+ self == o
231
+ end
232
+
233
+ # Calculates hash code according to all attributes.
234
+ # @return [Integer] Hash code
235
+ def hash
236
+ [kind, included_segment_ids, excluded_segment_ids, action, sending_node_id, client_node_id, name, attributes, entry_event_match_attributes].hash
237
+ end
238
+
239
+ # Builds the object from hash
240
+ # @param [Hash] attributes Model attributes in the form of hash
241
+ # @return [Object] Returns the model itself
242
+ def self.build_from_hash(attributes)
243
+ new.build_from_hash(attributes)
244
+ end
245
+
246
+ # Builds the object from hash
247
+ # @param [Hash] attributes Model attributes in the form of hash
248
+ # @return [Object] Returns the model itself
249
+ def build_from_hash(attributes)
250
+ return nil unless attributes.is_a?(Hash)
251
+ attributes = attributes.transform_keys(&:to_sym)
252
+ self.class.openapi_types.each_pair do |key, type|
253
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
254
+ self.send("#{key}=", nil)
255
+ elsif type =~ /\AArray<(.*)>/i
256
+ # check to ensure the input is an array given that the attribute
257
+ # is documented as an array but the input is not
258
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
259
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
260
+ end
261
+ elsif !attributes[self.class.attribute_map[key]].nil?
262
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
263
+ end
264
+ end
265
+
266
+ self
267
+ end
268
+
269
+ # Deserializes the data based on type
270
+ # @param string type Data type
271
+ # @param string value Value to be deserialized
272
+ # @return [Object] Deserialized data
273
+ def _deserialize(type, value)
274
+ case type.to_sym
275
+ when :Time
276
+ Time.parse(value)
277
+ when :Date
278
+ Date.parse(value)
279
+ when :String
280
+ value.to_s
281
+ when :Integer
282
+ value.to_i
283
+ when :Float
284
+ value.to_f
285
+ when :Boolean
286
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
287
+ true
288
+ else
289
+ false
290
+ end
291
+ when :Object
292
+ # generic object (usually a Hash), return directly
293
+ value
294
+ when /\AArray<(?<inner_type>.+)>\z/
295
+ inner_type = Regexp.last_match[:inner_type]
296
+ value.map { |v| _deserialize(inner_type, v) }
297
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
298
+ k_type = Regexp.last_match[:k_type]
299
+ v_type = Regexp.last_match[:v_type]
300
+ {}.tap do |hash|
301
+ value.each do |k, v|
302
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
303
+ end
304
+ end
305
+ else # model
306
+ # models (e.g. Pet) or oneOf
307
+ klass = OneSignal.const_get(type)
308
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
309
+ end
310
+ end
311
+
312
+ # Returns the string representation of the object
313
+ # @return [String] String presentation of the object
314
+ def to_s
315
+ to_hash.to_s
316
+ end
317
+
318
+ # to_body is an alias to to_hash (backward compatibility)
319
+ # @return [Hash] Returns the object in the form of hash
320
+ def to_body
321
+ to_hash
322
+ end
323
+
324
+ # Returns the object in the form of hash
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_hash
327
+ hash = {}
328
+ self.class.attribute_map.each_pair do |attr, param|
329
+ value = self.send(attr)
330
+ if value.nil?
331
+ is_nullable = self.class.openapi_nullable.include?(attr)
332
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
333
+ end
334
+
335
+ hash[param] = _to_hash(value)
336
+ end
337
+ hash
338
+ end
339
+
340
+ # Outputs non-array value in the form of hash
341
+ # For object, use to_hash. Otherwise, just return the value
342
+ # @param [Object] value Any valid value
343
+ # @return [Hash] Returns the value in the form of hash
344
+ def _to_hash(value)
345
+ if value.is_a?(Array)
346
+ value.compact.map { |v| _to_hash(v) }
347
+ elsif value.is_a?(Hash)
348
+ {}.tap do |hash|
349
+ value.each { |k, v| hash[k] = _to_hash(v) }
350
+ end
351
+ elsif value.respond_to? :to_hash
352
+ value.to_hash
353
+ else
354
+ value
355
+ end
356
+ end
357
+
358
+ end
359
+
360
+ end