svix 1.45.1 → 1.57.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 (98) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/application_api.rb +115 -10
  4. data/lib/svix/api/authentication_api.rb +101 -16
  5. data/lib/svix/api/background_tasks_api.rb +43 -17
  6. data/lib/svix/api/endpoint_api.rb +312 -96
  7. data/lib/svix/api/inbound_api.rb +4 -4
  8. data/lib/svix/api/integration_api.rb +102 -24
  9. data/lib/svix/api/message_api.rb +142 -39
  10. data/lib/svix/api/message_attempt_api.rb +135 -372
  11. data/lib/svix/api/statistics_api.rb +6 -6
  12. data/lib/svix/api/stream_api.rb +203 -142
  13. data/lib/svix/api/transformation_template_api.rb +88 -23
  14. data/lib/svix/api/webhook_endpoint_api.rb +253 -77
  15. data/lib/svix/background_tasks_api.rb +2 -2
  16. data/lib/svix/message_attempt_api.rb +7 -3
  17. data/lib/svix/models/active_application_out.rb +373 -0
  18. data/lib/svix/models/active_endpoint_out.rb +355 -0
  19. data/lib/svix/models/aggregate_event_types_out.rb +40 -0
  20. data/lib/svix/models/aggregated_event_types.rb +305 -0
  21. data/lib/svix/models/app_portal_access_in.rb +18 -0
  22. data/lib/svix/models/app_usage_stats_out.rb +40 -0
  23. data/lib/svix/models/application_message_failure.rb +277 -0
  24. data/lib/svix/models/application_message_id_pair.rb +317 -0
  25. data/lib/svix/models/application_out.rb +41 -2
  26. data/lib/svix/models/application_patch.rb +1 -1
  27. data/lib/svix/models/application_stats.rb +41 -2
  28. data/lib/svix/models/application_stats_out.rb +324 -0
  29. data/lib/svix/models/auth_token_out.rb +40 -1
  30. data/lib/svix/models/background_task_finished_event.rb +272 -0
  31. data/lib/svix/models/background_task_finished_event2.rb +331 -0
  32. data/lib/svix/models/background_task_out.rb +40 -0
  33. data/lib/svix/models/background_task_type.rb +2 -1
  34. data/lib/svix/models/{template_in.rb → connector_in.rb} +4 -4
  35. data/lib/svix/models/{transformation_template_kind.rb → connector_kind.rb} +3 -3
  36. data/lib/svix/models/create_stream_in.rb +12 -12
  37. data/lib/svix/models/data.rb +108 -0
  38. data/lib/svix/models/data_any_of.rb +240 -0
  39. data/lib/svix/models/data_any_of1.rb +223 -0
  40. data/lib/svix/models/data_any_of2.rb +241 -0
  41. data/lib/svix/models/data_any_of3.rb +223 -0
  42. data/lib/svix/models/data_any_of4.rb +240 -0
  43. data/lib/svix/models/endpoint_created_event_data.rb +82 -4
  44. data/lib/svix/models/endpoint_deleted_event_data.rb +82 -4
  45. data/lib/svix/models/endpoint_disabled_event.rb +1 -1
  46. data/lib/svix/models/endpoint_disabled_event_data.rb +119 -16
  47. data/lib/svix/models/endpoint_disabled_trigger.rb +40 -0
  48. data/lib/svix/models/endpoint_enabled_event.rb +272 -0
  49. data/lib/svix/models/endpoint_enabled_event_data.rb +410 -0
  50. data/lib/svix/models/endpoint_message_out.rb +40 -1
  51. data/lib/svix/models/endpoint_mtls_config_out.rb +215 -0
  52. data/lib/svix/models/endpoint_oauth_config_in.rb +2 -2
  53. data/lib/svix/models/endpoint_oauth_config_out.rb +315 -0
  54. data/lib/svix/models/endpoint_out.rb +40 -1
  55. data/lib/svix/models/endpoint_patch.rb +1 -1
  56. data/lib/svix/models/endpoint_updated_event_data.rb +82 -4
  57. data/lib/svix/models/environment_in.rb +17 -19
  58. data/lib/svix/models/environment_settings_out.rb +23 -1
  59. data/lib/svix/models/event_type_import_open_api_in.rb +14 -2
  60. data/lib/svix/models/export_event_type_out.rb +40 -0
  61. data/lib/svix/models/expung_all_contents_out.rb +315 -0
  62. data/lib/svix/models/inbound_path_params.rb +1 -1
  63. data/lib/svix/models/integration_in.rb +41 -1
  64. data/lib/svix/models/integration_out.rb +81 -2
  65. data/lib/svix/models/integration_update.rb +41 -1
  66. data/lib/svix/models/list_response_active_application_out.rb +261 -0
  67. data/lib/svix/models/message_attempt_endpoint_out.rb +120 -3
  68. data/lib/svix/models/message_attempt_exhausted_event_data.rb +122 -5
  69. data/lib/svix/models/message_attempt_failed_data.rb +40 -1
  70. data/lib/svix/models/message_attempt_failing_event_data.rb +122 -5
  71. data/lib/svix/models/message_attempt_out.rb +120 -3
  72. data/lib/svix/models/message_attempt_recovered_event_data.rb +122 -5
  73. data/lib/svix/models/message_broadcast_out.rb +40 -0
  74. data/lib/svix/models/message_endpoint_out.rb +40 -1
  75. data/lib/svix/models/message_out.rb +40 -1
  76. data/lib/svix/models/message_precheck_in.rb +288 -0
  77. data/lib/svix/models/message_precheck_out.rb +221 -0
  78. data/lib/svix/models/{oauth2_auth_method_in.rb → oauth2_auth_method_in_out.rb} +3 -3
  79. data/lib/svix/models/{oauth2_grant_type_in.rb → oauth2_grant_type_in_out.rb} +3 -3
  80. data/lib/svix/models/operational_webhook_endpoint_headers_in.rb +223 -0
  81. data/lib/svix/models/operational_webhook_endpoint_headers_out.rb +251 -0
  82. data/lib/svix/models/operational_webhook_endpoint_out.rb +40 -1
  83. data/lib/svix/models/polling_endpoint_message_out.rb +454 -0
  84. data/lib/svix/models/polling_endpoint_out.rb +255 -0
  85. data/lib/svix/models/recover_out.rb +40 -0
  86. data/lib/svix/models/replay_out.rb +40 -0
  87. data/lib/svix/models/rotate_poller_token_in.rb +1 -1
  88. data/lib/svix/models/sink_secret_out.rb +233 -0
  89. data/lib/svix/models/stream_in.rb +6 -7
  90. data/lib/svix/models/stream_out.rb +46 -7
  91. data/lib/svix/models/stream_patch.rb +6 -7
  92. data/lib/svix/models/stream_portal_access_in.rb +293 -0
  93. data/lib/svix/models/template_out.rb +81 -1
  94. data/lib/svix/models/template_patch.rb +1 -1
  95. data/lib/svix/models/template_update.rb +1 -1
  96. data/lib/svix/version.rb +1 -1
  97. metadata +35 -7
  98. data/lib/svix/operational_webhook_endpoint_api.rb +0 -37
@@ -0,0 +1,305 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class AggregatedEventTypes
18
+ # The Application's ID.
19
+ attr_accessor :app_id
20
+
21
+ attr_accessor :explicitly_subscribed_event_types
22
+
23
+ attr_accessor :has_catch_all_endpoint
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'app_id' => :'appId',
29
+ :'explicitly_subscribed_event_types' => :'explicitlySubscribedEventTypes',
30
+ :'has_catch_all_endpoint' => :'hasCatchAllEndpoint'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'app_id' => :'String',
43
+ :'explicitly_subscribed_event_types' => :'Array<String>',
44
+ :'has_catch_all_endpoint' => :'Boolean'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::AggregatedEventTypes` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::AggregatedEventTypes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'app_id')
70
+ self.app_id = attributes[:'app_id']
71
+ else
72
+ self.app_id = nil
73
+ end
74
+
75
+ if attributes.key?(:'explicitly_subscribed_event_types')
76
+ if (value = attributes[:'explicitly_subscribed_event_types']).is_a?(Array)
77
+ self.explicitly_subscribed_event_types = value
78
+ end
79
+ else
80
+ self.explicitly_subscribed_event_types = nil
81
+ end
82
+
83
+ if attributes.key?(:'has_catch_all_endpoint')
84
+ self.has_catch_all_endpoint = attributes[:'has_catch_all_endpoint']
85
+ else
86
+ self.has_catch_all_endpoint = nil
87
+ end
88
+ end
89
+
90
+ # Show invalid properties with the reasons. Usually used together with valid?
91
+ # @return Array for valid properties with the reasons
92
+ def list_invalid_properties
93
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
94
+ invalid_properties = Array.new
95
+ if @app_id.nil?
96
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
97
+ end
98
+
99
+ if @app_id.to_s.length > 31
100
+ invalid_properties.push('invalid value for "app_id", the character length must be smaller than or equal to 31.')
101
+ end
102
+
103
+ if @app_id.to_s.length < 31
104
+ invalid_properties.push('invalid value for "app_id", the character length must be great than or equal to 31.')
105
+ end
106
+
107
+ pattern = Regexp.new(/^app_[A-Za-z0-9]{27}$/)
108
+ if @app_id !~ pattern
109
+ invalid_properties.push("invalid value for \"app_id\", must conform to the pattern #{pattern}.")
110
+ end
111
+
112
+ if @explicitly_subscribed_event_types.nil?
113
+ invalid_properties.push('invalid value for "explicitly_subscribed_event_types", explicitly_subscribed_event_types cannot be nil.')
114
+ end
115
+
116
+ if @has_catch_all_endpoint.nil?
117
+ invalid_properties.push('invalid value for "has_catch_all_endpoint", has_catch_all_endpoint cannot be nil.')
118
+ end
119
+
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ warn '[DEPRECATED] the `valid?` method is obsolete'
127
+ return false if @app_id.nil?
128
+ return false if @app_id.to_s.length > 31
129
+ return false if @app_id.to_s.length < 31
130
+ return false if @app_id !~ Regexp.new(/^app_[A-Za-z0-9]{27}$/)
131
+ return false if @explicitly_subscribed_event_types.nil?
132
+ return false if @has_catch_all_endpoint.nil?
133
+ true
134
+ end
135
+
136
+ # Custom attribute writer method with validation
137
+ # @param [Object] app_id Value to be assigned
138
+ def app_id=(app_id)
139
+ if app_id.nil?
140
+ fail ArgumentError, 'app_id cannot be nil'
141
+ end
142
+
143
+ if app_id.to_s.length > 31
144
+ fail ArgumentError, 'invalid value for "app_id", the character length must be smaller than or equal to 31.'
145
+ end
146
+
147
+ if app_id.to_s.length < 31
148
+ fail ArgumentError, 'invalid value for "app_id", the character length must be great than or equal to 31.'
149
+ end
150
+
151
+ pattern = Regexp.new(/^app_[A-Za-z0-9]{27}$/)
152
+ if app_id !~ pattern
153
+ fail ArgumentError, "invalid value for \"app_id\", must conform to the pattern #{pattern}."
154
+ end
155
+
156
+ @app_id = app_id
157
+ end
158
+
159
+ # Custom attribute writer method with validation
160
+ # @param [Object] explicitly_subscribed_event_types Value to be assigned
161
+ def explicitly_subscribed_event_types=(explicitly_subscribed_event_types)
162
+ if explicitly_subscribed_event_types.nil?
163
+ fail ArgumentError, 'explicitly_subscribed_event_types cannot be nil'
164
+ end
165
+
166
+ @explicitly_subscribed_event_types = explicitly_subscribed_event_types
167
+ end
168
+
169
+ # Checks equality by comparing each attribute.
170
+ # @param [Object] Object to be compared
171
+ def ==(o)
172
+ return true if self.equal?(o)
173
+ self.class == o.class &&
174
+ app_id == o.app_id &&
175
+ explicitly_subscribed_event_types == o.explicitly_subscribed_event_types &&
176
+ has_catch_all_endpoint == o.has_catch_all_endpoint
177
+ end
178
+
179
+ # @see the `==` method
180
+ # @param [Object] Object to be compared
181
+ def eql?(o)
182
+ self == o
183
+ end
184
+
185
+ # Calculates hash code according to all attributes.
186
+ # @return [Integer] Hash code
187
+ def hash
188
+ [app_id, explicitly_subscribed_event_types, has_catch_all_endpoint].hash
189
+ end
190
+
191
+ # Builds the object from hash
192
+ # @param [Hash] attributes Model attributes in the form of hash
193
+ # @return [Object] Returns the model itself
194
+ def self.build_from_hash(attributes)
195
+ return nil unless attributes.is_a?(Hash)
196
+ attributes = attributes.transform_keys(&:to_sym)
197
+ transformed_hash = {}
198
+ openapi_types.each_pair do |key, type|
199
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
200
+ transformed_hash["#{key}"] = nil
201
+ elsif type =~ /\AArray<(.*)>/i
202
+ # check to ensure the input is an array given that the attribute
203
+ # is documented as an array but the input is not
204
+ if attributes[attribute_map[key]].is_a?(Array)
205
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
206
+ end
207
+ elsif !attributes[attribute_map[key]].nil?
208
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
209
+ end
210
+ end
211
+ new(transformed_hash)
212
+ end
213
+
214
+ # Deserializes the data based on type
215
+ # @param string type Data type
216
+ # @param string value Value to be deserialized
217
+ # @return [Object] Deserialized data
218
+ def self._deserialize(type, value)
219
+ case type.to_sym
220
+ when :Time
221
+ Time.parse(value)
222
+ when :Date
223
+ Date.parse(value)
224
+ when :String
225
+ value.to_s
226
+ when :Integer
227
+ value.to_i
228
+ when :Float
229
+ value.to_f
230
+ when :Boolean
231
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
232
+ true
233
+ else
234
+ false
235
+ end
236
+ when :Object
237
+ # generic object (usually a Hash), return directly
238
+ value
239
+ when /\AArray<(?<inner_type>.+)>\z/
240
+ inner_type = Regexp.last_match[:inner_type]
241
+ value.map { |v| _deserialize(inner_type, v) }
242
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
243
+ k_type = Regexp.last_match[:k_type]
244
+ v_type = Regexp.last_match[:v_type]
245
+ {}.tap do |hash|
246
+ value.each do |k, v|
247
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
248
+ end
249
+ end
250
+ else # model
251
+ # models (e.g. Pet) or oneOf
252
+ klass = Svix.const_get(type)
253
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
254
+ end
255
+ end
256
+
257
+ # Returns the string representation of the object
258
+ # @return [String] String presentation of the object
259
+ def to_s
260
+ to_hash.to_s
261
+ end
262
+
263
+ # to_body is an alias to to_hash (backward compatibility)
264
+ # @return [Hash] Returns the object in the form of hash
265
+ def to_body
266
+ to_hash
267
+ end
268
+
269
+ # Returns the object in the form of hash
270
+ # @return [Hash] Returns the object in the form of hash
271
+ def to_hash
272
+ hash = {}
273
+ self.class.attribute_map.each_pair do |attr, param|
274
+ value = self.send(attr)
275
+ if value.nil?
276
+ is_nullable = self.class.openapi_nullable.include?(attr)
277
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
278
+ end
279
+
280
+ hash[param] = _to_hash(value)
281
+ end
282
+ hash
283
+ end
284
+
285
+ # Outputs non-array value in the form of hash
286
+ # For object, use to_hash. Otherwise, just return the value
287
+ # @param [Object] value Any valid value
288
+ # @return [Hash] Returns the value in the form of hash
289
+ def _to_hash(value)
290
+ if value.is_a?(Array)
291
+ value.compact.map { |v| _to_hash(v) }
292
+ elsif value.is_a?(Hash)
293
+ {}.tap do |hash|
294
+ value.each { |k, v| hash[k] = _to_hash(v) }
295
+ end
296
+ elsif value.respond_to? :to_hash
297
+ value.to_hash
298
+ else
299
+ value
300
+ end
301
+ end
302
+
303
+ end
304
+
305
+ end
@@ -108,6 +108,14 @@ module Svix
108
108
  invalid_properties.push('invalid value for "expiry", must be greater than or equal to 3600.')
109
109
  end
110
110
 
111
+ if !@feature_flags.nil? && @feature_flags.length > 25
112
+ invalid_properties.push('invalid value for "feature_flags", number of items must be less than or equal to 25.')
113
+ end
114
+
115
+ if !@feature_flags.nil? && @feature_flags.length < 1
116
+ invalid_properties.push('invalid value for "feature_flags", number of items must be greater than or equal to 1.')
117
+ end
118
+
111
119
  invalid_properties
112
120
  end
113
121
 
@@ -117,6 +125,8 @@ module Svix
117
125
  warn '[DEPRECATED] the `valid?` method is obsolete'
118
126
  return false if !@expiry.nil? && @expiry > 604800
119
127
  return false if !@expiry.nil? && @expiry < 3600
128
+ return false if !@feature_flags.nil? && @feature_flags.length > 25
129
+ return false if !@feature_flags.nil? && @feature_flags.length < 1
120
130
  true
121
131
  end
122
132
 
@@ -141,6 +151,14 @@ module Svix
141
151
  fail ArgumentError, 'feature_flags cannot be nil'
142
152
  end
143
153
 
154
+ if feature_flags.length > 25
155
+ fail ArgumentError, 'invalid value for "feature_flags", number of items must be less than or equal to 25.'
156
+ end
157
+
158
+ if feature_flags.length < 1
159
+ fail ArgumentError, 'invalid value for "feature_flags", number of items must be greater than or equal to 1.'
160
+ end
161
+
144
162
  @feature_flags = feature_flags
145
163
  end
146
164
 
@@ -15,6 +15,7 @@ require 'time'
15
15
 
16
16
  module Svix
17
17
  class AppUsageStatsOut
18
+ # The QueueBackgroundTask's ID.
18
19
  attr_accessor :id
19
20
 
20
21
  attr_accessor :status
@@ -128,6 +129,19 @@ module Svix
128
129
  invalid_properties.push('invalid value for "id", id cannot be nil.')
129
130
  end
130
131
 
132
+ if @id.to_s.length > 33
133
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 33.')
134
+ end
135
+
136
+ if @id.to_s.length < 33
137
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 33.')
138
+ end
139
+
140
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
141
+ if @id !~ pattern
142
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
143
+ end
144
+
131
145
  if @status.nil?
132
146
  invalid_properties.push('invalid value for "status", status cannot be nil.')
133
147
  end
@@ -148,12 +162,38 @@ module Svix
148
162
  def valid?
149
163
  warn '[DEPRECATED] the `valid?` method is obsolete'
150
164
  return false if @id.nil?
165
+ return false if @id.to_s.length > 33
166
+ return false if @id.to_s.length < 33
167
+ return false if @id !~ Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
151
168
  return false if @status.nil?
152
169
  return false if @task.nil?
153
170
  return false if @unresolved_app_ids.nil?
154
171
  true
155
172
  end
156
173
 
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] id Value to be assigned
176
+ def id=(id)
177
+ if id.nil?
178
+ fail ArgumentError, 'id cannot be nil'
179
+ end
180
+
181
+ if id.to_s.length > 33
182
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 33.'
183
+ end
184
+
185
+ if id.to_s.length < 33
186
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 33.'
187
+ end
188
+
189
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
190
+ if id !~ pattern
191
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
192
+ end
193
+
194
+ @id = id
195
+ end
196
+
157
197
  # Custom attribute writer method with validation
158
198
  # @param [Object] unresolved_app_ids Value to be assigned
159
199
  def unresolved_app_ids=(unresolved_app_ids)
@@ -0,0 +1,277 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class ApplicationMessageFailure
18
+ # The Application's ID.
19
+ attr_accessor :app_id
20
+
21
+ attr_accessor :reason
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'app_id' => :'appId',
27
+ :'reason' => :'reason'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'app_id' => :'String',
40
+ :'reason' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::ApplicationMessageFailure` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::ApplicationMessageFailure`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'app_id')
66
+ self.app_id = attributes[:'app_id']
67
+ else
68
+ self.app_id = nil
69
+ end
70
+
71
+ if attributes.key?(:'reason')
72
+ self.reason = attributes[:'reason']
73
+ else
74
+ self.reason = nil
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
+ invalid_properties = Array.new
83
+ if @app_id.nil?
84
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
85
+ end
86
+
87
+ if @app_id.to_s.length > 31
88
+ invalid_properties.push('invalid value for "app_id", the character length must be smaller than or equal to 31.')
89
+ end
90
+
91
+ if @app_id.to_s.length < 31
92
+ invalid_properties.push('invalid value for "app_id", the character length must be great than or equal to 31.')
93
+ end
94
+
95
+ pattern = Regexp.new(/^app_[A-Za-z0-9]{27}$/)
96
+ if @app_id !~ pattern
97
+ invalid_properties.push("invalid value for \"app_id\", must conform to the pattern #{pattern}.")
98
+ end
99
+
100
+ if @reason.nil?
101
+ invalid_properties.push('invalid value for "reason", reason cannot be nil.')
102
+ end
103
+
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ warn '[DEPRECATED] the `valid?` method is obsolete'
111
+ return false if @app_id.nil?
112
+ return false if @app_id.to_s.length > 31
113
+ return false if @app_id.to_s.length < 31
114
+ return false if @app_id !~ Regexp.new(/^app_[A-Za-z0-9]{27}$/)
115
+ return false if @reason.nil?
116
+ true
117
+ end
118
+
119
+ # Custom attribute writer method with validation
120
+ # @param [Object] app_id Value to be assigned
121
+ def app_id=(app_id)
122
+ if app_id.nil?
123
+ fail ArgumentError, 'app_id cannot be nil'
124
+ end
125
+
126
+ if app_id.to_s.length > 31
127
+ fail ArgumentError, 'invalid value for "app_id", the character length must be smaller than or equal to 31.'
128
+ end
129
+
130
+ if app_id.to_s.length < 31
131
+ fail ArgumentError, 'invalid value for "app_id", the character length must be great than or equal to 31.'
132
+ end
133
+
134
+ pattern = Regexp.new(/^app_[A-Za-z0-9]{27}$/)
135
+ if app_id !~ pattern
136
+ fail ArgumentError, "invalid value for \"app_id\", must conform to the pattern #{pattern}."
137
+ end
138
+
139
+ @app_id = app_id
140
+ end
141
+
142
+ # Checks equality by comparing each attribute.
143
+ # @param [Object] Object to be compared
144
+ def ==(o)
145
+ return true if self.equal?(o)
146
+ self.class == o.class &&
147
+ app_id == o.app_id &&
148
+ reason == o.reason
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [app_id, reason].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ attributes = attributes.transform_keys(&:to_sym)
169
+ transformed_hash = {}
170
+ openapi_types.each_pair do |key, type|
171
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
172
+ transformed_hash["#{key}"] = nil
173
+ elsif type =~ /\AArray<(.*)>/i
174
+ # check to ensure the input is an array given that the attribute
175
+ # is documented as an array but the input is not
176
+ if attributes[attribute_map[key]].is_a?(Array)
177
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
178
+ end
179
+ elsif !attributes[attribute_map[key]].nil?
180
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
181
+ end
182
+ end
183
+ new(transformed_hash)
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def self._deserialize(type, value)
191
+ case type.to_sym
192
+ when :Time
193
+ Time.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :Boolean
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ # models (e.g. Pet) or oneOf
224
+ klass = Svix.const_get(type)
225
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ if value.nil?
248
+ is_nullable = self.class.openapi_nullable.include?(attr)
249
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
+ end
251
+
252
+ hash[param] = _to_hash(value)
253
+ end
254
+ hash
255
+ end
256
+
257
+ # Outputs non-array value in the form of hash
258
+ # For object, use to_hash. Otherwise, just return the value
259
+ # @param [Object] value Any valid value
260
+ # @return [Hash] Returns the value in the form of hash
261
+ def _to_hash(value)
262
+ if value.is_a?(Array)
263
+ value.compact.map { |v| _to_hash(v) }
264
+ elsif value.is_a?(Hash)
265
+ {}.tap do |hash|
266
+ value.each { |k, v| hash[k] = _to_hash(v) }
267
+ end
268
+ elsif value.respond_to? :to_hash
269
+ value.to_hash
270
+ else
271
+ value
272
+ end
273
+ end
274
+
275
+ end
276
+
277
+ end