svix 0.32.0 → 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/endpoint_api.rb +507 -0
  4. data/lib/svix/api/event_type_api.rb +83 -6
  5. data/lib/svix/api/message_api.rb +2 -2
  6. data/lib/svix/api/message_attempt_api.rb +4 -4
  7. data/lib/svix/api/organization_settings_api.rb +79 -0
  8. data/lib/svix/api/statistics_api.rb +205 -0
  9. data/lib/svix/endpoint_api.rb +22 -1
  10. data/lib/svix/event_type_api.rb +4 -0
  11. data/lib/svix/models/application_out.rb +18 -4
  12. data/lib/svix/models/attempt_statistics_data.rb +231 -0
  13. data/lib/svix/models/attempt_statistics_response.rb +265 -0
  14. data/lib/svix/models/border_radii_config.rb +236 -0
  15. data/lib/svix/models/border_radius_config.rb +236 -0
  16. data/lib/svix/models/border_radius_enum.rb +40 -0
  17. data/lib/svix/models/custom_theme_override.rb +227 -0
  18. data/lib/svix/models/endpoint_created_event_data.rb +36 -0
  19. data/lib/svix/models/endpoint_deleted_event_data.rb +36 -0
  20. data/lib/svix/models/endpoint_disabled_event_data.rb +36 -0
  21. data/lib/svix/models/endpoint_headers_in.rb +225 -0
  22. data/lib/svix/models/endpoint_headers_out.rb +252 -0
  23. data/lib/svix/models/endpoint_in.rb +26 -0
  24. data/lib/svix/models/endpoint_out.rb +24 -1
  25. data/lib/svix/models/endpoint_secret_out.rb +21 -0
  26. data/lib/svix/models/endpoint_secret_rotate_in.rb +236 -0
  27. data/lib/svix/models/endpoint_update.rb +9 -0
  28. data/lib/svix/models/endpoint_updated_event.rb +269 -0
  29. data/lib/svix/models/endpoint_updated_event_data.rb +36 -0
  30. data/lib/svix/models/event_type_example_out.rb +223 -0
  31. data/lib/svix/models/event_type_in.rb +12 -1
  32. data/lib/svix/models/event_type_out.rb +43 -4
  33. data/lib/svix/models/event_type_schema_in.rb +224 -0
  34. data/lib/svix/models/event_type_update.rb +12 -1
  35. data/lib/svix/models/font_size_config.rb +218 -0
  36. data/lib/svix/models/message_attempt_exhausted_event_data.rb +36 -0
  37. data/lib/svix/models/message_endpoint_out.rb +9 -0
  38. data/lib/svix/models/portal_settings_out.rb +286 -0
  39. data/lib/svix/models/radii_enum.rb +39 -0
  40. data/lib/svix/models/recover_in.rb +223 -0
  41. data/lib/svix/models/settings_out.rb +323 -0
  42. data/lib/svix/models/statistics_period.rb +37 -0
  43. data/lib/svix/models/webhook_types.rb +1 -1
  44. data/lib/svix/version.rb +1 -1
  45. data/lib/svix.rb +6 -2
  46. metadata +22 -2
@@ -0,0 +1,252 @@
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 of your users. - `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}`. <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/). ## 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.4
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
+ # The value of the headers is returned in the `headers` field. Sensitive headers that have been redacted are returned in the sensitive field.
18
+ class EndpointHeadersOut
19
+ attr_accessor :headers
20
+
21
+ attr_accessor :sensitive
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'headers' => :'headers',
27
+ :'sensitive' => :'sensitive'
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
+ :'headers' => :'Hash<String, String>',
40
+ :'sensitive' => :'Array<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::EndpointHeadersOut` 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::EndpointHeadersOut`. 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?(:'headers')
66
+ if (value = attributes[:'headers']).is_a?(Hash)
67
+ self.headers = value
68
+ end
69
+ end
70
+
71
+ if attributes.key?(:'sensitive')
72
+ if (value = attributes[:'sensitive']).is_a?(Array)
73
+ self.sensitive = value
74
+ end
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ if @headers.nil?
83
+ invalid_properties.push('invalid value for "headers", headers cannot be nil.')
84
+ end
85
+
86
+ if @sensitive.nil?
87
+ invalid_properties.push('invalid value for "sensitive", sensitive cannot be nil.')
88
+ end
89
+
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ return false if @headers.nil?
97
+ return false if @sensitive.nil?
98
+ true
99
+ end
100
+
101
+ # Custom attribute writer method with validation
102
+ # @param [Object] sensitive Value to be assigned
103
+ def sensitive=(sensitive)
104
+ if sensitive.nil?
105
+ fail ArgumentError, 'sensitive cannot be nil'
106
+ end
107
+
108
+ @sensitive = sensitive
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ headers == o.headers &&
117
+ sensitive == o.sensitive
118
+ end
119
+
120
+ # @see the `==` method
121
+ # @param [Object] Object to be compared
122
+ def eql?(o)
123
+ self == o
124
+ end
125
+
126
+ # Calculates hash code according to all attributes.
127
+ # @return [Integer] Hash code
128
+ def hash
129
+ [headers, sensitive].hash
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def self.build_from_hash(attributes)
136
+ new.build_from_hash(attributes)
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def build_from_hash(attributes)
143
+ return nil unless attributes.is_a?(Hash)
144
+ self.class.openapi_types.each_pair do |key, type|
145
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
146
+ self.send("#{key}=", nil)
147
+ elsif type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :Time
168
+ Time.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ # models (e.g. Pet) or oneOf
199
+ klass = Svix.const_get(type)
200
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ if value.nil?
223
+ is_nullable = self.class.openapi_nullable.include?(attr)
224
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
225
+ end
226
+
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end
@@ -130,6 +130,15 @@ module Svix
130
130
  # @return Array for valid properties with the reasons
131
131
  def list_invalid_properties
132
132
  invalid_properties = Array.new
133
+ if !@filter_types.nil? && @filter_types.length < 1
134
+ invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
135
+ end
136
+
137
+ pattern = Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
138
+ if !@secret.nil? && @secret !~ pattern
139
+ invalid_properties.push("invalid value for \"secret\", must conform to the pattern #{pattern}.")
140
+ end
141
+
133
142
  if !@uid.nil? && @uid.to_s.length > 256
134
143
  invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 256.')
135
144
  end
@@ -165,6 +174,8 @@ module Svix
165
174
  # Check to see if the all the properties in the model are valid
166
175
  # @return true if the model is valid
167
176
  def valid?
177
+ return false if !@filter_types.nil? && @filter_types.length < 1
178
+ return false if !@secret.nil? && @secret !~ Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
168
179
  return false if !@uid.nil? && @uid.to_s.length > 256
169
180
  return false if !@uid.nil? && @uid.to_s.length < 1
170
181
  return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
@@ -178,9 +189,24 @@ module Svix
178
189
  # Custom attribute writer method with validation
179
190
  # @param [Object] filter_types Value to be assigned
180
191
  def filter_types=(filter_types)
192
+ if !filter_types.nil? && filter_types.length < 1
193
+ fail ArgumentError, 'invalid value for "filter_types", number of items must be greater than or equal to 1.'
194
+ end
195
+
181
196
  @filter_types = filter_types
182
197
  end
183
198
 
199
+ # Custom attribute writer method with validation
200
+ # @param [Object] secret Value to be assigned
201
+ def secret=(secret)
202
+ pattern = Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
203
+ if !secret.nil? && secret !~ pattern
204
+ fail ArgumentError, "invalid value for \"secret\", must conform to the pattern #{pattern}."
205
+ end
206
+
207
+ @secret = secret
208
+ end
209
+
184
210
  # Custom attribute writer method with validation
185
211
  # @param [Object] uid Value to be assigned
186
212
  def uid=(uid)
@@ -30,6 +30,8 @@ module Svix
30
30
  # Optional unique identifier for the endpoint
31
31
  attr_accessor :uid
32
32
 
33
+ attr_accessor :updated_at
34
+
33
35
  attr_accessor :url
34
36
 
35
37
  attr_accessor :version
@@ -44,6 +46,7 @@ module Svix
44
46
  :'id' => :'id',
45
47
  :'rate_limit' => :'rateLimit',
46
48
  :'uid' => :'uid',
49
+ :'updated_at' => :'updatedAt',
47
50
  :'url' => :'url',
48
51
  :'version' => :'version'
49
52
  }
@@ -64,6 +67,7 @@ module Svix
64
67
  :'id' => :'String',
65
68
  :'rate_limit' => :'Integer',
66
69
  :'uid' => :'String',
70
+ :'updated_at' => :'Time',
67
71
  :'url' => :'String',
68
72
  :'version' => :'Integer'
69
73
  }
@@ -124,6 +128,10 @@ module Svix
124
128
  self.uid = attributes[:'uid']
125
129
  end
126
130
 
131
+ if attributes.key?(:'updated_at')
132
+ self.updated_at = attributes[:'updated_at']
133
+ end
134
+
127
135
  if attributes.key?(:'url')
128
136
  self.url = attributes[:'url']
129
137
  end
@@ -141,6 +149,10 @@ module Svix
141
149
  invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
142
150
  end
143
151
 
152
+ if !@filter_types.nil? && @filter_types.length < 1
153
+ invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
154
+ end
155
+
144
156
  if @id.nil?
145
157
  invalid_properties.push('invalid value for "id", id cannot be nil.')
146
158
  end
@@ -158,6 +170,10 @@ module Svix
158
170
  invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.")
159
171
  end
160
172
 
173
+ if @updated_at.nil?
174
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
175
+ end
176
+
161
177
  if @url.nil?
162
178
  invalid_properties.push('invalid value for "url", url cannot be nil.')
163
179
  end
@@ -181,10 +197,12 @@ module Svix
181
197
  # @return true if the model is valid
182
198
  def valid?
183
199
  return false if @created_at.nil?
200
+ return false if !@filter_types.nil? && @filter_types.length < 1
184
201
  return false if @id.nil?
185
202
  return false if !@uid.nil? && @uid.to_s.length > 256
186
203
  return false if !@uid.nil? && @uid.to_s.length < 1
187
204
  return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
205
+ return false if @updated_at.nil?
188
206
  return false if @url.nil?
189
207
  return false if @url.to_s.length > 65536
190
208
  return false if @url.to_s.length < 1
@@ -195,6 +213,10 @@ module Svix
195
213
  # Custom attribute writer method with validation
196
214
  # @param [Object] filter_types Value to be assigned
197
215
  def filter_types=(filter_types)
216
+ if !filter_types.nil? && filter_types.length < 1
217
+ fail ArgumentError, 'invalid value for "filter_types", number of items must be greater than or equal to 1.'
218
+ end
219
+
198
220
  @filter_types = filter_types
199
221
  end
200
222
 
@@ -247,6 +269,7 @@ module Svix
247
269
  id == o.id &&
248
270
  rate_limit == o.rate_limit &&
249
271
  uid == o.uid &&
272
+ updated_at == o.updated_at &&
250
273
  url == o.url &&
251
274
  version == o.version
252
275
  end
@@ -260,7 +283,7 @@ module Svix
260
283
  # Calculates hash code according to all attributes.
261
284
  # @return [Integer] Hash code
262
285
  def hash
263
- [created_at, description, disabled, filter_types, id, rate_limit, uid, url, version].hash
286
+ [created_at, description, disabled, filter_types, id, rate_limit, uid, updated_at, url, version].hash
264
287
  end
265
288
 
266
289
  # Builds the object from hash
@@ -71,6 +71,11 @@ module Svix
71
71
  invalid_properties.push('invalid value for "key", key cannot be nil.')
72
72
  end
73
73
 
74
+ pattern = Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
75
+ if @key !~ pattern
76
+ invalid_properties.push("invalid value for \"key\", must conform to the pattern #{pattern}.")
77
+ end
78
+
74
79
  invalid_properties
75
80
  end
76
81
 
@@ -78,9 +83,25 @@ module Svix
78
83
  # @return true if the model is valid
79
84
  def valid?
80
85
  return false if @key.nil?
86
+ return false if @key !~ Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
81
87
  true
82
88
  end
83
89
 
90
+ # Custom attribute writer method with validation
91
+ # @param [Object] key Value to be assigned
92
+ def key=(key)
93
+ if key.nil?
94
+ fail ArgumentError, 'key cannot be nil'
95
+ end
96
+
97
+ pattern = Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
98
+ if key !~ pattern
99
+ fail ArgumentError, "invalid value for \"key\", must conform to the pattern #{pattern}."
100
+ end
101
+
102
+ @key = key
103
+ end
104
+
84
105
  # Checks equality by comparing each attribute.
85
106
  # @param [Object] Object to be compared
86
107
  def ==(o)
@@ -0,0 +1,236 @@
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 of your users. - `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}`. <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/). ## 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.4
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 EndpointSecretRotateIn
18
+ # The endpoint's verification secret. If `null` is passed, a secret is automatically generated.
19
+ attr_accessor :key
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'key' => :'key'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'key' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::EndpointSecretRotateIn` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::EndpointSecretRotateIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'key')
62
+ self.key = attributes[:'key']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ pattern = Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
71
+ if !@key.nil? && @key !~ pattern
72
+ invalid_properties.push("invalid value for \"key\", must conform to the pattern #{pattern}.")
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 !@key.nil? && @key !~ Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
82
+ true
83
+ end
84
+
85
+ # Custom attribute writer method with validation
86
+ # @param [Object] key Value to be assigned
87
+ def key=(key)
88
+ pattern = Regexp.new(/^whsec_[a-zA-Z0-9+\/]{32}$/)
89
+ if !key.nil? && key !~ pattern
90
+ fail ArgumentError, "invalid value for \"key\", must conform to the pattern #{pattern}."
91
+ end
92
+
93
+ @key = key
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ key == o.key
102
+ end
103
+
104
+ # @see the `==` method
105
+ # @param [Object] Object to be compared
106
+ def eql?(o)
107
+ self == o
108
+ end
109
+
110
+ # Calculates hash code according to all attributes.
111
+ # @return [Integer] Hash code
112
+ def hash
113
+ [key].hash
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def self.build_from_hash(attributes)
120
+ new.build_from_hash(attributes)
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ self.class.openapi_types.each_pair do |key, type|
129
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
130
+ self.send("#{key}=", nil)
131
+ elsif type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
135
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
136
+ end
137
+ elsif !attributes[self.class.attribute_map[key]].nil?
138
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
139
+ end
140
+ end
141
+
142
+ self
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def _deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = Svix.const_get(type)
184
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ end