onesignal 5.2.1.pre.beta1 → 5.3.0.pre.beta1

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/README.md +33 -5
  3. data/docs/ApiKeyToken.md +28 -0
  4. data/docs/ApiKeyTokensListResponse.md +18 -0
  5. data/docs/CopyTemplateRequest.md +18 -0
  6. data/docs/CreateApiKeyRequest.md +22 -0
  7. data/docs/CreateApiKeyResponse.md +20 -0
  8. data/docs/CreateTemplateRequest.md +32 -0
  9. data/docs/CustomEvent.md +26 -0
  10. data/docs/CustomEventsRequest.md +18 -0
  11. data/docs/DefaultApi.md +1132 -110
  12. data/docs/StartLiveActivityRequest.md +48 -0
  13. data/docs/StartLiveActivitySuccessResponse.md +18 -0
  14. data/docs/TemplateResource.md +28 -0
  15. data/docs/TemplatesListResponse.md +18 -0
  16. data/docs/UpdateApiKeyRequest.md +22 -0
  17. data/docs/UpdateTemplateRequest.md +30 -0
  18. data/lib/onesignal/api/default_api.rb +1043 -1
  19. data/lib/onesignal/api_client.rb +2 -2
  20. data/lib/onesignal/api_error.rb +1 -1
  21. data/lib/onesignal/configuration.rb +1 -1
  22. data/lib/onesignal/models/api_key_token.rb +300 -0
  23. data/lib/onesignal/models/api_key_tokens_list_response.rb +221 -0
  24. data/lib/onesignal/models/app.rb +1 -1
  25. data/lib/onesignal/models/basic_notification.rb +1 -1
  26. data/lib/onesignal/models/basic_notification_all_of.rb +1 -1
  27. data/lib/onesignal/models/basic_notification_all_of_android_background_layout.rb +1 -1
  28. data/lib/onesignal/models/button.rb +1 -1
  29. data/lib/onesignal/models/copy_template_request.rb +225 -0
  30. data/lib/onesignal/models/create_api_key_request.rb +273 -0
  31. data/lib/onesignal/models/create_api_key_response.rb +228 -0
  32. data/lib/onesignal/models/create_notification_success_response.rb +1 -1
  33. data/lib/onesignal/models/create_segment_conflict_response.rb +1 -1
  34. data/lib/onesignal/models/create_segment_success_response.rb +1 -1
  35. data/lib/onesignal/models/create_template_request.rb +307 -0
  36. data/lib/onesignal/models/create_user_conflict_response.rb +1 -1
  37. data/lib/onesignal/models/create_user_conflict_response_errors_inner.rb +1 -1
  38. data/lib/onesignal/models/create_user_conflict_response_errors_items_meta.rb +1 -1
  39. data/lib/onesignal/models/custom_event.rb +269 -0
  40. data/lib/onesignal/models/custom_events_request.rb +226 -0
  41. data/lib/onesignal/models/delivery_data.rb +1 -1
  42. data/lib/onesignal/models/export_events_success_response.rb +1 -1
  43. data/lib/onesignal/models/export_subscriptions_request_body.rb +1 -1
  44. data/lib/onesignal/models/export_subscriptions_success_response.rb +1 -1
  45. data/lib/onesignal/models/filter.rb +1 -1
  46. data/lib/onesignal/models/filter_expression.rb +1 -1
  47. data/lib/onesignal/models/generic_error.rb +1 -1
  48. data/lib/onesignal/models/generic_success_bool_response.rb +1 -1
  49. data/lib/onesignal/models/get_notification_history_request_body.rb +1 -1
  50. data/lib/onesignal/models/get_segments_success_response.rb +1 -1
  51. data/lib/onesignal/models/language_string_map.rb +1 -1
  52. data/lib/onesignal/models/notification.rb +1 -1
  53. data/lib/onesignal/models/notification_all_of.rb +1 -1
  54. data/lib/onesignal/models/notification_history_success_response.rb +1 -1
  55. data/lib/onesignal/models/notification_slice.rb +1 -1
  56. data/lib/onesignal/models/notification_target.rb +1 -1
  57. data/lib/onesignal/models/notification_with_meta.rb +1 -1
  58. data/lib/onesignal/models/notification_with_meta_all_of.rb +1 -1
  59. data/lib/onesignal/models/operator.rb +1 -1
  60. data/lib/onesignal/models/outcome_data.rb +1 -1
  61. data/lib/onesignal/models/outcomes_data.rb +1 -1
  62. data/lib/onesignal/models/platform_delivery_data.rb +1 -1
  63. data/lib/onesignal/models/platform_delivery_data_email_all_of.rb +1 -1
  64. data/lib/onesignal/models/platform_delivery_data_sms_all_of.rb +1 -1
  65. data/lib/onesignal/models/properties_body.rb +1 -1
  66. data/lib/onesignal/models/properties_deltas.rb +1 -1
  67. data/lib/onesignal/models/properties_object.rb +1 -1
  68. data/lib/onesignal/models/purchase.rb +1 -1
  69. data/lib/onesignal/models/rate_limit_error.rb +1 -1
  70. data/lib/onesignal/models/segment.rb +1 -1
  71. data/lib/onesignal/models/segment_data.rb +1 -1
  72. data/lib/onesignal/models/segment_notification_target.rb +1 -1
  73. data/lib/onesignal/models/start_live_activity_request.rb +454 -0
  74. data/lib/onesignal/models/start_live_activity_success_response.rb +219 -0
  75. data/lib/onesignal/models/subscription.rb +1 -1
  76. data/lib/onesignal/models/subscription_body.rb +1 -1
  77. data/lib/onesignal/models/subscription_notification_target.rb +1 -1
  78. data/lib/onesignal/models/template_resource.rb +302 -0
  79. data/lib/onesignal/models/templates_list_response.rb +221 -0
  80. data/lib/onesignal/models/transfer_subscription_request_body.rb +1 -1
  81. data/lib/onesignal/models/update_api_key_request.rb +273 -0
  82. data/lib/onesignal/models/update_live_activity_request.rb +1 -1
  83. data/lib/onesignal/models/update_live_activity_success_response.rb +1 -1
  84. data/lib/onesignal/models/update_template_request.rb +282 -0
  85. data/lib/onesignal/models/update_user_request.rb +1 -1
  86. data/lib/onesignal/models/user.rb +1 -1
  87. data/lib/onesignal/models/user_identity_body.rb +1 -1
  88. data/lib/onesignal/models/web_button.rb +1 -1
  89. data/lib/onesignal/version.rb +2 -2
  90. data/lib/onesignal.rb +15 -1
  91. data/onesignal.gemspec +1 -1
  92. data/spec/api/default_api_spec.rb +189 -1
  93. data/spec/api_client_spec.rb +1 -1
  94. data/spec/configuration_spec.rb +1 -1
  95. data/spec/models/api_key_token_spec.rb +68 -0
  96. data/spec/models/api_key_tokens_list_response_spec.rb +34 -0
  97. data/spec/models/app_spec.rb +1 -1
  98. data/spec/models/basic_notification_all_of_android_background_layout_spec.rb +1 -1
  99. data/spec/models/basic_notification_all_of_spec.rb +1 -1
  100. data/spec/models/basic_notification_spec.rb +1 -1
  101. data/spec/models/button_spec.rb +1 -1
  102. data/spec/models/copy_template_request_spec.rb +34 -0
  103. data/spec/models/create_api_key_request_spec.rb +50 -0
  104. data/spec/models/create_api_key_response_spec.rb +40 -0
  105. data/spec/models/create_notification_success_response_spec.rb +1 -1
  106. data/spec/models/create_segment_conflict_response_spec.rb +1 -1
  107. data/spec/models/create_segment_success_response_spec.rb +1 -1
  108. data/spec/models/create_template_request_spec.rb +76 -0
  109. data/spec/models/create_user_conflict_response_errors_inner_spec.rb +1 -1
  110. data/spec/models/create_user_conflict_response_errors_items_meta_spec.rb +1 -1
  111. data/spec/models/create_user_conflict_response_spec.rb +1 -1
  112. data/spec/models/custom_event_spec.rb +58 -0
  113. data/spec/models/custom_events_request_spec.rb +34 -0
  114. data/spec/models/delivery_data_spec.rb +1 -1
  115. data/spec/models/export_events_success_response_spec.rb +1 -1
  116. data/spec/models/export_subscriptions_request_body_spec.rb +1 -1
  117. data/spec/models/export_subscriptions_success_response_spec.rb +1 -1
  118. data/spec/models/filter_expression_spec.rb +1 -1
  119. data/spec/models/filter_spec.rb +1 -1
  120. data/spec/models/generic_error_spec.rb +1 -1
  121. data/spec/models/generic_success_bool_response_spec.rb +1 -1
  122. data/spec/models/get_notification_history_request_body_spec.rb +1 -1
  123. data/spec/models/get_segments_success_response_spec.rb +1 -1
  124. data/spec/models/language_string_map_spec.rb +1 -1
  125. data/spec/models/notification_all_of_spec.rb +1 -1
  126. data/spec/models/notification_history_success_response_spec.rb +1 -1
  127. data/spec/models/notification_slice_spec.rb +1 -1
  128. data/spec/models/notification_spec.rb +1 -1
  129. data/spec/models/notification_target_spec.rb +1 -1
  130. data/spec/models/notification_with_meta_all_of_spec.rb +1 -1
  131. data/spec/models/notification_with_meta_spec.rb +1 -1
  132. data/spec/models/operator_spec.rb +1 -1
  133. data/spec/models/outcome_data_spec.rb +1 -1
  134. data/spec/models/outcomes_data_spec.rb +1 -1
  135. data/spec/models/platform_delivery_data_email_all_of_spec.rb +1 -1
  136. data/spec/models/platform_delivery_data_sms_all_of_spec.rb +1 -1
  137. data/spec/models/platform_delivery_data_spec.rb +1 -1
  138. data/spec/models/properties_body_spec.rb +1 -1
  139. data/spec/models/properties_deltas_spec.rb +1 -1
  140. data/spec/models/properties_object_spec.rb +1 -1
  141. data/spec/models/purchase_spec.rb +1 -1
  142. data/spec/models/rate_limit_error_spec.rb +1 -1
  143. data/spec/models/segment_data_spec.rb +1 -1
  144. data/spec/models/segment_notification_target_spec.rb +1 -1
  145. data/spec/models/segment_spec.rb +1 -1
  146. data/spec/models/start_live_activity_request_spec.rb +128 -0
  147. data/spec/models/start_live_activity_success_response_spec.rb +34 -0
  148. data/spec/models/subscription_body_spec.rb +1 -1
  149. data/spec/models/subscription_notification_target_spec.rb +1 -1
  150. data/spec/models/subscription_spec.rb +1 -1
  151. data/spec/models/template_resource_spec.rb +68 -0
  152. data/spec/models/templates_list_response_spec.rb +34 -0
  153. data/spec/models/transfer_subscription_request_body_spec.rb +1 -1
  154. data/spec/models/update_api_key_request_spec.rb +50 -0
  155. data/spec/models/update_live_activity_request_spec.rb +1 -1
  156. data/spec/models/update_live_activity_success_response_spec.rb +1 -1
  157. data/spec/models/update_template_request_spec.rb +70 -0
  158. data/spec/models/update_user_request_spec.rb +1 -1
  159. data/spec/models/user_identity_body_spec.rb +1 -1
  160. data/spec/models/user_spec.rb +1 -1
  161. data/spec/models/web_button_spec.rb +1 -1
  162. data/spec/spec_helper.rb +1 -1
  163. metadata +57 -1
@@ -0,0 +1,225 @@
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
+ The version of the OpenAPI document: 5.3.0
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OneSignal
17
+ class CopyTemplateRequest
18
+ # Destination OneSignal App ID in UUID v4 format.
19
+ attr_accessor :target_app_id
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'target_app_id' => :'target_app_id'
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
+ :'target_app_id' => :'String'
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::CopyTemplateRequest` 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::CopyTemplateRequest`. 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?(:'target_app_id')
62
+ self.target_app_id = attributes[:'target_app_id']
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
+ if @target_app_id.nil?
71
+ invalid_properties.push('invalid value for "target_app_id", target_app_id cannot be nil.')
72
+ end
73
+
74
+ invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ return false if @target_app_id.nil?
81
+ true
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ target_app_id == o.target_app_id
90
+ end
91
+
92
+ # @see the `==` method
93
+ # @param [Object] Object to be compared
94
+ def eql?(o)
95
+ self == o
96
+ end
97
+
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Integer] Hash code
100
+ def hash
101
+ [target_app_id].hash
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def self.build_from_hash(attributes)
108
+ new.build_from_hash(attributes)
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ self.class.openapi_types.each_pair do |key, type|
118
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
119
+ self.send("#{key}=", nil)
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = OneSignal.const_get(type)
173
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -0,0 +1,273 @@
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
+ The version of the OpenAPI document: 5.3.0
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OneSignal
17
+ class CreateApiKeyRequest
18
+ attr_accessor :name
19
+
20
+ attr_accessor :ip_allowlist_mode
21
+
22
+ attr_accessor :ip_allowlist
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
+ :'name' => :'name',
50
+ :'ip_allowlist_mode' => :'ip_allowlist_mode',
51
+ :'ip_allowlist' => :'ip_allowlist'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'name' => :'String',
64
+ :'ip_allowlist_mode' => :'String',
65
+ :'ip_allowlist' => :'Array<String>'
66
+ }
67
+ end
68
+
69
+ # List of attributes with nullable: true
70
+ def self.openapi_nullable
71
+ Set.new([
72
+ ])
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ if (!attributes.is_a?(Hash))
79
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::CreateApiKeyRequest` initialize method"
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) { |(k, v), h|
84
+ if (!self.class.attribute_map.key?(k.to_sym))
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::CreateApiKeyRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
+ end
87
+ h[k.to_sym] = v
88
+ }
89
+
90
+ if attributes.key?(:'name')
91
+ self.name = attributes[:'name']
92
+ end
93
+
94
+ if attributes.key?(:'ip_allowlist_mode')
95
+ self.ip_allowlist_mode = attributes[:'ip_allowlist_mode']
96
+ end
97
+
98
+ if attributes.key?(:'ip_allowlist')
99
+ if (value = attributes[:'ip_allowlist']).is_a?(Array)
100
+ self.ip_allowlist = value
101
+ end
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ invalid_properties = Array.new
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ ip_allowlist_mode_validator = EnumAttributeValidator.new('String', ["disabled", "explicit"])
116
+ return false unless ip_allowlist_mode_validator.valid?(@ip_allowlist_mode)
117
+ true
118
+ end
119
+
120
+ # Custom attribute writer method checking allowed values (enum).
121
+ # @param [Object] ip_allowlist_mode Object to be assigned
122
+ def ip_allowlist_mode=(ip_allowlist_mode)
123
+ validator = EnumAttributeValidator.new('String', ["disabled", "explicit"])
124
+ unless validator.valid?(ip_allowlist_mode)
125
+ fail ArgumentError, "invalid value for \"ip_allowlist_mode\", must be one of #{validator.allowable_values}."
126
+ end
127
+ @ip_allowlist_mode = ip_allowlist_mode
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
+ name == o.name &&
136
+ ip_allowlist_mode == o.ip_allowlist_mode &&
137
+ ip_allowlist == o.ip_allowlist
138
+ end
139
+
140
+ # @see the `==` method
141
+ # @param [Object] Object to be compared
142
+ def eql?(o)
143
+ self == o
144
+ end
145
+
146
+ # Calculates hash code according to all attributes.
147
+ # @return [Integer] Hash code
148
+ def hash
149
+ [name, ip_allowlist_mode, ip_allowlist].hash
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def self.build_from_hash(attributes)
156
+ new.build_from_hash(attributes)
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ attributes = attributes.transform_keys(&:to_sym)
165
+ self.class.openapi_types.each_pair do |key, type|
166
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
167
+ self.send("#{key}=", nil)
168
+ elsif type =~ /\AArray<(.*)>/i
169
+ # check to ensure the input is an array given that the attribute
170
+ # is documented as an array but the input is not
171
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
172
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
173
+ end
174
+ elsif !attributes[self.class.attribute_map[key]].nil?
175
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
176
+ end
177
+ end
178
+
179
+ self
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def _deserialize(type, value)
187
+ case type.to_sym
188
+ when :Time
189
+ Time.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ # models (e.g. Pet) or oneOf
220
+ klass = OneSignal.const_get(type)
221
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ end