svix 1.24.0 → 1.25.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/lib/svix/api/endpoint_api.rb +277 -2
  4. data/lib/svix/api/message_api.rb +218 -2
  5. data/lib/svix/api/streams_api.rb +185 -0
  6. data/lib/svix/api/transformation_template_api.rb +195 -24
  7. data/lib/svix/models/auth_token_out.rb +272 -0
  8. data/lib/svix/models/create_message_token_in.rb +250 -0
  9. data/lib/svix/models/create_stream_in.rb +225 -0
  10. data/lib/svix/models/endpoint_created_event_data.rb +1 -0
  11. data/lib/svix/models/endpoint_deleted_event_data.rb +1 -0
  12. data/lib/svix/models/endpoint_mtls_config_in.rb +15 -19
  13. data/lib/svix/models/endpoint_oauth_config_in.rb +13 -2
  14. data/lib/svix/models/endpoint_updated_event_data.rb +1 -0
  15. data/lib/svix/models/environment_settings_out.rb +15 -4
  16. data/lib/svix/models/event_in.rb +223 -0
  17. data/lib/svix/models/event_out.rb +223 -0
  18. data/lib/svix/models/event_type_from_open_api.rb +280 -0
  19. data/lib/svix/models/event_type_import_open_api_in.rb +13 -1
  20. data/lib/svix/models/event_type_import_open_api_out_data.rb +16 -4
  21. data/lib/svix/models/hubspot_oauth_config_in.rb +223 -0
  22. data/lib/svix/models/{oauth_payload_out.rb → incoming_webhook_payload_out.rb} +3 -3
  23. data/lib/svix/models/kafka_security_protocol_type.rb +38 -0
  24. data/lib/svix/models/list_response_event_out.rb +259 -0
  25. data/lib/svix/models/list_response_sink_out.rb +259 -0
  26. data/lib/svix/models/message_subscriber_auth_token_out.rb +237 -0
  27. data/lib/svix/models/{oauth_payload_in.rb → o_auth_payload_in.rb} +3 -3
  28. data/lib/svix/models/o_auth_payload_out.rb +239 -0
  29. data/lib/svix/models/{oauth2_grant_type.rb → oauth2_grant_type_in.rb} +4 -3
  30. data/lib/svix/models/settings_in.rb +15 -4
  31. data/lib/svix/models/settings_out.rb +15 -4
  32. data/lib/svix/models/sink_in.rb +107 -0
  33. data/lib/svix/models/sink_in_one_of.rb +285 -0
  34. data/lib/svix/models/sink_in_one_of1.rb +313 -0
  35. data/lib/svix/models/sink_in_one_of2.rb +321 -0
  36. data/lib/svix/models/sink_in_one_of3.rb +271 -0
  37. data/lib/svix/models/sink_out.rb +107 -0
  38. data/lib/svix/version.rb +1 -1
  39. metadata +24 -5
@@ -0,0 +1,225 @@
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 CreateStreamIn
18
+ attr_accessor :events
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'events' => :'events'
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
+ :'events' => :'Array<EventIn>'
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::CreateStreamIn` 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::CreateStreamIn`. 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?(:'events')
61
+ if (value = attributes[:'events']).is_a?(Array)
62
+ self.events = value
63
+ end
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ invalid_properties = Array.new
71
+ if @events.nil?
72
+ invalid_properties.push('invalid value for "events", events cannot be nil.')
73
+ end
74
+
75
+ invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ return false if @events.nil?
82
+ true
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(o)
88
+ return true if self.equal?(o)
89
+ self.class == o.class &&
90
+ events == o.events
91
+ end
92
+
93
+ # @see the `==` method
94
+ # @param [Object] Object to be compared
95
+ def eql?(o)
96
+ self == o
97
+ end
98
+
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Integer] Hash code
101
+ def hash
102
+ [events].hash
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def self.build_from_hash(attributes)
109
+ new.build_from_hash(attributes)
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def build_from_hash(attributes)
116
+ return nil unless attributes.is_a?(Hash)
117
+ self.class.openapi_types.each_pair do |key, type|
118
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
119
+ self.send("#{key}=", nil)
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Svix.const_get(type)
173
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
+ # Sent when an endpoint is created, updated, or deleted
17
18
  class EndpointCreatedEventData
18
19
  # The app's ID
19
20
  attr_accessor :app_id
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
+ # Sent when an endpoint is created, updated, or deleted
17
18
  class EndpointDeletedEventData
18
19
  # The app's ID
19
20
  attr_accessor :app_id
@@ -15,17 +15,17 @@ require 'time'
15
15
 
16
16
  module Svix
17
17
  class EndpointMtlsConfigIn
18
- # A PEM encoded X509 certificate used to verify the webhook receiver's certificate.
19
- attr_accessor :ca_cert
20
-
21
18
  # A PEM encoded private key and X509 certificate to identify the webhook sender.
22
19
  attr_accessor :identity
23
20
 
21
+ # A PEM encoded X509 certificate used to verify the webhook receiver's certificate.
22
+ attr_accessor :server_ca_cert
23
+
24
24
  # Attribute mapping from ruby-style variable name to JSON key.
25
25
  def self.attribute_map
26
26
  {
27
- :'ca_cert' => :'caCert',
28
- :'identity' => :'identity'
27
+ :'identity' => :'identity',
28
+ :'server_ca_cert' => :'serverCaCert'
29
29
  }
30
30
  end
31
31
 
@@ -37,14 +37,15 @@ module Svix
37
37
  # Attribute type mapping.
38
38
  def self.openapi_types
39
39
  {
40
- :'ca_cert' => :'String',
41
- :'identity' => :'String'
40
+ :'identity' => :'String',
41
+ :'server_ca_cert' => :'String'
42
42
  }
43
43
  end
44
44
 
45
45
  # List of attributes with nullable: true
46
46
  def self.openapi_nullable
47
47
  Set.new([
48
+ :'server_ca_cert'
48
49
  ])
49
50
  end
50
51
 
@@ -63,23 +64,19 @@ module Svix
63
64
  h[k.to_sym] = v
64
65
  }
65
66
 
66
- if attributes.key?(:'ca_cert')
67
- self.ca_cert = attributes[:'ca_cert']
68
- end
69
-
70
67
  if attributes.key?(:'identity')
71
68
  self.identity = attributes[:'identity']
72
69
  end
70
+
71
+ if attributes.key?(:'server_ca_cert')
72
+ self.server_ca_cert = attributes[:'server_ca_cert']
73
+ end
73
74
  end
74
75
 
75
76
  # Show invalid properties with the reasons. Usually used together with valid?
76
77
  # @return Array for valid properties with the reasons
77
78
  def list_invalid_properties
78
79
  invalid_properties = Array.new
79
- if @ca_cert.nil?
80
- invalid_properties.push('invalid value for "ca_cert", ca_cert cannot be nil.')
81
- end
82
-
83
80
  if @identity.nil?
84
81
  invalid_properties.push('invalid value for "identity", identity cannot be nil.')
85
82
  end
@@ -90,7 +87,6 @@ module Svix
90
87
  # Check to see if the all the properties in the model are valid
91
88
  # @return true if the model is valid
92
89
  def valid?
93
- return false if @ca_cert.nil?
94
90
  return false if @identity.nil?
95
91
  true
96
92
  end
@@ -100,8 +96,8 @@ module Svix
100
96
  def ==(o)
101
97
  return true if self.equal?(o)
102
98
  self.class == o.class &&
103
- ca_cert == o.ca_cert &&
104
- identity == o.identity
99
+ identity == o.identity &&
100
+ server_ca_cert == o.server_ca_cert
105
101
  end
106
102
 
107
103
  # @see the `==` method
@@ -113,7 +109,7 @@ module Svix
113
109
  # Calculates hash code according to all attributes.
114
110
  # @return [Integer] Hash code
115
111
  def hash
116
- [ca_cert, identity].hash
112
+ [identity, server_ca_cert].hash
117
113
  end
118
114
 
119
115
  # Builds the object from hash
@@ -30,6 +30,9 @@ module Svix
30
30
 
31
31
  attr_accessor :jwt_params
32
32
 
33
+ # For `refreshToken` grant type
34
+ attr_accessor :refresh_token
35
+
33
36
  # Optional OAuth scopes added to the request body.
34
37
  attr_accessor :scopes
35
38
 
@@ -45,6 +48,7 @@ module Svix
45
48
  :'extra_params' => :'extraParams',
46
49
  :'grant_type' => :'grantType',
47
50
  :'jwt_params' => :'jwtParams',
51
+ :'refresh_token' => :'refreshToken',
48
52
  :'scopes' => :'scopes',
49
53
  :'token_url' => :'tokenUrl'
50
54
  }
@@ -62,8 +66,9 @@ module Svix
62
66
  :'client_id' => :'String',
63
67
  :'client_secret' => :'String',
64
68
  :'extra_params' => :'Hash<String, String>',
65
- :'grant_type' => :'Oauth2GrantType',
69
+ :'grant_type' => :'Oauth2GrantTypeIn',
66
70
  :'jwt_params' => :'ClientSecretJwtParamsIn',
71
+ :'refresh_token' => :'String',
67
72
  :'scopes' => :'Array<String>',
68
73
  :'token_url' => :'String'
69
74
  }
@@ -74,6 +79,7 @@ module Svix
74
79
  Set.new([
75
80
  :'client_secret',
76
81
  :'extra_params',
82
+ :'refresh_token',
77
83
  :'scopes',
78
84
  ])
79
85
  end
@@ -119,6 +125,10 @@ module Svix
119
125
  self.jwt_params = attributes[:'jwt_params']
120
126
  end
121
127
 
128
+ if attributes.key?(:'refresh_token')
129
+ self.refresh_token = attributes[:'refresh_token']
130
+ end
131
+
122
132
  if attributes.key?(:'scopes')
123
133
  if (value = attributes[:'scopes']).is_a?(Array)
124
134
  self.scopes = value
@@ -174,6 +184,7 @@ module Svix
174
184
  extra_params == o.extra_params &&
175
185
  grant_type == o.grant_type &&
176
186
  jwt_params == o.jwt_params &&
187
+ refresh_token == o.refresh_token &&
177
188
  scopes == o.scopes &&
178
189
  token_url == o.token_url
179
190
  end
@@ -187,7 +198,7 @@ module Svix
187
198
  # Calculates hash code according to all attributes.
188
199
  # @return [Integer] Hash code
189
200
  def hash
190
- [auth_method, client_id, client_secret, extra_params, grant_type, jwt_params, scopes, token_url].hash
201
+ [auth_method, client_id, client_secret, extra_params, grant_type, jwt_params, refresh_token, scopes, token_url].hash
191
202
  end
192
203
 
193
204
  # Builds the object from hash
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
+ # Sent when an endpoint is created, updated, or deleted
17
18
  class EndpointUpdatedEventData
18
19
  # The app's ID
19
20
  attr_accessor :app_id
@@ -41,6 +41,8 @@ module Svix
41
41
 
42
42
  attr_accessor :show_use_svix_play
43
43
 
44
+ attr_accessor :wipe_successful_payload
45
+
44
46
  # Attribute mapping from ruby-style variable name to JSON key.
45
47
  def self.attribute_map
46
48
  {
@@ -56,7 +58,8 @@ module Svix
56
58
  :'enable_integration_management' => :'enableIntegrationManagement',
57
59
  :'enable_message_tags' => :'enableMessageTags',
58
60
  :'enable_transformations' => :'enableTransformations',
59
- :'show_use_svix_play' => :'showUseSvixPlay'
61
+ :'show_use_svix_play' => :'showUseSvixPlay',
62
+ :'wipe_successful_payload' => :'wipeSuccessfulPayload'
60
63
  }
61
64
  end
62
65
 
@@ -80,7 +83,8 @@ module Svix
80
83
  :'enable_integration_management' => :'Boolean',
81
84
  :'enable_message_tags' => :'Boolean',
82
85
  :'enable_transformations' => :'Boolean',
83
- :'show_use_svix_play' => :'Boolean'
86
+ :'show_use_svix_play' => :'Boolean',
87
+ :'wipe_successful_payload' => :'Boolean'
84
88
  }
85
89
  end
86
90
 
@@ -171,6 +175,12 @@ module Svix
171
175
  else
172
176
  self.show_use_svix_play = true
173
177
  end
178
+
179
+ if attributes.key?(:'wipe_successful_payload')
180
+ self.wipe_successful_payload = attributes[:'wipe_successful_payload']
181
+ else
182
+ self.wipe_successful_payload = false
183
+ end
174
184
  end
175
185
 
176
186
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -268,7 +278,8 @@ module Svix
268
278
  enable_integration_management == o.enable_integration_management &&
269
279
  enable_message_tags == o.enable_message_tags &&
270
280
  enable_transformations == o.enable_transformations &&
271
- show_use_svix_play == o.show_use_svix_play
281
+ show_use_svix_play == o.show_use_svix_play &&
282
+ wipe_successful_payload == o.wipe_successful_payload
272
283
  end
273
284
 
274
285
  # @see the `==` method
@@ -280,7 +291,7 @@ module Svix
280
291
  # Calculates hash code according to all attributes.
281
292
  # @return [Integer] Hash code
282
293
  def hash
283
- [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_message_tags, enable_transformations, show_use_svix_play].hash
294
+ [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_message_tags, enable_transformations, show_use_svix_play, wipe_successful_payload].hash
284
295
  end
285
296
 
286
297
  # Builds the object from hash
@@ -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 EventIn
18
+ attr_accessor :payload
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'payload' => :'payload'
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
+ :'payload' => :'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::EventIn` 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::EventIn`. 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?(:'payload')
61
+ self.payload = attributes[:'payload']
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 @payload.nil?
70
+ invalid_properties.push('invalid value for "payload", payload 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 @payload.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
+ payload == o.payload
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
+ [payload].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