svix 0.43.2 → 0.44.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 +1 -1
- data/lib/svix/api/application_api.rb +3 -0
- data/lib/svix/api/environment_api.rb +152 -0
- data/lib/svix/api/environment_settings_api.rb +79 -0
- data/lib/svix/api/integration_api.rb +606 -0
- data/lib/svix/api/message_api.rb +13 -0
- data/lib/svix/api/message_attempt_api.rb +65 -0
- data/lib/svix/integration_api.rb +38 -0
- data/lib/svix/internal.rb +1 -0
- data/lib/svix/models/environment_in.rb +257 -0
- data/lib/svix/models/environment_out.rb +259 -0
- data/lib/svix/models/environment_settings_out.rb +308 -0
- data/lib/svix/models/integration_in.rb +223 -0
- data/lib/svix/models/integration_key_out.rb +223 -0
- data/lib/svix/models/integration_out.rb +265 -0
- data/lib/svix/models/integration_update.rb +223 -0
- data/lib/svix/models/list_response_integration_out.rb +248 -0
- data/lib/svix/models/settings_in.rb +12 -1
- data/lib/svix/models/settings_out.rb +12 -1
- data/lib/svix/svix.rb +2 -0
- data/lib/svix/version.rb +1 -1
- data/lib/svix.rb +7 -2
- metadata +14 -2
@@ -50,6 +50,19 @@ module Svix
|
|
50
50
|
if @api_client.config.client_side_validation && msg_id.nil?
|
51
51
|
fail ArgumentError, "Missing the required parameter 'msg_id' when calling MessageAttemptApi.get_attempt_api_v1_app_app_id_msg_msg_id_attempt_attempt_id_get"
|
52
52
|
end
|
53
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length > 256
|
54
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.get_attempt_api_v1_app_app_id_msg_msg_id_attempt_attempt_id_get, the character length must be smaller than or equal to 256.'
|
55
|
+
end
|
56
|
+
|
57
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length < 1
|
58
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.get_attempt_api_v1_app_app_id_msg_msg_id_attempt_attempt_id_get, the character length must be great than or equal to 1.'
|
59
|
+
end
|
60
|
+
|
61
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
62
|
+
if @api_client.config.client_side_validation && msg_id !~ pattern
|
63
|
+
fail ArgumentError, "invalid value for 'msg_id' when calling MessageAttemptApi.get_attempt_api_v1_app_app_id_msg_msg_id_attempt_attempt_id_get, must conform to the pattern #{pattern}."
|
64
|
+
end
|
65
|
+
|
53
66
|
# verify the required parameter 'app_id' is set
|
54
67
|
if @api_client.config.client_side_validation && app_id.nil?
|
55
68
|
fail ArgumentError, "Missing the required parameter 'app_id' when calling MessageAttemptApi.get_attempt_api_v1_app_app_id_msg_msg_id_attempt_attempt_id_get"
|
@@ -136,6 +149,19 @@ module Svix
|
|
136
149
|
if @api_client.config.client_side_validation && msg_id.nil?
|
137
150
|
fail ArgumentError, "Missing the required parameter 'msg_id' when calling MessageAttemptApi.list_attempted_destinations_api_v1_app_app_id_msg_msg_id_endpoint_get"
|
138
151
|
end
|
152
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length > 256
|
153
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.list_attempted_destinations_api_v1_app_app_id_msg_msg_id_endpoint_get, the character length must be smaller than or equal to 256.'
|
154
|
+
end
|
155
|
+
|
156
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length < 1
|
157
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.list_attempted_destinations_api_v1_app_app_id_msg_msg_id_endpoint_get, the character length must be great than or equal to 1.'
|
158
|
+
end
|
159
|
+
|
160
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
161
|
+
if @api_client.config.client_side_validation && msg_id !~ pattern
|
162
|
+
fail ArgumentError, "invalid value for 'msg_id' when calling MessageAttemptApi.list_attempted_destinations_api_v1_app_app_id_msg_msg_id_endpoint_get, must conform to the pattern #{pattern}."
|
163
|
+
end
|
164
|
+
|
139
165
|
# verify the required parameter 'app_id' is set
|
140
166
|
if @api_client.config.client_side_validation && app_id.nil?
|
141
167
|
fail ArgumentError, "Missing the required parameter 'app_id' when calling MessageAttemptApi.list_attempted_destinations_api_v1_app_app_id_msg_msg_id_endpoint_get"
|
@@ -358,6 +384,19 @@ module Svix
|
|
358
384
|
if @api_client.config.client_side_validation && msg_id.nil?
|
359
385
|
fail ArgumentError, "Missing the required parameter 'msg_id' when calling MessageAttemptApi.list_attempts_api_v1_app_app_id_msg_msg_id_attempt_get"
|
360
386
|
end
|
387
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length > 256
|
388
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.list_attempts_api_v1_app_app_id_msg_msg_id_attempt_get, the character length must be smaller than or equal to 256.'
|
389
|
+
end
|
390
|
+
|
391
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length < 1
|
392
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.list_attempts_api_v1_app_app_id_msg_msg_id_attempt_get, the character length must be great than or equal to 1.'
|
393
|
+
end
|
394
|
+
|
395
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
396
|
+
if @api_client.config.client_side_validation && msg_id !~ pattern
|
397
|
+
fail ArgumentError, "invalid value for 'msg_id' when calling MessageAttemptApi.list_attempts_api_v1_app_app_id_msg_msg_id_attempt_get, must conform to the pattern #{pattern}."
|
398
|
+
end
|
399
|
+
|
361
400
|
if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250
|
362
401
|
fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling MessageAttemptApi.list_attempts_api_v1_app_app_id_msg_msg_id_attempt_get, must be smaller than or equal to 250.'
|
363
402
|
end
|
@@ -442,6 +481,19 @@ module Svix
|
|
442
481
|
if @api_client.config.client_side_validation && msg_id.nil?
|
443
482
|
fail ArgumentError, "Missing the required parameter 'msg_id' when calling MessageAttemptApi.list_attempts_for_endpoint_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_attempt_get"
|
444
483
|
end
|
484
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length > 256
|
485
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.list_attempts_for_endpoint_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_attempt_get, the character length must be smaller than or equal to 256.'
|
486
|
+
end
|
487
|
+
|
488
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length < 1
|
489
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.list_attempts_for_endpoint_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_attempt_get, the character length must be great than or equal to 1.'
|
490
|
+
end
|
491
|
+
|
492
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
493
|
+
if @api_client.config.client_side_validation && msg_id !~ pattern
|
494
|
+
fail ArgumentError, "invalid value for 'msg_id' when calling MessageAttemptApi.list_attempts_for_endpoint_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_attempt_get, must conform to the pattern #{pattern}."
|
495
|
+
end
|
496
|
+
|
445
497
|
# verify the required parameter 'app_id' is set
|
446
498
|
if @api_client.config.client_side_validation && app_id.nil?
|
447
499
|
fail ArgumentError, "Missing the required parameter 'app_id' when calling MessageAttemptApi.list_attempts_for_endpoint_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_attempt_get"
|
@@ -569,6 +621,19 @@ module Svix
|
|
569
621
|
if @api_client.config.client_side_validation && msg_id.nil?
|
570
622
|
fail ArgumentError, "Missing the required parameter 'msg_id' when calling MessageAttemptApi.resend_webhook_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_resend_post"
|
571
623
|
end
|
624
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length > 256
|
625
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.resend_webhook_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_resend_post, the character length must be smaller than or equal to 256.'
|
626
|
+
end
|
627
|
+
|
628
|
+
if @api_client.config.client_side_validation && msg_id.to_s.length < 1
|
629
|
+
fail ArgumentError, 'invalid value for "msg_id" when calling MessageAttemptApi.resend_webhook_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_resend_post, the character length must be great than or equal to 1.'
|
630
|
+
end
|
631
|
+
|
632
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
633
|
+
if @api_client.config.client_side_validation && msg_id !~ pattern
|
634
|
+
fail ArgumentError, "invalid value for 'msg_id' when calling MessageAttemptApi.resend_webhook_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_resend_post, must conform to the pattern #{pattern}."
|
635
|
+
end
|
636
|
+
|
572
637
|
# verify the required parameter 'app_id' is set
|
573
638
|
if @api_client.config.client_side_validation && app_id.nil?
|
574
639
|
fail ArgumentError, "Missing the required parameter 'app_id' when calling MessageAttemptApi.resend_webhook_api_v1_app_app_id_msg_msg_id_endpoint_endpoint_id_resend_post"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Svix
|
4
|
+
class IntegrationAPI
|
5
|
+
def initialize(api_client)
|
6
|
+
@api = IntegrationApi.new(api_client)
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(app_id, options = {})
|
10
|
+
return @api.list_integrations_api_v1_app_app_id_integration_get(app_id, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(app_id, integ_in)
|
14
|
+
return @api.create_integration_api_v1_app_app_id_integration_post(app_id, integ_in)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(app_id, integ_id)
|
18
|
+
return @api.get_integration_api_v1_app_app_id_integration_integ_id_get(integ_id, app_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(app_id, integ_id, integ_update)
|
22
|
+
return @api.update_integration_api_v1_app_app_id_integration_integ_id_put(integ_id, app_id, integ_update)
|
23
|
+
end
|
24
|
+
|
25
|
+
def delete(app_id, integ_id)
|
26
|
+
return @api.delete_integration_api_v1_app_app_id_integration_integ_id_delete(integ_id, app_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_key(app_id, integ_id)
|
30
|
+
return @api.get_integration_key_api_v1_app_app_id_integration_integ_id_key_get(integ_id, app_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def rotate_key(app_id, integ_id)
|
34
|
+
return @api.rotate_integration_key_api_v1_app_app_id_integration_integ_id_key_rotate_post(integ_id, app_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/svix/internal.rb
CHANGED
@@ -0,0 +1,257 @@
|
|
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 user on your platform. - `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/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## 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 EnvironmentIn
|
18
|
+
attr_accessor :created_at
|
19
|
+
|
20
|
+
attr_accessor :event_types
|
21
|
+
|
22
|
+
attr_accessor :settings
|
23
|
+
|
24
|
+
attr_accessor :version
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'created_at' => :'createdAt',
|
30
|
+
:'event_types' => :'eventTypes',
|
31
|
+
:'settings' => :'settings',
|
32
|
+
:'version' => :'version'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns all the JSON keys this model knows about
|
37
|
+
def self.acceptable_attributes
|
38
|
+
attribute_map.values
|
39
|
+
end
|
40
|
+
|
41
|
+
# Attribute type mapping.
|
42
|
+
def self.openapi_types
|
43
|
+
{
|
44
|
+
:'created_at' => :'Time',
|
45
|
+
:'event_types' => :'Array<EventTypeIn>',
|
46
|
+
:'settings' => :'SettingsIn',
|
47
|
+
:'version' => :'Integer'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# List of attributes with nullable: true
|
52
|
+
def self.openapi_nullable
|
53
|
+
Set.new([
|
54
|
+
])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Initializes the object
|
58
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
59
|
+
def initialize(attributes = {})
|
60
|
+
if (!attributes.is_a?(Hash))
|
61
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::EnvironmentIn` initialize method"
|
62
|
+
end
|
63
|
+
|
64
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
66
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::EnvironmentIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
68
|
+
end
|
69
|
+
h[k.to_sym] = v
|
70
|
+
}
|
71
|
+
|
72
|
+
if attributes.key?(:'created_at')
|
73
|
+
self.created_at = attributes[:'created_at']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:'event_types')
|
77
|
+
if (value = attributes[:'event_types']).is_a?(Array)
|
78
|
+
self.event_types = value
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'settings')
|
83
|
+
self.settings = attributes[:'settings']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'version')
|
87
|
+
self.version = attributes[:'version']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
92
|
+
# @return Array for valid properties with the reasons
|
93
|
+
def list_invalid_properties
|
94
|
+
invalid_properties = Array.new
|
95
|
+
if @created_at.nil?
|
96
|
+
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
|
97
|
+
end
|
98
|
+
|
99
|
+
if @version.nil?
|
100
|
+
invalid_properties.push('invalid value for "version", version cannot be nil.')
|
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 @created_at.nil?
|
110
|
+
return false if @version.nil?
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
# Checks equality by comparing each attribute.
|
115
|
+
# @param [Object] Object to be compared
|
116
|
+
def ==(o)
|
117
|
+
return true if self.equal?(o)
|
118
|
+
self.class == o.class &&
|
119
|
+
created_at == o.created_at &&
|
120
|
+
event_types == o.event_types &&
|
121
|
+
settings == o.settings &&
|
122
|
+
version == o.version
|
123
|
+
end
|
124
|
+
|
125
|
+
# @see the `==` method
|
126
|
+
# @param [Object] Object to be compared
|
127
|
+
def eql?(o)
|
128
|
+
self == o
|
129
|
+
end
|
130
|
+
|
131
|
+
# Calculates hash code according to all attributes.
|
132
|
+
# @return [Integer] Hash code
|
133
|
+
def hash
|
134
|
+
[created_at, event_types, settings, version].hash
|
135
|
+
end
|
136
|
+
|
137
|
+
# Builds the object from hash
|
138
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
139
|
+
# @return [Object] Returns the model itself
|
140
|
+
def self.build_from_hash(attributes)
|
141
|
+
new.build_from_hash(attributes)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Builds the object from hash
|
145
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
146
|
+
# @return [Object] Returns the model itself
|
147
|
+
def build_from_hash(attributes)
|
148
|
+
return nil unless attributes.is_a?(Hash)
|
149
|
+
self.class.openapi_types.each_pair do |key, type|
|
150
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
151
|
+
self.send("#{key}=", nil)
|
152
|
+
elsif type =~ /\AArray<(.*)>/i
|
153
|
+
# check to ensure the input is an array given that the attribute
|
154
|
+
# is documented as an array but the input is not
|
155
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
156
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
157
|
+
end
|
158
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
159
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
self
|
164
|
+
end
|
165
|
+
|
166
|
+
# Deserializes the data based on type
|
167
|
+
# @param string type Data type
|
168
|
+
# @param string value Value to be deserialized
|
169
|
+
# @return [Object] Deserialized data
|
170
|
+
def _deserialize(type, value)
|
171
|
+
case type.to_sym
|
172
|
+
when :Time
|
173
|
+
Time.parse(value)
|
174
|
+
when :Date
|
175
|
+
Date.parse(value)
|
176
|
+
when :String
|
177
|
+
value.to_s
|
178
|
+
when :Integer
|
179
|
+
value.to_i
|
180
|
+
when :Float
|
181
|
+
value.to_f
|
182
|
+
when :Boolean
|
183
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
184
|
+
true
|
185
|
+
else
|
186
|
+
false
|
187
|
+
end
|
188
|
+
when :Object
|
189
|
+
# generic object (usually a Hash), return directly
|
190
|
+
value
|
191
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
192
|
+
inner_type = Regexp.last_match[:inner_type]
|
193
|
+
value.map { |v| _deserialize(inner_type, v) }
|
194
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
195
|
+
k_type = Regexp.last_match[:k_type]
|
196
|
+
v_type = Regexp.last_match[:v_type]
|
197
|
+
{}.tap do |hash|
|
198
|
+
value.each do |k, v|
|
199
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
else # model
|
203
|
+
# models (e.g. Pet) or oneOf
|
204
|
+
klass = Svix.const_get(type)
|
205
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Returns the string representation of the object
|
210
|
+
# @return [String] String presentation of the object
|
211
|
+
def to_s
|
212
|
+
to_hash.to_s
|
213
|
+
end
|
214
|
+
|
215
|
+
# to_body is an alias to to_hash (backward compatibility)
|
216
|
+
# @return [Hash] Returns the object in the form of hash
|
217
|
+
def to_body
|
218
|
+
to_hash
|
219
|
+
end
|
220
|
+
|
221
|
+
# Returns the object in the form of hash
|
222
|
+
# @return [Hash] Returns the object in the form of hash
|
223
|
+
def to_hash
|
224
|
+
hash = {}
|
225
|
+
self.class.attribute_map.each_pair do |attr, param|
|
226
|
+
value = self.send(attr)
|
227
|
+
if value.nil?
|
228
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
229
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
230
|
+
end
|
231
|
+
|
232
|
+
hash[param] = _to_hash(value)
|
233
|
+
end
|
234
|
+
hash
|
235
|
+
end
|
236
|
+
|
237
|
+
# Outputs non-array value in the form of hash
|
238
|
+
# For object, use to_hash. Otherwise, just return the value
|
239
|
+
# @param [Object] value Any valid value
|
240
|
+
# @return [Hash] Returns the value in the form of hash
|
241
|
+
def _to_hash(value)
|
242
|
+
if value.is_a?(Array)
|
243
|
+
value.compact.map { |v| _to_hash(v) }
|
244
|
+
elsif value.is_a?(Hash)
|
245
|
+
{}.tap do |hash|
|
246
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
247
|
+
end
|
248
|
+
elsif value.respond_to? :to_hash
|
249
|
+
value.to_hash
|
250
|
+
else
|
251
|
+
value
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
@@ -0,0 +1,259 @@
|
|
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 user on your platform. - `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/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## 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 EnvironmentOut
|
18
|
+
attr_accessor :created_at
|
19
|
+
|
20
|
+
attr_accessor :event_types
|
21
|
+
|
22
|
+
attr_accessor :settings
|
23
|
+
|
24
|
+
attr_accessor :version
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'created_at' => :'createdAt',
|
30
|
+
:'event_types' => :'eventTypes',
|
31
|
+
:'settings' => :'settings',
|
32
|
+
:'version' => :'version'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns all the JSON keys this model knows about
|
37
|
+
def self.acceptable_attributes
|
38
|
+
attribute_map.values
|
39
|
+
end
|
40
|
+
|
41
|
+
# Attribute type mapping.
|
42
|
+
def self.openapi_types
|
43
|
+
{
|
44
|
+
:'created_at' => :'Time',
|
45
|
+
:'event_types' => :'Array<EventTypeOut>',
|
46
|
+
:'settings' => :'SettingsOut',
|
47
|
+
:'version' => :'Integer'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# List of attributes with nullable: true
|
52
|
+
def self.openapi_nullable
|
53
|
+
Set.new([
|
54
|
+
])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Initializes the object
|
58
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
59
|
+
def initialize(attributes = {})
|
60
|
+
if (!attributes.is_a?(Hash))
|
61
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::EnvironmentOut` initialize method"
|
62
|
+
end
|
63
|
+
|
64
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
66
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::EnvironmentOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
68
|
+
end
|
69
|
+
h[k.to_sym] = v
|
70
|
+
}
|
71
|
+
|
72
|
+
if attributes.key?(:'created_at')
|
73
|
+
self.created_at = attributes[:'created_at']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:'event_types')
|
77
|
+
if (value = attributes[:'event_types']).is_a?(Array)
|
78
|
+
self.event_types = value
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'settings')
|
83
|
+
self.settings = attributes[:'settings']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'version')
|
87
|
+
self.version = attributes[:'version']
|
88
|
+
else
|
89
|
+
self.version = 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
94
|
+
# @return Array for valid properties with the reasons
|
95
|
+
def list_invalid_properties
|
96
|
+
invalid_properties = Array.new
|
97
|
+
if @created_at.nil?
|
98
|
+
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
|
99
|
+
end
|
100
|
+
|
101
|
+
if @event_types.nil?
|
102
|
+
invalid_properties.push('invalid value for "event_types", event_types cannot be nil.')
|
103
|
+
end
|
104
|
+
|
105
|
+
invalid_properties
|
106
|
+
end
|
107
|
+
|
108
|
+
# Check to see if the all the properties in the model are valid
|
109
|
+
# @return true if the model is valid
|
110
|
+
def valid?
|
111
|
+
return false if @created_at.nil?
|
112
|
+
return false if @event_types.nil?
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
# Checks equality by comparing each attribute.
|
117
|
+
# @param [Object] Object to be compared
|
118
|
+
def ==(o)
|
119
|
+
return true if self.equal?(o)
|
120
|
+
self.class == o.class &&
|
121
|
+
created_at == o.created_at &&
|
122
|
+
event_types == o.event_types &&
|
123
|
+
settings == o.settings &&
|
124
|
+
version == o.version
|
125
|
+
end
|
126
|
+
|
127
|
+
# @see the `==` method
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def eql?(o)
|
130
|
+
self == o
|
131
|
+
end
|
132
|
+
|
133
|
+
# Calculates hash code according to all attributes.
|
134
|
+
# @return [Integer] Hash code
|
135
|
+
def hash
|
136
|
+
[created_at, event_types, settings, version].hash
|
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 self.build_from_hash(attributes)
|
143
|
+
new.build_from_hash(attributes)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Builds the object from hash
|
147
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
148
|
+
# @return [Object] Returns the model itself
|
149
|
+
def build_from_hash(attributes)
|
150
|
+
return nil unless attributes.is_a?(Hash)
|
151
|
+
self.class.openapi_types.each_pair do |key, type|
|
152
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
153
|
+
self.send("#{key}=", nil)
|
154
|
+
elsif type =~ /\AArray<(.*)>/i
|
155
|
+
# check to ensure the input is an array given that the attribute
|
156
|
+
# is documented as an array but the input is not
|
157
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
158
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
159
|
+
end
|
160
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
161
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
self
|
166
|
+
end
|
167
|
+
|
168
|
+
# Deserializes the data based on type
|
169
|
+
# @param string type Data type
|
170
|
+
# @param string value Value to be deserialized
|
171
|
+
# @return [Object] Deserialized data
|
172
|
+
def _deserialize(type, value)
|
173
|
+
case type.to_sym
|
174
|
+
when :Time
|
175
|
+
Time.parse(value)
|
176
|
+
when :Date
|
177
|
+
Date.parse(value)
|
178
|
+
when :String
|
179
|
+
value.to_s
|
180
|
+
when :Integer
|
181
|
+
value.to_i
|
182
|
+
when :Float
|
183
|
+
value.to_f
|
184
|
+
when :Boolean
|
185
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
186
|
+
true
|
187
|
+
else
|
188
|
+
false
|
189
|
+
end
|
190
|
+
when :Object
|
191
|
+
# generic object (usually a Hash), return directly
|
192
|
+
value
|
193
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
194
|
+
inner_type = Regexp.last_match[:inner_type]
|
195
|
+
value.map { |v| _deserialize(inner_type, v) }
|
196
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
197
|
+
k_type = Regexp.last_match[:k_type]
|
198
|
+
v_type = Regexp.last_match[:v_type]
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each do |k, v|
|
201
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
else # model
|
205
|
+
# models (e.g. Pet) or oneOf
|
206
|
+
klass = Svix.const_get(type)
|
207
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the object in the form of hash
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_hash
|
226
|
+
hash = {}
|
227
|
+
self.class.attribute_map.each_pair do |attr, param|
|
228
|
+
value = self.send(attr)
|
229
|
+
if value.nil?
|
230
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
231
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
232
|
+
end
|
233
|
+
|
234
|
+
hash[param] = _to_hash(value)
|
235
|
+
end
|
236
|
+
hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Outputs non-array value in the form of hash
|
240
|
+
# For object, use to_hash. Otherwise, just return the value
|
241
|
+
# @param [Object] value Any valid value
|
242
|
+
# @return [Hash] Returns the value in the form of hash
|
243
|
+
def _to_hash(value)
|
244
|
+
if value.is_a?(Array)
|
245
|
+
value.compact.map { |v| _to_hash(v) }
|
246
|
+
elsif value.is_a?(Hash)
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
249
|
+
end
|
250
|
+
elsif value.respond_to? :to_hash
|
251
|
+
value.to_hash
|
252
|
+
else
|
253
|
+
value
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|