moonlogs-ruby 1.7.17 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +114 -5
- data/docs/ActionRequest.md +13 -0
- data/docs/ActionResponse.md +14 -0
- data/docs/Condition.md +9 -0
- data/docs/DefaultApi.md +316 -0
- data/docs/InlineResponse20015.md +11 -0
- data/docs/InlineResponse20016.md +11 -0
- data/docs/InlineResponse20017.md +11 -0
- data/docs/InlineResponse20018.md +11 -0
- data/docs/InlineResponse20019.md +11 -0
- data/docs/RecordRequest.md +1 -0
- data/docs/RecordResponse.md +1 -0
- data/lib/moonlogs-ruby/api/default_api.rb +343 -1
- data/lib/moonlogs-ruby/api_client.rb +1 -1
- data/lib/moonlogs-ruby/api_error.rb +1 -1
- data/lib/moonlogs-ruby/configuration.rb +1 -1
- data/lib/moonlogs-ruby/models/action_request.rb +287 -0
- data/lib/moonlogs-ruby/models/action_response.rb +311 -0
- data/lib/moonlogs-ruby/models/api_token_request.rb +1 -1
- data/lib/moonlogs-ruby/models/api_token_response.rb +1 -1
- data/lib/moonlogs-ruby/models/condition.rb +239 -0
- data/lib/moonlogs-ruby/models/credentials.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_1.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_10.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_11.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_12.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_13.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_14.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_15.rb +267 -0
- data/lib/moonlogs-ruby/models/inline_response_200_16.rb +267 -0
- data/lib/moonlogs-ruby/models/inline_response_200_17.rb +269 -0
- data/lib/moonlogs-ruby/models/inline_response_200_18.rb +267 -0
- data/lib/moonlogs-ruby/models/inline_response_200_19.rb +268 -0
- data/lib/moonlogs-ruby/models/inline_response_200_2.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_3.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_4.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_5.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_6.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_7.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_8.rb +1 -1
- data/lib/moonlogs-ruby/models/inline_response_200_9.rb +1 -1
- data/lib/moonlogs-ruby/models/level.rb +1 -1
- data/lib/moonlogs-ruby/models/meta.rb +1 -1
- data/lib/moonlogs-ruby/models/one_of_record_request_level.rb +1 -1
- data/lib/moonlogs-ruby/models/one_of_record_response_level.rb +1 -1
- data/lib/moonlogs-ruby/models/one_of_user_request_role.rb +1 -1
- data/lib/moonlogs-ruby/models/one_of_user_response_role.rb +1 -1
- data/lib/moonlogs-ruby/models/record_request.rb +14 -5
- data/lib/moonlogs-ruby/models/record_response.rb +19 -5
- data/lib/moonlogs-ruby/models/role.rb +1 -1
- data/lib/moonlogs-ruby/models/schema_field.rb +1 -1
- data/lib/moonlogs-ruby/models/schema_kind.rb +1 -1
- data/lib/moonlogs-ruby/models/schema_request.rb +1 -1
- data/lib/moonlogs-ruby/models/schema_response.rb +1 -1
- data/lib/moonlogs-ruby/models/session.rb +1 -1
- data/lib/moonlogs-ruby/models/tag_request.rb +1 -1
- data/lib/moonlogs-ruby/models/tag_response.rb +1 -1
- data/lib/moonlogs-ruby/models/user_request.rb +1 -1
- data/lib/moonlogs-ruby/models/user_response.rb +1 -1
- data/lib/moonlogs-ruby/version.rb +2 -2
- data/lib/moonlogs-ruby.rb +9 -1
- data/moonlogs-ruby.gemspec +1 -1
- data/spec/models/action_request_spec.rb +76 -0
- data/spec/models/action_response_spec.rb +82 -0
- data/spec/models/condition_spec.rb +52 -0
- data/spec/models/inline_response_200_15_spec.rb +64 -0
- data/spec/models/inline_response_200_16_spec.rb +64 -0
- data/spec/models/inline_response_200_17_spec.rb +64 -0
- data/spec/models/inline_response_200_18_spec.rb +64 -0
- data/spec/models/inline_response_200_19_spec.rb +64 -0
- metadata +34 -2
@@ -0,0 +1,311 @@
|
|
1
|
+
=begin
|
2
|
+
#Moonlogs
|
3
|
+
|
4
|
+
#Moonlogs API
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.8.0
|
7
|
+
Contact: shalpack@gmail.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.52
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module MoonlogsRuby
|
15
|
+
class ActionResponse
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
attr_accessor :name
|
19
|
+
|
20
|
+
attr_accessor :pattern
|
21
|
+
|
22
|
+
attr_accessor :method
|
23
|
+
|
24
|
+
attr_accessor :conditions
|
25
|
+
|
26
|
+
attr_accessor :schema_name
|
27
|
+
|
28
|
+
attr_accessor :schema_id
|
29
|
+
|
30
|
+
attr_accessor :disabled
|
31
|
+
|
32
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
33
|
+
def self.attribute_map
|
34
|
+
{
|
35
|
+
:'id' => :'id',
|
36
|
+
:'name' => :'name',
|
37
|
+
:'pattern' => :'pattern',
|
38
|
+
:'method' => :'method',
|
39
|
+
:'conditions' => :'conditions',
|
40
|
+
:'schema_name' => :'schema_name',
|
41
|
+
:'schema_id' => :'schema_id',
|
42
|
+
:'disabled' => :'disabled'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attribute type mapping.
|
47
|
+
def self.openapi_types
|
48
|
+
{
|
49
|
+
:'id' => :'Object',
|
50
|
+
:'name' => :'Object',
|
51
|
+
:'pattern' => :'Object',
|
52
|
+
:'method' => :'Object',
|
53
|
+
:'conditions' => :'Object',
|
54
|
+
:'schema_name' => :'Object',
|
55
|
+
:'schema_id' => :'Object',
|
56
|
+
:'disabled' => :'Object'
|
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 `MoonlogsRuby::ActionResponse` 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 `MoonlogsRuby::ActionResponse`. 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?(:'id')
|
82
|
+
self.id = attributes[:'id']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'name')
|
86
|
+
self.name = attributes[:'name']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'pattern')
|
90
|
+
self.pattern = attributes[:'pattern']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'method')
|
94
|
+
self.method = attributes[:'method']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'conditions')
|
98
|
+
if (value = attributes[:'conditions']).is_a?(Array)
|
99
|
+
self.conditions = value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.key?(:'schema_name')
|
104
|
+
self.schema_name = attributes[:'schema_name']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'schema_id')
|
108
|
+
self.schema_id = attributes[:'schema_id']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'disabled')
|
112
|
+
self.disabled = attributes[:'disabled']
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
117
|
+
# @return Array for valid properties with the reasons
|
118
|
+
def list_invalid_properties
|
119
|
+
invalid_properties = Array.new
|
120
|
+
if @id.nil?
|
121
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
122
|
+
end
|
123
|
+
|
124
|
+
if @name.nil?
|
125
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
126
|
+
end
|
127
|
+
|
128
|
+
if @pattern.nil?
|
129
|
+
invalid_properties.push('invalid value for "pattern", pattern cannot be nil.')
|
130
|
+
end
|
131
|
+
|
132
|
+
if @method.nil?
|
133
|
+
invalid_properties.push('invalid value for "method", method cannot be nil.')
|
134
|
+
end
|
135
|
+
|
136
|
+
if @conditions.nil?
|
137
|
+
invalid_properties.push('invalid value for "conditions", conditions cannot be nil.')
|
138
|
+
end
|
139
|
+
|
140
|
+
if @schema_name.nil?
|
141
|
+
invalid_properties.push('invalid value for "schema_name", schema_name cannot be nil.')
|
142
|
+
end
|
143
|
+
|
144
|
+
if @schema_id.nil?
|
145
|
+
invalid_properties.push('invalid value for "schema_id", schema_id cannot be nil.')
|
146
|
+
end
|
147
|
+
|
148
|
+
if @disabled.nil?
|
149
|
+
invalid_properties.push('invalid value for "disabled", disabled cannot be nil.')
|
150
|
+
end
|
151
|
+
|
152
|
+
invalid_properties
|
153
|
+
end
|
154
|
+
|
155
|
+
# Check to see if the all the properties in the model are valid
|
156
|
+
# @return true if the model is valid
|
157
|
+
def valid?
|
158
|
+
return false if @id.nil?
|
159
|
+
return false if @name.nil?
|
160
|
+
return false if @pattern.nil?
|
161
|
+
return false if @method.nil?
|
162
|
+
return false if @conditions.nil?
|
163
|
+
return false if @schema_name.nil?
|
164
|
+
return false if @schema_id.nil?
|
165
|
+
return false if @disabled.nil?
|
166
|
+
true
|
167
|
+
end
|
168
|
+
|
169
|
+
# Checks equality by comparing each attribute.
|
170
|
+
# @param [Object] Object to be compared
|
171
|
+
def ==(o)
|
172
|
+
return true if self.equal?(o)
|
173
|
+
self.class == o.class &&
|
174
|
+
id == o.id &&
|
175
|
+
name == o.name &&
|
176
|
+
pattern == o.pattern &&
|
177
|
+
method == o.method &&
|
178
|
+
conditions == o.conditions &&
|
179
|
+
schema_name == o.schema_name &&
|
180
|
+
schema_id == o.schema_id &&
|
181
|
+
disabled == o.disabled
|
182
|
+
end
|
183
|
+
|
184
|
+
# @see the `==` method
|
185
|
+
# @param [Object] Object to be compared
|
186
|
+
def eql?(o)
|
187
|
+
self == o
|
188
|
+
end
|
189
|
+
|
190
|
+
# Calculates hash code according to all attributes.
|
191
|
+
# @return [Integer] Hash code
|
192
|
+
def hash
|
193
|
+
[id, name, pattern, method, conditions, schema_name, schema_id, disabled].hash
|
194
|
+
end
|
195
|
+
|
196
|
+
# Builds the object from hash
|
197
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
198
|
+
# @return [Object] Returns the model itself
|
199
|
+
def self.build_from_hash(attributes)
|
200
|
+
new.build_from_hash(attributes)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Builds the object from hash
|
204
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
205
|
+
# @return [Object] Returns the model itself
|
206
|
+
def build_from_hash(attributes)
|
207
|
+
return nil unless attributes.is_a?(Hash)
|
208
|
+
self.class.openapi_types.each_pair do |key, type|
|
209
|
+
if type =~ /\AArray<(.*)>/i
|
210
|
+
# check to ensure the input is an array given that the attribute
|
211
|
+
# is documented as an array but the input is not
|
212
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
213
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
214
|
+
end
|
215
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
216
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
217
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
218
|
+
self.send("#{key}=", nil)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
self
|
223
|
+
end
|
224
|
+
|
225
|
+
# Deserializes the data based on type
|
226
|
+
# @param string type Data type
|
227
|
+
# @param string value Value to be deserialized
|
228
|
+
# @return [Object] Deserialized data
|
229
|
+
def _deserialize(type, value)
|
230
|
+
case type.to_sym
|
231
|
+
when :DateTime
|
232
|
+
DateTime.parse(value)
|
233
|
+
when :Date
|
234
|
+
Date.parse(value)
|
235
|
+
when :String
|
236
|
+
value.to_s
|
237
|
+
when :Integer
|
238
|
+
value.to_i
|
239
|
+
when :Float
|
240
|
+
value.to_f
|
241
|
+
when :Boolean
|
242
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
243
|
+
true
|
244
|
+
else
|
245
|
+
false
|
246
|
+
end
|
247
|
+
when :Object
|
248
|
+
# generic object (usually a Hash), return directly
|
249
|
+
value
|
250
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
251
|
+
inner_type = Regexp.last_match[:inner_type]
|
252
|
+
value.map { |v| _deserialize(inner_type, v) }
|
253
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
254
|
+
k_type = Regexp.last_match[:k_type]
|
255
|
+
v_type = Regexp.last_match[:v_type]
|
256
|
+
{}.tap do |hash|
|
257
|
+
value.each do |k, v|
|
258
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
else # model
|
262
|
+
MoonlogsRuby.const_get(type).build_from_hash(value)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Returns the string representation of the object
|
267
|
+
# @return [String] String presentation of the object
|
268
|
+
def to_s
|
269
|
+
to_hash.to_s
|
270
|
+
end
|
271
|
+
|
272
|
+
# to_body is an alias to to_hash (backward compatibility)
|
273
|
+
# @return [Hash] Returns the object in the form of hash
|
274
|
+
def to_body
|
275
|
+
to_hash
|
276
|
+
end
|
277
|
+
|
278
|
+
# Returns the object in the form of hash
|
279
|
+
# @return [Hash] Returns the object in the form of hash
|
280
|
+
def to_hash
|
281
|
+
hash = {}
|
282
|
+
self.class.attribute_map.each_pair do |attr, param|
|
283
|
+
value = self.send(attr)
|
284
|
+
if value.nil?
|
285
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
286
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
287
|
+
end
|
288
|
+
|
289
|
+
hash[param] = _to_hash(value)
|
290
|
+
end
|
291
|
+
hash
|
292
|
+
end
|
293
|
+
|
294
|
+
# Outputs non-array value in the form of hash
|
295
|
+
# For object, use to_hash. Otherwise, just return the value
|
296
|
+
# @param [Object] value Any valid value
|
297
|
+
# @return [Hash] Returns the value in the form of hash
|
298
|
+
def _to_hash(value)
|
299
|
+
if value.is_a?(Array)
|
300
|
+
value.compact.map { |v| _to_hash(v) }
|
301
|
+
elsif value.is_a?(Hash)
|
302
|
+
{}.tap do |hash|
|
303
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
304
|
+
end
|
305
|
+
elsif value.respond_to? :to_hash
|
306
|
+
value.to_hash
|
307
|
+
else
|
308
|
+
value
|
309
|
+
end
|
310
|
+
end end
|
311
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
=begin
|
2
|
+
#Moonlogs
|
3
|
+
|
4
|
+
#Moonlogs API
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.8.0
|
7
|
+
Contact: shalpack@gmail.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.52
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module MoonlogsRuby
|
15
|
+
class Condition
|
16
|
+
attr_accessor :attribute
|
17
|
+
|
18
|
+
attr_accessor :operation
|
19
|
+
|
20
|
+
attr_accessor :value
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'attribute' => :'attribute',
|
26
|
+
:'operation' => :'operation',
|
27
|
+
:'value' => :'value'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.openapi_types
|
33
|
+
{
|
34
|
+
:'attribute' => :'Object',
|
35
|
+
:'operation' => :'Object',
|
36
|
+
:'value' => :'Object'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# List of attributes with nullable: true
|
41
|
+
def self.openapi_nullable
|
42
|
+
Set.new([
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
# Initializes the object
|
47
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
48
|
+
def initialize(attributes = {})
|
49
|
+
if (!attributes.is_a?(Hash))
|
50
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MoonlogsRuby::Condition` initialize method"
|
51
|
+
end
|
52
|
+
|
53
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
55
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
56
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MoonlogsRuby::Condition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
57
|
+
end
|
58
|
+
h[k.to_sym] = v
|
59
|
+
}
|
60
|
+
|
61
|
+
if attributes.key?(:'attribute')
|
62
|
+
self.attribute = attributes[:'attribute']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.key?(:'operation')
|
66
|
+
self.operation = attributes[:'operation']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.key?(:'value')
|
70
|
+
self.value = attributes[:'value']
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
75
|
+
# @return Array for valid properties with the reasons
|
76
|
+
def list_invalid_properties
|
77
|
+
invalid_properties = Array.new
|
78
|
+
if @attribute.nil?
|
79
|
+
invalid_properties.push('invalid value for "attribute", attribute cannot be nil.')
|
80
|
+
end
|
81
|
+
|
82
|
+
if @operation.nil?
|
83
|
+
invalid_properties.push('invalid value for "operation", operation cannot be nil.')
|
84
|
+
end
|
85
|
+
|
86
|
+
if @value.nil?
|
87
|
+
invalid_properties.push('invalid value for "value", value cannot be nil.')
|
88
|
+
end
|
89
|
+
|
90
|
+
invalid_properties
|
91
|
+
end
|
92
|
+
|
93
|
+
# Check to see if the all the properties in the model are valid
|
94
|
+
# @return true if the model is valid
|
95
|
+
def valid?
|
96
|
+
return false if @attribute.nil?
|
97
|
+
return false if @operation.nil?
|
98
|
+
return false if @value.nil?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
# Checks equality by comparing each attribute.
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def ==(o)
|
105
|
+
return true if self.equal?(o)
|
106
|
+
self.class == o.class &&
|
107
|
+
attribute == o.attribute &&
|
108
|
+
operation == o.operation &&
|
109
|
+
value == o.value
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Integer] Hash code
|
120
|
+
def hash
|
121
|
+
[attribute, operation, value].hash
|
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 self.build_from_hash(attributes)
|
128
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
135
|
+
return nil unless attributes.is_a?(Hash)
|
136
|
+
self.class.openapi_types.each_pair do |key, type|
|
137
|
+
if type =~ /\AArray<(.*)>/i
|
138
|
+
# check to ensure the input is an array given that the attribute
|
139
|
+
# is documented as an array but the input is not
|
140
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
141
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
142
|
+
end
|
143
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
144
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
145
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
146
|
+
self.send("#{key}=", nil)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
157
|
+
def _deserialize(type, value)
|
158
|
+
case type.to_sym
|
159
|
+
when :DateTime
|
160
|
+
DateTime.parse(value)
|
161
|
+
when :Date
|
162
|
+
Date.parse(value)
|
163
|
+
when :String
|
164
|
+
value.to_s
|
165
|
+
when :Integer
|
166
|
+
value.to_i
|
167
|
+
when :Float
|
168
|
+
value.to_f
|
169
|
+
when :Boolean
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
171
|
+
true
|
172
|
+
else
|
173
|
+
false
|
174
|
+
end
|
175
|
+
when :Object
|
176
|
+
# generic object (usually a Hash), return directly
|
177
|
+
value
|
178
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
179
|
+
inner_type = Regexp.last_match[:inner_type]
|
180
|
+
value.map { |v| _deserialize(inner_type, v) }
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
182
|
+
k_type = Regexp.last_match[:k_type]
|
183
|
+
v_type = Regexp.last_match[:v_type]
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each do |k, v|
|
186
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else # model
|
190
|
+
MoonlogsRuby.const_get(type).build_from_hash(value)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the string representation of the object
|
195
|
+
# @return [String] String presentation of the object
|
196
|
+
def to_s
|
197
|
+
to_hash.to_s
|
198
|
+
end
|
199
|
+
|
200
|
+
# to_body is an alias to to_hash (backward compatibility)
|
201
|
+
# @return [Hash] Returns the object in the form of hash
|
202
|
+
def to_body
|
203
|
+
to_hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the object in the form of hash
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_hash
|
209
|
+
hash = {}
|
210
|
+
self.class.attribute_map.each_pair do |attr, param|
|
211
|
+
value = self.send(attr)
|
212
|
+
if value.nil?
|
213
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
214
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
215
|
+
end
|
216
|
+
|
217
|
+
hash[param] = _to_hash(value)
|
218
|
+
end
|
219
|
+
hash
|
220
|
+
end
|
221
|
+
|
222
|
+
# Outputs non-array value in the form of hash
|
223
|
+
# For object, use to_hash. Otherwise, just return the value
|
224
|
+
# @param [Object] value Any valid value
|
225
|
+
# @return [Hash] Returns the value in the form of hash
|
226
|
+
def _to_hash(value)
|
227
|
+
if value.is_a?(Array)
|
228
|
+
value.compact.map { |v| _to_hash(v) }
|
229
|
+
elsif value.is_a?(Hash)
|
230
|
+
{}.tap do |hash|
|
231
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
232
|
+
end
|
233
|
+
elsif value.respond_to? :to_hash
|
234
|
+
value.to_hash
|
235
|
+
else
|
236
|
+
value
|
237
|
+
end
|
238
|
+
end end
|
239
|
+
end
|