svix 1.15.0 → 1.16.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.
@@ -0,0 +1,281 @@
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
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class GenerateOut
18
+ attr_accessor :choices
19
+
20
+ attr_accessor :created
21
+
22
+ attr_accessor :id
23
+
24
+ attr_accessor :model
25
+
26
+ attr_accessor :object
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'choices' => :'choices',
32
+ :'created' => :'created',
33
+ :'id' => :'id',
34
+ :'model' => :'model',
35
+ :'object' => :'object'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'choices' => :'Array<CompletionChoice>',
48
+ :'created' => :'Integer',
49
+ :'id' => :'String',
50
+ :'model' => :'String',
51
+ :'object' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::GenerateOut` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::GenerateOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'choices')
77
+ if (value = attributes[:'choices']).is_a?(Array)
78
+ self.choices = value
79
+ end
80
+ end
81
+
82
+ if attributes.key?(:'created')
83
+ self.created = attributes[:'created']
84
+ end
85
+
86
+ if attributes.key?(:'id')
87
+ self.id = attributes[:'id']
88
+ end
89
+
90
+ if attributes.key?(:'model')
91
+ self.model = attributes[:'model']
92
+ end
93
+
94
+ if attributes.key?(:'object')
95
+ self.object = attributes[:'object']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ if @choices.nil?
104
+ invalid_properties.push('invalid value for "choices", choices cannot be nil.')
105
+ end
106
+
107
+ if @created.nil?
108
+ invalid_properties.push('invalid value for "created", created cannot be nil.')
109
+ end
110
+
111
+ if @id.nil?
112
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
113
+ end
114
+
115
+ if @model.nil?
116
+ invalid_properties.push('invalid value for "model", model cannot be nil.')
117
+ end
118
+
119
+ if @object.nil?
120
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
121
+ end
122
+
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ return false if @choices.nil?
130
+ return false if @created.nil?
131
+ return false if @id.nil?
132
+ return false if @model.nil?
133
+ return false if @object.nil?
134
+ true
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ choices == o.choices &&
143
+ created == o.created &&
144
+ id == o.id &&
145
+ model == o.model &&
146
+ object == o.object
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [choices, created, id, model, object].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ new.build_from_hash(attributes)
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def build_from_hash(attributes)
172
+ return nil unless attributes.is_a?(Hash)
173
+ self.class.openapi_types.each_pair do |key, type|
174
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
175
+ self.send("#{key}=", nil)
176
+ elsif type =~ /\AArray<(.*)>/i
177
+ # check to ensure the input is an array given that the attribute
178
+ # is documented as an array but the input is not
179
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
180
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
181
+ end
182
+ elsif !attributes[self.class.attribute_map[key]].nil?
183
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
184
+ end
185
+ end
186
+
187
+ self
188
+ end
189
+
190
+ # Deserializes the data based on type
191
+ # @param string type Data type
192
+ # @param string value Value to be deserialized
193
+ # @return [Object] Deserialized data
194
+ def _deserialize(type, value)
195
+ case type.to_sym
196
+ when :Time
197
+ Time.parse(value)
198
+ when :Date
199
+ Date.parse(value)
200
+ when :String
201
+ value.to_s
202
+ when :Integer
203
+ value.to_i
204
+ when :Float
205
+ value.to_f
206
+ when :Boolean
207
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
208
+ true
209
+ else
210
+ false
211
+ end
212
+ when :Object
213
+ # generic object (usually a Hash), return directly
214
+ value
215
+ when /\AArray<(?<inner_type>.+)>\z/
216
+ inner_type = Regexp.last_match[:inner_type]
217
+ value.map { |v| _deserialize(inner_type, v) }
218
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
219
+ k_type = Regexp.last_match[:k_type]
220
+ v_type = Regexp.last_match[:v_type]
221
+ {}.tap do |hash|
222
+ value.each do |k, v|
223
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
224
+ end
225
+ end
226
+ else # model
227
+ # models (e.g. Pet) or oneOf
228
+ klass = Svix.const_get(type)
229
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
230
+ end
231
+ end
232
+
233
+ # Returns the string representation of the object
234
+ # @return [String] String presentation of the object
235
+ def to_s
236
+ to_hash.to_s
237
+ end
238
+
239
+ # to_body is an alias to to_hash (backward compatibility)
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_body
242
+ to_hash
243
+ end
244
+
245
+ # Returns the object in the form of hash
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_hash
248
+ hash = {}
249
+ self.class.attribute_map.each_pair do |attr, param|
250
+ value = self.send(attr)
251
+ if value.nil?
252
+ is_nullable = self.class.openapi_nullable.include?(attr)
253
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
254
+ end
255
+
256
+ hash[param] = _to_hash(value)
257
+ end
258
+ hash
259
+ end
260
+
261
+ # Outputs non-array value in the form of hash
262
+ # For object, use to_hash. Otherwise, just return the value
263
+ # @param [Object] value Any valid value
264
+ # @return [Hash] Returns the value in the form of hash
265
+ def _to_hash(value)
266
+ if value.is_a?(Array)
267
+ value.compact.map { |v| _to_hash(v) }
268
+ elsif value.is_a?(Hash)
269
+ {}.tap do |hash|
270
+ value.each { |k, v| hash[k] = _to_hash(v) }
271
+ end
272
+ elsif value.respond_to? :to_hash
273
+ value.to_hash
274
+ else
275
+ value
276
+ end
277
+ end
278
+
279
+ end
280
+
281
+ end
@@ -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
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class InboundPathParams
18
+ # The app's ID or UID
19
+ attr_accessor :app_id
20
+
21
+ attr_accessor :inbound_token
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'app_id' => :'app_id',
27
+ :'inbound_token' => :'inbound_token'
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
+ :'inbound_token' => :'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::InboundPathParams` 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::InboundPathParams`. 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
+ end
68
+
69
+ if attributes.key?(:'inbound_token')
70
+ self.inbound_token = attributes[:'inbound_token']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ if @app_id.nil?
79
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
80
+ end
81
+
82
+ if @app_id.to_s.length > 256
83
+ invalid_properties.push('invalid value for "app_id", the character length must be smaller than or equal to 256.')
84
+ end
85
+
86
+ if @app_id.to_s.length < 1
87
+ invalid_properties.push('invalid value for "app_id", the character length must be great than or equal to 1.')
88
+ end
89
+
90
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
91
+ if @app_id !~ pattern
92
+ invalid_properties.push("invalid value for \"app_id\", must conform to the pattern #{pattern}.")
93
+ end
94
+
95
+ if @inbound_token.nil?
96
+ invalid_properties.push('invalid value for "inbound_token", inbound_token cannot be nil.')
97
+ end
98
+
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ return false if @app_id.nil?
106
+ return false if @app_id.to_s.length > 256
107
+ return false if @app_id.to_s.length < 1
108
+ return false if @app_id !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
109
+ return false if @inbound_token.nil?
110
+ true
111
+ end
112
+
113
+ # Custom attribute writer method with validation
114
+ # @param [Object] app_id Value to be assigned
115
+ def app_id=(app_id)
116
+ if app_id.nil?
117
+ fail ArgumentError, 'app_id cannot be nil'
118
+ end
119
+
120
+ if app_id.to_s.length > 256
121
+ fail ArgumentError, 'invalid value for "app_id", the character length must be smaller than or equal to 256.'
122
+ end
123
+
124
+ if app_id.to_s.length < 1
125
+ fail ArgumentError, 'invalid value for "app_id", the character length must be great than or equal to 1.'
126
+ end
127
+
128
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
129
+ if app_id !~ pattern
130
+ fail ArgumentError, "invalid value for \"app_id\", must conform to the pattern #{pattern}."
131
+ end
132
+
133
+ @app_id = app_id
134
+ end
135
+
136
+ # Checks equality by comparing each attribute.
137
+ # @param [Object] Object to be compared
138
+ def ==(o)
139
+ return true if self.equal?(o)
140
+ self.class == o.class &&
141
+ app_id == o.app_id &&
142
+ inbound_token == o.inbound_token
143
+ end
144
+
145
+ # @see the `==` method
146
+ # @param [Object] Object to be compared
147
+ def eql?(o)
148
+ self == o
149
+ end
150
+
151
+ # Calculates hash code according to all attributes.
152
+ # @return [Integer] Hash code
153
+ def hash
154
+ [app_id, inbound_token].hash
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def self.build_from_hash(attributes)
161
+ new.build_from_hash(attributes)
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def build_from_hash(attributes)
168
+ return nil unless attributes.is_a?(Hash)
169
+ self.class.openapi_types.each_pair do |key, type|
170
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
171
+ self.send("#{key}=", nil)
172
+ elsif type =~ /\AArray<(.*)>/i
173
+ # check to ensure the input is an array given that the attribute
174
+ # is documented as an array but the input is not
175
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
176
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
177
+ end
178
+ elsif !attributes[self.class.attribute_map[key]].nil?
179
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
180
+ end
181
+ end
182
+
183
+ self
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 _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_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
@@ -33,6 +33,9 @@ module Svix
33
33
  # List of free-form tags that can be filtered by when listing messages
34
34
  attr_accessor :tags
35
35
 
36
+ # Extra parameters to pass to Transformations (for future use)
37
+ attr_accessor :transformations_params
38
+
36
39
  # Attribute mapping from ruby-style variable name to JSON key.
37
40
  def self.attribute_map
38
41
  {
@@ -42,7 +45,8 @@ module Svix
42
45
  :'event_type' => :'eventType',
43
46
  :'payload' => :'payload',
44
47
  :'payload_retention_period' => :'payloadRetentionPeriod',
45
- :'tags' => :'tags'
48
+ :'tags' => :'tags',
49
+ :'transformations_params' => :'transformationsParams'
46
50
  }
47
51
  end
48
52
 
@@ -60,7 +64,8 @@ module Svix
60
64
  :'event_type' => :'String',
61
65
  :'payload' => :'Object',
62
66
  :'payload_retention_period' => :'Integer',
63
- :'tags' => :'Array<String>'
67
+ :'tags' => :'Array<String>',
68
+ :'transformations_params' => :'Object'
64
69
  }
65
70
  end
66
71
 
@@ -69,7 +74,8 @@ module Svix
69
74
  Set.new([
70
75
  :'channels',
71
76
  :'event_id',
72
- :'tags'
77
+ :'tags',
78
+ :'transformations_params'
73
79
  ])
74
80
  end
75
81
 
@@ -121,6 +127,10 @@ module Svix
121
127
  self.tags = value
122
128
  end
123
129
  end
130
+
131
+ if attributes.key?(:'transformations_params')
132
+ self.transformations_params = attributes[:'transformations_params']
133
+ end
124
134
  end
125
135
 
126
136
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -294,7 +304,8 @@ module Svix
294
304
  event_type == o.event_type &&
295
305
  payload == o.payload &&
296
306
  payload_retention_period == o.payload_retention_period &&
297
- tags == o.tags
307
+ tags == o.tags &&
308
+ transformations_params == o.transformations_params
298
309
  end
299
310
 
300
311
  # @see the `==` method
@@ -306,7 +317,7 @@ module Svix
306
317
  # Calculates hash code according to all attributes.
307
318
  # @return [Integer] Hash code
308
319
  def hash
309
- [application, channels, event_id, event_type, payload, payload_retention_period, tags].hash
320
+ [application, channels, event_id, event_type, payload, payload_retention_period, tags, transformations_params].hash
310
321
  end
311
322
 
312
323
  # Builds the object from hash