docspring 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/.gitignore +39 -0
- data/.openapi-generator-ignore +23 -0
- data/.openapi-generator/VERSION +1 -0
- data/.rspec +2 -0
- data/.rubocop.yml +154 -0
- data/.swagger-codegen-ignore +31 -0
- data/.swagger-codegen/VERSION +1 -0
- data/.swagger-revision +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +48 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +80 -0
- data/LICENSE +7 -0
- data/README.md +162 -0
- data/Rakefile +10 -0
- data/docs/AuthenticationError.md +9 -0
- data/docs/AuthenticationSuccessResponse.md +8 -0
- data/docs/CombinePdfsData.md +12 -0
- data/docs/CombinedSubmission.md +16 -0
- data/docs/CombinedSubmissionAction.md +13 -0
- data/docs/CombinedSubmissionData.md +11 -0
- data/docs/CreateCombinedSubmissionResponse.md +10 -0
- data/docs/CreateCustomFileData.md +8 -0
- data/docs/CreateCustomFileResponse.md +10 -0
- data/docs/CreateFolderData.md +8 -0
- data/docs/CreateSubmissionBatchResponse.md +12 -0
- data/docs/CreateSubmissionBatchSubmissionsResponse.md +10 -0
- data/docs/CreateSubmissionDataRequestData.md +20 -0
- data/docs/CreateSubmissionDataRequestTokenResponse.md +10 -0
- data/docs/CreateSubmissionDataRequestTokenResponseToken.md +11 -0
- data/docs/CreateSubmissionResponse.md +10 -0
- data/docs/CreateTemplateData.md +8 -0
- data/docs/CustomFile.md +9 -0
- data/docs/Error.md +9 -0
- data/docs/Folder.md +11 -0
- data/docs/FoldersFolder.md +9 -0
- data/docs/InvalidRequest.md +9 -0
- data/docs/MoveFolderData.md +8 -0
- data/docs/MoveTemplateData.md +8 -0
- data/docs/PDFApi.md +1385 -0
- data/docs/PendingTemplate.md +22 -0
- data/docs/RenameFolderData.md +8 -0
- data/docs/Submission.md +21 -0
- data/docs/SubmissionAction.md +13 -0
- data/docs/SubmissionBatch.md +16 -0
- data/docs/SubmissionBatchData.md +11 -0
- data/docs/SubmissionData.md +13 -0
- data/docs/SubmissionDataBatchRequest.md +13 -0
- data/docs/SubmissionDataRequest.md +24 -0
- data/docs/Template.md +25 -0
- data/docs/Templatesv2Template.md +19 -0
- data/docs/Templatesv2TemplateDocument.md +10 -0
- data/docs/Templatesv2TemplateDocumentMetadata.md +10 -0
- data/docs/UpdateDataRequestResponse.md +10 -0
- data/docs/UpdateSubmissionDataRequestData.md +20 -0
- data/docspring.gemspec +47 -0
- data/git_push.sh +55 -0
- data/lib/docspring.rb +82 -0
- data/lib/docspring/api/client.rb +174 -0
- data/lib/docspring/api/pdf_api.rb +1481 -0
- data/lib/docspring/api_client.rb +406 -0
- data/lib/docspring/api_error.rb +38 -0
- data/lib/docspring/configuration.rb +230 -0
- data/lib/docspring/models/authentication_error.rb +231 -0
- data/lib/docspring/models/authentication_success_response.rb +217 -0
- data/lib/docspring/models/combine_pdfs_data.rb +226 -0
- data/lib/docspring/models/combined_submission.rb +295 -0
- data/lib/docspring/models/combined_submission_action.rb +316 -0
- data/lib/docspring/models/combined_submission_data.rb +217 -0
- data/lib/docspring/models/create_combined_submission_response.rb +237 -0
- data/lib/docspring/models/create_custom_file_data.rb +207 -0
- data/lib/docspring/models/create_custom_file_response.rb +237 -0
- data/lib/docspring/models/create_folder_data.rb +188 -0
- data/lib/docspring/models/create_submission_batch_response.rb +257 -0
- data/lib/docspring/models/create_submission_batch_submissions_response.rb +237 -0
- data/lib/docspring/models/create_submission_data_request_data.rb +339 -0
- data/lib/docspring/models/create_submission_data_request_token_response.rb +237 -0
- data/lib/docspring/models/create_submission_data_request_token_response_token.rb +210 -0
- data/lib/docspring/models/create_submission_response.rb +237 -0
- data/lib/docspring/models/create_template_data.rb +188 -0
- data/lib/docspring/models/custom_file.rb +192 -0
- data/lib/docspring/models/error.rb +236 -0
- data/lib/docspring/models/folder.rb +210 -0
- data/lib/docspring/models/folders_folder.rb +192 -0
- data/lib/docspring/models/invalid_request.rb +238 -0
- data/lib/docspring/models/move_folder_data.rb +183 -0
- data/lib/docspring/models/move_template_data.rb +183 -0
- data/lib/docspring/models/pending_template.rb +343 -0
- data/lib/docspring/models/rename_folder_data.rb +188 -0
- data/lib/docspring/models/submission.rb +358 -0
- data/lib/docspring/models/submission_action.rb +316 -0
- data/lib/docspring/models/submission_batch.rb +291 -0
- data/lib/docspring/models/submission_batch_data.rb +217 -0
- data/lib/docspring/models/submission_data.rb +235 -0
- data/lib/docspring/models/submission_data_batch_request.rb +228 -0
- data/lib/docspring/models/submission_data_request.rb +422 -0
- data/lib/docspring/models/template.rb +372 -0
- data/lib/docspring/models/templatesv2_template.rb +316 -0
- data/lib/docspring/models/templatesv2_template_document.rb +235 -0
- data/lib/docspring/models/templatesv2_template_document_metadata.rb +235 -0
- data/lib/docspring/models/update_data_request_response.rb +237 -0
- data/lib/docspring/models/update_submission_data_request_data.rb +339 -0
- data/lib/docspring/version.rb +15 -0
- data/spec/api/client_integration_spec.rb +259 -0
- data/spec/api/pdf_api_integration_spec.rb +377 -0
- data/spec/api/pdf_api_spec_original.skipped.rb +397 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +53 -0
- data/spec/models/authentication_error_spec.rb +51 -0
- data/spec/models/authentication_success_response_spec.rb +45 -0
- data/spec/models/combine_pdfs_data_spec.rb +65 -0
- data/spec/models/combined_submission_action_spec.rb +83 -0
- data/spec/models/combined_submission_data_spec.rb +59 -0
- data/spec/models/combined_submission_spec.rb +93 -0
- data/spec/models/create_combined_submission_response_spec.rb +57 -0
- data/spec/models/create_custom_file_data_spec.rb +41 -0
- data/spec/models/create_custom_file_response_spec.rb +57 -0
- data/spec/models/create_folder_data_spec.rb +41 -0
- data/spec/models/create_submission_batch_response_spec.rb +69 -0
- data/spec/models/create_submission_batch_submissions_response_spec.rb +57 -0
- data/spec/models/create_submission_data_request_data_spec.rb +121 -0
- data/spec/models/create_submission_data_request_token_response_spec.rb +57 -0
- data/spec/models/create_submission_data_request_token_response_token_spec.rb +59 -0
- data/spec/models/create_submission_response_spec.rb +57 -0
- data/spec/models/create_template_data_spec.rb +41 -0
- data/spec/models/custom_file_spec.rb +47 -0
- data/spec/models/error_spec.rb +51 -0
- data/spec/models/folder_spec.rb +59 -0
- data/spec/models/folders_folder_spec.rb +47 -0
- data/spec/models/invalid_request_spec.rb +51 -0
- data/spec/models/move_folder_data_spec.rb +41 -0
- data/spec/models/move_template_data_spec.rb +41 -0
- data/spec/models/pending_template_spec.rb +129 -0
- data/spec/models/rename_folder_data_spec.rb +41 -0
- data/spec/models/submission_action_spec.rb +83 -0
- data/spec/models/submission_batch_data_spec.rb +59 -0
- data/spec/models/submission_batch_spec.rb +93 -0
- data/spec/models/submission_data_batch_request_spec.rb +71 -0
- data/spec/models/submission_data_request_spec.rb +149 -0
- data/spec/models/submission_data_spec.rb +71 -0
- data/spec/models/submission_spec.rb +123 -0
- data/spec/models/template_spec.rb +147 -0
- data/spec/models/templatesv2_template_document_metadata_spec.rb +57 -0
- data/spec/models/templatesv2_template_document_spec.rb +57 -0
- data/spec/models/templatesv2_template_spec.rb +111 -0
- data/spec/models/update_data_request_response_spec.rb +57 -0
- data/spec/models/update_submission_data_request_data_spec.rb +121 -0
- data/spec/spec_helper.rb +117 -0
- metadata +430 -0
@@ -0,0 +1,217 @@
|
|
1
|
+
=begin
|
2
|
+
#API v1
|
3
|
+
|
4
|
+
#DocSpring is a service that helps you fill out and sign PDF templates.
|
5
|
+
|
6
|
+
OpenAPI spec version: v1
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 3.3.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DocSpring
|
16
|
+
class CombinedSubmissionData
|
17
|
+
attr_accessor :test
|
18
|
+
|
19
|
+
attr_accessor :submission_ids
|
20
|
+
|
21
|
+
attr_accessor :metadata
|
22
|
+
|
23
|
+
attr_accessor :expires_in
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'test' => :'test',
|
29
|
+
:'submission_ids' => :'submission_ids',
|
30
|
+
:'metadata' => :'metadata',
|
31
|
+
:'expires_in' => :'expires_in'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'test' => :'BOOLEAN',
|
39
|
+
:'submission_ids' => :'Array<String>',
|
40
|
+
:'metadata' => :'Object',
|
41
|
+
:'expires_in' => :'Integer'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
return unless attributes.is_a?(Hash)
|
49
|
+
|
50
|
+
# convert string to symbol for hash key
|
51
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
52
|
+
|
53
|
+
if attributes.has_key?(:'test')
|
54
|
+
self.test = attributes[:'test']
|
55
|
+
end
|
56
|
+
|
57
|
+
if attributes.has_key?(:'submission_ids')
|
58
|
+
if (value = attributes[:'submission_ids']).is_a?(Array)
|
59
|
+
self.submission_ids = value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'metadata')
|
64
|
+
self.metadata = attributes[:'metadata']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'expires_in')
|
68
|
+
self.expires_in = attributes[:'expires_in']
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
73
|
+
# @return Array for valid properties with the reasons
|
74
|
+
def list_invalid_properties
|
75
|
+
invalid_properties = Array.new
|
76
|
+
if @submission_ids.nil?
|
77
|
+
invalid_properties.push('invalid value for "submission_ids", submission_ids cannot be nil.')
|
78
|
+
end
|
79
|
+
|
80
|
+
invalid_properties
|
81
|
+
end
|
82
|
+
|
83
|
+
# Check to see if the all the properties in the model are valid
|
84
|
+
# @return true if the model is valid
|
85
|
+
def valid?
|
86
|
+
return false if @submission_ids.nil?
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
# Checks equality by comparing each attribute.
|
91
|
+
# @param [Object] Object to be compared
|
92
|
+
def ==(o)
|
93
|
+
return true if self.equal?(o)
|
94
|
+
self.class == o.class &&
|
95
|
+
test == o.test &&
|
96
|
+
submission_ids == o.submission_ids &&
|
97
|
+
metadata == o.metadata &&
|
98
|
+
expires_in == o.expires_in
|
99
|
+
end
|
100
|
+
|
101
|
+
# @see the `==` method
|
102
|
+
# @param [Object] Object to be compared
|
103
|
+
def eql?(o)
|
104
|
+
self == o
|
105
|
+
end
|
106
|
+
|
107
|
+
# Calculates hash code according to all attributes.
|
108
|
+
# @return [Fixnum] Hash code
|
109
|
+
def hash
|
110
|
+
[test, submission_ids, metadata, expires_in].hash
|
111
|
+
end
|
112
|
+
|
113
|
+
# Builds the object from hash
|
114
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
115
|
+
# @return [Object] Returns the model itself
|
116
|
+
def build_from_hash(attributes)
|
117
|
+
return nil unless attributes.is_a?(Hash)
|
118
|
+
self.class.openapi_types.each_pair do |key, type|
|
119
|
+
if type =~ /\AArray<(.*)>/i
|
120
|
+
# check to ensure the input is an array given that the the attribute
|
121
|
+
# is documented as an array but the input is not
|
122
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
123
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
124
|
+
end
|
125
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
126
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
127
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
128
|
+
end
|
129
|
+
|
130
|
+
self
|
131
|
+
end
|
132
|
+
|
133
|
+
# Deserializes the data based on type
|
134
|
+
# @param string type Data type
|
135
|
+
# @param string value Value to be deserialized
|
136
|
+
# @return [Object] Deserialized data
|
137
|
+
def _deserialize(type, value)
|
138
|
+
case type.to_sym
|
139
|
+
when :DateTime
|
140
|
+
DateTime.parse(value)
|
141
|
+
when :Date
|
142
|
+
Date.parse(value)
|
143
|
+
when :String
|
144
|
+
value.to_s
|
145
|
+
when :Integer
|
146
|
+
value.to_i
|
147
|
+
when :Float
|
148
|
+
value.to_f
|
149
|
+
when :BOOLEAN
|
150
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
151
|
+
true
|
152
|
+
else
|
153
|
+
false
|
154
|
+
end
|
155
|
+
when :Object
|
156
|
+
# generic object (usually a Hash), return directly
|
157
|
+
value
|
158
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
159
|
+
inner_type = Regexp.last_match[:inner_type]
|
160
|
+
value.map { |v| _deserialize(inner_type, v) }
|
161
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
162
|
+
k_type = Regexp.last_match[:k_type]
|
163
|
+
v_type = Regexp.last_match[:v_type]
|
164
|
+
{}.tap do |hash|
|
165
|
+
value.each do |k, v|
|
166
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
else # model
|
170
|
+
temp_model = DocSpring.const_get(type).new
|
171
|
+
temp_model.build_from_hash(value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the string representation of the object
|
176
|
+
# @return [String] String presentation of the object
|
177
|
+
def to_s
|
178
|
+
to_hash.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_body
|
184
|
+
to_hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the object in the form of hash
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
next if value.nil?
|
194
|
+
hash[param] = _to_hash(value)
|
195
|
+
end
|
196
|
+
hash
|
197
|
+
end
|
198
|
+
|
199
|
+
# Outputs non-array value in the form of hash
|
200
|
+
# For object, use to_hash. Otherwise, just return the value
|
201
|
+
# @param [Object] value Any valid value
|
202
|
+
# @return [Hash] Returns the value in the form of hash
|
203
|
+
def _to_hash(value)
|
204
|
+
if value.is_a?(Array)
|
205
|
+
value.compact.map { |v| _to_hash(v) }
|
206
|
+
elsif value.is_a?(Hash)
|
207
|
+
{}.tap do |hash|
|
208
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
209
|
+
end
|
210
|
+
elsif value.respond_to? :to_hash
|
211
|
+
value.to_hash
|
212
|
+
else
|
213
|
+
value
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
=begin
|
2
|
+
#API v1
|
3
|
+
|
4
|
+
#DocSpring is a service that helps you fill out and sign PDF templates.
|
5
|
+
|
6
|
+
OpenAPI spec version: v1
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 3.3.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DocSpring
|
16
|
+
class CreateCombinedSubmissionResponse
|
17
|
+
attr_accessor :combined_submission
|
18
|
+
|
19
|
+
attr_accessor :errors
|
20
|
+
|
21
|
+
attr_accessor :status
|
22
|
+
|
23
|
+
class EnumAttributeValidator
|
24
|
+
attr_reader :datatype
|
25
|
+
attr_reader :allowable_values
|
26
|
+
|
27
|
+
def initialize(datatype, allowable_values)
|
28
|
+
@allowable_values = allowable_values.map do |value|
|
29
|
+
case datatype.to_s
|
30
|
+
when /Integer/i
|
31
|
+
value.to_i
|
32
|
+
when /Float/i
|
33
|
+
value.to_f
|
34
|
+
else
|
35
|
+
value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def valid?(value)
|
41
|
+
!value || allowable_values.include?(value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
46
|
+
def self.attribute_map
|
47
|
+
{
|
48
|
+
:'combined_submission' => :'combined_submission',
|
49
|
+
:'errors' => :'errors',
|
50
|
+
:'status' => :'status'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute type mapping.
|
55
|
+
def self.openapi_types
|
56
|
+
{
|
57
|
+
:'combined_submission' => :'CombinedSubmission',
|
58
|
+
:'errors' => :'Array<String>',
|
59
|
+
:'status' => :'String'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Initializes the object
|
64
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
65
|
+
def initialize(attributes = {})
|
66
|
+
return unless attributes.is_a?(Hash)
|
67
|
+
|
68
|
+
# convert string to symbol for hash key
|
69
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
70
|
+
|
71
|
+
if attributes.has_key?(:'combined_submission')
|
72
|
+
self.combined_submission = attributes[:'combined_submission']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.has_key?(:'errors')
|
76
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
77
|
+
self.errors = value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'status')
|
82
|
+
self.status = attributes[:'status']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
87
|
+
# @return Array for valid properties with the reasons
|
88
|
+
def list_invalid_properties
|
89
|
+
invalid_properties = Array.new
|
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
|
+
status_validator = EnumAttributeValidator.new('String', ['success', 'error'])
|
97
|
+
return false unless status_validator.valid?(@status)
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
# Custom attribute writer method checking allowed values (enum).
|
102
|
+
# @param [Object] status Object to be assigned
|
103
|
+
def status=(status)
|
104
|
+
validator = EnumAttributeValidator.new('String', ['success', 'error'])
|
105
|
+
unless validator.valid?(status)
|
106
|
+
fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
|
107
|
+
end
|
108
|
+
@status = status
|
109
|
+
end
|
110
|
+
|
111
|
+
# Checks equality by comparing each attribute.
|
112
|
+
# @param [Object] Object to be compared
|
113
|
+
def ==(o)
|
114
|
+
return true if self.equal?(o)
|
115
|
+
self.class == o.class &&
|
116
|
+
combined_submission == o.combined_submission &&
|
117
|
+
errors == o.errors &&
|
118
|
+
status == o.status
|
119
|
+
end
|
120
|
+
|
121
|
+
# @see the `==` method
|
122
|
+
# @param [Object] Object to be compared
|
123
|
+
def eql?(o)
|
124
|
+
self == o
|
125
|
+
end
|
126
|
+
|
127
|
+
# Calculates hash code according to all attributes.
|
128
|
+
# @return [Fixnum] Hash code
|
129
|
+
def hash
|
130
|
+
[combined_submission, errors, status].hash
|
131
|
+
end
|
132
|
+
|
133
|
+
# Builds the object from hash
|
134
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
135
|
+
# @return [Object] Returns the model itself
|
136
|
+
def build_from_hash(attributes)
|
137
|
+
return nil unless attributes.is_a?(Hash)
|
138
|
+
self.class.openapi_types.each_pair do |key, type|
|
139
|
+
if type =~ /\AArray<(.*)>/i
|
140
|
+
# check to ensure the input is an array given that the the attribute
|
141
|
+
# is documented as an array but the input is not
|
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
|
+
end
|
145
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
146
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
147
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
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
|
+
temp_model = DocSpring.const_get(type).new
|
191
|
+
temp_model.build_from_hash(value)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# Returns the string representation of the object
|
196
|
+
# @return [String] String presentation of the object
|
197
|
+
def to_s
|
198
|
+
to_hash.to_s
|
199
|
+
end
|
200
|
+
|
201
|
+
# to_body is an alias to to_hash (backward compatibility)
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
203
|
+
def to_body
|
204
|
+
to_hash
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the object in the form of hash
|
208
|
+
# @return [Hash] Returns the object in the form of hash
|
209
|
+
def to_hash
|
210
|
+
hash = {}
|
211
|
+
self.class.attribute_map.each_pair do |attr, param|
|
212
|
+
value = self.send(attr)
|
213
|
+
next if value.nil?
|
214
|
+
hash[param] = _to_hash(value)
|
215
|
+
end
|
216
|
+
hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Outputs non-array value in the form of hash
|
220
|
+
# For object, use to_hash. Otherwise, just return the value
|
221
|
+
# @param [Object] value Any valid value
|
222
|
+
# @return [Hash] Returns the value in the form of hash
|
223
|
+
def _to_hash(value)
|
224
|
+
if value.is_a?(Array)
|
225
|
+
value.compact.map { |v| _to_hash(v) }
|
226
|
+
elsif value.is_a?(Hash)
|
227
|
+
{}.tap do |hash|
|
228
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
229
|
+
end
|
230
|
+
elsif value.respond_to? :to_hash
|
231
|
+
value.to_hash
|
232
|
+
else
|
233
|
+
value
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|