svix 0.16.0 → 0.34.1

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