svix 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/svix/api/environment_api.rb +61 -12
- data/lib/svix/api/event_type_api.rb +152 -0
- data/lib/svix/api/inbound_api.rb +206 -0
- data/lib/svix/api/message_api.rb +108 -0
- data/lib/svix/api/message_attempt_api.rb +3 -0
- data/lib/svix/api/statistics_api.rb +13 -13
- data/lib/svix/api/transformation_template_api.rb +68 -0
- data/lib/svix/models/completion_choice.rb +251 -0
- data/lib/svix/models/completion_message.rb +237 -0
- data/lib/svix/models/custom_color_palette.rb +28 -7
- data/lib/svix/models/duration.rb +275 -0
- data/lib/svix/models/environment_settings_out.rb +45 -2
- data/lib/svix/models/font_size_config.rb +15 -0
- data/lib/svix/models/generate_in.rb +223 -0
- data/lib/svix/models/generate_out.rb +281 -0
- data/lib/svix/models/inbound_path_params.rb +277 -0
- data/lib/svix/models/message_attempt_endpoint_out.rb +10 -1
- data/lib/svix/models/message_attempt_out.rb +10 -1
- data/lib/svix/models/message_in.rb +52 -4
- data/lib/svix/models/message_stream_out.rb +253 -0
- data/lib/svix/models/retry_schedule_in_out.rb +220 -0
- data/lib/svix/models/rotated_url_out.rb +223 -0
- data/lib/svix/models/settings_in.rb +35 -2
- data/lib/svix/models/settings_out.rb +35 -2
- data/lib/svix/models/transformation_template_kind.rb +8 -2
- data/lib/svix/version.rb +1 -1
- data/svix.gemspec +1 -1
- metadata +13 -3
@@ -580,6 +580,7 @@ module Svix
|
|
580
580
|
# @option opts [Time] :before Only include items created before a certain date
|
581
581
|
# @option opts [Time] :after Only include items created after a certain date
|
582
582
|
# @option opts [Boolean] :with_content When `true` attempt content is included in the response (default to true)
|
583
|
+
# @option opts [Boolean] :with_msg When `true`, the message information is included in the response (default to false)
|
583
584
|
# @option opts [Array<String>] :event_types Filter response based on the event type
|
584
585
|
# @return [ListResponseMessageAttemptOut]
|
585
586
|
def v1_message_attempt_list_by_endpoint(app_id, endpoint_id, opts = {})
|
@@ -600,6 +601,7 @@ module Svix
|
|
600
601
|
# @option opts [Time] :before Only include items created before a certain date
|
601
602
|
# @option opts [Time] :after Only include items created after a certain date
|
602
603
|
# @option opts [Boolean] :with_content When `true` attempt content is included in the response
|
604
|
+
# @option opts [Boolean] :with_msg When `true`, the message information is included in the response
|
603
605
|
# @option opts [Array<String>] :event_types Filter response based on the event type
|
604
606
|
# @return [Array<(ListResponseMessageAttemptOut, Integer, Hash)>] ListResponseMessageAttemptOut data, response status code and response headers
|
605
607
|
def v1_message_attempt_list_by_endpoint_with_http_info(app_id, endpoint_id, opts = {})
|
@@ -670,6 +672,7 @@ module Svix
|
|
670
672
|
query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
|
671
673
|
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
|
672
674
|
query_params[:'with_content'] = opts[:'with_content'] if !opts[:'with_content'].nil?
|
675
|
+
query_params[:'with_msg'] = opts[:'with_msg'] if !opts[:'with_msg'].nil?
|
673
676
|
query_params[:'event_types'] = @api_client.build_collection_param(opts[:'event_types'], :multi) if !opts[:'event_types'].nil?
|
674
677
|
|
675
678
|
# header parameters
|
@@ -25,8 +25,8 @@ module Svix
|
|
25
25
|
# @param [Hash] opts the optional parameters
|
26
26
|
# @option opts [String] :idempotency_key The request's idempotency key
|
27
27
|
# @return [AppUsageStatsOut]
|
28
|
-
def
|
29
|
-
data, _status_code, _headers =
|
28
|
+
def v1_statistics_aggregate_app_stats(app_usage_stats_in, opts = {})
|
29
|
+
data, _status_code, _headers = v1_statistics_aggregate_app_stats_with_http_info(app_usage_stats_in, opts)
|
30
30
|
data
|
31
31
|
end
|
32
32
|
|
@@ -36,13 +36,13 @@ module Svix
|
|
36
36
|
# @param [Hash] opts the optional parameters
|
37
37
|
# @option opts [String] :idempotency_key The request's idempotency key
|
38
38
|
# @return [Array<(AppUsageStatsOut, Integer, Hash)>] AppUsageStatsOut data, response status code and response headers
|
39
|
-
def
|
39
|
+
def v1_statistics_aggregate_app_stats_with_http_info(app_usage_stats_in, opts = {})
|
40
40
|
if @api_client.config.debugging
|
41
|
-
@api_client.config.logger.debug 'Calling API: StatisticsApi.
|
41
|
+
@api_client.config.logger.debug 'Calling API: StatisticsApi.v1_statistics_aggregate_app_stats ...'
|
42
42
|
end
|
43
43
|
# verify the required parameter 'app_usage_stats_in' is set
|
44
44
|
if @api_client.config.client_side_validation && app_usage_stats_in.nil?
|
45
|
-
fail ArgumentError, "Missing the required parameter 'app_usage_stats_in' when calling StatisticsApi.
|
45
|
+
fail ArgumentError, "Missing the required parameter 'app_usage_stats_in' when calling StatisticsApi.v1_statistics_aggregate_app_stats"
|
46
46
|
end
|
47
47
|
# resource path
|
48
48
|
local_var_path = '/api/v1/stats/usage/app/'
|
@@ -71,7 +71,7 @@ module Svix
|
|
71
71
|
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
72
72
|
|
73
73
|
new_options = opts.merge(
|
74
|
-
:operation => :"StatisticsApi.
|
74
|
+
:operation => :"StatisticsApi.v1_statistics_aggregate_app_stats",
|
75
75
|
:header_params => header_params,
|
76
76
|
:query_params => query_params,
|
77
77
|
:form_params => form_params,
|
@@ -82,7 +82,7 @@ module Svix
|
|
82
82
|
|
83
83
|
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
84
84
|
if @api_client.config.debugging
|
85
|
-
@api_client.config.logger.debug "API called: StatisticsApi#
|
85
|
+
@api_client.config.logger.debug "API called: StatisticsApi#v1_statistics_aggregate_app_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
86
86
|
end
|
87
87
|
return data, status_code, headers
|
88
88
|
end
|
@@ -91,8 +91,8 @@ module Svix
|
|
91
91
|
# Creates a background task to calculate the listed event types for all apps in the organization. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation.
|
92
92
|
# @param [Hash] opts the optional parameters
|
93
93
|
# @return [AggregateEventTypesOut]
|
94
|
-
def
|
95
|
-
data, _status_code, _headers =
|
94
|
+
def v1_statistics_aggregate_event_types(opts = {})
|
95
|
+
data, _status_code, _headers = v1_statistics_aggregate_event_types_with_http_info(opts)
|
96
96
|
data
|
97
97
|
end
|
98
98
|
|
@@ -100,9 +100,9 @@ module Svix
|
|
100
100
|
# Creates a background task to calculate the listed event types for all apps in the organization. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation.
|
101
101
|
# @param [Hash] opts the optional parameters
|
102
102
|
# @return [Array<(AggregateEventTypesOut, Integer, Hash)>] AggregateEventTypesOut data, response status code and response headers
|
103
|
-
def
|
103
|
+
def v1_statistics_aggregate_event_types_with_http_info(opts = {})
|
104
104
|
if @api_client.config.debugging
|
105
|
-
@api_client.config.logger.debug 'Calling API: StatisticsApi.
|
105
|
+
@api_client.config.logger.debug 'Calling API: StatisticsApi.v1_statistics_aggregate_event_types ...'
|
106
106
|
end
|
107
107
|
# resource path
|
108
108
|
local_var_path = '/api/v1/stats/usage/event-types/'
|
@@ -128,7 +128,7 @@ module Svix
|
|
128
128
|
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
129
129
|
|
130
130
|
new_options = opts.merge(
|
131
|
-
:operation => :"StatisticsApi.
|
131
|
+
:operation => :"StatisticsApi.v1_statistics_aggregate_event_types",
|
132
132
|
:header_params => header_params,
|
133
133
|
:query_params => query_params,
|
134
134
|
:form_params => form_params,
|
@@ -139,7 +139,7 @@ module Svix
|
|
139
139
|
|
140
140
|
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
141
141
|
if @api_client.config.debugging
|
142
|
-
@api_client.config.logger.debug "API called: StatisticsApi#
|
142
|
+
@api_client.config.logger.debug "API called: StatisticsApi#v1_statistics_aggregate_event_types\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
143
143
|
end
|
144
144
|
return data, status_code, headers
|
145
145
|
end
|
@@ -150,6 +150,74 @@ module Svix
|
|
150
150
|
return data, status_code, headers
|
151
151
|
end
|
152
152
|
|
153
|
+
# Generate
|
154
|
+
# Use OpenAI's Completion API to generate code for a transformation template
|
155
|
+
# @param generate_in [GenerateIn]
|
156
|
+
# @param [Hash] opts the optional parameters
|
157
|
+
# @option opts [String] :idempotency_key The request's idempotency key
|
158
|
+
# @return [GenerateOut]
|
159
|
+
def v1_transformation_template_generate(generate_in, opts = {})
|
160
|
+
data, _status_code, _headers = v1_transformation_template_generate_with_http_info(generate_in, opts)
|
161
|
+
data
|
162
|
+
end
|
163
|
+
|
164
|
+
# Generate
|
165
|
+
# Use OpenAI's Completion API to generate code for a transformation template
|
166
|
+
# @param generate_in [GenerateIn]
|
167
|
+
# @param [Hash] opts the optional parameters
|
168
|
+
# @option opts [String] :idempotency_key The request's idempotency key
|
169
|
+
# @return [Array<(GenerateOut, Integer, Hash)>] GenerateOut data, response status code and response headers
|
170
|
+
def v1_transformation_template_generate_with_http_info(generate_in, opts = {})
|
171
|
+
if @api_client.config.debugging
|
172
|
+
@api_client.config.logger.debug 'Calling API: TransformationTemplateApi.v1_transformation_template_generate ...'
|
173
|
+
end
|
174
|
+
# verify the required parameter 'generate_in' is set
|
175
|
+
if @api_client.config.client_side_validation && generate_in.nil?
|
176
|
+
fail ArgumentError, "Missing the required parameter 'generate_in' when calling TransformationTemplateApi.v1_transformation_template_generate"
|
177
|
+
end
|
178
|
+
# resource path
|
179
|
+
local_var_path = '/api/v1/transformation-template/generate'
|
180
|
+
|
181
|
+
# query parameters
|
182
|
+
query_params = opts[:query_params] || {}
|
183
|
+
|
184
|
+
# header parameters
|
185
|
+
header_params = opts[:header_params] || {}
|
186
|
+
# HTTP header 'Accept' (if needed)
|
187
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
188
|
+
# HTTP header 'Content-Type'
|
189
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
190
|
+
header_params[:'idempotency-key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
|
191
|
+
|
192
|
+
# form parameters
|
193
|
+
form_params = opts[:form_params] || {}
|
194
|
+
|
195
|
+
# http body (model)
|
196
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(generate_in)
|
197
|
+
|
198
|
+
# return_type
|
199
|
+
return_type = opts[:debug_return_type] || 'GenerateOut'
|
200
|
+
|
201
|
+
# auth_names
|
202
|
+
auth_names = opts[:debug_auth_names] || ['HTTPBearer']
|
203
|
+
|
204
|
+
new_options = opts.merge(
|
205
|
+
:operation => :"TransformationTemplateApi.v1_transformation_template_generate",
|
206
|
+
:header_params => header_params,
|
207
|
+
:query_params => query_params,
|
208
|
+
:form_params => form_params,
|
209
|
+
:body => post_body,
|
210
|
+
:auth_names => auth_names,
|
211
|
+
:return_type => return_type
|
212
|
+
)
|
213
|
+
|
214
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
215
|
+
if @api_client.config.debugging
|
216
|
+
@api_client.config.logger.debug "API called: TransformationTemplateApi#v1_transformation_template_generate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
217
|
+
end
|
218
|
+
return data, status_code, headers
|
219
|
+
end
|
220
|
+
|
153
221
|
# Get Transformation Template
|
154
222
|
# Get a transformation template
|
155
223
|
# @param transformation_template_id [String]
|
@@ -0,0 +1,251 @@
|
|
1
|
+
=begin
|
2
|
+
#Svix API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.1.1
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.2.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Svix
|
17
|
+
class CompletionChoice
|
18
|
+
attr_accessor :finish_reason
|
19
|
+
|
20
|
+
attr_accessor :index
|
21
|
+
|
22
|
+
attr_accessor :message
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'finish_reason' => :'finish_reason',
|
28
|
+
:'index' => :'index',
|
29
|
+
:'message' => :'message'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'finish_reason' => :'String',
|
42
|
+
:'index' => :'Integer',
|
43
|
+
:'message' => :'CompletionMessage'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# List of attributes with nullable: true
|
48
|
+
def self.openapi_nullable
|
49
|
+
Set.new([
|
50
|
+
])
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initializes the object
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
|
+
def initialize(attributes = {})
|
56
|
+
if (!attributes.is_a?(Hash))
|
57
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::CompletionChoice` initialize method"
|
58
|
+
end
|
59
|
+
|
60
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
61
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
62
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
63
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::CompletionChoice`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
64
|
+
end
|
65
|
+
h[k.to_sym] = v
|
66
|
+
}
|
67
|
+
|
68
|
+
if attributes.key?(:'finish_reason')
|
69
|
+
self.finish_reason = attributes[:'finish_reason']
|
70
|
+
end
|
71
|
+
|
72
|
+
if attributes.key?(:'index')
|
73
|
+
self.index = attributes[:'index']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:'message')
|
77
|
+
self.message = attributes[:'message']
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
82
|
+
# @return Array for valid properties with the reasons
|
83
|
+
def list_invalid_properties
|
84
|
+
invalid_properties = Array.new
|
85
|
+
if @finish_reason.nil?
|
86
|
+
invalid_properties.push('invalid value for "finish_reason", finish_reason cannot be nil.')
|
87
|
+
end
|
88
|
+
|
89
|
+
if @index.nil?
|
90
|
+
invalid_properties.push('invalid value for "index", index cannot be nil.')
|
91
|
+
end
|
92
|
+
|
93
|
+
if @message.nil?
|
94
|
+
invalid_properties.push('invalid value for "message", message cannot be nil.')
|
95
|
+
end
|
96
|
+
|
97
|
+
invalid_properties
|
98
|
+
end
|
99
|
+
|
100
|
+
# Check to see if the all the properties in the model are valid
|
101
|
+
# @return true if the model is valid
|
102
|
+
def valid?
|
103
|
+
return false if @finish_reason.nil?
|
104
|
+
return false if @index.nil?
|
105
|
+
return false if @message.nil?
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
# Checks equality by comparing each attribute.
|
110
|
+
# @param [Object] Object to be compared
|
111
|
+
def ==(o)
|
112
|
+
return true if self.equal?(o)
|
113
|
+
self.class == o.class &&
|
114
|
+
finish_reason == o.finish_reason &&
|
115
|
+
index == o.index &&
|
116
|
+
message == o.message
|
117
|
+
end
|
118
|
+
|
119
|
+
# @see the `==` method
|
120
|
+
# @param [Object] Object to be compared
|
121
|
+
def eql?(o)
|
122
|
+
self == o
|
123
|
+
end
|
124
|
+
|
125
|
+
# Calculates hash code according to all attributes.
|
126
|
+
# @return [Integer] Hash code
|
127
|
+
def hash
|
128
|
+
[finish_reason, index, message].hash
|
129
|
+
end
|
130
|
+
|
131
|
+
# Builds the object from hash
|
132
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
133
|
+
# @return [Object] Returns the model itself
|
134
|
+
def self.build_from_hash(attributes)
|
135
|
+
new.build_from_hash(attributes)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Builds the object from hash
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
140
|
+
# @return [Object] Returns the model itself
|
141
|
+
def build_from_hash(attributes)
|
142
|
+
return nil unless attributes.is_a?(Hash)
|
143
|
+
self.class.openapi_types.each_pair do |key, type|
|
144
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
145
|
+
self.send("#{key}=", nil)
|
146
|
+
elsif type =~ /\AArray<(.*)>/i
|
147
|
+
# check to ensure the input is an array given that the attribute
|
148
|
+
# is documented as an array but the input is not
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
151
|
+
end
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
self
|
158
|
+
end
|
159
|
+
|
160
|
+
# Deserializes the data based on type
|
161
|
+
# @param string type Data type
|
162
|
+
# @param string value Value to be deserialized
|
163
|
+
# @return [Object] Deserialized data
|
164
|
+
def _deserialize(type, value)
|
165
|
+
case type.to_sym
|
166
|
+
when :Time
|
167
|
+
Time.parse(value)
|
168
|
+
when :Date
|
169
|
+
Date.parse(value)
|
170
|
+
when :String
|
171
|
+
value.to_s
|
172
|
+
when :Integer
|
173
|
+
value.to_i
|
174
|
+
when :Float
|
175
|
+
value.to_f
|
176
|
+
when :Boolean
|
177
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
178
|
+
true
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
when :Object
|
183
|
+
# generic object (usually a Hash), return directly
|
184
|
+
value
|
185
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
186
|
+
inner_type = Regexp.last_match[:inner_type]
|
187
|
+
value.map { |v| _deserialize(inner_type, v) }
|
188
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
189
|
+
k_type = Regexp.last_match[:k_type]
|
190
|
+
v_type = Regexp.last_match[:v_type]
|
191
|
+
{}.tap do |hash|
|
192
|
+
value.each do |k, v|
|
193
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
else # model
|
197
|
+
# models (e.g. Pet) or oneOf
|
198
|
+
klass = Svix.const_get(type)
|
199
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the string representation of the object
|
204
|
+
# @return [String] String presentation of the object
|
205
|
+
def to_s
|
206
|
+
to_hash.to_s
|
207
|
+
end
|
208
|
+
|
209
|
+
# to_body is an alias to to_hash (backward compatibility)
|
210
|
+
# @return [Hash] Returns the object in the form of hash
|
211
|
+
def to_body
|
212
|
+
to_hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns the object in the form of hash
|
216
|
+
# @return [Hash] Returns the object in the form of hash
|
217
|
+
def to_hash
|
218
|
+
hash = {}
|
219
|
+
self.class.attribute_map.each_pair do |attr, param|
|
220
|
+
value = self.send(attr)
|
221
|
+
if value.nil?
|
222
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
223
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
224
|
+
end
|
225
|
+
|
226
|
+
hash[param] = _to_hash(value)
|
227
|
+
end
|
228
|
+
hash
|
229
|
+
end
|
230
|
+
|
231
|
+
# Outputs non-array value in the form of hash
|
232
|
+
# For object, use to_hash. Otherwise, just return the value
|
233
|
+
# @param [Object] value Any valid value
|
234
|
+
# @return [Hash] Returns the value in the form of hash
|
235
|
+
def _to_hash(value)
|
236
|
+
if value.is_a?(Array)
|
237
|
+
value.compact.map { |v| _to_hash(v) }
|
238
|
+
elsif value.is_a?(Hash)
|
239
|
+
{}.tap do |hash|
|
240
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
241
|
+
end
|
242
|
+
elsif value.respond_to? :to_hash
|
243
|
+
value.to_hash
|
244
|
+
else
|
245
|
+
value
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
=begin
|
2
|
+
#Svix API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.1.1
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.2.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Svix
|
17
|
+
class CompletionMessage
|
18
|
+
attr_accessor :content
|
19
|
+
|
20
|
+
attr_accessor :role
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'content' => :'content',
|
26
|
+
:'role' => :'role'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'content' => :'String',
|
39
|
+
:'role' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::CompletionMessage` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::CompletionMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'content')
|
65
|
+
self.content = attributes[:'content']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'role')
|
69
|
+
self.role = attributes[:'role']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
if @content.nil?
|
78
|
+
invalid_properties.push('invalid value for "content", content cannot be nil.')
|
79
|
+
end
|
80
|
+
|
81
|
+
if @role.nil?
|
82
|
+
invalid_properties.push('invalid value for "role", role cannot be nil.')
|
83
|
+
end
|
84
|
+
|
85
|
+
invalid_properties
|
86
|
+
end
|
87
|
+
|
88
|
+
# Check to see if the all the properties in the model are valid
|
89
|
+
# @return true if the model is valid
|
90
|
+
def valid?
|
91
|
+
return false if @content.nil?
|
92
|
+
return false if @role.nil?
|
93
|
+
true
|
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
|
+
content == o.content &&
|
102
|
+
role == o.role
|
103
|
+
end
|
104
|
+
|
105
|
+
# @see the `==` method
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def eql?(o)
|
108
|
+
self == o
|
109
|
+
end
|
110
|
+
|
111
|
+
# Calculates hash code according to all attributes.
|
112
|
+
# @return [Integer] Hash code
|
113
|
+
def hash
|
114
|
+
[content, role].hash
|
115
|
+
end
|
116
|
+
|
117
|
+
# Builds the object from hash
|
118
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
119
|
+
# @return [Object] Returns the model itself
|
120
|
+
def self.build_from_hash(attributes)
|
121
|
+
new.build_from_hash(attributes)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def build_from_hash(attributes)
|
128
|
+
return nil unless attributes.is_a?(Hash)
|
129
|
+
self.class.openapi_types.each_pair do |key, type|
|
130
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
131
|
+
self.send("#{key}=", nil)
|
132
|
+
elsif type =~ /\AArray<(.*)>/i
|
133
|
+
# check to ensure the input is an array given that the attribute
|
134
|
+
# is documented as an array but the input is not
|
135
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
136
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
137
|
+
end
|
138
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
139
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
# Deserializes the data based on type
|
147
|
+
# @param string type Data type
|
148
|
+
# @param string value Value to be deserialized
|
149
|
+
# @return [Object] Deserialized data
|
150
|
+
def _deserialize(type, value)
|
151
|
+
case type.to_sym
|
152
|
+
when :Time
|
153
|
+
Time.parse(value)
|
154
|
+
when :Date
|
155
|
+
Date.parse(value)
|
156
|
+
when :String
|
157
|
+
value.to_s
|
158
|
+
when :Integer
|
159
|
+
value.to_i
|
160
|
+
when :Float
|
161
|
+
value.to_f
|
162
|
+
when :Boolean
|
163
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
164
|
+
true
|
165
|
+
else
|
166
|
+
false
|
167
|
+
end
|
168
|
+
when :Object
|
169
|
+
# generic object (usually a Hash), return directly
|
170
|
+
value
|
171
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
172
|
+
inner_type = Regexp.last_match[:inner_type]
|
173
|
+
value.map { |v| _deserialize(inner_type, v) }
|
174
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
175
|
+
k_type = Regexp.last_match[:k_type]
|
176
|
+
v_type = Regexp.last_match[:v_type]
|
177
|
+
{}.tap do |hash|
|
178
|
+
value.each do |k, v|
|
179
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
else # model
|
183
|
+
# models (e.g. Pet) or oneOf
|
184
|
+
klass = Svix.const_get(type)
|
185
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns the string representation of the object
|
190
|
+
# @return [String] String presentation of the object
|
191
|
+
def to_s
|
192
|
+
to_hash.to_s
|
193
|
+
end
|
194
|
+
|
195
|
+
# to_body is an alias to to_hash (backward compatibility)
|
196
|
+
# @return [Hash] Returns the object in the form of hash
|
197
|
+
def to_body
|
198
|
+
to_hash
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the object in the form of hash
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
203
|
+
def to_hash
|
204
|
+
hash = {}
|
205
|
+
self.class.attribute_map.each_pair do |attr, param|
|
206
|
+
value = self.send(attr)
|
207
|
+
if value.nil?
|
208
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
209
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
210
|
+
end
|
211
|
+
|
212
|
+
hash[param] = _to_hash(value)
|
213
|
+
end
|
214
|
+
hash
|
215
|
+
end
|
216
|
+
|
217
|
+
# Outputs non-array value in the form of hash
|
218
|
+
# For object, use to_hash. Otherwise, just return the value
|
219
|
+
# @param [Object] value Any valid value
|
220
|
+
# @return [Hash] Returns the value in the form of hash
|
221
|
+
def _to_hash(value)
|
222
|
+
if value.is_a?(Array)
|
223
|
+
value.compact.map { |v| _to_hash(v) }
|
224
|
+
elsif value.is_a?(Hash)
|
225
|
+
{}.tap do |hash|
|
226
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
227
|
+
end
|
228
|
+
elsif value.respond_to? :to_hash
|
229
|
+
value.to_hash
|
230
|
+
else
|
231
|
+
value
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|