docspring 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -45
  3. data/Gemfile +2 -1
  4. data/Gemfile.lock +37 -32
  5. data/README.md +15 -9
  6. data/docs/CombinedSubmission.md +1 -0
  7. data/docs/CreateTemplateData.md +1 -1
  8. data/docs/CreateTemplateData1.md +8 -0
  9. data/docs/PDFApi.md +114 -12
  10. data/docs/PendingTemplate.md +1 -0
  11. data/docs/Submission.md +1 -0
  12. data/docs/SubmissionData.md +1 -0
  13. data/docs/SubmissionDataRequest.md +2 -0
  14. data/docs/Template.md +1 -0
  15. data/docs/TemplatesdesccachedUploadTemplate.md +25 -0
  16. data/docs/TemplatesdesccachedUploadTemplateDocument.md +10 -0
  17. data/docs/{Templatesv2TemplateDocumentMetadata.md → TemplatesdesccachedUploadTemplateDocumentMetadata.md} +1 -1
  18. data/docs/{Templatesv2Template.md → TemplatestemplateIdTemplate.md} +10 -6
  19. data/docs/UpdateTemplateData.md +8 -0
  20. data/docs/UpdateTemplateResponse.md +9 -0
  21. data/docspring.gemspec +1 -1
  22. data/lib/docspring.rb +7 -3
  23. data/lib/docspring/api/pdf_api.rb +128 -16
  24. data/lib/docspring/models/combined_submission.rb +10 -1
  25. data/lib/docspring/models/create_template_data.rb +1 -1
  26. data/lib/docspring/models/create_template_data1.rb +188 -0
  27. data/lib/docspring/models/pending_template.rb +10 -1
  28. data/lib/docspring/models/submission.rb +12 -3
  29. data/lib/docspring/models/submission_data.rb +10 -1
  30. data/lib/docspring/models/submission_data_request.rb +22 -4
  31. data/lib/docspring/models/template.rb +10 -1
  32. data/lib/docspring/models/templatesdesccached_upload_template.rb +382 -0
  33. data/lib/docspring/models/{templatesv2_template_document.rb → templatesdesccached_upload_template_document.rb} +2 -2
  34. data/lib/docspring/models/{templatesv2_template_document_metadata.rb → templatesdesccached_upload_template_document_metadata.rb} +1 -1
  35. data/lib/docspring/models/{templatesv2_template.rb → templatestemplate_id_template.rb} +77 -41
  36. data/lib/docspring/models/update_template_data.rb +188 -0
  37. data/lib/docspring/models/update_template_response.rb +228 -0
  38. data/lib/docspring/version.rb +1 -1
  39. data/spec/api/client_integration_spec.rb +14 -2
  40. data/spec/api/pdf_api_spec_original.skipped.rb +33 -7
  41. data/spec/models/combined_submission_spec.rb +6 -0
  42. data/spec/models/create_template_data1_spec.rb +41 -0
  43. data/spec/models/pending_template_spec.rb +6 -0
  44. data/spec/models/submission_data_request_spec.rb +12 -0
  45. data/spec/models/submission_data_spec.rb +6 -0
  46. data/spec/models/submission_spec.rb +7 -1
  47. data/spec/models/template_spec.rb +6 -0
  48. data/spec/models/{templatesv2_template_document_metadata_spec.rb → templatesdesccached_upload_template_document_metadata_spec.rb} +6 -6
  49. data/spec/models/{templatesv2_template_document_spec.rb → templatesdesccached_upload_template_document_spec.rb} +6 -6
  50. data/spec/models/templatesdesccached_upload_template_spec.rb +151 -0
  51. data/spec/models/{templatesv2_template_spec.rb → templatestemplate_id_template_spec.rb} +39 -15
  52. data/spec/models/update_template_data_spec.rb +41 -0
  53. data/spec/models/update_template_response_spec.rb +51 -0
  54. metadata +39 -27
  55. data/.swagger-codegen-ignore +0 -31
  56. data/.swagger-codegen/VERSION +0 -1
  57. data/.swagger-revision +0 -1
  58. data/.travis.yml +0 -8
  59. data/docs/Templatesv2TemplateDocument.md +0 -10
@@ -13,7 +13,7 @@ OpenAPI Generator version: 3.3.0-SNAPSHOT
13
13
  require 'date'
14
14
 
15
15
  module DocSpring
16
- class Templatesv2TemplateDocument
16
+ class TemplatesdesccachedUploadTemplateDocument
17
17
  attr_accessor :metadata
18
18
 
19
19
  attr_accessor :id
@@ -54,7 +54,7 @@ module DocSpring
54
54
  # Attribute type mapping.
55
55
  def self.openapi_types
56
56
  {
57
- :'metadata' => :'Templatesv2TemplateDocumentMetadata',
57
+ :'metadata' => :'TemplatesdesccachedUploadTemplateDocumentMetadata',
58
58
  :'id' => :'String',
59
59
  :'storage' => :'String'
60
60
  }
@@ -13,7 +13,7 @@ OpenAPI Generator version: 3.3.0-SNAPSHOT
13
13
  require 'date'
14
14
 
15
15
  module DocSpring
16
- class Templatesv2TemplateDocumentMetadata
16
+ class TemplatesdesccachedUploadTemplateDocumentMetadata
17
17
  attr_accessor :filename
18
18
 
19
19
  attr_accessor :size
@@ -13,29 +13,37 @@ OpenAPI Generator version: 3.3.0-SNAPSHOT
13
13
  require 'date'
14
14
 
15
15
  module DocSpring
16
- class Templatesv2Template
16
+ class TemplatestemplateIdTemplate
17
17
  attr_accessor :expiration_interval
18
18
 
19
- attr_accessor :public_web_form
20
-
21
19
  attr_accessor :webhook_url
22
20
 
23
- attr_accessor :editable_submissions
24
-
25
- attr_accessor :expire_submissions
21
+ attr_accessor :scss
26
22
 
27
23
  attr_accessor :expire_after
28
24
 
29
25
  attr_accessor :allow_additional_properties
30
26
 
31
- attr_accessor :document
32
-
33
- attr_accessor :name
27
+ attr_accessor :description
34
28
 
35
29
  attr_accessor :public_submissions
36
30
 
37
31
  attr_accessor :slack_webhook_url
38
32
 
33
+ attr_accessor :header_html
34
+
35
+ attr_accessor :public_web_form
36
+
37
+ attr_accessor :editable_submissions
38
+
39
+ attr_accessor :expire_submissions
40
+
41
+ attr_accessor :name
42
+
43
+ attr_accessor :html
44
+
45
+ attr_accessor :footer_html
46
+
39
47
  attr_accessor :redirect_url
40
48
 
41
49
  class EnumAttributeValidator
@@ -64,16 +72,20 @@ module DocSpring
64
72
  def self.attribute_map
65
73
  {
66
74
  :'expiration_interval' => :'expiration_interval',
67
- :'public_web_form' => :'public_web_form',
68
75
  :'webhook_url' => :'webhook_url',
69
- :'editable_submissions' => :'editable_submissions',
70
- :'expire_submissions' => :'expire_submissions',
76
+ :'scss' => :'scss',
71
77
  :'expire_after' => :'expire_after',
72
78
  :'allow_additional_properties' => :'allow_additional_properties',
73
- :'document' => :'document',
74
- :'name' => :'name',
79
+ :'description' => :'description',
75
80
  :'public_submissions' => :'public_submissions',
76
81
  :'slack_webhook_url' => :'slack_webhook_url',
82
+ :'header_html' => :'header_html',
83
+ :'public_web_form' => :'public_web_form',
84
+ :'editable_submissions' => :'editable_submissions',
85
+ :'expire_submissions' => :'expire_submissions',
86
+ :'name' => :'name',
87
+ :'html' => :'html',
88
+ :'footer_html' => :'footer_html',
77
89
  :'redirect_url' => :'redirect_url'
78
90
  }
79
91
  end
@@ -82,16 +94,20 @@ module DocSpring
82
94
  def self.openapi_types
83
95
  {
84
96
  :'expiration_interval' => :'String',
85
- :'public_web_form' => :'BOOLEAN',
86
97
  :'webhook_url' => :'String',
87
- :'editable_submissions' => :'BOOLEAN',
88
- :'expire_submissions' => :'BOOLEAN',
98
+ :'scss' => :'String',
89
99
  :'expire_after' => :'Float',
90
100
  :'allow_additional_properties' => :'BOOLEAN',
91
- :'document' => :'Templatesv2TemplateDocument',
92
- :'name' => :'String',
101
+ :'description' => :'String',
93
102
  :'public_submissions' => :'BOOLEAN',
94
103
  :'slack_webhook_url' => :'String',
104
+ :'header_html' => :'String',
105
+ :'public_web_form' => :'BOOLEAN',
106
+ :'editable_submissions' => :'BOOLEAN',
107
+ :'expire_submissions' => :'BOOLEAN',
108
+ :'name' => :'String',
109
+ :'html' => :'String',
110
+ :'footer_html' => :'String',
95
111
  :'redirect_url' => :'String'
96
112
  }
97
113
  end
@@ -108,20 +124,12 @@ module DocSpring
108
124
  self.expiration_interval = attributes[:'expiration_interval']
109
125
  end
110
126
 
111
- if attributes.has_key?(:'public_web_form')
112
- self.public_web_form = attributes[:'public_web_form']
113
- end
114
-
115
127
  if attributes.has_key?(:'webhook_url')
116
128
  self.webhook_url = attributes[:'webhook_url']
117
129
  end
118
130
 
119
- if attributes.has_key?(:'editable_submissions')
120
- self.editable_submissions = attributes[:'editable_submissions']
121
- end
122
-
123
- if attributes.has_key?(:'expire_submissions')
124
- self.expire_submissions = attributes[:'expire_submissions']
131
+ if attributes.has_key?(:'scss')
132
+ self.scss = attributes[:'scss']
125
133
  end
126
134
 
127
135
  if attributes.has_key?(:'expire_after')
@@ -132,12 +140,8 @@ module DocSpring
132
140
  self.allow_additional_properties = attributes[:'allow_additional_properties']
133
141
  end
134
142
 
135
- if attributes.has_key?(:'document')
136
- self.document = attributes[:'document']
137
- end
138
-
139
- if attributes.has_key?(:'name')
140
- self.name = attributes[:'name']
143
+ if attributes.has_key?(:'description')
144
+ self.description = attributes[:'description']
141
145
  end
142
146
 
143
147
  if attributes.has_key?(:'public_submissions')
@@ -148,6 +152,34 @@ module DocSpring
148
152
  self.slack_webhook_url = attributes[:'slack_webhook_url']
149
153
  end
150
154
 
155
+ if attributes.has_key?(:'header_html')
156
+ self.header_html = attributes[:'header_html']
157
+ end
158
+
159
+ if attributes.has_key?(:'public_web_form')
160
+ self.public_web_form = attributes[:'public_web_form']
161
+ end
162
+
163
+ if attributes.has_key?(:'editable_submissions')
164
+ self.editable_submissions = attributes[:'editable_submissions']
165
+ end
166
+
167
+ if attributes.has_key?(:'expire_submissions')
168
+ self.expire_submissions = attributes[:'expire_submissions']
169
+ end
170
+
171
+ if attributes.has_key?(:'name')
172
+ self.name = attributes[:'name']
173
+ end
174
+
175
+ if attributes.has_key?(:'html')
176
+ self.html = attributes[:'html']
177
+ end
178
+
179
+ if attributes.has_key?(:'footer_html')
180
+ self.footer_html = attributes[:'footer_html']
181
+ end
182
+
151
183
  if attributes.has_key?(:'redirect_url')
152
184
  self.redirect_url = attributes[:'redirect_url']
153
185
  end
@@ -184,16 +216,20 @@ module DocSpring
184
216
  return true if self.equal?(o)
185
217
  self.class == o.class &&
186
218
  expiration_interval == o.expiration_interval &&
187
- public_web_form == o.public_web_form &&
188
219
  webhook_url == o.webhook_url &&
189
- editable_submissions == o.editable_submissions &&
190
- expire_submissions == o.expire_submissions &&
220
+ scss == o.scss &&
191
221
  expire_after == o.expire_after &&
192
222
  allow_additional_properties == o.allow_additional_properties &&
193
- document == o.document &&
194
- name == o.name &&
223
+ description == o.description &&
195
224
  public_submissions == o.public_submissions &&
196
225
  slack_webhook_url == o.slack_webhook_url &&
226
+ header_html == o.header_html &&
227
+ public_web_form == o.public_web_form &&
228
+ editable_submissions == o.editable_submissions &&
229
+ expire_submissions == o.expire_submissions &&
230
+ name == o.name &&
231
+ html == o.html &&
232
+ footer_html == o.footer_html &&
197
233
  redirect_url == o.redirect_url
198
234
  end
199
235
 
@@ -206,7 +242,7 @@ module DocSpring
206
242
  # Calculates hash code according to all attributes.
207
243
  # @return [Fixnum] Hash code
208
244
  def hash
209
- [expiration_interval, public_web_form, webhook_url, editable_submissions, expire_submissions, expire_after, allow_additional_properties, document, name, public_submissions, slack_webhook_url, redirect_url].hash
245
+ [expiration_interval, webhook_url, scss, expire_after, allow_additional_properties, description, public_submissions, slack_webhook_url, header_html, public_web_form, editable_submissions, expire_submissions, name, html, footer_html, redirect_url].hash
210
246
  end
211
247
 
212
248
  # Builds the object from hash
@@ -0,0 +1,188 @@
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 UpdateTemplateData
17
+ attr_accessor :template
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'template' => :'template'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'template' => :'TemplatestemplateIdTemplate'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
40
+
41
+ if attributes.has_key?(:'template')
42
+ self.template = attributes[:'template']
43
+ end
44
+ end
45
+
46
+ # Show invalid properties with the reasons. Usually used together with valid?
47
+ # @return Array for valid properties with the reasons
48
+ def list_invalid_properties
49
+ invalid_properties = Array.new
50
+ if @template.nil?
51
+ invalid_properties.push('invalid value for "template", template cannot be nil.')
52
+ end
53
+
54
+ invalid_properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ return false if @template.nil?
61
+ true
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class &&
69
+ template == o.template
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(o)
75
+ self == o
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Fixnum] Hash code
80
+ def hash
81
+ [template].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ self.class.openapi_types.each_pair do |key, type|
90
+ if type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
94
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
95
+ end
96
+ elsif !attributes[self.class.attribute_map[key]].nil?
97
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
+ end
100
+
101
+ self
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def _deserialize(type, value)
109
+ case type.to_sym
110
+ when :DateTime
111
+ DateTime.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :BOOLEAN
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when :Object
127
+ # generic object (usually a Hash), return directly
128
+ value
129
+ when /\AArray<(?<inner_type>.+)>\z/
130
+ inner_type = Regexp.last_match[:inner_type]
131
+ value.map { |v| _deserialize(inner_type, v) }
132
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
133
+ k_type = Regexp.last_match[:k_type]
134
+ v_type = Regexp.last_match[:v_type]
135
+ {}.tap do |hash|
136
+ value.each do |k, v|
137
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
138
+ end
139
+ end
140
+ else # model
141
+ temp_model = DocSpring.const_get(type).new
142
+ temp_model.build_from_hash(value)
143
+ end
144
+ end
145
+
146
+ # Returns the string representation of the object
147
+ # @return [String] String presentation of the object
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_hash (backward compatibility)
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_body
155
+ to_hash
156
+ end
157
+
158
+ # Returns the object in the form of hash
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_hash
161
+ hash = {}
162
+ self.class.attribute_map.each_pair do |attr, param|
163
+ value = self.send(attr)
164
+ next if value.nil?
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param [Object] value Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map { |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,228 @@
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 UpdateTemplateResponse
17
+ attr_accessor :errors
18
+
19
+ attr_accessor :status
20
+
21
+ class EnumAttributeValidator
22
+ attr_reader :datatype
23
+ attr_reader :allowable_values
24
+
25
+ def initialize(datatype, allowable_values)
26
+ @allowable_values = allowable_values.map do |value|
27
+ case datatype.to_s
28
+ when /Integer/i
29
+ value.to_i
30
+ when /Float/i
31
+ value.to_f
32
+ else
33
+ value
34
+ end
35
+ end
36
+ end
37
+
38
+ def valid?(value)
39
+ !value || allowable_values.include?(value)
40
+ end
41
+ end
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'errors' => :'errors',
47
+ :'status' => :'status'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'errors' => :'Array<String>',
55
+ :'status' => :'String'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ return unless attributes.is_a?(Hash)
63
+
64
+ # convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
66
+
67
+ if attributes.has_key?(:'errors')
68
+ if (value = attributes[:'errors']).is_a?(Array)
69
+ self.errors = value
70
+ end
71
+ end
72
+
73
+ if attributes.has_key?(:'status')
74
+ self.status = attributes[:'status']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ status_validator = EnumAttributeValidator.new('String', ['success', 'error'])
89
+ return false unless status_validator.valid?(@status)
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method checking allowed values (enum).
94
+ # @param [Object] status Object to be assigned
95
+ def status=(status)
96
+ validator = EnumAttributeValidator.new('String', ['success', 'error'])
97
+ unless validator.valid?(status)
98
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
99
+ end
100
+ @status = status
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ errors == o.errors &&
109
+ status == o.status
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 [Fixnum] Hash code
120
+ def hash
121
+ [errors, status].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 build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ self.class.openapi_types.each_pair do |key, type|
130
+ if type =~ /\AArray<(.*)>/i
131
+ # check to ensure the input is an array given that the the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :DateTime
151
+ DateTime.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :BOOLEAN
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ temp_model = DocSpring.const_get(type).new
182
+ temp_model.build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = self.send(attr)
204
+ next if value.nil?
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+ end
228
+ end