carbon_ruby_sdk 0.2.38 → 0.2.40
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/README.md +310 -2
- data/lib/carbon_ruby_sdk/api/github_api.rb +825 -0
- data/lib/carbon_ruby_sdk/models/comments_input.rb +330 -0
- data/lib/carbon_ruby_sdk/models/comments_order_by.rb +36 -0
- data/lib/carbon_ruby_sdk/models/comments_response.rb +232 -0
- data/lib/carbon_ruby_sdk/models/commit.rb +282 -0
- data/lib/carbon_ruby_sdk/models/commit_user.rb +234 -0
- data/lib/carbon_ruby_sdk/models/commit_user_nullable.rb +234 -0
- data/lib/carbon_ruby_sdk/models/commits_input.rb +307 -0
- data/lib/carbon_ruby_sdk/models/commits_response.rb +232 -0
- data/lib/carbon_ruby_sdk/models/file_status.rb +41 -0
- data/lib/carbon_ruby_sdk/models/files_input.rb +307 -0
- data/lib/carbon_ruby_sdk/models/files_response.rb +232 -0
- data/lib/carbon_ruby_sdk/models/head_or_base.rb +248 -0
- data/lib/carbon_ruby_sdk/models/issue.rb +434 -0
- data/lib/carbon_ruby_sdk/models/issue_pr.rb +230 -0
- data/lib/carbon_ruby_sdk/models/issue_pr_nullable.rb +230 -0
- data/lib/carbon_ruby_sdk/models/issues_filter.rb +217 -0
- data/lib/carbon_ruby_sdk/models/issues_input.rb +325 -0
- data/lib/carbon_ruby_sdk/models/issues_order_by.rb +37 -0
- data/lib/carbon_ruby_sdk/models/issues_response.rb +232 -0
- data/lib/carbon_ruby_sdk/models/label.rb +234 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_filters.rb +29 -1
- data/lib/carbon_ruby_sdk/models/pr_comment.rb +358 -0
- data/lib/carbon_ruby_sdk/models/pr_commit.rb +264 -0
- data/lib/carbon_ruby_sdk/models/pr_file.rb +342 -0
- data/lib/carbon_ruby_sdk/models/pr_order_by.rb +37 -0
- data/lib/carbon_ruby_sdk/models/pr_state.rb +36 -0
- data/lib/carbon_ruby_sdk/models/pr_state_input.rb +37 -0
- data/lib/carbon_ruby_sdk/models/pull_request.rb +438 -0
- data/lib/carbon_ruby_sdk/models/pull_request_extended.rb +536 -0
- data/lib/carbon_ruby_sdk/models/pull_request_filters.rb +239 -0
- data/lib/carbon_ruby_sdk/models/pull_request_response.rb +232 -0
- data/lib/carbon_ruby_sdk/models/pull_requests_input.rb +325 -0
- data/lib/carbon_ruby_sdk/models/sent_webhook_payload.rb +2 -2
- data/lib/carbon_ruby_sdk/models/team.rb +234 -0
- data/lib/carbon_ruby_sdk/models/tree.rb +234 -0
- data/lib/carbon_ruby_sdk/models/user.rb +234 -0
- data/lib/carbon_ruby_sdk/models/user_file.rb +11 -1
- data/lib/carbon_ruby_sdk/models/user_nullable.rb +234 -0
- data/lib/carbon_ruby_sdk/version.rb +1 -1
- data/lib/carbon_ruby_sdk.rb +38 -0
- data/spec/api/github_api_spec.rb +112 -0
- data/spec/models/comments_input_spec.rb +76 -0
- data/spec/models/comments_order_by_spec.rb +22 -0
- data/spec/models/comments_response_spec.rb +34 -0
- data/spec/models/commit_spec.rb +58 -0
- data/spec/models/commit_user_nullable_spec.rb +34 -0
- data/spec/models/commit_user_spec.rb +34 -0
- data/spec/models/commits_input_spec.rb +64 -0
- data/spec/models/commits_response_spec.rb +34 -0
- data/spec/models/file_status_spec.rb +22 -0
- data/spec/models/files_input_spec.rb +64 -0
- data/spec/models/files_response_spec.rb +34 -0
- data/spec/models/head_or_base_spec.rb +40 -0
- data/spec/models/issue_pr_nullable_spec.rb +34 -0
- data/spec/models/issue_pr_spec.rb +34 -0
- data/spec/models/issue_spec.rb +124 -0
- data/spec/models/issues_filter_spec.rb +28 -0
- data/spec/models/issues_input_spec.rb +76 -0
- data/spec/models/issues_order_by_spec.rb +22 -0
- data/spec/models/issues_response_spec.rb +34 -0
- data/spec/models/label_spec.rb +34 -0
- data/spec/models/organization_user_files_to_sync_filters_spec.rb +6 -0
- data/spec/models/pr_comment_spec.rb +94 -0
- data/spec/models/pr_commit_spec.rb +52 -0
- data/spec/models/pr_file_spec.rb +82 -0
- data/spec/models/pr_order_by_spec.rb +22 -0
- data/spec/models/pr_state_input_spec.rb +22 -0
- data/spec/models/pr_state_spec.rb +22 -0
- data/spec/models/pull_request_extended_spec.rb +166 -0
- data/spec/models/pull_request_filters_spec.rb +40 -0
- data/spec/models/pull_request_response_spec.rb +34 -0
- data/spec/models/pull_request_spec.rb +124 -0
- data/spec/models/pull_requests_input_spec.rb +76 -0
- data/spec/models/sent_webhook_payload_spec.rb +1 -1
- data/spec/models/team_spec.rb +34 -0
- data/spec/models/tree_spec.rb +34 -0
- data/spec/models/user_file_spec.rb +6 -0
- data/spec/models/user_nullable_spec.rb +34 -0
- data/spec/models/user_spec.rb +34 -0
- metadata +301 -193
@@ -0,0 +1,536 @@
|
|
1
|
+
=begin
|
2
|
+
#Carbon
|
3
|
+
|
4
|
+
#Connect external data to LLMs, no matter the source.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'date'
|
10
|
+
require 'time'
|
11
|
+
|
12
|
+
module Carbon
|
13
|
+
class PullRequestExtended
|
14
|
+
attr_accessor :title
|
15
|
+
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
attr_accessor :url
|
19
|
+
|
20
|
+
attr_accessor :number
|
21
|
+
|
22
|
+
attr_accessor :state
|
23
|
+
|
24
|
+
attr_accessor :user
|
25
|
+
|
26
|
+
attr_accessor :created_at
|
27
|
+
|
28
|
+
attr_accessor :updated_at
|
29
|
+
|
30
|
+
attr_accessor :closed_at
|
31
|
+
|
32
|
+
attr_accessor :merged_at
|
33
|
+
|
34
|
+
attr_accessor :requested_reviewers
|
35
|
+
|
36
|
+
attr_accessor :requested_teams
|
37
|
+
|
38
|
+
attr_accessor :labels
|
39
|
+
|
40
|
+
attr_accessor :draft
|
41
|
+
|
42
|
+
attr_accessor :head
|
43
|
+
|
44
|
+
attr_accessor :base
|
45
|
+
|
46
|
+
attr_accessor :remote_data
|
47
|
+
|
48
|
+
attr_accessor :merged
|
49
|
+
|
50
|
+
attr_accessor :num_comments
|
51
|
+
|
52
|
+
attr_accessor :num_review_comments
|
53
|
+
|
54
|
+
attr_accessor :num_commits
|
55
|
+
|
56
|
+
attr_accessor :num_additions
|
57
|
+
|
58
|
+
attr_accessor :num_deletions
|
59
|
+
|
60
|
+
attr_accessor :num_changed_files
|
61
|
+
|
62
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
63
|
+
def self.attribute_map
|
64
|
+
{
|
65
|
+
:'title' => :'title',
|
66
|
+
:'id' => :'id',
|
67
|
+
:'url' => :'url',
|
68
|
+
:'number' => :'number',
|
69
|
+
:'state' => :'state',
|
70
|
+
:'user' => :'user',
|
71
|
+
:'created_at' => :'created_at',
|
72
|
+
:'updated_at' => :'updated_at',
|
73
|
+
:'closed_at' => :'closed_at',
|
74
|
+
:'merged_at' => :'merged_at',
|
75
|
+
:'requested_reviewers' => :'requested_reviewers',
|
76
|
+
:'requested_teams' => :'requested_teams',
|
77
|
+
:'labels' => :'labels',
|
78
|
+
:'draft' => :'draft',
|
79
|
+
:'head' => :'head',
|
80
|
+
:'base' => :'base',
|
81
|
+
:'remote_data' => :'remote_data',
|
82
|
+
:'merged' => :'merged',
|
83
|
+
:'num_comments' => :'num_comments',
|
84
|
+
:'num_review_comments' => :'num_review_comments',
|
85
|
+
:'num_commits' => :'num_commits',
|
86
|
+
:'num_additions' => :'num_additions',
|
87
|
+
:'num_deletions' => :'num_deletions',
|
88
|
+
:'num_changed_files' => :'num_changed_files'
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns all the JSON keys this model knows about
|
93
|
+
def self.acceptable_attributes
|
94
|
+
attribute_map.values
|
95
|
+
end
|
96
|
+
|
97
|
+
# Attribute type mapping.
|
98
|
+
def self.openapi_types
|
99
|
+
{
|
100
|
+
:'title' => :'String',
|
101
|
+
:'id' => :'Integer',
|
102
|
+
:'url' => :'String',
|
103
|
+
:'number' => :'Integer',
|
104
|
+
:'state' => :'PRState',
|
105
|
+
:'user' => :'User',
|
106
|
+
:'created_at' => :'String',
|
107
|
+
:'updated_at' => :'String',
|
108
|
+
:'closed_at' => :'String',
|
109
|
+
:'merged_at' => :'String',
|
110
|
+
:'requested_reviewers' => :'Array<User>',
|
111
|
+
:'requested_teams' => :'Array<Team>',
|
112
|
+
:'labels' => :'Array<Label>',
|
113
|
+
:'draft' => :'Boolean',
|
114
|
+
:'head' => :'HeadOrBase',
|
115
|
+
:'base' => :'HeadOrBase',
|
116
|
+
:'remote_data' => :'Object',
|
117
|
+
:'merged' => :'Boolean',
|
118
|
+
:'num_comments' => :'Integer',
|
119
|
+
:'num_review_comments' => :'Integer',
|
120
|
+
:'num_commits' => :'Integer',
|
121
|
+
:'num_additions' => :'Integer',
|
122
|
+
:'num_deletions' => :'Integer',
|
123
|
+
:'num_changed_files' => :'Integer'
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
# List of attributes with nullable: true
|
128
|
+
def self.openapi_nullable
|
129
|
+
Set.new([
|
130
|
+
:'closed_at',
|
131
|
+
:'merged_at',
|
132
|
+
:'remote_data',
|
133
|
+
])
|
134
|
+
end
|
135
|
+
|
136
|
+
# Initializes the object
|
137
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
138
|
+
def initialize(attributes = {})
|
139
|
+
if (!attributes.is_a?(Hash))
|
140
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::PullRequestExtended` initialize method"
|
141
|
+
end
|
142
|
+
|
143
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
144
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
145
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
146
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::PullRequestExtended`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
147
|
+
end
|
148
|
+
h[k.to_sym] = v
|
149
|
+
}
|
150
|
+
|
151
|
+
if attributes.key?(:'title')
|
152
|
+
self.title = attributes[:'title']
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.key?(:'id')
|
156
|
+
self.id = attributes[:'id']
|
157
|
+
end
|
158
|
+
|
159
|
+
if attributes.key?(:'url')
|
160
|
+
self.url = attributes[:'url']
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.key?(:'number')
|
164
|
+
self.number = attributes[:'number']
|
165
|
+
end
|
166
|
+
|
167
|
+
if attributes.key?(:'state')
|
168
|
+
self.state = attributes[:'state']
|
169
|
+
end
|
170
|
+
|
171
|
+
if attributes.key?(:'user')
|
172
|
+
self.user = attributes[:'user']
|
173
|
+
end
|
174
|
+
|
175
|
+
if attributes.key?(:'created_at')
|
176
|
+
self.created_at = attributes[:'created_at']
|
177
|
+
end
|
178
|
+
|
179
|
+
if attributes.key?(:'updated_at')
|
180
|
+
self.updated_at = attributes[:'updated_at']
|
181
|
+
end
|
182
|
+
|
183
|
+
if attributes.key?(:'closed_at')
|
184
|
+
self.closed_at = attributes[:'closed_at']
|
185
|
+
end
|
186
|
+
|
187
|
+
if attributes.key?(:'merged_at')
|
188
|
+
self.merged_at = attributes[:'merged_at']
|
189
|
+
end
|
190
|
+
|
191
|
+
if attributes.key?(:'requested_reviewers')
|
192
|
+
if (value = attributes[:'requested_reviewers']).is_a?(Array)
|
193
|
+
self.requested_reviewers = value
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
if attributes.key?(:'requested_teams')
|
198
|
+
if (value = attributes[:'requested_teams']).is_a?(Array)
|
199
|
+
self.requested_teams = value
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
if attributes.key?(:'labels')
|
204
|
+
if (value = attributes[:'labels']).is_a?(Array)
|
205
|
+
self.labels = value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
if attributes.key?(:'draft')
|
210
|
+
self.draft = attributes[:'draft']
|
211
|
+
end
|
212
|
+
|
213
|
+
if attributes.key?(:'head')
|
214
|
+
self.head = attributes[:'head']
|
215
|
+
end
|
216
|
+
|
217
|
+
if attributes.key?(:'base')
|
218
|
+
self.base = attributes[:'base']
|
219
|
+
end
|
220
|
+
|
221
|
+
if attributes.key?(:'remote_data')
|
222
|
+
self.remote_data = attributes[:'remote_data']
|
223
|
+
end
|
224
|
+
|
225
|
+
if attributes.key?(:'merged')
|
226
|
+
self.merged = attributes[:'merged']
|
227
|
+
end
|
228
|
+
|
229
|
+
if attributes.key?(:'num_comments')
|
230
|
+
self.num_comments = attributes[:'num_comments']
|
231
|
+
end
|
232
|
+
|
233
|
+
if attributes.key?(:'num_review_comments')
|
234
|
+
self.num_review_comments = attributes[:'num_review_comments']
|
235
|
+
end
|
236
|
+
|
237
|
+
if attributes.key?(:'num_commits')
|
238
|
+
self.num_commits = attributes[:'num_commits']
|
239
|
+
end
|
240
|
+
|
241
|
+
if attributes.key?(:'num_additions')
|
242
|
+
self.num_additions = attributes[:'num_additions']
|
243
|
+
end
|
244
|
+
|
245
|
+
if attributes.key?(:'num_deletions')
|
246
|
+
self.num_deletions = attributes[:'num_deletions']
|
247
|
+
end
|
248
|
+
|
249
|
+
if attributes.key?(:'num_changed_files')
|
250
|
+
self.num_changed_files = attributes[:'num_changed_files']
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
255
|
+
# @return Array for valid properties with the reasons
|
256
|
+
def list_invalid_properties
|
257
|
+
invalid_properties = Array.new
|
258
|
+
if @title.nil?
|
259
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
260
|
+
end
|
261
|
+
|
262
|
+
if @id.nil?
|
263
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
264
|
+
end
|
265
|
+
|
266
|
+
if @url.nil?
|
267
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
268
|
+
end
|
269
|
+
|
270
|
+
if @number.nil?
|
271
|
+
invalid_properties.push('invalid value for "number", number cannot be nil.')
|
272
|
+
end
|
273
|
+
|
274
|
+
if @state.nil?
|
275
|
+
invalid_properties.push('invalid value for "state", state cannot be nil.')
|
276
|
+
end
|
277
|
+
|
278
|
+
if @user.nil?
|
279
|
+
invalid_properties.push('invalid value for "user", user cannot be nil.')
|
280
|
+
end
|
281
|
+
|
282
|
+
if @created_at.nil?
|
283
|
+
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
|
284
|
+
end
|
285
|
+
|
286
|
+
if @updated_at.nil?
|
287
|
+
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
|
288
|
+
end
|
289
|
+
|
290
|
+
if @requested_reviewers.nil?
|
291
|
+
invalid_properties.push('invalid value for "requested_reviewers", requested_reviewers cannot be nil.')
|
292
|
+
end
|
293
|
+
|
294
|
+
if @requested_teams.nil?
|
295
|
+
invalid_properties.push('invalid value for "requested_teams", requested_teams cannot be nil.')
|
296
|
+
end
|
297
|
+
|
298
|
+
if @labels.nil?
|
299
|
+
invalid_properties.push('invalid value for "labels", labels cannot be nil.')
|
300
|
+
end
|
301
|
+
|
302
|
+
if @draft.nil?
|
303
|
+
invalid_properties.push('invalid value for "draft", draft cannot be nil.')
|
304
|
+
end
|
305
|
+
|
306
|
+
if @head.nil?
|
307
|
+
invalid_properties.push('invalid value for "head", head cannot be nil.')
|
308
|
+
end
|
309
|
+
|
310
|
+
if @base.nil?
|
311
|
+
invalid_properties.push('invalid value for "base", base cannot be nil.')
|
312
|
+
end
|
313
|
+
|
314
|
+
if @merged.nil?
|
315
|
+
invalid_properties.push('invalid value for "merged", merged cannot be nil.')
|
316
|
+
end
|
317
|
+
|
318
|
+
if @num_comments.nil?
|
319
|
+
invalid_properties.push('invalid value for "num_comments", num_comments cannot be nil.')
|
320
|
+
end
|
321
|
+
|
322
|
+
if @num_review_comments.nil?
|
323
|
+
invalid_properties.push('invalid value for "num_review_comments", num_review_comments cannot be nil.')
|
324
|
+
end
|
325
|
+
|
326
|
+
if @num_commits.nil?
|
327
|
+
invalid_properties.push('invalid value for "num_commits", num_commits cannot be nil.')
|
328
|
+
end
|
329
|
+
|
330
|
+
if @num_additions.nil?
|
331
|
+
invalid_properties.push('invalid value for "num_additions", num_additions cannot be nil.')
|
332
|
+
end
|
333
|
+
|
334
|
+
if @num_deletions.nil?
|
335
|
+
invalid_properties.push('invalid value for "num_deletions", num_deletions cannot be nil.')
|
336
|
+
end
|
337
|
+
|
338
|
+
if @num_changed_files.nil?
|
339
|
+
invalid_properties.push('invalid value for "num_changed_files", num_changed_files cannot be nil.')
|
340
|
+
end
|
341
|
+
|
342
|
+
invalid_properties
|
343
|
+
end
|
344
|
+
|
345
|
+
# Check to see if the all the properties in the model are valid
|
346
|
+
# @return true if the model is valid
|
347
|
+
def valid?
|
348
|
+
return false if @title.nil?
|
349
|
+
return false if @id.nil?
|
350
|
+
return false if @url.nil?
|
351
|
+
return false if @number.nil?
|
352
|
+
return false if @state.nil?
|
353
|
+
return false if @user.nil?
|
354
|
+
return false if @created_at.nil?
|
355
|
+
return false if @updated_at.nil?
|
356
|
+
return false if @requested_reviewers.nil?
|
357
|
+
return false if @requested_teams.nil?
|
358
|
+
return false if @labels.nil?
|
359
|
+
return false if @draft.nil?
|
360
|
+
return false if @head.nil?
|
361
|
+
return false if @base.nil?
|
362
|
+
return false if @merged.nil?
|
363
|
+
return false if @num_comments.nil?
|
364
|
+
return false if @num_review_comments.nil?
|
365
|
+
return false if @num_commits.nil?
|
366
|
+
return false if @num_additions.nil?
|
367
|
+
return false if @num_deletions.nil?
|
368
|
+
return false if @num_changed_files.nil?
|
369
|
+
true
|
370
|
+
end
|
371
|
+
|
372
|
+
# Checks equality by comparing each attribute.
|
373
|
+
# @param [Object] Object to be compared
|
374
|
+
def ==(o)
|
375
|
+
return true if self.equal?(o)
|
376
|
+
self.class == o.class &&
|
377
|
+
title == o.title &&
|
378
|
+
id == o.id &&
|
379
|
+
url == o.url &&
|
380
|
+
number == o.number &&
|
381
|
+
state == o.state &&
|
382
|
+
user == o.user &&
|
383
|
+
created_at == o.created_at &&
|
384
|
+
updated_at == o.updated_at &&
|
385
|
+
closed_at == o.closed_at &&
|
386
|
+
merged_at == o.merged_at &&
|
387
|
+
requested_reviewers == o.requested_reviewers &&
|
388
|
+
requested_teams == o.requested_teams &&
|
389
|
+
labels == o.labels &&
|
390
|
+
draft == o.draft &&
|
391
|
+
head == o.head &&
|
392
|
+
base == o.base &&
|
393
|
+
remote_data == o.remote_data &&
|
394
|
+
merged == o.merged &&
|
395
|
+
num_comments == o.num_comments &&
|
396
|
+
num_review_comments == o.num_review_comments &&
|
397
|
+
num_commits == o.num_commits &&
|
398
|
+
num_additions == o.num_additions &&
|
399
|
+
num_deletions == o.num_deletions &&
|
400
|
+
num_changed_files == o.num_changed_files
|
401
|
+
end
|
402
|
+
|
403
|
+
# @see the `==` method
|
404
|
+
# @param [Object] Object to be compared
|
405
|
+
def eql?(o)
|
406
|
+
self == o
|
407
|
+
end
|
408
|
+
|
409
|
+
# Calculates hash code according to all attributes.
|
410
|
+
# @return [Integer] Hash code
|
411
|
+
def hash
|
412
|
+
[title, id, url, number, state, user, created_at, updated_at, closed_at, merged_at, requested_reviewers, requested_teams, labels, draft, head, base, remote_data, merged, num_comments, num_review_comments, num_commits, num_additions, num_deletions, num_changed_files].hash
|
413
|
+
end
|
414
|
+
|
415
|
+
# Builds the object from hash
|
416
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
417
|
+
# @return [Object] Returns the model itself
|
418
|
+
def self.build_from_hash(attributes)
|
419
|
+
new.build_from_hash(attributes)
|
420
|
+
end
|
421
|
+
|
422
|
+
# Builds the object from hash
|
423
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
424
|
+
# @return [Object] Returns the model itself
|
425
|
+
def build_from_hash(attributes)
|
426
|
+
return nil unless attributes.is_a?(Hash)
|
427
|
+
attributes = attributes.transform_keys(&:to_sym)
|
428
|
+
self.class.openapi_types.each_pair do |key, type|
|
429
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
430
|
+
self.send("#{key}=", nil)
|
431
|
+
elsif type =~ /\AArray<(.*)>/i
|
432
|
+
# check to ensure the input is an array given that the attribute
|
433
|
+
# is documented as an array but the input is not
|
434
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
435
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
436
|
+
end
|
437
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
438
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
self
|
443
|
+
end
|
444
|
+
|
445
|
+
# Deserializes the data based on type
|
446
|
+
# @param string type Data type
|
447
|
+
# @param string value Value to be deserialized
|
448
|
+
# @return [Object] Deserialized data
|
449
|
+
def _deserialize(type, value)
|
450
|
+
case type.to_sym
|
451
|
+
when :Time
|
452
|
+
Time.parse(value)
|
453
|
+
when :Date
|
454
|
+
Date.parse(value)
|
455
|
+
when :String
|
456
|
+
value.to_s
|
457
|
+
when :Integer
|
458
|
+
value.to_i
|
459
|
+
when :Float
|
460
|
+
value.to_f
|
461
|
+
when :Boolean
|
462
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
463
|
+
true
|
464
|
+
else
|
465
|
+
false
|
466
|
+
end
|
467
|
+
when :Object
|
468
|
+
# generic object (usually a Hash), return directly
|
469
|
+
value
|
470
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
471
|
+
inner_type = Regexp.last_match[:inner_type]
|
472
|
+
value.map { |v| _deserialize(inner_type, v) }
|
473
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
474
|
+
k_type = Regexp.last_match[:k_type]
|
475
|
+
v_type = Regexp.last_match[:v_type]
|
476
|
+
{}.tap do |hash|
|
477
|
+
value.each do |k, v|
|
478
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
479
|
+
end
|
480
|
+
end
|
481
|
+
else # model
|
482
|
+
# models (e.g. Pet) or oneOf
|
483
|
+
klass = Carbon.const_get(type)
|
484
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
# Returns the string representation of the object
|
489
|
+
# @return [String] String presentation of the object
|
490
|
+
def to_s
|
491
|
+
to_hash.to_s
|
492
|
+
end
|
493
|
+
|
494
|
+
# to_body is an alias to to_hash (backward compatibility)
|
495
|
+
# @return [Hash] Returns the object in the form of hash
|
496
|
+
def to_body
|
497
|
+
to_hash
|
498
|
+
end
|
499
|
+
|
500
|
+
# Returns the object in the form of hash
|
501
|
+
# @return [Hash] Returns the object in the form of hash
|
502
|
+
def to_hash
|
503
|
+
hash = {}
|
504
|
+
self.class.attribute_map.each_pair do |attr, param|
|
505
|
+
value = self.send(attr)
|
506
|
+
if value.nil?
|
507
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
508
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
509
|
+
end
|
510
|
+
|
511
|
+
hash[param] = _to_hash(value)
|
512
|
+
end
|
513
|
+
hash
|
514
|
+
end
|
515
|
+
|
516
|
+
# Outputs non-array value in the form of hash
|
517
|
+
# For object, use to_hash. Otherwise, just return the value
|
518
|
+
# @param [Object] value Any valid value
|
519
|
+
# @return [Hash] Returns the value in the form of hash
|
520
|
+
def _to_hash(value)
|
521
|
+
if value.is_a?(Array)
|
522
|
+
value.compact.map { |v| _to_hash(v) }
|
523
|
+
elsif value.is_a?(Hash)
|
524
|
+
{}.tap do |hash|
|
525
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
526
|
+
end
|
527
|
+
elsif value.respond_to? :to_hash
|
528
|
+
value.to_hash
|
529
|
+
else
|
530
|
+
value
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
end
|
535
|
+
|
536
|
+
end
|