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