svix 1.15.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/svix/api/environment_api.rb +61 -12
- data/lib/svix/api/event_type_api.rb +152 -0
- data/lib/svix/api/inbound_api.rb +206 -0
- data/lib/svix/api/message_api.rb +96 -0
- data/lib/svix/api/message_attempt_api.rb +2 -2
- data/lib/svix/api/transformation_template_api.rb +68 -0
- data/lib/svix/models/completion_choice.rb +251 -0
- data/lib/svix/models/completion_message.rb +237 -0
- data/lib/svix/models/custom_color_palette.rb +28 -7
- data/lib/svix/models/duration.rb +275 -0
- data/lib/svix/models/environment_settings_out.rb +45 -2
- data/lib/svix/models/font_size_config.rb +15 -0
- data/lib/svix/models/generate_in.rb +223 -0
- data/lib/svix/models/generate_out.rb +281 -0
- data/lib/svix/models/inbound_path_params.rb +277 -0
- data/lib/svix/models/message_in.rb +16 -5
- data/lib/svix/models/message_stream_out.rb +253 -0
- data/lib/svix/models/retry_schedule_in_out.rb +220 -0
- data/lib/svix/models/rotated_url_out.rb +223 -0
- data/lib/svix/models/settings_in.rb +35 -2
- data/lib/svix/models/settings_out.rb +35 -2
- data/lib/svix/version.rb +1 -1
- data/svix.gemspec +1 -1
- metadata +13 -3
@@ -0,0 +1,275 @@
|
|
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 Duration
|
18
|
+
attr_accessor :nanos
|
19
|
+
|
20
|
+
attr_accessor :secs
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'nanos' => :'nanos',
|
26
|
+
:'secs' => :'secs'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'nanos' => :'Integer',
|
39
|
+
:'secs' => :'Integer'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::Duration` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::Duration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'nanos')
|
65
|
+
self.nanos = attributes[:'nanos']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'secs')
|
69
|
+
self.secs = attributes[:'secs']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
if @nanos.nil?
|
78
|
+
invalid_properties.push('invalid value for "nanos", nanos cannot be nil.')
|
79
|
+
end
|
80
|
+
|
81
|
+
if @nanos < 0
|
82
|
+
invalid_properties.push('invalid value for "nanos", must be greater than or equal to 0.')
|
83
|
+
end
|
84
|
+
|
85
|
+
if @secs.nil?
|
86
|
+
invalid_properties.push('invalid value for "secs", secs cannot be nil.')
|
87
|
+
end
|
88
|
+
|
89
|
+
if @secs < 0
|
90
|
+
invalid_properties.push('invalid value for "secs", must be greater than or equal to 0.')
|
91
|
+
end
|
92
|
+
|
93
|
+
invalid_properties
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check to see if the all the properties in the model are valid
|
97
|
+
# @return true if the model is valid
|
98
|
+
def valid?
|
99
|
+
return false if @nanos.nil?
|
100
|
+
return false if @nanos < 0
|
101
|
+
return false if @secs.nil?
|
102
|
+
return false if @secs < 0
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
# Custom attribute writer method with validation
|
107
|
+
# @param [Object] nanos Value to be assigned
|
108
|
+
def nanos=(nanos)
|
109
|
+
if nanos.nil?
|
110
|
+
fail ArgumentError, 'nanos cannot be nil'
|
111
|
+
end
|
112
|
+
|
113
|
+
if nanos < 0
|
114
|
+
fail ArgumentError, 'invalid value for "nanos", must be greater than or equal to 0.'
|
115
|
+
end
|
116
|
+
|
117
|
+
@nanos = nanos
|
118
|
+
end
|
119
|
+
|
120
|
+
# Custom attribute writer method with validation
|
121
|
+
# @param [Object] secs Value to be assigned
|
122
|
+
def secs=(secs)
|
123
|
+
if secs.nil?
|
124
|
+
fail ArgumentError, 'secs cannot be nil'
|
125
|
+
end
|
126
|
+
|
127
|
+
if secs < 0
|
128
|
+
fail ArgumentError, 'invalid value for "secs", must be greater than or equal to 0.'
|
129
|
+
end
|
130
|
+
|
131
|
+
@secs = secs
|
132
|
+
end
|
133
|
+
|
134
|
+
# Checks equality by comparing each attribute.
|
135
|
+
# @param [Object] Object to be compared
|
136
|
+
def ==(o)
|
137
|
+
return true if self.equal?(o)
|
138
|
+
self.class == o.class &&
|
139
|
+
nanos == o.nanos &&
|
140
|
+
secs == o.secs
|
141
|
+
end
|
142
|
+
|
143
|
+
# @see the `==` method
|
144
|
+
# @param [Object] Object to be compared
|
145
|
+
def eql?(o)
|
146
|
+
self == o
|
147
|
+
end
|
148
|
+
|
149
|
+
# Calculates hash code according to all attributes.
|
150
|
+
# @return [Integer] Hash code
|
151
|
+
def hash
|
152
|
+
[nanos, secs].hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# Builds the object from hash
|
156
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
157
|
+
# @return [Object] Returns the model itself
|
158
|
+
def self.build_from_hash(attributes)
|
159
|
+
new.build_from_hash(attributes)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Builds the object from hash
|
163
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
164
|
+
# @return [Object] Returns the model itself
|
165
|
+
def build_from_hash(attributes)
|
166
|
+
return nil unless attributes.is_a?(Hash)
|
167
|
+
self.class.openapi_types.each_pair do |key, type|
|
168
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
169
|
+
self.send("#{key}=", nil)
|
170
|
+
elsif type =~ /\AArray<(.*)>/i
|
171
|
+
# check to ensure the input is an array given that the attribute
|
172
|
+
# is documented as an array but the input is not
|
173
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
174
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
175
|
+
end
|
176
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
177
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
self
|
182
|
+
end
|
183
|
+
|
184
|
+
# Deserializes the data based on type
|
185
|
+
# @param string type Data type
|
186
|
+
# @param string value Value to be deserialized
|
187
|
+
# @return [Object] Deserialized data
|
188
|
+
def _deserialize(type, value)
|
189
|
+
case type.to_sym
|
190
|
+
when :Time
|
191
|
+
Time.parse(value)
|
192
|
+
when :Date
|
193
|
+
Date.parse(value)
|
194
|
+
when :String
|
195
|
+
value.to_s
|
196
|
+
when :Integer
|
197
|
+
value.to_i
|
198
|
+
when :Float
|
199
|
+
value.to_f
|
200
|
+
when :Boolean
|
201
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
202
|
+
true
|
203
|
+
else
|
204
|
+
false
|
205
|
+
end
|
206
|
+
when :Object
|
207
|
+
# generic object (usually a Hash), return directly
|
208
|
+
value
|
209
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
210
|
+
inner_type = Regexp.last_match[:inner_type]
|
211
|
+
value.map { |v| _deserialize(inner_type, v) }
|
212
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
213
|
+
k_type = Regexp.last_match[:k_type]
|
214
|
+
v_type = Regexp.last_match[:v_type]
|
215
|
+
{}.tap do |hash|
|
216
|
+
value.each do |k, v|
|
217
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
else # model
|
221
|
+
# models (e.g. Pet) or oneOf
|
222
|
+
klass = Svix.const_get(type)
|
223
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the string representation of the object
|
228
|
+
# @return [String] String presentation of the object
|
229
|
+
def to_s
|
230
|
+
to_hash.to_s
|
231
|
+
end
|
232
|
+
|
233
|
+
# to_body is an alias to to_hash (backward compatibility)
|
234
|
+
# @return [Hash] Returns the object in the form of hash
|
235
|
+
def to_body
|
236
|
+
to_hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the object in the form of hash
|
240
|
+
# @return [Hash] Returns the object in the form of hash
|
241
|
+
def to_hash
|
242
|
+
hash = {}
|
243
|
+
self.class.attribute_map.each_pair do |attr, param|
|
244
|
+
value = self.send(attr)
|
245
|
+
if value.nil?
|
246
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
247
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
248
|
+
end
|
249
|
+
|
250
|
+
hash[param] = _to_hash(value)
|
251
|
+
end
|
252
|
+
hash
|
253
|
+
end
|
254
|
+
|
255
|
+
# Outputs non-array value in the form of hash
|
256
|
+
# For object, use to_hash. Otherwise, just return the value
|
257
|
+
# @param [Object] value Any valid value
|
258
|
+
# @return [Hash] Returns the value in the form of hash
|
259
|
+
def _to_hash(value)
|
260
|
+
if value.is_a?(Array)
|
261
|
+
value.compact.map { |v| _to_hash(v) }
|
262
|
+
elsif value.is_a?(Hash)
|
263
|
+
{}.tap do |hash|
|
264
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
265
|
+
end
|
266
|
+
elsif value.respond_to? :to_hash
|
267
|
+
value.to_hash
|
268
|
+
else
|
269
|
+
value
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
@@ -23,10 +23,14 @@ module Svix
|
|
23
23
|
|
24
24
|
attr_accessor :custom_font_family
|
25
25
|
|
26
|
+
attr_accessor :custom_font_family_url
|
27
|
+
|
26
28
|
attr_accessor :custom_logo_url
|
27
29
|
|
28
30
|
attr_accessor :custom_theme_override
|
29
31
|
|
32
|
+
attr_accessor :display_name
|
33
|
+
|
30
34
|
attr_accessor :enable_channels
|
31
35
|
|
32
36
|
attr_accessor :enable_integration_management
|
@@ -40,8 +44,10 @@ module Svix
|
|
40
44
|
:'color_palette_light' => :'colorPaletteLight',
|
41
45
|
:'custom_color' => :'customColor',
|
42
46
|
:'custom_font_family' => :'customFontFamily',
|
47
|
+
:'custom_font_family_url' => :'customFontFamilyUrl',
|
43
48
|
:'custom_logo_url' => :'customLogoUrl',
|
44
49
|
:'custom_theme_override' => :'customThemeOverride',
|
50
|
+
:'display_name' => :'displayName',
|
45
51
|
:'enable_channels' => :'enableChannels',
|
46
52
|
:'enable_integration_management' => :'enableIntegrationManagement',
|
47
53
|
:'enable_transformations' => :'enableTransformations'
|
@@ -60,8 +66,10 @@ module Svix
|
|
60
66
|
:'color_palette_light' => :'CustomColorPalette',
|
61
67
|
:'custom_color' => :'String',
|
62
68
|
:'custom_font_family' => :'String',
|
69
|
+
:'custom_font_family_url' => :'String',
|
63
70
|
:'custom_logo_url' => :'String',
|
64
71
|
:'custom_theme_override' => :'CustomThemeOverride',
|
72
|
+
:'display_name' => :'String',
|
65
73
|
:'enable_channels' => :'Boolean',
|
66
74
|
:'enable_integration_management' => :'Boolean',
|
67
75
|
:'enable_transformations' => :'Boolean'
|
@@ -71,9 +79,10 @@ module Svix
|
|
71
79
|
# List of attributes with nullable: true
|
72
80
|
def self.openapi_nullable
|
73
81
|
Set.new([
|
74
|
-
:'custom_color',
|
75
82
|
:'custom_font_family',
|
83
|
+
:'custom_font_family_url',
|
76
84
|
:'custom_logo_url',
|
85
|
+
:'display_name',
|
77
86
|
])
|
78
87
|
end
|
79
88
|
|
@@ -108,6 +117,10 @@ module Svix
|
|
108
117
|
self.custom_font_family = attributes[:'custom_font_family']
|
109
118
|
end
|
110
119
|
|
120
|
+
if attributes.key?(:'custom_font_family_url')
|
121
|
+
self.custom_font_family_url = attributes[:'custom_font_family_url']
|
122
|
+
end
|
123
|
+
|
111
124
|
if attributes.key?(:'custom_logo_url')
|
112
125
|
self.custom_logo_url = attributes[:'custom_logo_url']
|
113
126
|
end
|
@@ -116,6 +129,10 @@ module Svix
|
|
116
129
|
self.custom_theme_override = attributes[:'custom_theme_override']
|
117
130
|
end
|
118
131
|
|
132
|
+
if attributes.key?(:'display_name')
|
133
|
+
self.display_name = attributes[:'display_name']
|
134
|
+
end
|
135
|
+
|
119
136
|
if attributes.key?(:'enable_channels')
|
120
137
|
self.enable_channels = attributes[:'enable_channels']
|
121
138
|
else
|
@@ -144,6 +161,14 @@ module Svix
|
|
144
161
|
invalid_properties.push("invalid value for \"custom_font_family\", must conform to the pattern #{pattern}.")
|
145
162
|
end
|
146
163
|
|
164
|
+
if !@custom_font_family_url.nil? && @custom_font_family_url.to_s.length > 65536
|
165
|
+
invalid_properties.push('invalid value for "custom_font_family_url", the character length must be smaller than or equal to 65536.')
|
166
|
+
end
|
167
|
+
|
168
|
+
if !@custom_font_family_url.nil? && @custom_font_family_url.to_s.length < 1
|
169
|
+
invalid_properties.push('invalid value for "custom_font_family_url", the character length must be great than or equal to 1.')
|
170
|
+
end
|
171
|
+
|
147
172
|
if !@custom_logo_url.nil? && @custom_logo_url.to_s.length > 65536
|
148
173
|
invalid_properties.push('invalid value for "custom_logo_url", the character length must be smaller than or equal to 65536.')
|
149
174
|
end
|
@@ -159,6 +184,8 @@ module Svix
|
|
159
184
|
# @return true if the model is valid
|
160
185
|
def valid?
|
161
186
|
return false if !@custom_font_family.nil? && @custom_font_family !~ Regexp.new(/^[a-zA-Z0-9\-_ ]+$/)
|
187
|
+
return false if !@custom_font_family_url.nil? && @custom_font_family_url.to_s.length > 65536
|
188
|
+
return false if !@custom_font_family_url.nil? && @custom_font_family_url.to_s.length < 1
|
162
189
|
return false if !@custom_logo_url.nil? && @custom_logo_url.to_s.length > 65536
|
163
190
|
return false if !@custom_logo_url.nil? && @custom_logo_url.to_s.length < 1
|
164
191
|
true
|
@@ -175,6 +202,20 @@ module Svix
|
|
175
202
|
@custom_font_family = custom_font_family
|
176
203
|
end
|
177
204
|
|
205
|
+
# Custom attribute writer method with validation
|
206
|
+
# @param [Object] custom_font_family_url Value to be assigned
|
207
|
+
def custom_font_family_url=(custom_font_family_url)
|
208
|
+
if !custom_font_family_url.nil? && custom_font_family_url.to_s.length > 65536
|
209
|
+
fail ArgumentError, 'invalid value for "custom_font_family_url", the character length must be smaller than or equal to 65536.'
|
210
|
+
end
|
211
|
+
|
212
|
+
if !custom_font_family_url.nil? && custom_font_family_url.to_s.length < 1
|
213
|
+
fail ArgumentError, 'invalid value for "custom_font_family_url", the character length must be great than or equal to 1.'
|
214
|
+
end
|
215
|
+
|
216
|
+
@custom_font_family_url = custom_font_family_url
|
217
|
+
end
|
218
|
+
|
178
219
|
# Custom attribute writer method with validation
|
179
220
|
# @param [Object] custom_logo_url Value to be assigned
|
180
221
|
def custom_logo_url=(custom_logo_url)
|
@@ -198,8 +239,10 @@ module Svix
|
|
198
239
|
color_palette_light == o.color_palette_light &&
|
199
240
|
custom_color == o.custom_color &&
|
200
241
|
custom_font_family == o.custom_font_family &&
|
242
|
+
custom_font_family_url == o.custom_font_family_url &&
|
201
243
|
custom_logo_url == o.custom_logo_url &&
|
202
244
|
custom_theme_override == o.custom_theme_override &&
|
245
|
+
display_name == o.display_name &&
|
203
246
|
enable_channels == o.enable_channels &&
|
204
247
|
enable_integration_management == o.enable_integration_management &&
|
205
248
|
enable_transformations == o.enable_transformations
|
@@ -214,7 +257,7 @@ module Svix
|
|
214
257
|
# Calculates hash code according to all attributes.
|
215
258
|
# @return [Integer] Hash code
|
216
259
|
def hash
|
217
|
-
[color_palette_dark, color_palette_light, custom_color, custom_font_family, custom_logo_url, custom_theme_override, enable_channels, enable_integration_management, enable_transformations].hash
|
260
|
+
[color_palette_dark, color_palette_light, custom_color, custom_font_family, custom_font_family_url, custom_logo_url, custom_theme_override, display_name, enable_channels, enable_integration_management, enable_transformations].hash
|
218
261
|
end
|
219
262
|
|
220
263
|
# Builds the object from hash
|
@@ -67,15 +67,30 @@ module Svix
|
|
67
67
|
# @return Array for valid properties with the reasons
|
68
68
|
def list_invalid_properties
|
69
69
|
invalid_properties = Array.new
|
70
|
+
if !@base.nil? && @base < 0
|
71
|
+
invalid_properties.push('invalid value for "base", must be greater than or equal to 0.')
|
72
|
+
end
|
73
|
+
|
70
74
|
invalid_properties
|
71
75
|
end
|
72
76
|
|
73
77
|
# Check to see if the all the properties in the model are valid
|
74
78
|
# @return true if the model is valid
|
75
79
|
def valid?
|
80
|
+
return false if !@base.nil? && @base < 0
|
76
81
|
true
|
77
82
|
end
|
78
83
|
|
84
|
+
# Custom attribute writer method with validation
|
85
|
+
# @param [Object] base Value to be assigned
|
86
|
+
def base=(base)
|
87
|
+
if !base.nil? && base < 0
|
88
|
+
fail ArgumentError, 'invalid value for "base", must be greater than or equal to 0.'
|
89
|
+
end
|
90
|
+
|
91
|
+
@base = base
|
92
|
+
end
|
93
|
+
|
79
94
|
# Checks equality by comparing each attribute.
|
80
95
|
# @param [Object] Object to be compared
|
81
96
|
def ==(o)
|
@@ -0,0 +1,223 @@
|
|
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 GenerateIn
|
18
|
+
attr_accessor :prompt
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'prompt' => :'prompt'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.openapi_types
|
34
|
+
{
|
35
|
+
:'prompt' => :'String'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# List of attributes with nullable: true
|
40
|
+
def self.openapi_nullable
|
41
|
+
Set.new([
|
42
|
+
])
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
if (!attributes.is_a?(Hash))
|
49
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::GenerateIn` initialize method"
|
50
|
+
end
|
51
|
+
|
52
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
54
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
55
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::GenerateIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
56
|
+
end
|
57
|
+
h[k.to_sym] = v
|
58
|
+
}
|
59
|
+
|
60
|
+
if attributes.key?(:'prompt')
|
61
|
+
self.prompt = attributes[:'prompt']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
+
# @return Array for valid properties with the reasons
|
67
|
+
def list_invalid_properties
|
68
|
+
invalid_properties = Array.new
|
69
|
+
if @prompt.nil?
|
70
|
+
invalid_properties.push('invalid value for "prompt", prompt cannot be nil.')
|
71
|
+
end
|
72
|
+
|
73
|
+
invalid_properties
|
74
|
+
end
|
75
|
+
|
76
|
+
# Check to see if the all the properties in the model are valid
|
77
|
+
# @return true if the model is valid
|
78
|
+
def valid?
|
79
|
+
return false if @prompt.nil?
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Checks equality by comparing each attribute.
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def ==(o)
|
86
|
+
return true if self.equal?(o)
|
87
|
+
self.class == o.class &&
|
88
|
+
prompt == o.prompt
|
89
|
+
end
|
90
|
+
|
91
|
+
# @see the `==` method
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def eql?(o)
|
94
|
+
self == o
|
95
|
+
end
|
96
|
+
|
97
|
+
# Calculates hash code according to all attributes.
|
98
|
+
# @return [Integer] Hash code
|
99
|
+
def hash
|
100
|
+
[prompt].hash
|
101
|
+
end
|
102
|
+
|
103
|
+
# Builds the object from hash
|
104
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
105
|
+
# @return [Object] Returns the model itself
|
106
|
+
def self.build_from_hash(attributes)
|
107
|
+
new.build_from_hash(attributes)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Builds the object from hash
|
111
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
112
|
+
# @return [Object] Returns the model itself
|
113
|
+
def build_from_hash(attributes)
|
114
|
+
return nil unless attributes.is_a?(Hash)
|
115
|
+
self.class.openapi_types.each_pair do |key, type|
|
116
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
117
|
+
self.send("#{key}=", nil)
|
118
|
+
elsif type =~ /\AArray<(.*)>/i
|
119
|
+
# check to ensure the input is an array given that the attribute
|
120
|
+
# is documented as an array but the input is not
|
121
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
122
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
123
|
+
end
|
124
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
125
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deserializes the data based on type
|
133
|
+
# @param string type Data type
|
134
|
+
# @param string value Value to be deserialized
|
135
|
+
# @return [Object] Deserialized data
|
136
|
+
def _deserialize(type, value)
|
137
|
+
case type.to_sym
|
138
|
+
when :Time
|
139
|
+
Time.parse(value)
|
140
|
+
when :Date
|
141
|
+
Date.parse(value)
|
142
|
+
when :String
|
143
|
+
value.to_s
|
144
|
+
when :Integer
|
145
|
+
value.to_i
|
146
|
+
when :Float
|
147
|
+
value.to_f
|
148
|
+
when :Boolean
|
149
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
150
|
+
true
|
151
|
+
else
|
152
|
+
false
|
153
|
+
end
|
154
|
+
when :Object
|
155
|
+
# generic object (usually a Hash), return directly
|
156
|
+
value
|
157
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
158
|
+
inner_type = Regexp.last_match[:inner_type]
|
159
|
+
value.map { |v| _deserialize(inner_type, v) }
|
160
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
161
|
+
k_type = Regexp.last_match[:k_type]
|
162
|
+
v_type = Regexp.last_match[:v_type]
|
163
|
+
{}.tap do |hash|
|
164
|
+
value.each do |k, v|
|
165
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
else # model
|
169
|
+
# models (e.g. Pet) or oneOf
|
170
|
+
klass = Svix.const_get(type)
|
171
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the string representation of the object
|
176
|
+
# @return [String] String presentation of the object
|
177
|
+
def to_s
|
178
|
+
to_hash.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_body
|
184
|
+
to_hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the object in the form of hash
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
if value.nil?
|
194
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
195
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
196
|
+
end
|
197
|
+
|
198
|
+
hash[param] = _to_hash(value)
|
199
|
+
end
|
200
|
+
hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Outputs non-array value in the form of hash
|
204
|
+
# For object, use to_hash. Otherwise, just return the value
|
205
|
+
# @param [Object] value Any valid value
|
206
|
+
# @return [Hash] Returns the value in the form of hash
|
207
|
+
def _to_hash(value)
|
208
|
+
if value.is_a?(Array)
|
209
|
+
value.compact.map { |v| _to_hash(v) }
|
210
|
+
elsif value.is_a?(Hash)
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
213
|
+
end
|
214
|
+
elsif value.respond_to? :to_hash
|
215
|
+
value.to_hash
|
216
|
+
else
|
217
|
+
value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|