vericite_api 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/lib/vericite_client/api/default_api.rb +361 -0
- data/lib/vericite_client/api_client.rb +360 -0
- data/lib/vericite_client/api_error.rb +28 -0
- data/lib/vericite_client/configuration.rb +163 -0
- data/lib/vericite_client/models/assignment_data.rb +232 -0
- data/lib/vericite_client/models/consumer_data.rb +231 -0
- data/lib/vericite_client/models/consumer_response.rb +165 -0
- data/lib/vericite_client/models/error.rb +153 -0
- data/lib/vericite_client/models/external_content_data.rb +187 -0
- data/lib/vericite_client/models/external_content_upload_info.rb +198 -0
- data/lib/vericite_client/models/report_meta_data.rb +221 -0
- data/lib/vericite_client/models/report_score_reponse.rb +183 -0
- data/lib/vericite_client/models/report_url_link_reponse.rb +198 -0
- data/lib/vericite_client/version.rb +7 -0
- data/lib/vericite_client.rb +41 -0
- data/spec/api/default_api_spec.rb +110 -0
- data/spec/models/assignment_data_spec.rb +104 -0
- data/spec/models/consumer_data_spec.rb +105 -0
- data/spec/models/consumer_response_spec.rb +45 -0
- data/spec/models/error_spec.rb +35 -0
- data/spec/models/external_content_data_spec.rb +65 -0
- data/spec/models/external_content_upload_info_spec.rb +75 -0
- data/spec/models/report_meta_data_spec.rb +95 -0
- data/spec/models/report_score_reponse_spec.rb +65 -0
- data/spec/models/report_url_link_reponse_spec.rb +75 -0
- data/vericite_api.gemspec +32 -0
- metadata +242 -0
@@ -0,0 +1,232 @@
|
|
1
|
+
=begin
|
2
|
+
VeriCiteV1
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
module VeriCiteClient
|
8
|
+
class AssignmentData
|
9
|
+
# The title of the assignment
|
10
|
+
attr_accessor :assignment_title
|
11
|
+
|
12
|
+
# Instructions for assignment
|
13
|
+
attr_accessor :assignment_instructions
|
14
|
+
|
15
|
+
# exclude quotes
|
16
|
+
attr_accessor :assignment_exclude_quotes
|
17
|
+
|
18
|
+
# exclude self plagiarism
|
19
|
+
attr_accessor :assignment_exclude_self_plag
|
20
|
+
|
21
|
+
# store in index
|
22
|
+
attr_accessor :assignment_store_in_index
|
23
|
+
|
24
|
+
# Assignment due date. Pass in 0 to delete.
|
25
|
+
attr_accessor :assignment_due_date
|
26
|
+
|
27
|
+
# Assignment grade. Pass in 0 to delete.
|
28
|
+
attr_accessor :assignment_grade
|
29
|
+
|
30
|
+
attr_accessor :assignment_attachment_external_content
|
31
|
+
|
32
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
33
|
+
def self.attribute_map
|
34
|
+
{
|
35
|
+
|
36
|
+
:'assignment_title' => :'assignmentTitle',
|
37
|
+
|
38
|
+
:'assignment_instructions' => :'assignmentInstructions',
|
39
|
+
|
40
|
+
:'assignment_exclude_quotes' => :'assignmentExcludeQuotes',
|
41
|
+
|
42
|
+
:'assignment_exclude_self_plag' => :'assignmentExcludeSelfPlag',
|
43
|
+
|
44
|
+
:'assignment_store_in_index' => :'assignmentStoreInIndex',
|
45
|
+
|
46
|
+
:'assignment_due_date' => :'assignmentDueDate',
|
47
|
+
|
48
|
+
:'assignment_grade' => :'assignmentGrade',
|
49
|
+
|
50
|
+
:'assignment_attachment_external_content' => :'assignmentAttachmentExternalContent'
|
51
|
+
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute type mapping.
|
56
|
+
def self.swagger_types
|
57
|
+
{
|
58
|
+
:'assignment_title' => :'String',
|
59
|
+
:'assignment_instructions' => :'String',
|
60
|
+
:'assignment_exclude_quotes' => :'BOOLEAN',
|
61
|
+
:'assignment_exclude_self_plag' => :'BOOLEAN',
|
62
|
+
:'assignment_store_in_index' => :'BOOLEAN',
|
63
|
+
:'assignment_due_date' => :'Integer',
|
64
|
+
:'assignment_grade' => :'Integer',
|
65
|
+
:'assignment_attachment_external_content' => :'Array<ExternalContentData>'
|
66
|
+
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
def initialize(attributes = {})
|
71
|
+
return unless attributes.is_a?(Hash)
|
72
|
+
|
73
|
+
# convert string to symbol for hash key
|
74
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
75
|
+
|
76
|
+
|
77
|
+
if attributes[:'assignmentTitle']
|
78
|
+
self.assignment_title = attributes[:'assignmentTitle']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes[:'assignmentInstructions']
|
82
|
+
self.assignment_instructions = attributes[:'assignmentInstructions']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes[:'assignmentExcludeQuotes']
|
86
|
+
self.assignment_exclude_quotes = attributes[:'assignmentExcludeQuotes']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes[:'assignmentExcludeSelfPlag']
|
90
|
+
self.assignment_exclude_self_plag = attributes[:'assignmentExcludeSelfPlag']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes[:'assignmentStoreInIndex']
|
94
|
+
self.assignment_store_in_index = attributes[:'assignmentStoreInIndex']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes[:'assignmentDueDate']
|
98
|
+
self.assignment_due_date = attributes[:'assignmentDueDate']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes[:'assignmentGrade']
|
102
|
+
self.assignment_grade = attributes[:'assignmentGrade']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes[:'assignmentAttachmentExternalContent']
|
106
|
+
if (value = attributes[:'assignmentAttachmentExternalContent']).is_a?(Array)
|
107
|
+
self.assignment_attachment_external_content = value
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
# Check equality by comparing each attribute.
|
114
|
+
def ==(o)
|
115
|
+
return true if self.equal?(o)
|
116
|
+
self.class == o.class &&
|
117
|
+
assignment_title == o.assignment_title &&
|
118
|
+
assignment_instructions == o.assignment_instructions &&
|
119
|
+
assignment_exclude_quotes == o.assignment_exclude_quotes &&
|
120
|
+
assignment_exclude_self_plag == o.assignment_exclude_self_plag &&
|
121
|
+
assignment_store_in_index == o.assignment_store_in_index &&
|
122
|
+
assignment_due_date == o.assignment_due_date &&
|
123
|
+
assignment_grade == o.assignment_grade &&
|
124
|
+
assignment_attachment_external_content == o.assignment_attachment_external_content
|
125
|
+
end
|
126
|
+
|
127
|
+
# @see the `==` method
|
128
|
+
def eql?(o)
|
129
|
+
self == o
|
130
|
+
end
|
131
|
+
|
132
|
+
# Calculate hash code according to all attributes.
|
133
|
+
def hash
|
134
|
+
[assignment_title, assignment_instructions, assignment_exclude_quotes, assignment_exclude_self_plag, assignment_exclude_self_plag, assignment_due_date, assignment_grade, assignment_attachment_external_content].hash
|
135
|
+
end
|
136
|
+
|
137
|
+
# build the object from hash
|
138
|
+
def build_from_hash(attributes)
|
139
|
+
return nil unless attributes.is_a?(Hash)
|
140
|
+
self.class.swagger_types.each_pair do |key, type|
|
141
|
+
if type =~ /^Array<(.*)>/i
|
142
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
143
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
144
|
+
else
|
145
|
+
#TODO show warning in debug mode
|
146
|
+
end
|
147
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
148
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
149
|
+
else
|
150
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
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 =~ /^(true|t|yes|y|1)$/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
|
+
_model = VeriCiteClient.const_get(type).new
|
191
|
+
_model.build_from_hash(value)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def to_s
|
196
|
+
to_hash.to_s
|
197
|
+
end
|
198
|
+
|
199
|
+
# to_body is an alias to to_body (backward compatibility))
|
200
|
+
def to_body
|
201
|
+
to_hash
|
202
|
+
end
|
203
|
+
|
204
|
+
# return the object in the form of hash
|
205
|
+
def to_hash
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
next if value.nil?
|
210
|
+
hash[param] = _to_hash(value)
|
211
|
+
end
|
212
|
+
hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Method to output non-array value in the form of hash
|
216
|
+
# For object, use to_hash. Otherwise, just return the value
|
217
|
+
def _to_hash(value)
|
218
|
+
if value.is_a?(Array)
|
219
|
+
value.compact.map{ |v| _to_hash(v) }
|
220
|
+
elsif value.is_a?(Hash)
|
221
|
+
{}.tap do |hash|
|
222
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
223
|
+
end
|
224
|
+
elsif value.respond_to? :to_hash
|
225
|
+
value.to_hash
|
226
|
+
else
|
227
|
+
value
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
=begin
|
2
|
+
VeriCiteV1
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
module VeriCiteClient
|
8
|
+
class ConsumerData
|
9
|
+
# Description
|
10
|
+
attr_accessor :description
|
11
|
+
|
12
|
+
# Is Trial?
|
13
|
+
attr_accessor :trial
|
14
|
+
|
15
|
+
# Trial End Date
|
16
|
+
attr_accessor :trial_end_date
|
17
|
+
|
18
|
+
# Contact Email
|
19
|
+
attr_accessor :contact_email
|
20
|
+
|
21
|
+
# Contact Name
|
22
|
+
attr_accessor :contact_name
|
23
|
+
|
24
|
+
# Time Zone
|
25
|
+
attr_accessor :time_zone
|
26
|
+
|
27
|
+
# FTE Student Count
|
28
|
+
attr_accessor :fte_count
|
29
|
+
|
30
|
+
# Additional Notes
|
31
|
+
attr_accessor :notes
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
|
37
|
+
:'description' => :'description',
|
38
|
+
|
39
|
+
:'trial' => :'trial',
|
40
|
+
|
41
|
+
:'trial_end_date' => :'trialEndDate',
|
42
|
+
|
43
|
+
:'contact_email' => :'contactEmail',
|
44
|
+
|
45
|
+
:'contact_name' => :'contactName',
|
46
|
+
|
47
|
+
:'time_zone' => :'timeZone',
|
48
|
+
|
49
|
+
:'fte_count' => :'fteCount',
|
50
|
+
|
51
|
+
:'notes' => :'notes'
|
52
|
+
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
# Attribute type mapping.
|
57
|
+
def self.swagger_types
|
58
|
+
{
|
59
|
+
:'description' => :'String',
|
60
|
+
:'trial' => :'BOOLEAN',
|
61
|
+
:'trial_end_date' => :'Integer',
|
62
|
+
:'contact_email' => :'String',
|
63
|
+
:'contact_name' => :'String',
|
64
|
+
:'time_zone' => :'String',
|
65
|
+
:'fte_count' => :'Integer',
|
66
|
+
:'notes' => :'String'
|
67
|
+
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def initialize(attributes = {})
|
72
|
+
return unless attributes.is_a?(Hash)
|
73
|
+
|
74
|
+
# convert string to symbol for hash key
|
75
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
76
|
+
|
77
|
+
|
78
|
+
if attributes[:'description']
|
79
|
+
self.description = attributes[:'description']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes[:'trial']
|
83
|
+
self.trial = attributes[:'trial']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes[:'trialEndDate']
|
87
|
+
self.trial_end_date = attributes[:'trialEndDate']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes[:'contactEmail']
|
91
|
+
self.contact_email = attributes[:'contactEmail']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes[:'contactName']
|
95
|
+
self.contact_name = attributes[:'contactName']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes[:'timeZone']
|
99
|
+
self.time_zone = attributes[:'timeZone']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes[:'fteCount']
|
103
|
+
self.fte_count = attributes[:'fteCount']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes[:'notes']
|
107
|
+
self.notes = attributes[:'notes']
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
# Check equality by comparing each attribute.
|
113
|
+
def ==(o)
|
114
|
+
return true if self.equal?(o)
|
115
|
+
self.class == o.class &&
|
116
|
+
description == o.description &&
|
117
|
+
trial == o.trial &&
|
118
|
+
trial_end_date == o.trial_end_date &&
|
119
|
+
contact_email == o.contact_email &&
|
120
|
+
contact_name == o.contact_name &&
|
121
|
+
time_zone == o.time_zone &&
|
122
|
+
fte_count == o.fte_count &&
|
123
|
+
notes == o.notes
|
124
|
+
end
|
125
|
+
|
126
|
+
# @see the `==` method
|
127
|
+
def eql?(o)
|
128
|
+
self == o
|
129
|
+
end
|
130
|
+
|
131
|
+
# Calculate hash code according to all attributes.
|
132
|
+
def hash
|
133
|
+
[description, trial, trial_end_date, contact_email, contact_name, time_zone, fte_count, notes].hash
|
134
|
+
end
|
135
|
+
|
136
|
+
# build the object from hash
|
137
|
+
def build_from_hash(attributes)
|
138
|
+
return nil unless attributes.is_a?(Hash)
|
139
|
+
self.class.swagger_types.each_pair do |key, type|
|
140
|
+
if type =~ /^Array<(.*)>/i
|
141
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
142
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
143
|
+
else
|
144
|
+
#TODO show warning in debug mode
|
145
|
+
end
|
146
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
147
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
148
|
+
else
|
149
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
self
|
154
|
+
end
|
155
|
+
|
156
|
+
def _deserialize(type, value)
|
157
|
+
case type.to_sym
|
158
|
+
when :DateTime
|
159
|
+
DateTime.parse(value)
|
160
|
+
when :Date
|
161
|
+
Date.parse(value)
|
162
|
+
when :String
|
163
|
+
value.to_s
|
164
|
+
when :Integer
|
165
|
+
value.to_i
|
166
|
+
when :Float
|
167
|
+
value.to_f
|
168
|
+
when :BOOLEAN
|
169
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
170
|
+
true
|
171
|
+
else
|
172
|
+
false
|
173
|
+
end
|
174
|
+
when :Object
|
175
|
+
# generic object (usually a Hash), return directly
|
176
|
+
value
|
177
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
178
|
+
inner_type = Regexp.last_match[:inner_type]
|
179
|
+
value.map { |v| _deserialize(inner_type, v) }
|
180
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
181
|
+
k_type = Regexp.last_match[:k_type]
|
182
|
+
v_type = Regexp.last_match[:v_type]
|
183
|
+
{}.tap do |hash|
|
184
|
+
value.each do |k, v|
|
185
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
else # model
|
189
|
+
_model = VeriCiteClient.const_get(type).new
|
190
|
+
_model.build_from_hash(value)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def to_s
|
195
|
+
to_hash.to_s
|
196
|
+
end
|
197
|
+
|
198
|
+
# to_body is an alias to to_body (backward compatibility))
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# return the object in the form of hash
|
204
|
+
def to_hash
|
205
|
+
hash = {}
|
206
|
+
self.class.attribute_map.each_pair do |attr, param|
|
207
|
+
value = self.send(attr)
|
208
|
+
next if value.nil?
|
209
|
+
hash[param] = _to_hash(value)
|
210
|
+
end
|
211
|
+
hash
|
212
|
+
end
|
213
|
+
|
214
|
+
# Method to output non-array value in the form of hash
|
215
|
+
# For object, use to_hash. Otherwise, just return the value
|
216
|
+
def _to_hash(value)
|
217
|
+
if value.is_a?(Array)
|
218
|
+
value.compact.map{ |v| _to_hash(v) }
|
219
|
+
elsif value.is_a?(Hash)
|
220
|
+
{}.tap do |hash|
|
221
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
222
|
+
end
|
223
|
+
elsif value.respond_to? :to_hash
|
224
|
+
value.to_hash
|
225
|
+
else
|
226
|
+
value
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
=begin
|
2
|
+
VeriCiteV1
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
module VeriCiteClient
|
8
|
+
class ConsumerResponse
|
9
|
+
# The key of the newly created consumer
|
10
|
+
attr_accessor :consumer_key
|
11
|
+
|
12
|
+
# The secret of the newly created consumer
|
13
|
+
attr_accessor :consumer_secret
|
14
|
+
|
15
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
16
|
+
def self.attribute_map
|
17
|
+
{
|
18
|
+
|
19
|
+
:'consumer_key' => :'consumerKey',
|
20
|
+
|
21
|
+
:'consumer_secret' => :'consumerSecret'
|
22
|
+
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'consumer_key' => :'String',
|
30
|
+
:'consumer_secret' => :'String'
|
31
|
+
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(attributes = {})
|
36
|
+
return unless attributes.is_a?(Hash)
|
37
|
+
|
38
|
+
# convert string to symbol for hash key
|
39
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
40
|
+
|
41
|
+
|
42
|
+
if attributes[:'consumerKey']
|
43
|
+
self.consumer_key = attributes[:'consumerKey']
|
44
|
+
end
|
45
|
+
|
46
|
+
if attributes[:'consumerSecret']
|
47
|
+
self.consumer_secret = attributes[:'consumerSecret']
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# Check equality by comparing each attribute.
|
53
|
+
def ==(o)
|
54
|
+
return true if self.equal?(o)
|
55
|
+
self.class == o.class &&
|
56
|
+
consumer_key == o.consumer_key &&
|
57
|
+
consumer_secret == o.consumer_secret
|
58
|
+
end
|
59
|
+
|
60
|
+
# @see the `==` method
|
61
|
+
def eql?(o)
|
62
|
+
self == o
|
63
|
+
end
|
64
|
+
|
65
|
+
# Calculate hash code according to all attributes.
|
66
|
+
def hash
|
67
|
+
[consumer_key, consumer_secret].hash
|
68
|
+
end
|
69
|
+
|
70
|
+
# build the object from hash
|
71
|
+
def build_from_hash(attributes)
|
72
|
+
return nil unless attributes.is_a?(Hash)
|
73
|
+
self.class.swagger_types.each_pair do |key, type|
|
74
|
+
if type =~ /^Array<(.*)>/i
|
75
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
76
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
77
|
+
else
|
78
|
+
#TODO show warning in debug mode
|
79
|
+
end
|
80
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
81
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
82
|
+
else
|
83
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
def _deserialize(type, value)
|
91
|
+
case type.to_sym
|
92
|
+
when :DateTime
|
93
|
+
DateTime.parse(value)
|
94
|
+
when :Date
|
95
|
+
Date.parse(value)
|
96
|
+
when :String
|
97
|
+
value.to_s
|
98
|
+
when :Integer
|
99
|
+
value.to_i
|
100
|
+
when :Float
|
101
|
+
value.to_f
|
102
|
+
when :BOOLEAN
|
103
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
104
|
+
true
|
105
|
+
else
|
106
|
+
false
|
107
|
+
end
|
108
|
+
when :Object
|
109
|
+
# generic object (usually a Hash), return directly
|
110
|
+
value
|
111
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
112
|
+
inner_type = Regexp.last_match[:inner_type]
|
113
|
+
value.map { |v| _deserialize(inner_type, v) }
|
114
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
115
|
+
k_type = Regexp.last_match[:k_type]
|
116
|
+
v_type = Regexp.last_match[:v_type]
|
117
|
+
{}.tap do |hash|
|
118
|
+
value.each do |k, v|
|
119
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
else # model
|
123
|
+
_model = VeriCiteClient.const_get(type).new
|
124
|
+
_model.build_from_hash(value)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def to_s
|
129
|
+
to_hash.to_s
|
130
|
+
end
|
131
|
+
|
132
|
+
# to_body is an alias to to_body (backward compatibility))
|
133
|
+
def to_body
|
134
|
+
to_hash
|
135
|
+
end
|
136
|
+
|
137
|
+
# return the object in the form of hash
|
138
|
+
def to_hash
|
139
|
+
hash = {}
|
140
|
+
self.class.attribute_map.each_pair do |attr, param|
|
141
|
+
value = self.send(attr)
|
142
|
+
next if value.nil?
|
143
|
+
hash[param] = _to_hash(value)
|
144
|
+
end
|
145
|
+
hash
|
146
|
+
end
|
147
|
+
|
148
|
+
# Method to output non-array value in the form of hash
|
149
|
+
# For object, use to_hash. Otherwise, just return the value
|
150
|
+
def _to_hash(value)
|
151
|
+
if value.is_a?(Array)
|
152
|
+
value.compact.map{ |v| _to_hash(v) }
|
153
|
+
elsif value.is_a?(Hash)
|
154
|
+
{}.tap do |hash|
|
155
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
156
|
+
end
|
157
|
+
elsif value.respond_to? :to_hash
|
158
|
+
value.to_hash
|
159
|
+
else
|
160
|
+
value
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|