svix 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/application_api.rb +1 -1
  4. data/lib/svix/api/authentication_api.rb +1 -1
  5. data/lib/svix/api/background_tasks_api.rb +1 -1
  6. data/lib/svix/api/broadcast_api.rb +1 -1
  7. data/lib/svix/api/endpoint_api.rb +1 -1
  8. data/lib/svix/api/environment_api.rb +1 -1
  9. data/lib/svix/api/environment_settings_api.rb +1 -1
  10. data/lib/svix/api/event_type_api.rb +1 -1
  11. data/lib/svix/api/health_api.rb +1 -1
  12. data/lib/svix/api/integration_api.rb +1 -1
  13. data/lib/svix/api/message_api.rb +3 -3
  14. data/lib/svix/api/message_attempt_api.rb +21 -12
  15. data/lib/svix/api/statistics_api.rb +1 -1
  16. data/lib/svix/api/transformation_template_api.rb +432 -0
  17. data/lib/svix/api_client.rb +1 -1
  18. data/lib/svix/api_error.rb +1 -1
  19. data/lib/svix/configuration.rb +1 -1
  20. data/lib/svix/models/app_portal_access_in.rb +1 -1
  21. data/lib/svix/models/app_portal_access_out.rb +1 -1
  22. data/lib/svix/models/app_usage_stats_in.rb +1 -1
  23. data/lib/svix/models/app_usage_stats_out.rb +1 -1
  24. data/lib/svix/models/application_in.rb +1 -1
  25. data/lib/svix/models/application_out.rb +1 -1
  26. data/lib/svix/models/application_patch.rb +1 -1
  27. data/lib/svix/models/application_stats.rb +1 -1
  28. data/lib/svix/models/application_token_expire_in.rb +1 -1
  29. data/lib/svix/models/attempt_statistics_data.rb +1 -1
  30. data/lib/svix/models/attempt_statistics_response.rb +1 -1
  31. data/lib/svix/models/background_task_out.rb +1 -1
  32. data/lib/svix/models/background_task_status.rb +1 -1
  33. data/lib/svix/models/background_task_type.rb +1 -1
  34. data/lib/svix/models/border_radius_config.rb +1 -1
  35. data/lib/svix/models/border_radius_enum.rb +1 -1
  36. data/lib/svix/models/custom_color_palette.rb +1 -1
  37. data/lib/svix/models/custom_theme_override.rb +1 -1
  38. data/lib/svix/models/dashboard_access_out.rb +1 -1
  39. data/lib/svix/models/endpoint_created_event.rb +1 -1
  40. data/lib/svix/models/endpoint_created_event_data.rb +1 -1
  41. data/lib/svix/models/endpoint_deleted_event.rb +1 -1
  42. data/lib/svix/models/endpoint_deleted_event_data.rb +1 -1
  43. data/lib/svix/models/endpoint_disabled_event.rb +1 -1
  44. data/lib/svix/models/endpoint_disabled_event_data.rb +1 -1
  45. data/lib/svix/models/endpoint_headers_in.rb +1 -1
  46. data/lib/svix/models/endpoint_headers_out.rb +1 -1
  47. data/lib/svix/models/endpoint_headers_patch_in.rb +1 -1
  48. data/lib/svix/models/endpoint_in.rb +7 -13
  49. data/lib/svix/models/endpoint_message_out.rb +1 -1
  50. data/lib/svix/models/endpoint_out.rb +1 -1
  51. data/lib/svix/models/endpoint_patch.rb +6 -6
  52. data/lib/svix/models/endpoint_secret_out.rb +1 -1
  53. data/lib/svix/models/endpoint_secret_rotate_in.rb +1 -1
  54. data/lib/svix/models/endpoint_stats.rb +1 -1
  55. data/lib/svix/models/endpoint_transformation_in.rb +1 -1
  56. data/lib/svix/models/endpoint_transformation_out.rb +1 -1
  57. data/lib/svix/models/endpoint_transformation_simulate_in.rb +1 -1
  58. data/lib/svix/models/endpoint_transformation_simulate_out.rb +1 -1
  59. data/lib/svix/models/endpoint_update.rb +7 -13
  60. data/lib/svix/models/endpoint_updated_event.rb +1 -1
  61. data/lib/svix/models/endpoint_updated_event_data.rb +1 -1
  62. data/lib/svix/models/environment_in.rb +1 -1
  63. data/lib/svix/models/environment_out.rb +1 -1
  64. data/lib/svix/models/environment_settings_out.rb +1 -1
  65. data/lib/svix/models/event_example_in.rb +1 -1
  66. data/lib/svix/models/event_type_example_out.rb +1 -1
  67. data/lib/svix/models/event_type_in.rb +1 -1
  68. data/lib/svix/models/event_type_out.rb +1 -1
  69. data/lib/svix/models/event_type_patch.rb +1 -1
  70. data/lib/svix/models/event_type_schema_in.rb +1 -1
  71. data/lib/svix/models/event_type_update.rb +1 -1
  72. data/lib/svix/models/font_size_config.rb +1 -1
  73. data/lib/svix/models/http_error_out.rb +1 -1
  74. data/lib/svix/models/http_validation_error.rb +1 -1
  75. data/lib/svix/models/integration_in.rb +1 -1
  76. data/lib/svix/models/integration_key_out.rb +1 -1
  77. data/lib/svix/models/integration_out.rb +1 -1
  78. data/lib/svix/models/integration_update.rb +1 -1
  79. data/lib/svix/models/list_response_application_out.rb +1 -1
  80. data/lib/svix/models/list_response_application_stats.rb +1 -1
  81. data/lib/svix/models/list_response_background_task_out.rb +1 -1
  82. data/lib/svix/models/list_response_endpoint_message_out.rb +1 -1
  83. data/lib/svix/models/list_response_endpoint_out.rb +1 -1
  84. data/lib/svix/models/list_response_event_type_out.rb +1 -1
  85. data/lib/svix/models/list_response_integration_out.rb +1 -1
  86. data/lib/svix/models/list_response_message_attempt_endpoint_out.rb +1 -1
  87. data/lib/svix/models/list_response_message_attempt_out.rb +1 -1
  88. data/lib/svix/models/list_response_message_endpoint_out.rb +1 -1
  89. data/lib/svix/models/list_response_message_out.rb +1 -1
  90. data/lib/svix/models/list_response_template_out.rb +259 -0
  91. data/lib/svix/models/message_attempt_endpoint_out.rb +1 -1
  92. data/lib/svix/models/message_attempt_exhausted_event.rb +1 -1
  93. data/lib/svix/models/message_attempt_exhausted_event_data.rb +1 -1
  94. data/lib/svix/models/message_attempt_failed_data.rb +1 -1
  95. data/lib/svix/models/message_attempt_failing_event.rb +1 -1
  96. data/lib/svix/models/message_attempt_failing_event_data.rb +1 -1
  97. data/lib/svix/models/message_attempt_headers_out.rb +1 -1
  98. data/lib/svix/models/message_attempt_out.rb +1 -1
  99. data/lib/svix/models/message_attempt_recovered_event.rb +274 -0
  100. data/lib/svix/models/message_attempt_recovered_event_data.rb +361 -0
  101. data/lib/svix/models/message_attempt_trigger_type.rb +1 -1
  102. data/lib/svix/models/message_broadcast_in.rb +1 -1
  103. data/lib/svix/models/message_broadcast_out.rb +1 -1
  104. data/lib/svix/models/message_endpoint_out.rb +1 -1
  105. data/lib/svix/models/message_in.rb +1 -1
  106. data/lib/svix/models/message_out.rb +1 -1
  107. data/lib/svix/models/message_status.rb +1 -1
  108. data/lib/svix/models/one_time_token_in.rb +1 -1
  109. data/lib/svix/models/one_time_token_out.rb +1 -1
  110. data/lib/svix/models/ordering.rb +1 -1
  111. data/lib/svix/models/recover_in.rb +1 -1
  112. data/lib/svix/models/recover_out.rb +1 -1
  113. data/lib/svix/models/replay_in.rb +1 -1
  114. data/lib/svix/models/replay_out.rb +1 -1
  115. data/lib/svix/models/settings_in.rb +1 -1
  116. data/lib/svix/models/settings_out.rb +1 -1
  117. data/lib/svix/models/statistics_period.rb +1 -1
  118. data/lib/svix/models/status_code_class.rb +1 -1
  119. data/lib/svix/models/template_in.rb +340 -0
  120. data/lib/svix/models/template_out.rb +386 -0
  121. data/lib/svix/models/template_patch.rb +315 -0
  122. data/lib/svix/models/template_update.rb +335 -0
  123. data/lib/svix/models/transformation_http_method.rb +1 -1
  124. data/lib/svix/models/transformation_template_kind.rb +36 -0
  125. data/lib/svix/models/validation_error.rb +1 -1
  126. data/lib/svix/version.rb +1 -1
  127. metadata +11 -2
@@ -0,0 +1,386 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #Welcome to the Svix API documentation! Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/) # Introduction This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com). ## Main concepts In Svix you have four important entities you will be interacting with: - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each user on your platform. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint. ## Authentication Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`. For more information on authentication, please refer to the [authentication token docs](https://docs.svix.com/api-keys). <SecurityDefinitions /> ## Code samples The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.
5
+
6
+ The version of the OpenAPI document: 1.7.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class TemplateOut
18
+ attr_accessor :created_at
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :filter_types
23
+
24
+ attr_accessor :id
25
+
26
+ attr_accessor :instructions
27
+
28
+ attr_accessor :instructions_link
29
+
30
+ attr_accessor :kind
31
+
32
+ attr_accessor :logo
33
+
34
+ attr_accessor :name
35
+
36
+ attr_accessor :org_id
37
+
38
+ attr_accessor :transformation
39
+
40
+ attr_accessor :updated_at
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'created_at' => :'createdAt',
46
+ :'description' => :'description',
47
+ :'filter_types' => :'filterTypes',
48
+ :'id' => :'id',
49
+ :'instructions' => :'instructions',
50
+ :'instructions_link' => :'instructionsLink',
51
+ :'kind' => :'kind',
52
+ :'logo' => :'logo',
53
+ :'name' => :'name',
54
+ :'org_id' => :'orgId',
55
+ :'transformation' => :'transformation',
56
+ :'updated_at' => :'updatedAt'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'created_at' => :'Time',
69
+ :'description' => :'String',
70
+ :'filter_types' => :'Array<String>',
71
+ :'id' => :'String',
72
+ :'instructions' => :'String',
73
+ :'instructions_link' => :'String',
74
+ :'kind' => :'TransformationTemplateKind',
75
+ :'logo' => :'String',
76
+ :'name' => :'String',
77
+ :'org_id' => :'String',
78
+ :'transformation' => :'String',
79
+ :'updated_at' => :'Time'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ :'filter_types',
87
+ :'instructions_link',
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::TemplateOut` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::TemplateOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'created_at')
107
+ self.created_at = attributes[:'created_at']
108
+ end
109
+
110
+ if attributes.key?(:'description')
111
+ self.description = attributes[:'description']
112
+ end
113
+
114
+ if attributes.key?(:'filter_types')
115
+ if (value = attributes[:'filter_types']).is_a?(Array)
116
+ self.filter_types = value
117
+ end
118
+ end
119
+
120
+ if attributes.key?(:'id')
121
+ self.id = attributes[:'id']
122
+ end
123
+
124
+ if attributes.key?(:'instructions')
125
+ self.instructions = attributes[:'instructions']
126
+ end
127
+
128
+ if attributes.key?(:'instructions_link')
129
+ self.instructions_link = attributes[:'instructions_link']
130
+ end
131
+
132
+ if attributes.key?(:'kind')
133
+ self.kind = attributes[:'kind']
134
+ end
135
+
136
+ if attributes.key?(:'logo')
137
+ self.logo = attributes[:'logo']
138
+ end
139
+
140
+ if attributes.key?(:'name')
141
+ self.name = attributes[:'name']
142
+ end
143
+
144
+ if attributes.key?(:'org_id')
145
+ self.org_id = attributes[:'org_id']
146
+ end
147
+
148
+ if attributes.key?(:'transformation')
149
+ self.transformation = attributes[:'transformation']
150
+ end
151
+
152
+ if attributes.key?(:'updated_at')
153
+ self.updated_at = attributes[:'updated_at']
154
+ end
155
+ end
156
+
157
+ # Show invalid properties with the reasons. Usually used together with valid?
158
+ # @return Array for valid properties with the reasons
159
+ def list_invalid_properties
160
+ invalid_properties = Array.new
161
+ if @created_at.nil?
162
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
163
+ end
164
+
165
+ if @description.nil?
166
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
167
+ end
168
+
169
+ if !@filter_types.nil? && @filter_types.length < 1
170
+ invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
171
+ end
172
+
173
+ if @id.nil?
174
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
175
+ end
176
+
177
+ if @instructions.nil?
178
+ invalid_properties.push('invalid value for "instructions", instructions cannot be nil.')
179
+ end
180
+
181
+ if @kind.nil?
182
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
183
+ end
184
+
185
+ if @logo.nil?
186
+ invalid_properties.push('invalid value for "logo", logo cannot be nil.')
187
+ end
188
+
189
+ if @name.nil?
190
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
191
+ end
192
+
193
+ if @org_id.nil?
194
+ invalid_properties.push('invalid value for "org_id", org_id cannot be nil.')
195
+ end
196
+
197
+ if @transformation.nil?
198
+ invalid_properties.push('invalid value for "transformation", transformation cannot be nil.')
199
+ end
200
+
201
+ if @updated_at.nil?
202
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
203
+ end
204
+
205
+ invalid_properties
206
+ end
207
+
208
+ # Check to see if the all the properties in the model are valid
209
+ # @return true if the model is valid
210
+ def valid?
211
+ return false if @created_at.nil?
212
+ return false if @description.nil?
213
+ return false if !@filter_types.nil? && @filter_types.length < 1
214
+ return false if @id.nil?
215
+ return false if @instructions.nil?
216
+ return false if @kind.nil?
217
+ return false if @logo.nil?
218
+ return false if @name.nil?
219
+ return false if @org_id.nil?
220
+ return false if @transformation.nil?
221
+ return false if @updated_at.nil?
222
+ true
223
+ end
224
+
225
+ # Custom attribute writer method with validation
226
+ # @param [Object] filter_types Value to be assigned
227
+ def filter_types=(filter_types)
228
+ if !filter_types.nil? && filter_types.length < 1
229
+ fail ArgumentError, 'invalid value for "filter_types", number of items must be greater than or equal to 1.'
230
+ end
231
+
232
+ @filter_types = filter_types
233
+ end
234
+
235
+ # Checks equality by comparing each attribute.
236
+ # @param [Object] Object to be compared
237
+ def ==(o)
238
+ return true if self.equal?(o)
239
+ self.class == o.class &&
240
+ created_at == o.created_at &&
241
+ description == o.description &&
242
+ filter_types == o.filter_types &&
243
+ id == o.id &&
244
+ instructions == o.instructions &&
245
+ instructions_link == o.instructions_link &&
246
+ kind == o.kind &&
247
+ logo == o.logo &&
248
+ name == o.name &&
249
+ org_id == o.org_id &&
250
+ transformation == o.transformation &&
251
+ updated_at == o.updated_at
252
+ end
253
+
254
+ # @see the `==` method
255
+ # @param [Object] Object to be compared
256
+ def eql?(o)
257
+ self == o
258
+ end
259
+
260
+ # Calculates hash code according to all attributes.
261
+ # @return [Integer] Hash code
262
+ def hash
263
+ [created_at, description, filter_types, id, instructions, instructions_link, kind, logo, name, org_id, transformation, updated_at].hash
264
+ end
265
+
266
+ # Builds the object from hash
267
+ # @param [Hash] attributes Model attributes in the form of hash
268
+ # @return [Object] Returns the model itself
269
+ def self.build_from_hash(attributes)
270
+ new.build_from_hash(attributes)
271
+ end
272
+
273
+ # Builds the object from hash
274
+ # @param [Hash] attributes Model attributes in the form of hash
275
+ # @return [Object] Returns the model itself
276
+ def build_from_hash(attributes)
277
+ return nil unless attributes.is_a?(Hash)
278
+ self.class.openapi_types.each_pair do |key, type|
279
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
280
+ self.send("#{key}=", nil)
281
+ elsif type =~ /\AArray<(.*)>/i
282
+ # check to ensure the input is an array given that the attribute
283
+ # is documented as an array but the input is not
284
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
285
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
286
+ end
287
+ elsif !attributes[self.class.attribute_map[key]].nil?
288
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
289
+ end
290
+ end
291
+
292
+ self
293
+ end
294
+
295
+ # Deserializes the data based on type
296
+ # @param string type Data type
297
+ # @param string value Value to be deserialized
298
+ # @return [Object] Deserialized data
299
+ def _deserialize(type, value)
300
+ case type.to_sym
301
+ when :Time
302
+ Time.parse(value)
303
+ when :Date
304
+ Date.parse(value)
305
+ when :String
306
+ value.to_s
307
+ when :Integer
308
+ value.to_i
309
+ when :Float
310
+ value.to_f
311
+ when :Boolean
312
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
313
+ true
314
+ else
315
+ false
316
+ end
317
+ when :Object
318
+ # generic object (usually a Hash), return directly
319
+ value
320
+ when /\AArray<(?<inner_type>.+)>\z/
321
+ inner_type = Regexp.last_match[:inner_type]
322
+ value.map { |v| _deserialize(inner_type, v) }
323
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
324
+ k_type = Regexp.last_match[:k_type]
325
+ v_type = Regexp.last_match[:v_type]
326
+ {}.tap do |hash|
327
+ value.each do |k, v|
328
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
329
+ end
330
+ end
331
+ else # model
332
+ # models (e.g. Pet) or oneOf
333
+ klass = Svix.const_get(type)
334
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
335
+ end
336
+ end
337
+
338
+ # Returns the string representation of the object
339
+ # @return [String] String presentation of the object
340
+ def to_s
341
+ to_hash.to_s
342
+ end
343
+
344
+ # to_body is an alias to to_hash (backward compatibility)
345
+ # @return [Hash] Returns the object in the form of hash
346
+ def to_body
347
+ to_hash
348
+ end
349
+
350
+ # Returns the object in the form of hash
351
+ # @return [Hash] Returns the object in the form of hash
352
+ def to_hash
353
+ hash = {}
354
+ self.class.attribute_map.each_pair do |attr, param|
355
+ value = self.send(attr)
356
+ if value.nil?
357
+ is_nullable = self.class.openapi_nullable.include?(attr)
358
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
359
+ end
360
+
361
+ hash[param] = _to_hash(value)
362
+ end
363
+ hash
364
+ end
365
+
366
+ # Outputs non-array value in the form of hash
367
+ # For object, use to_hash. Otherwise, just return the value
368
+ # @param [Object] value Any valid value
369
+ # @return [Hash] Returns the value in the form of hash
370
+ def _to_hash(value)
371
+ if value.is_a?(Array)
372
+ value.compact.map { |v| _to_hash(v) }
373
+ elsif value.is_a?(Hash)
374
+ {}.tap do |hash|
375
+ value.each { |k, v| hash[k] = _to_hash(v) }
376
+ end
377
+ elsif value.respond_to? :to_hash
378
+ value.to_hash
379
+ else
380
+ value
381
+ end
382
+ end
383
+
384
+ end
385
+
386
+ end
@@ -0,0 +1,315 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #Welcome to the Svix API documentation! Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/) # Introduction This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com). ## Main concepts In Svix you have four important entities you will be interacting with: - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each user on your platform. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint. ## Authentication Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`. For more information on authentication, please refer to the [authentication token docs](https://docs.svix.com/api-keys). <SecurityDefinitions /> ## Code samples The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.
5
+
6
+ The version of the OpenAPI document: 1.7.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class TemplatePatch
18
+ attr_accessor :description
19
+
20
+ attr_accessor :filter_types
21
+
22
+ attr_accessor :instructions
23
+
24
+ attr_accessor :instructions_link
25
+
26
+ attr_accessor :logo
27
+
28
+ attr_accessor :name
29
+
30
+ attr_accessor :transformation
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'description' => :'description',
36
+ :'filter_types' => :'filterTypes',
37
+ :'instructions' => :'instructions',
38
+ :'instructions_link' => :'instructionsLink',
39
+ :'logo' => :'logo',
40
+ :'name' => :'name',
41
+ :'transformation' => :'transformation'
42
+ }
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'description' => :'String',
54
+ :'filter_types' => :'Array<String>',
55
+ :'instructions' => :'String',
56
+ :'instructions_link' => :'String',
57
+ :'logo' => :'String',
58
+ :'name' => :'String',
59
+ :'transformation' => :'String'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ :'filter_types',
67
+ :'instructions_link',
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::TemplatePatch` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::TemplatePatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'description')
87
+ self.description = attributes[:'description']
88
+ end
89
+
90
+ if attributes.key?(:'filter_types')
91
+ if (value = attributes[:'filter_types']).is_a?(Array)
92
+ self.filter_types = value
93
+ end
94
+ end
95
+
96
+ if attributes.key?(:'instructions')
97
+ self.instructions = attributes[:'instructions']
98
+ end
99
+
100
+ if attributes.key?(:'instructions_link')
101
+ self.instructions_link = attributes[:'instructions_link']
102
+ end
103
+
104
+ if attributes.key?(:'logo')
105
+ self.logo = attributes[:'logo']
106
+ end
107
+
108
+ if attributes.key?(:'name')
109
+ self.name = attributes[:'name']
110
+ end
111
+
112
+ if attributes.key?(:'transformation')
113
+ self.transformation = attributes[:'transformation']
114
+ end
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def list_invalid_properties
120
+ invalid_properties = Array.new
121
+ if !@filter_types.nil? && @filter_types.length < 1
122
+ invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
123
+ end
124
+
125
+ if !@transformation.nil? && @transformation.to_s.length > 51200
126
+ invalid_properties.push('invalid value for "transformation", the character length must be smaller than or equal to 51200.')
127
+ end
128
+
129
+ if !@transformation.nil? && @transformation.to_s.length < 10
130
+ invalid_properties.push('invalid value for "transformation", the character length must be great than or equal to 10.')
131
+ end
132
+
133
+ invalid_properties
134
+ end
135
+
136
+ # Check to see if the all the properties in the model are valid
137
+ # @return true if the model is valid
138
+ def valid?
139
+ return false if !@filter_types.nil? && @filter_types.length < 1
140
+ return false if !@transformation.nil? && @transformation.to_s.length > 51200
141
+ return false if !@transformation.nil? && @transformation.to_s.length < 10
142
+ true
143
+ end
144
+
145
+ # Custom attribute writer method with validation
146
+ # @param [Object] filter_types Value to be assigned
147
+ def filter_types=(filter_types)
148
+ if !filter_types.nil? && filter_types.length < 1
149
+ fail ArgumentError, 'invalid value for "filter_types", number of items must be greater than or equal to 1.'
150
+ end
151
+
152
+ @filter_types = filter_types
153
+ end
154
+
155
+ # Custom attribute writer method with validation
156
+ # @param [Object] transformation Value to be assigned
157
+ def transformation=(transformation)
158
+ if !transformation.nil? && transformation.to_s.length > 51200
159
+ fail ArgumentError, 'invalid value for "transformation", the character length must be smaller than or equal to 51200.'
160
+ end
161
+
162
+ if !transformation.nil? && transformation.to_s.length < 10
163
+ fail ArgumentError, 'invalid value for "transformation", the character length must be great than or equal to 10.'
164
+ end
165
+
166
+ @transformation = transformation
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
+ description == o.description &&
175
+ filter_types == o.filter_types &&
176
+ instructions == o.instructions &&
177
+ instructions_link == o.instructions_link &&
178
+ logo == o.logo &&
179
+ name == o.name &&
180
+ transformation == o.transformation
181
+ end
182
+
183
+ # @see the `==` method
184
+ # @param [Object] Object to be compared
185
+ def eql?(o)
186
+ self == o
187
+ end
188
+
189
+ # Calculates hash code according to all attributes.
190
+ # @return [Integer] Hash code
191
+ def hash
192
+ [description, filter_types, instructions, instructions_link, logo, name, transformation].hash
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def self.build_from_hash(attributes)
199
+ new.build_from_hash(attributes)
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def build_from_hash(attributes)
206
+ return nil unless attributes.is_a?(Hash)
207
+ self.class.openapi_types.each_pair do |key, type|
208
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
209
+ self.send("#{key}=", nil)
210
+ elsif type =~ /\AArray<(.*)>/i
211
+ # check to ensure the input is an array given that the attribute
212
+ # is documented as an array but the input is not
213
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
214
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
215
+ end
216
+ elsif !attributes[self.class.attribute_map[key]].nil?
217
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
218
+ end
219
+ end
220
+
221
+ self
222
+ end
223
+
224
+ # Deserializes the data based on type
225
+ # @param string type Data type
226
+ # @param string value Value to be deserialized
227
+ # @return [Object] Deserialized data
228
+ def _deserialize(type, value)
229
+ case type.to_sym
230
+ when :Time
231
+ Time.parse(value)
232
+ when :Date
233
+ Date.parse(value)
234
+ when :String
235
+ value.to_s
236
+ when :Integer
237
+ value.to_i
238
+ when :Float
239
+ value.to_f
240
+ when :Boolean
241
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
242
+ true
243
+ else
244
+ false
245
+ end
246
+ when :Object
247
+ # generic object (usually a Hash), return directly
248
+ value
249
+ when /\AArray<(?<inner_type>.+)>\z/
250
+ inner_type = Regexp.last_match[:inner_type]
251
+ value.map { |v| _deserialize(inner_type, v) }
252
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
253
+ k_type = Regexp.last_match[:k_type]
254
+ v_type = Regexp.last_match[:v_type]
255
+ {}.tap do |hash|
256
+ value.each do |k, v|
257
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
258
+ end
259
+ end
260
+ else # model
261
+ # models (e.g. Pet) or oneOf
262
+ klass = Svix.const_get(type)
263
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
264
+ end
265
+ end
266
+
267
+ # Returns the string representation of the object
268
+ # @return [String] String presentation of the object
269
+ def to_s
270
+ to_hash.to_s
271
+ end
272
+
273
+ # to_body is an alias to to_hash (backward compatibility)
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_body
276
+ to_hash
277
+ end
278
+
279
+ # Returns the object in the form of hash
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_hash
282
+ hash = {}
283
+ self.class.attribute_map.each_pair do |attr, param|
284
+ value = self.send(attr)
285
+ if value.nil?
286
+ is_nullable = self.class.openapi_nullable.include?(attr)
287
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
288
+ end
289
+
290
+ hash[param] = _to_hash(value)
291
+ end
292
+ hash
293
+ end
294
+
295
+ # Outputs non-array value in the form of hash
296
+ # For object, use to_hash. Otherwise, just return the value
297
+ # @param [Object] value Any valid value
298
+ # @return [Hash] Returns the value in the form of hash
299
+ def _to_hash(value)
300
+ if value.is_a?(Array)
301
+ value.compact.map { |v| _to_hash(v) }
302
+ elsif value.is_a?(Hash)
303
+ {}.tap do |hash|
304
+ value.each { |k, v| hash[k] = _to_hash(v) }
305
+ end
306
+ elsif value.respond_to? :to_hash
307
+ value.to_hash
308
+ else
309
+ value
310
+ end
311
+ end
312
+
313
+ end
314
+
315
+ end