svix 1.39.0 → 1.40.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/stream_api.rb +157 -0
- data/lib/svix/api/stream_event_types_api.rb +486 -0
- data/lib/svix/models/event_example_in.rb +35 -4
- data/lib/svix/models/event_in.rb +38 -1
- data/lib/svix/models/event_out.rb +38 -1
- data/lib/svix/models/list_response_stream_event_type_out.rb +259 -0
- data/lib/svix/models/stream_event_type_in.rb +262 -0
- data/lib/svix/models/stream_event_type_out.rb +294 -0
- data/lib/svix/models/stream_event_type_patch.rb +254 -0
- data/lib/svix/version.rb +1 -1
- metadata +7 -3
- data/lib/svix/api/sink_api.rb +0 -179
@@ -18,10 +18,14 @@ module Svix
|
|
18
18
|
# The event type's name
|
19
19
|
attr_accessor :event_type
|
20
20
|
|
21
|
+
# If the event type schema contains an array of examples, chooses which one to send. Defaults to the first example. Ignored if the schema doesn't contain an array of examples.
|
22
|
+
attr_accessor :example_index
|
23
|
+
|
21
24
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
25
|
def self.attribute_map
|
23
26
|
{
|
24
|
-
:'event_type' => :'eventType'
|
27
|
+
:'event_type' => :'eventType',
|
28
|
+
:'example_index' => :'exampleIndex'
|
25
29
|
}
|
26
30
|
end
|
27
31
|
|
@@ -33,7 +37,8 @@ module Svix
|
|
33
37
|
# Attribute type mapping.
|
34
38
|
def self.openapi_types
|
35
39
|
{
|
36
|
-
:'event_type' => :'String'
|
40
|
+
:'event_type' => :'String',
|
41
|
+
:'example_index' => :'Integer'
|
37
42
|
}
|
38
43
|
end
|
39
44
|
|
@@ -63,6 +68,12 @@ module Svix
|
|
63
68
|
else
|
64
69
|
self.event_type = nil
|
65
70
|
end
|
71
|
+
|
72
|
+
if attributes.key?(:'example_index')
|
73
|
+
self.example_index = attributes[:'example_index']
|
74
|
+
else
|
75
|
+
self.example_index = 0
|
76
|
+
end
|
66
77
|
end
|
67
78
|
|
68
79
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -83,6 +94,10 @@ module Svix
|
|
83
94
|
invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
|
84
95
|
end
|
85
96
|
|
97
|
+
if !@example_index.nil? && @example_index < 0
|
98
|
+
invalid_properties.push('invalid value for "example_index", must be greater than or equal to 0.')
|
99
|
+
end
|
100
|
+
|
86
101
|
invalid_properties
|
87
102
|
end
|
88
103
|
|
@@ -93,6 +108,7 @@ module Svix
|
|
93
108
|
return false if @event_type.nil?
|
94
109
|
return false if @event_type.to_s.length > 256
|
95
110
|
return false if @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
111
|
+
return false if !@example_index.nil? && @example_index < 0
|
96
112
|
true
|
97
113
|
end
|
98
114
|
|
@@ -115,12 +131,27 @@ module Svix
|
|
115
131
|
@event_type = event_type
|
116
132
|
end
|
117
133
|
|
134
|
+
# Custom attribute writer method with validation
|
135
|
+
# @param [Object] example_index Value to be assigned
|
136
|
+
def example_index=(example_index)
|
137
|
+
if example_index.nil?
|
138
|
+
fail ArgumentError, 'example_index cannot be nil'
|
139
|
+
end
|
140
|
+
|
141
|
+
if example_index < 0
|
142
|
+
fail ArgumentError, 'invalid value for "example_index", must be greater than or equal to 0.'
|
143
|
+
end
|
144
|
+
|
145
|
+
@example_index = example_index
|
146
|
+
end
|
147
|
+
|
118
148
|
# Checks equality by comparing each attribute.
|
119
149
|
# @param [Object] Object to be compared
|
120
150
|
def ==(o)
|
121
151
|
return true if self.equal?(o)
|
122
152
|
self.class == o.class &&
|
123
|
-
event_type == o.event_type
|
153
|
+
event_type == o.event_type &&
|
154
|
+
example_index == o.example_index
|
124
155
|
end
|
125
156
|
|
126
157
|
# @see the `==` method
|
@@ -132,7 +163,7 @@ module Svix
|
|
132
163
|
# Calculates hash code according to all attributes.
|
133
164
|
# @return [Integer] Hash code
|
134
165
|
def hash
|
135
|
-
[event_type].hash
|
166
|
+
[event_type, example_index].hash
|
136
167
|
end
|
137
168
|
|
138
169
|
# Builds the object from hash
|
data/lib/svix/models/event_in.rb
CHANGED
@@ -15,11 +15,15 @@ require 'time'
|
|
15
15
|
|
16
16
|
module Svix
|
17
17
|
class EventIn
|
18
|
+
# The event type's name
|
19
|
+
attr_accessor :event_type
|
20
|
+
|
18
21
|
attr_accessor :payload
|
19
22
|
|
20
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
21
24
|
def self.attribute_map
|
22
25
|
{
|
26
|
+
:'event_type' => :'eventType',
|
23
27
|
:'payload' => :'payload'
|
24
28
|
}
|
25
29
|
end
|
@@ -32,6 +36,7 @@ module Svix
|
|
32
36
|
# Attribute type mapping.
|
33
37
|
def self.openapi_types
|
34
38
|
{
|
39
|
+
:'event_type' => :'String',
|
35
40
|
:'payload' => :'String'
|
36
41
|
}
|
37
42
|
end
|
@@ -39,6 +44,7 @@ module Svix
|
|
39
44
|
# List of attributes with nullable: true
|
40
45
|
def self.openapi_nullable
|
41
46
|
Set.new([
|
47
|
+
:'event_type',
|
42
48
|
])
|
43
49
|
end
|
44
50
|
|
@@ -57,6 +63,10 @@ module Svix
|
|
57
63
|
h[k.to_sym] = v
|
58
64
|
}
|
59
65
|
|
66
|
+
if attributes.key?(:'event_type')
|
67
|
+
self.event_type = attributes[:'event_type']
|
68
|
+
end
|
69
|
+
|
60
70
|
if attributes.key?(:'payload')
|
61
71
|
self.payload = attributes[:'payload']
|
62
72
|
else
|
@@ -69,6 +79,15 @@ module Svix
|
|
69
79
|
def list_invalid_properties
|
70
80
|
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
71
81
|
invalid_properties = Array.new
|
82
|
+
if !@event_type.nil? && @event_type.to_s.length > 256
|
83
|
+
invalid_properties.push('invalid value for "event_type", the character length must be smaller than or equal to 256.')
|
84
|
+
end
|
85
|
+
|
86
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
87
|
+
if !@event_type.nil? && @event_type !~ pattern
|
88
|
+
invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
|
89
|
+
end
|
90
|
+
|
72
91
|
if @payload.nil?
|
73
92
|
invalid_properties.push('invalid value for "payload", payload cannot be nil.')
|
74
93
|
end
|
@@ -80,15 +99,33 @@ module Svix
|
|
80
99
|
# @return true if the model is valid
|
81
100
|
def valid?
|
82
101
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
102
|
+
return false if !@event_type.nil? && @event_type.to_s.length > 256
|
103
|
+
return false if !@event_type.nil? && @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
83
104
|
return false if @payload.nil?
|
84
105
|
true
|
85
106
|
end
|
86
107
|
|
108
|
+
# Custom attribute writer method with validation
|
109
|
+
# @param [Object] event_type Value to be assigned
|
110
|
+
def event_type=(event_type)
|
111
|
+
if !event_type.nil? && event_type.to_s.length > 256
|
112
|
+
fail ArgumentError, 'invalid value for "event_type", the character length must be smaller than or equal to 256.'
|
113
|
+
end
|
114
|
+
|
115
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
116
|
+
if !event_type.nil? && event_type !~ pattern
|
117
|
+
fail ArgumentError, "invalid value for \"event_type\", must conform to the pattern #{pattern}."
|
118
|
+
end
|
119
|
+
|
120
|
+
@event_type = event_type
|
121
|
+
end
|
122
|
+
|
87
123
|
# Checks equality by comparing each attribute.
|
88
124
|
# @param [Object] Object to be compared
|
89
125
|
def ==(o)
|
90
126
|
return true if self.equal?(o)
|
91
127
|
self.class == o.class &&
|
128
|
+
event_type == o.event_type &&
|
92
129
|
payload == o.payload
|
93
130
|
end
|
94
131
|
|
@@ -101,7 +138,7 @@ module Svix
|
|
101
138
|
# Calculates hash code according to all attributes.
|
102
139
|
# @return [Integer] Hash code
|
103
140
|
def hash
|
104
|
-
[payload].hash
|
141
|
+
[event_type, payload].hash
|
105
142
|
end
|
106
143
|
|
107
144
|
# Builds the object from hash
|
@@ -15,6 +15,9 @@ require 'time'
|
|
15
15
|
|
16
16
|
module Svix
|
17
17
|
class EventOut
|
18
|
+
# The event type's name
|
19
|
+
attr_accessor :event_type
|
20
|
+
|
18
21
|
attr_accessor :payload
|
19
22
|
|
20
23
|
attr_accessor :timestamp
|
@@ -22,6 +25,7 @@ module Svix
|
|
22
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
26
|
def self.attribute_map
|
24
27
|
{
|
28
|
+
:'event_type' => :'eventType',
|
25
29
|
:'payload' => :'payload',
|
26
30
|
:'timestamp' => :'timestamp'
|
27
31
|
}
|
@@ -35,6 +39,7 @@ module Svix
|
|
35
39
|
# Attribute type mapping.
|
36
40
|
def self.openapi_types
|
37
41
|
{
|
42
|
+
:'event_type' => :'String',
|
38
43
|
:'payload' => :'String',
|
39
44
|
:'timestamp' => :'Time'
|
40
45
|
}
|
@@ -43,6 +48,7 @@ module Svix
|
|
43
48
|
# List of attributes with nullable: true
|
44
49
|
def self.openapi_nullable
|
45
50
|
Set.new([
|
51
|
+
:'event_type',
|
46
52
|
])
|
47
53
|
end
|
48
54
|
|
@@ -61,6 +67,10 @@ module Svix
|
|
61
67
|
h[k.to_sym] = v
|
62
68
|
}
|
63
69
|
|
70
|
+
if attributes.key?(:'event_type')
|
71
|
+
self.event_type = attributes[:'event_type']
|
72
|
+
end
|
73
|
+
|
64
74
|
if attributes.key?(:'payload')
|
65
75
|
self.payload = attributes[:'payload']
|
66
76
|
else
|
@@ -79,6 +89,15 @@ module Svix
|
|
79
89
|
def list_invalid_properties
|
80
90
|
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
81
91
|
invalid_properties = Array.new
|
92
|
+
if !@event_type.nil? && @event_type.to_s.length > 256
|
93
|
+
invalid_properties.push('invalid value for "event_type", the character length must be smaller than or equal to 256.')
|
94
|
+
end
|
95
|
+
|
96
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
97
|
+
if !@event_type.nil? && @event_type !~ pattern
|
98
|
+
invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
|
99
|
+
end
|
100
|
+
|
82
101
|
if @payload.nil?
|
83
102
|
invalid_properties.push('invalid value for "payload", payload cannot be nil.')
|
84
103
|
end
|
@@ -94,16 +113,34 @@ module Svix
|
|
94
113
|
# @return true if the model is valid
|
95
114
|
def valid?
|
96
115
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
116
|
+
return false if !@event_type.nil? && @event_type.to_s.length > 256
|
117
|
+
return false if !@event_type.nil? && @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
97
118
|
return false if @payload.nil?
|
98
119
|
return false if @timestamp.nil?
|
99
120
|
true
|
100
121
|
end
|
101
122
|
|
123
|
+
# Custom attribute writer method with validation
|
124
|
+
# @param [Object] event_type Value to be assigned
|
125
|
+
def event_type=(event_type)
|
126
|
+
if !event_type.nil? && event_type.to_s.length > 256
|
127
|
+
fail ArgumentError, 'invalid value for "event_type", the character length must be smaller than or equal to 256.'
|
128
|
+
end
|
129
|
+
|
130
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
131
|
+
if !event_type.nil? && event_type !~ pattern
|
132
|
+
fail ArgumentError, "invalid value for \"event_type\", must conform to the pattern #{pattern}."
|
133
|
+
end
|
134
|
+
|
135
|
+
@event_type = event_type
|
136
|
+
end
|
137
|
+
|
102
138
|
# Checks equality by comparing each attribute.
|
103
139
|
# @param [Object] Object to be compared
|
104
140
|
def ==(o)
|
105
141
|
return true if self.equal?(o)
|
106
142
|
self.class == o.class &&
|
143
|
+
event_type == o.event_type &&
|
107
144
|
payload == o.payload &&
|
108
145
|
timestamp == o.timestamp
|
109
146
|
end
|
@@ -117,7 +154,7 @@ module Svix
|
|
117
154
|
# Calculates hash code according to all attributes.
|
118
155
|
# @return [Integer] Hash code
|
119
156
|
def hash
|
120
|
-
[payload, timestamp].hash
|
157
|
+
[event_type, payload, timestamp].hash
|
121
158
|
end
|
122
159
|
|
123
160
|
# Builds the object from hash
|
@@ -0,0 +1,259 @@
|
|
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
|
+
Generator version: 7.9.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Svix
|
17
|
+
class ListResponseStreamEventTypeOut
|
18
|
+
attr_accessor :data
|
19
|
+
|
20
|
+
attr_accessor :done
|
21
|
+
|
22
|
+
attr_accessor :iterator
|
23
|
+
|
24
|
+
attr_accessor :prev_iterator
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'data' => :'data',
|
30
|
+
:'done' => :'done',
|
31
|
+
:'iterator' => :'iterator',
|
32
|
+
:'prev_iterator' => :'prevIterator'
|
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
|
+
:'data' => :'Array<StreamEventTypeOut>',
|
45
|
+
:'done' => :'Boolean',
|
46
|
+
:'iterator' => :'String',
|
47
|
+
:'prev_iterator' => :'String'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# List of attributes with nullable: true
|
52
|
+
def self.openapi_nullable
|
53
|
+
Set.new([
|
54
|
+
:'iterator',
|
55
|
+
:'prev_iterator'
|
56
|
+
])
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initializes the object
|
60
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
61
|
+
def initialize(attributes = {})
|
62
|
+
if (!attributes.is_a?(Hash))
|
63
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::ListResponseStreamEventTypeOut` initialize method"
|
64
|
+
end
|
65
|
+
|
66
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
67
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
68
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
69
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::ListResponseStreamEventTypeOut`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
70
|
+
end
|
71
|
+
h[k.to_sym] = v
|
72
|
+
}
|
73
|
+
|
74
|
+
if attributes.key?(:'data')
|
75
|
+
if (value = attributes[:'data']).is_a?(Array)
|
76
|
+
self.data = value
|
77
|
+
end
|
78
|
+
else
|
79
|
+
self.data = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'done')
|
83
|
+
self.done = attributes[:'done']
|
84
|
+
else
|
85
|
+
self.done = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:'iterator')
|
89
|
+
self.iterator = attributes[:'iterator']
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:'prev_iterator')
|
93
|
+
self.prev_iterator = attributes[:'prev_iterator']
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
98
|
+
# @return Array for valid properties with the reasons
|
99
|
+
def list_invalid_properties
|
100
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
101
|
+
invalid_properties = Array.new
|
102
|
+
if @data.nil?
|
103
|
+
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
104
|
+
end
|
105
|
+
|
106
|
+
if @done.nil?
|
107
|
+
invalid_properties.push('invalid value for "done", done cannot be nil.')
|
108
|
+
end
|
109
|
+
|
110
|
+
invalid_properties
|
111
|
+
end
|
112
|
+
|
113
|
+
# Check to see if the all the properties in the model are valid
|
114
|
+
# @return true if the model is valid
|
115
|
+
def valid?
|
116
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
117
|
+
return false if @data.nil?
|
118
|
+
return false if @done.nil?
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
# Checks equality by comparing each attribute.
|
123
|
+
# @param [Object] Object to be compared
|
124
|
+
def ==(o)
|
125
|
+
return true if self.equal?(o)
|
126
|
+
self.class == o.class &&
|
127
|
+
data == o.data &&
|
128
|
+
done == o.done &&
|
129
|
+
iterator == o.iterator &&
|
130
|
+
prev_iterator == o.prev_iterator
|
131
|
+
end
|
132
|
+
|
133
|
+
# @see the `==` method
|
134
|
+
# @param [Object] Object to be compared
|
135
|
+
def eql?(o)
|
136
|
+
self == o
|
137
|
+
end
|
138
|
+
|
139
|
+
# Calculates hash code according to all attributes.
|
140
|
+
# @return [Integer] Hash code
|
141
|
+
def hash
|
142
|
+
[data, done, iterator, prev_iterator].hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def self.build_from_hash(attributes)
|
149
|
+
return nil unless attributes.is_a?(Hash)
|
150
|
+
attributes = attributes.transform_keys(&:to_sym)
|
151
|
+
transformed_hash = {}
|
152
|
+
openapi_types.each_pair do |key, type|
|
153
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
154
|
+
transformed_hash["#{key}"] = nil
|
155
|
+
elsif type =~ /\AArray<(.*)>/i
|
156
|
+
# check to ensure the input is an array given that the attribute
|
157
|
+
# is documented as an array but the input is not
|
158
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
159
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
160
|
+
end
|
161
|
+
elsif !attributes[attribute_map[key]].nil?
|
162
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
163
|
+
end
|
164
|
+
end
|
165
|
+
new(transformed_hash)
|
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 self._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_any_of) || 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
|