docspring 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +26 -0
  3. data/.openapi-generator/FILES +220 -0
  4. data/.openapi-generator/VERSION +1 -1
  5. data/.rubocop.yml +6 -12
  6. data/.travis.yml +11 -0
  7. data/CHANGELOG.md +9 -0
  8. data/Gemfile +5 -1
  9. data/Gemfile.lock +85 -48
  10. data/README.md +47 -16
  11. data/docs/AddFieldsData.md +13 -3
  12. data/docs/AddFieldsTemplateResponse.md +17 -5
  13. data/docs/AuthenticationError.md +15 -4
  14. data/docs/AuthenticationSuccessResponse.md +13 -3
  15. data/docs/CombinePdfsData.md +23 -7
  16. data/docs/CombinedSubmission.md +37 -12
  17. data/docs/CombinedSubmissionAction.md +23 -8
  18. data/docs/CombinedSubmissionData.md +21 -6
  19. data/docs/CopyTemplateData.md +15 -4
  20. data/docs/CreateCombinedSubmissionResponse.md +17 -5
  21. data/docs/CreateCustomFileData.md +13 -3
  22. data/docs/CreateCustomFileResponse.md +17 -5
  23. data/docs/CreateFolderAttributes.md +20 -0
  24. data/docs/CreateFolderData.md +13 -3
  25. data/docs/CreateHtmlTemplateData.md +13 -3
  26. data/docs/CreateSubmissionBatchResponse.md +21 -7
  27. data/docs/CreateSubmissionBatchSubmissionsResponse.md +17 -5
  28. data/docs/CreateSubmissionData.md +36 -0
  29. data/docs/CreateSubmissionDataRequestData.md +37 -15
  30. data/docs/CreateSubmissionDataRequestEventRequest.md +24 -0
  31. data/docs/CreateSubmissionDataRequestEventResponse.md +22 -0
  32. data/docs/CreateSubmissionDataRequestTokenResponse.md +17 -5
  33. data/docs/CreateSubmissionResponse.md +17 -5
  34. data/docs/CreateTemplateFromUploadData.md +13 -3
  35. data/docs/DataRequestToken.md +24 -0
  36. data/docs/DeleteTemplateResponse.md +20 -0
  37. data/docs/ErrorResponse.md +20 -0
  38. data/docs/Folder.md +19 -6
  39. data/docs/FullTemplate.md +94 -0
  40. data/docs/HtmlTemplateData.md +51 -19
  41. data/docs/HtmlTemplateDataWebhookOptions.md +18 -0
  42. data/docs/InvalidRequest.md +15 -4
  43. data/docs/InvalidRequestSingleError.md +20 -0
  44. data/docs/ListSubmissionsResponse.md +22 -0
  45. data/docs/MoveFolderData.md +13 -3
  46. data/docs/MoveTemplateData.md +13 -3
  47. data/docs/PDFApi.md +1746 -495
  48. data/docs/PendingTemplate.md +45 -19
  49. data/docs/PreviewPdfResponse.md +20 -0
  50. data/docs/PublishTemplateVersion404Response.md +20 -0
  51. data/docs/PublishTemplateVersion422Response.md +20 -0
  52. data/docs/PublishTemplateVersionResponse.md +20 -0
  53. data/docs/PublishTemplateVersionResponseResult.md +24 -0
  54. data/docs/PublishVersionData.md +20 -0
  55. data/docs/RenameFolderData.md +13 -3
  56. data/docs/RestoreTemplateVersionResponse.md +18 -0
  57. data/docs/RestoreVersionData.md +18 -0
  58. data/docs/Submission.md +49 -21
  59. data/docs/SubmissionAction.md +23 -8
  60. data/docs/SubmissionBatch.md +29 -11
  61. data/docs/SubmissionBatchData.md +21 -6
  62. data/docs/SubmissionData.md +23 -9
  63. data/docs/SubmissionDataBatchRequest.md +25 -8
  64. data/docs/SubmissionDataRequest.md +53 -22
  65. data/docs/SubmissionDataRequestEvent.md +30 -0
  66. data/docs/Template.md +51 -22
  67. data/docs/TemplateData.md +49 -18
  68. data/docs/TemplateDefaults.md +22 -0
  69. data/docs/TemplateDocument.md +22 -0
  70. data/docs/TemplateDocumentMetadata.md +22 -0
  71. data/docs/TemplateSchema.md +34 -0
  72. data/docs/UpdateDataRequestResponse.md +17 -5
  73. data/docs/UpdateSubmissionDataRequestData.md +37 -15
  74. data/docs/UpdateTemplateData.md +13 -3
  75. data/docs/UpdateTemplateResponse.md +15 -4
  76. data/docs/UploadPresign.md +24 -0
  77. data/docs/UploadTemplateData.md +53 -20
  78. data/docspring.gemspec +14 -11
  79. data/git_push.sh +11 -9
  80. data/lib/docspring/api/pdf_api.rb +1485 -497
  81. data/lib/docspring/api_client.rb +106 -98
  82. data/lib/docspring/api_error.rb +22 -2
  83. data/lib/docspring/configuration.rb +127 -16
  84. data/lib/docspring/models/add_fields_data.rb +59 -26
  85. data/lib/docspring/models/add_fields_template_response.rb +81 -43
  86. data/lib/docspring/models/authentication_error.rb +62 -29
  87. data/lib/docspring/models/authentication_success_response.rb +66 -28
  88. data/lib/docspring/models/combine_pdfs_data.rb +74 -32
  89. data/lib/docspring/models/combined_submission.rb +167 -68
  90. data/lib/docspring/models/combined_submission_action.rb +83 -39
  91. data/lib/docspring/models/combined_submission_data.rb +72 -30
  92. data/lib/docspring/models/copy_template_data.rb +59 -26
  93. data/lib/docspring/models/create_combined_submission_response.rb +86 -41
  94. data/lib/docspring/models/create_custom_file_data.rb +58 -25
  95. data/lib/docspring/models/create_custom_file_response.rb +86 -41
  96. data/lib/docspring/models/create_folder_attributes.rb +230 -0
  97. data/lib/docspring/models/create_folder_data.rb +59 -26
  98. data/lib/docspring/models/create_html_template_data.rb +58 -25
  99. data/lib/docspring/models/create_submission_batch_response.rb +104 -52
  100. data/lib/docspring/models/create_submission_batch_submissions_response.rb +79 -41
  101. data/lib/docspring/models/create_submission_data.rb +304 -0
  102. data/lib/docspring/models/create_submission_data_request_data.rb +139 -90
  103. data/lib/docspring/models/create_submission_data_request_event_request.rb +297 -0
  104. data/lib/docspring/models/create_submission_data_request_event_response.rb +282 -0
  105. data/lib/docspring/models/create_submission_data_request_token_response.rb +85 -40
  106. data/lib/docspring/models/create_submission_response.rb +86 -41
  107. data/lib/docspring/models/create_template_from_upload_data.rb +58 -25
  108. data/lib/docspring/models/{custom_file.rb → data_request_token.rb} +110 -33
  109. data/lib/docspring/models/delete_template_response.rb +266 -0
  110. data/lib/docspring/models/{error.rb → error_response.rb} +65 -30
  111. data/lib/docspring/models/folder.rb +78 -46
  112. data/lib/docspring/models/full_template.rb +801 -0
  113. data/lib/docspring/models/html_template_data.rb +180 -110
  114. data/lib/docspring/models/{folders_folder.rb → html_template_data_webhook_options.rb} +63 -41
  115. data/lib/docspring/models/invalid_request.rb +64 -29
  116. data/lib/docspring/models/invalid_request_single_error.rb +271 -0
  117. data/lib/docspring/models/list_submissions_response.rb +251 -0
  118. data/lib/docspring/models/move_folder_data.rb +56 -25
  119. data/lib/docspring/models/move_template_data.rb +58 -25
  120. data/lib/docspring/models/pending_template.rb +221 -118
  121. data/lib/docspring/models/preview_pdf_response.rb +264 -0
  122. data/lib/docspring/models/publish_template_version404_response.rb +271 -0
  123. data/lib/docspring/models/publish_template_version422_response.rb +273 -0
  124. data/lib/docspring/models/publish_template_version_response.rb +271 -0
  125. data/lib/docspring/models/publish_template_version_response_result.rb +263 -0
  126. data/lib/docspring/models/publish_version_data.rb +230 -0
  127. data/lib/docspring/models/rename_folder_data.rb +58 -25
  128. data/lib/docspring/models/restore_template_version_response.rb +255 -0
  129. data/lib/docspring/models/{create_submission_data_request_token_response_token.rb → restore_version_data.rb} +69 -58
  130. data/lib/docspring/models/submission.rb +98 -49
  131. data/lib/docspring/models/submission_action.rb +83 -39
  132. data/lib/docspring/models/submission_batch.rb +158 -75
  133. data/lib/docspring/models/submission_batch_data.rb +74 -30
  134. data/lib/docspring/models/submission_data.rb +65 -41
  135. data/lib/docspring/models/submission_data_batch_request.rb +100 -49
  136. data/lib/docspring/models/submission_data_request.rb +123 -54
  137. data/lib/docspring/models/submission_data_request_event.rb +309 -0
  138. data/lib/docspring/models/template.rb +267 -132
  139. data/lib/docspring/models/template_data.rb +173 -105
  140. data/lib/docspring/models/template_defaults.rb +249 -0
  141. data/lib/docspring/models/{upload_template_data_document.rb → template_document.rb} +91 -39
  142. data/lib/docspring/models/{upload_template_data_document_metadata.rb → template_document_metadata.rb} +94 -42
  143. data/lib/docspring/models/template_schema.rb +288 -0
  144. data/lib/docspring/models/update_data_request_response.rb +86 -41
  145. data/lib/docspring/models/update_submission_data_request_data.rb +82 -43
  146. data/lib/docspring/models/update_template_data.rb +58 -25
  147. data/lib/docspring/models/update_template_response.rb +79 -41
  148. data/lib/docspring/models/upload_presign.rb +296 -0
  149. data/lib/docspring/models/upload_template_data.rb +186 -116
  150. data/lib/docspring/version.rb +3 -3
  151. data/lib/docspring.rb +30 -10
  152. data/spec/api/client_integration_spec.rb +26 -19
  153. data/spec/api/pdf_api_integration_spec.rb +21 -19
  154. data/spec/api/pdf_api_spec_original.skipped.rb +469 -98
  155. data/spec/models/add_fields_data_spec.rb +8 -13
  156. data/spec/models/add_fields_template_response_spec.rb +16 -21
  157. data/spec/models/authentication_error_spec.rb +10 -15
  158. data/spec/models/authentication_success_response_spec.rb +9 -14
  159. data/spec/models/combine_pdfs_data_spec.rb +18 -17
  160. data/spec/models/combined_submission_action_spec.rb +16 -21
  161. data/spec/models/combined_submission_data_spec.rb +17 -16
  162. data/spec/models/combined_submission_spec.rb +45 -32
  163. data/spec/models/copy_template_data_spec.rb +9 -14
  164. data/spec/models/create_combined_submission_response_spec.rb +16 -21
  165. data/spec/models/create_custom_file_data_spec.rb +8 -13
  166. data/spec/models/create_custom_file_response_spec.rb +16 -21
  167. data/spec/models/create_folder_attributes_spec.rb +42 -0
  168. data/spec/models/create_folder_data_spec.rb +8 -13
  169. data/spec/models/create_html_template_data_spec.rb +8 -13
  170. data/spec/models/create_submission_batch_response_spec.rb +21 -26
  171. data/spec/models/create_submission_batch_submissions_response_spec.rb +16 -21
  172. data/spec/models/create_submission_data_request_data_spec.rb +33 -38
  173. data/spec/models/create_submission_data_request_event_request_spec.rb +62 -0
  174. data/spec/models/create_submission_data_request_event_response_spec.rb +52 -0
  175. data/spec/models/create_submission_data_request_token_response_spec.rb +15 -20
  176. data/spec/models/create_submission_data_spec.rb +90 -0
  177. data/spec/models/create_submission_response_spec.rb +16 -21
  178. data/spec/models/create_template_from_upload_data_spec.rb +8 -13
  179. data/spec/models/data_request_token_spec.rb +54 -0
  180. data/spec/models/delete_template_response_spec.rb +46 -0
  181. data/spec/models/error_response_spec.rb +46 -0
  182. data/spec/models/folder_spec.rb +15 -20
  183. data/spec/models/full_template_spec.rb +268 -0
  184. data/spec/models/html_template_data_spec.rb +62 -49
  185. data/spec/models/html_template_data_webhook_options_spec.rb +36 -0
  186. data/spec/models/invalid_request_single_error_spec.rb +46 -0
  187. data/spec/models/invalid_request_spec.rb +10 -15
  188. data/spec/models/list_submissions_response_spec.rb +48 -0
  189. data/spec/models/move_folder_data_spec.rb +8 -13
  190. data/spec/models/move_template_data_spec.rb +8 -13
  191. data/spec/models/pending_template_spec.rb +45 -50
  192. data/spec/models/preview_pdf_response_spec.rb +46 -0
  193. data/spec/models/publish_template_version404_response_spec.rb +46 -0
  194. data/spec/models/publish_template_version422_response_spec.rb +46 -0
  195. data/spec/models/publish_template_version_response_result_spec.rb +54 -0
  196. data/spec/models/publish_template_version_response_spec.rb +46 -0
  197. data/spec/models/publish_version_data_spec.rb +42 -0
  198. data/spec/models/rename_folder_data_spec.rb +8 -13
  199. data/spec/models/restore_template_version_response_spec.rb +40 -0
  200. data/spec/models/restore_version_data_spec.rb +36 -0
  201. data/spec/models/submission_action_spec.rb +16 -21
  202. data/spec/models/submission_batch_data_spec.rb +17 -16
  203. data/spec/models/submission_batch_spec.rb +29 -34
  204. data/spec/models/submission_data_batch_request_spec.rb +24 -23
  205. data/spec/models/submission_data_request_event_spec.rb +72 -0
  206. data/spec/models/submission_data_request_spec.rb +36 -35
  207. data/spec/models/submission_data_spec.rb +13 -24
  208. data/spec/models/submission_spec.rb +27 -32
  209. data/spec/models/template_data_spec.rb +59 -46
  210. data/spec/models/template_defaults_spec.rb +48 -0
  211. data/spec/models/template_document_metadata_spec.rb +52 -0
  212. data/spec/models/template_document_spec.rb +52 -0
  213. data/spec/models/template_schema_spec.rb +84 -0
  214. data/spec/models/template_spec.rb +50 -55
  215. data/spec/models/update_data_request_response_spec.rb +16 -21
  216. data/spec/models/update_submission_data_request_data_spec.rb +22 -27
  217. data/spec/models/update_template_data_spec.rb +8 -13
  218. data/spec/models/update_template_response_spec.rb +14 -19
  219. data/spec/models/upload_presign_spec.rb +58 -0
  220. data/spec/models/upload_template_data_spec.rb +64 -51
  221. data/spec/spec_helper.rb +5 -5
  222. metadata +112 -124
  223. data/docs/CreateSubmissionDataRequestTokenResponseToken.md +0 -11
  224. data/docs/CustomFile.md +0 -9
  225. data/docs/Error.md +0 -9
  226. data/docs/FoldersFolder.md +0 -9
  227. data/docs/TemplatestemplateIdaddFieldsFields.md +0 -92
  228. data/docs/UploadTemplateDataDocument.md +0 -10
  229. data/docs/UploadTemplateDataDocumentMetadata.md +0 -10
  230. data/lib/docspring/models/templatestemplate_idadd_fields_fields.rb +0 -1306
  231. data/spec/api_client_spec.rb +0 -226
  232. data/spec/configuration_spec.rb +0 -53
  233. data/spec/models/create_submission_data_request_token_response_token_spec.rb +0 -59
  234. data/spec/models/custom_file_spec.rb +0 -47
  235. data/spec/models/error_spec.rb +0 -51
  236. data/spec/models/folders_folder_spec.rb +0 -47
  237. data/spec/models/templatestemplate_idadd_fields_fields_spec.rb +0 -589
  238. data/spec/models/upload_template_data_document_metadata_spec.rb +0 -57
  239. data/spec/models/upload_template_data_document_spec.rb +0 -57
@@ -3,14 +3,15 @@
3
3
 
4
4
  #DocSpring is a service that helps you fill out and sign PDF templates.
5
5
 
6
- OpenAPI spec version: v1
6
+ The version of the OpenAPI document: v1
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.0
9
+ Generator version: 7.11.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module DocSpring
16
17
  class AuthenticationSuccessResponse
@@ -45,6 +46,11 @@ module DocSpring
45
46
  }
46
47
  end
47
48
 
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ attribute_map.values
52
+ end
53
+
48
54
  # Attribute type mapping.
49
55
  def self.openapi_types
50
56
  {
@@ -52,30 +58,52 @@ module DocSpring
52
58
  }
53
59
  end
54
60
 
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
55
67
  # Initializes the object
56
68
  # @param [Hash] attributes Model attributes in the form of hash
57
69
  def initialize(attributes = {})
58
- return unless attributes.is_a?(Hash)
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DocSpring::AuthenticationSuccessResponse` initialize method"
72
+ end
59
73
 
60
- # convert string to symbol for hash key
61
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DocSpring::AuthenticationSuccessResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
62
81
 
63
- if attributes.has_key?(:'status')
82
+ if attributes.key?(:'status')
64
83
  self.status = attributes[:'status']
84
+ else
85
+ self.status = nil
65
86
  end
66
87
  end
67
88
 
68
89
  # Show invalid properties with the reasons. Usually used together with valid?
69
90
  # @return Array for valid properties with the reasons
70
91
  def list_invalid_properties
92
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
93
  invalid_properties = Array.new
94
+ if @status.nil?
95
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
96
+ end
97
+
72
98
  invalid_properties
73
99
  end
74
100
 
75
101
  # Check to see if the all the properties in the model are valid
76
102
  # @return true if the model is valid
77
103
  def valid?
78
- status_validator = EnumAttributeValidator.new('String', ['success'])
104
+ warn '[DEPRECATED] the `valid?` method is obsolete'
105
+ return false if @status.nil?
106
+ status_validator = EnumAttributeValidator.new('String', ["success"])
79
107
  return false unless status_validator.valid?(@status)
80
108
  true
81
109
  end
@@ -83,9 +111,9 @@ module DocSpring
83
111
  # Custom attribute writer method checking allowed values (enum).
84
112
  # @param [Object] status Object to be assigned
85
113
  def status=(status)
86
- validator = EnumAttributeValidator.new('String', ['success'])
114
+ validator = EnumAttributeValidator.new('String', ["success"])
87
115
  unless validator.valid?(status)
88
- fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
116
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
89
117
  end
90
118
  @status = status
91
119
  end
@@ -105,7 +133,7 @@ module DocSpring
105
133
  end
106
134
 
107
135
  # Calculates hash code according to all attributes.
108
- # @return [Fixnum] Hash code
136
+ # @return [Integer] Hash code
109
137
  def hash
110
138
  [status].hash
111
139
  end
@@ -113,31 +141,34 @@ module DocSpring
113
141
  # Builds the object from hash
114
142
  # @param [Hash] attributes Model attributes in the form of hash
115
143
  # @return [Object] Returns the model itself
116
- def build_from_hash(attributes)
144
+ def self.build_from_hash(attributes)
117
145
  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
146
+ attributes = attributes.transform_keys(&:to_sym)
147
+ transformed_hash = {}
148
+ openapi_types.each_pair do |key, type|
149
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
150
+ transformed_hash["#{key}"] = nil
151
+ elsif type =~ /\AArray<(.*)>/i
152
+ # check to ensure the input is an array given that the attribute
121
153
  # 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) })
154
+ if attributes[attribute_map[key]].is_a?(Array)
155
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
124
156
  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
157
+ elsif !attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
159
+ end
128
160
  end
129
-
130
- self
161
+ new(transformed_hash)
131
162
  end
132
163
 
133
164
  # Deserializes the data based on type
134
165
  # @param string type Data type
135
166
  # @param string value Value to be deserialized
136
167
  # @return [Object] Deserialized data
137
- def _deserialize(type, value)
168
+ def self._deserialize(type, value)
138
169
  case type.to_sym
139
- when :DateTime
140
- DateTime.parse(value)
170
+ when :Time
171
+ Time.parse(value)
141
172
  when :Date
142
173
  Date.parse(value)
143
174
  when :String
@@ -146,7 +177,7 @@ module DocSpring
146
177
  value.to_i
147
178
  when :Float
148
179
  value.to_f
149
- when :BOOLEAN
180
+ when :Boolean
150
181
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
182
  true
152
183
  else
@@ -167,8 +198,9 @@ module DocSpring
167
198
  end
168
199
  end
169
200
  else # model
170
- temp_model = DocSpring.const_get(type).new
171
- temp_model.build_from_hash(value)
201
+ # models (e.g. Pet) or oneOf
202
+ klass = DocSpring.const_get(type)
203
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
172
204
  end
173
205
  end
174
206
 
@@ -190,7 +222,11 @@ module DocSpring
190
222
  hash = {}
191
223
  self.class.attribute_map.each_pair do |attr, param|
192
224
  value = self.send(attr)
193
- next if value.nil?
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
194
230
  hash[param] = _to_hash(value)
195
231
  end
196
232
  hash
@@ -213,5 +249,7 @@ module DocSpring
213
249
  value
214
250
  end
215
251
  end
252
+
216
253
  end
254
+
217
255
  end
@@ -3,14 +3,15 @@
3
3
 
4
4
  #DocSpring is a service that helps you fill out and sign PDF templates.
5
5
 
6
- OpenAPI spec version: v1
6
+ The version of the OpenAPI document: v1
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.0
9
+ Generator version: 7.11.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module DocSpring
16
17
  class CombinePdfsData
@@ -20,6 +21,8 @@ module DocSpring
20
21
 
21
22
  attr_accessor :metadata
22
23
 
24
+ attr_accessor :password
25
+
23
26
  attr_accessor :source_pdfs
24
27
 
25
28
  attr_accessor :test
@@ -30,49 +33,75 @@ module DocSpring
30
33
  :'delete_custom_files' => :'delete_custom_files',
31
34
  :'expires_in' => :'expires_in',
32
35
  :'metadata' => :'metadata',
36
+ :'password' => :'password',
33
37
  :'source_pdfs' => :'source_pdfs',
34
38
  :'test' => :'test'
35
39
  }
36
40
  end
37
41
 
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
38
47
  # Attribute type mapping.
39
48
  def self.openapi_types
40
49
  {
41
- :'delete_custom_files' => :'BOOLEAN',
50
+ :'delete_custom_files' => :'Boolean',
42
51
  :'expires_in' => :'Integer',
43
52
  :'metadata' => :'Object',
53
+ :'password' => :'String',
44
54
  :'source_pdfs' => :'Array<Object>',
45
- :'test' => :'BOOLEAN'
55
+ :'test' => :'Boolean'
46
56
  }
47
57
  end
48
58
 
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ ])
63
+ end
64
+
49
65
  # Initializes the object
50
66
  # @param [Hash] attributes Model attributes in the form of hash
51
67
  def initialize(attributes = {})
52
- return unless attributes.is_a?(Hash)
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DocSpring::CombinePdfsData` initialize method"
70
+ end
53
71
 
54
- # convert string to symbol for hash key
55
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DocSpring::CombinePdfsData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
56
79
 
57
- if attributes.has_key?(:'delete_custom_files')
80
+ if attributes.key?(:'delete_custom_files')
58
81
  self.delete_custom_files = attributes[:'delete_custom_files']
59
82
  end
60
83
 
61
- if attributes.has_key?(:'expires_in')
84
+ if attributes.key?(:'expires_in')
62
85
  self.expires_in = attributes[:'expires_in']
63
86
  end
64
87
 
65
- if attributes.has_key?(:'metadata')
88
+ if attributes.key?(:'metadata')
66
89
  self.metadata = attributes[:'metadata']
67
90
  end
68
91
 
69
- if attributes.has_key?(:'source_pdfs')
92
+ if attributes.key?(:'password')
93
+ self.password = attributes[:'password']
94
+ end
95
+
96
+ if attributes.key?(:'source_pdfs')
70
97
  if (value = attributes[:'source_pdfs']).is_a?(Array)
71
98
  self.source_pdfs = value
72
99
  end
100
+ else
101
+ self.source_pdfs = nil
73
102
  end
74
103
 
75
- if attributes.has_key?(:'test')
104
+ if attributes.key?(:'test')
76
105
  self.test = attributes[:'test']
77
106
  end
78
107
  end
@@ -80,6 +109,7 @@ module DocSpring
80
109
  # Show invalid properties with the reasons. Usually used together with valid?
81
110
  # @return Array for valid properties with the reasons
82
111
  def list_invalid_properties
112
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
113
  invalid_properties = Array.new
84
114
  if @source_pdfs.nil?
85
115
  invalid_properties.push('invalid value for "source_pdfs", source_pdfs cannot be nil.')
@@ -91,6 +121,7 @@ module DocSpring
91
121
  # Check to see if the all the properties in the model are valid
92
122
  # @return true if the model is valid
93
123
  def valid?
124
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
125
  return false if @source_pdfs.nil?
95
126
  true
96
127
  end
@@ -103,6 +134,7 @@ module DocSpring
103
134
  delete_custom_files == o.delete_custom_files &&
104
135
  expires_in == o.expires_in &&
105
136
  metadata == o.metadata &&
137
+ password == o.password &&
106
138
  source_pdfs == o.source_pdfs &&
107
139
  test == o.test
108
140
  end
@@ -114,39 +146,42 @@ module DocSpring
114
146
  end
115
147
 
116
148
  # Calculates hash code according to all attributes.
117
- # @return [Fixnum] Hash code
149
+ # @return [Integer] Hash code
118
150
  def hash
119
- [delete_custom_files, expires_in, metadata, source_pdfs, test].hash
151
+ [delete_custom_files, expires_in, metadata, password, source_pdfs, test].hash
120
152
  end
121
153
 
122
154
  # Builds the object from hash
123
155
  # @param [Hash] attributes Model attributes in the form of hash
124
156
  # @return [Object] Returns the model itself
125
- def build_from_hash(attributes)
157
+ def self.build_from_hash(attributes)
126
158
  return nil unless attributes.is_a?(Hash)
127
- self.class.openapi_types.each_pair do |key, type|
128
- if type =~ /\AArray<(.*)>/i
129
- # check to ensure the input is an array given that the the attribute
159
+ attributes = attributes.transform_keys(&:to_sym)
160
+ transformed_hash = {}
161
+ openapi_types.each_pair do |key, type|
162
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
163
+ transformed_hash["#{key}"] = nil
164
+ elsif type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
130
166
  # is documented as an array but the input is not
131
- if attributes[self.class.attribute_map[key]].is_a?(Array)
132
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
167
+ if attributes[attribute_map[key]].is_a?(Array)
168
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
133
169
  end
134
- elsif !attributes[self.class.attribute_map[key]].nil?
135
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
- end # or else data not found in attributes(hash), not an issue as the data can be optional
170
+ elsif !attributes[attribute_map[key]].nil?
171
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
172
+ end
137
173
  end
138
-
139
- self
174
+ new(transformed_hash)
140
175
  end
141
176
 
142
177
  # Deserializes the data based on type
143
178
  # @param string type Data type
144
179
  # @param string value Value to be deserialized
145
180
  # @return [Object] Deserialized data
146
- def _deserialize(type, value)
181
+ def self._deserialize(type, value)
147
182
  case type.to_sym
148
- when :DateTime
149
- DateTime.parse(value)
183
+ when :Time
184
+ Time.parse(value)
150
185
  when :Date
151
186
  Date.parse(value)
152
187
  when :String
@@ -155,7 +190,7 @@ module DocSpring
155
190
  value.to_i
156
191
  when :Float
157
192
  value.to_f
158
- when :BOOLEAN
193
+ when :Boolean
159
194
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
195
  true
161
196
  else
@@ -176,8 +211,9 @@ module DocSpring
176
211
  end
177
212
  end
178
213
  else # model
179
- temp_model = DocSpring.const_get(type).new
180
- temp_model.build_from_hash(value)
214
+ # models (e.g. Pet) or oneOf
215
+ klass = DocSpring.const_get(type)
216
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
181
217
  end
182
218
  end
183
219
 
@@ -199,7 +235,11 @@ module DocSpring
199
235
  hash = {}
200
236
  self.class.attribute_map.each_pair do |attr, param|
201
237
  value = self.send(attr)
202
- next if value.nil?
238
+ if value.nil?
239
+ is_nullable = self.class.openapi_nullable.include?(attr)
240
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
241
+ end
242
+
203
243
  hash[param] = _to_hash(value)
204
244
  end
205
245
  hash
@@ -222,5 +262,7 @@ module DocSpring
222
262
  value
223
263
  end
224
264
  end
265
+
225
266
  end
267
+
226
268
  end