docspring 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/FILES +99 -0
  3. data/.travis.yml +1 -1
  4. data/AGENTS.md +3 -2
  5. data/CHANGELOG.md +64 -0
  6. data/Gemfile.lock +9 -9
  7. data/README.md +14 -1
  8. data/docs/AddTemplateFieldsRequest.md +18 -0
  9. data/docs/Client.md +917 -80
  10. data/docs/CombinedPdf.md +1 -1
  11. data/docs/CreateCombinedPdfRequest.md +1 -1
  12. data/docs/CreateSubmissionBatchRequest.md +2 -0
  13. data/docs/CreateSubmissionRequest.md +4 -2
  14. data/docs/CreateTemplatePreviewRequest.md +18 -0
  15. data/docs/CreateTemplateRequest.md +13 -3
  16. data/docs/ErrorDetail.md +1 -1
  17. data/docs/ErrorInfo.md +4 -4
  18. data/docs/Field.md +198 -0
  19. data/docs/FieldDependency.md +22 -0
  20. data/docs/FieldDependencyInput.md +22 -0
  21. data/docs/FieldGroup.md +32 -0
  22. data/docs/FieldGroupInput.md +30 -0
  23. data/docs/FieldGroupType.md +15 -0
  24. data/docs/FieldInput.md +196 -0
  25. data/docs/FieldType.md +15 -0
  26. data/docs/GenerateFilesFormat.md +15 -0
  27. data/docs/GenerateSubmissionFilesRequest.md +18 -0
  28. data/docs/OutputFormat.md +15 -0
  29. data/docs/PageImage.md +34 -0
  30. data/docs/PageImages.md +24 -0
  31. data/docs/PredefinedField.md +30 -0
  32. data/docs/PredefinedFieldInput.md +30 -0
  33. data/docs/RemoveTemplateFieldsRequest.md +18 -0
  34. data/docs/ReorderTemplateFieldsRequest.md +18 -0
  35. data/docs/Submission.md +16 -14
  36. data/docs/SubmissionFiles.md +3 -1
  37. data/docs/SubmissionInput.md +4 -2
  38. data/docs/SubmissionList.md +1 -1
  39. data/docs/SubmissionSummary.md +54 -0
  40. data/docs/SubmissionValidation.md +24 -0
  41. data/docs/Template.md +18 -10
  42. data/docs/TemplateActor.md +1 -1
  43. data/docs/TemplateDiff.md +30 -0
  44. data/docs/TemplateDiffSummary.md +28 -0
  45. data/docs/TemplateDocument.md +6 -6
  46. data/docs/TemplateDocumentSummary.md +24 -0
  47. data/docs/TemplateFieldChange.md +24 -0
  48. data/docs/TemplateFieldChanges.md +24 -0
  49. data/docs/TemplateFieldDependency.md +1 -1
  50. data/docs/TemplateFieldDependencyInput.md +1 -1
  51. data/docs/TemplateFieldMove.md +22 -0
  52. data/docs/TemplateFields.md +22 -0
  53. data/docs/TemplatePageImages.md +24 -0
  54. data/docs/TemplatePreview.md +32 -0
  55. data/docs/TemplatePreviewState.md +15 -0
  56. data/docs/TemplateSummary.md +2 -48
  57. data/docs/UpdateTemplateDocumentRequest.md +6 -2
  58. data/docs/UpdateTemplateFieldsRequest.md +18 -0
  59. data/docs/UpdateTemplateRequest.md +10 -2
  60. data/docs/ValidateSubmissionRequest.md +38 -0
  61. data/lib/docspring/api/client.rb +869 -51
  62. data/lib/docspring/api_client.rb +4 -2
  63. data/lib/docspring/date_time_values.rb +33 -0
  64. data/lib/docspring/models/add_template_fields_request.rb +187 -0
  65. data/lib/docspring/models/combined_pdf.rb +1 -1
  66. data/lib/docspring/models/create_combined_pdf_request.rb +1 -1
  67. data/lib/docspring/models/create_submission_batch_request.rb +23 -1
  68. data/lib/docspring/models/create_submission_request.rb +25 -3
  69. data/lib/docspring/models/create_template_preview_request.rb +187 -0
  70. data/lib/docspring/models/create_template_request.rb +59 -4
  71. data/lib/docspring/models/error_code.rb +3 -1
  72. data/lib/docspring/models/error_detail.rb +1 -1
  73. data/lib/docspring/models/error_info.rb +4 -4
  74. data/lib/docspring/models/field.rb +2217 -0
  75. data/lib/docspring/models/field_dependency.rb +246 -0
  76. data/lib/docspring/models/field_dependency_input.rb +246 -0
  77. data/lib/docspring/models/field_group.rb +368 -0
  78. data/lib/docspring/models/field_group_input.rb +247 -0
  79. data/lib/docspring/models/field_group_type.rb +41 -0
  80. data/lib/docspring/models/field_input.rb +1109 -0
  81. data/lib/docspring/models/field_type.rb +54 -0
  82. data/lib/docspring/models/generate_files_format.rb +40 -0
  83. data/lib/docspring/models/generate_submission_files_request.rb +187 -0
  84. data/lib/docspring/models/output_format.rb +41 -0
  85. data/lib/docspring/models/page_image.rb +359 -0
  86. data/lib/docspring/models/page_images.rb +248 -0
  87. data/lib/docspring/models/predefined_field.rb +287 -0
  88. data/lib/docspring/models/predefined_field_input.rb +287 -0
  89. data/lib/docspring/models/remove_template_fields_request.rb +187 -0
  90. data/lib/docspring/models/reorder_template_fields_request.rb +187 -0
  91. data/lib/docspring/models/submission.rb +146 -117
  92. data/lib/docspring/models/submission_files.rb +13 -4
  93. data/lib/docspring/models/submission_input.rb +25 -3
  94. data/lib/docspring/models/submission_list.rb +1 -1
  95. data/lib/docspring/models/submission_summary.rb +601 -0
  96. data/lib/docspring/models/submission_validation.rb +234 -0
  97. data/lib/docspring/models/template.rb +169 -83
  98. data/lib/docspring/models/template_actor.rb +1 -1
  99. data/lib/docspring/models/template_diff.rb +321 -0
  100. data/lib/docspring/models/template_diff_summary.rb +320 -0
  101. data/lib/docspring/models/template_document.rb +44 -44
  102. data/lib/docspring/models/template_document_state.rb +3 -1
  103. data/lib/docspring/models/template_document_summary.rb +260 -0
  104. data/lib/docspring/models/template_field_change.rb +266 -0
  105. data/lib/docspring/models/template_field_changes.rb +274 -0
  106. data/lib/docspring/models/template_field_dependency.rb +1 -1
  107. data/lib/docspring/models/template_field_dependency_input.rb +1 -1
  108. data/lib/docspring/models/template_field_move.rb +239 -0
  109. data/lib/docspring/models/template_fields.rb +227 -0
  110. data/lib/docspring/models/template_page_images.rb +254 -0
  111. data/lib/docspring/models/template_preview.rb +356 -0
  112. data/lib/docspring/models/template_preview_state.rb +42 -0
  113. data/lib/docspring/models/template_summary.rb +5 -572
  114. data/lib/docspring/models/update_template_document_request.rb +23 -20
  115. data/lib/docspring/models/update_template_fields_request.rb +187 -0
  116. data/lib/docspring/models/update_template_request.rb +53 -6
  117. data/lib/docspring/models/validate_submission_request.rb +288 -0
  118. data/lib/docspring/request_schemas.json +3465 -1588
  119. data/lib/docspring/version.rb +1 -1
  120. data/lib/docspring/webhook_signature.rb +45 -0
  121. data/lib/docspring.rb +34 -0
  122. data/spec/api/client_spec.rb +167 -13
  123. data/spec/models/add_template_fields_request_spec.rb +36 -0
  124. data/spec/models/create_submission_batch_request_spec.rb +6 -0
  125. data/spec/models/create_submission_request_spec.rb +6 -0
  126. data/spec/models/create_template_preview_request_spec.rb +36 -0
  127. data/spec/models/create_template_request_spec.rb +30 -0
  128. data/spec/models/field_dependency_input_spec.rb +48 -0
  129. data/spec/models/field_dependency_spec.rb +48 -0
  130. data/spec/models/field_group_input_spec.rb +72 -0
  131. data/spec/models/field_group_spec.rb +78 -0
  132. data/spec/models/field_group_type_spec.rb +30 -0
  133. data/spec/models/field_input_spec.rb +570 -0
  134. data/spec/models/field_spec.rb +576 -0
  135. data/spec/models/field_type_spec.rb +30 -0
  136. data/spec/models/generate_files_format_spec.rb +30 -0
  137. data/spec/models/generate_submission_files_request_spec.rb +36 -0
  138. data/spec/models/output_format_spec.rb +30 -0
  139. data/spec/models/page_image_spec.rb +84 -0
  140. data/spec/models/page_images_spec.rb +54 -0
  141. data/spec/models/predefined_field_input_spec.rb +72 -0
  142. data/spec/models/predefined_field_spec.rb +72 -0
  143. data/spec/models/remove_template_fields_request_spec.rb +36 -0
  144. data/spec/models/reorder_template_fields_request_spec.rb +36 -0
  145. data/spec/models/submission_files_spec.rb +6 -0
  146. data/spec/models/submission_input_spec.rb +6 -0
  147. data/spec/models/submission_spec.rb +17 -11
  148. data/spec/models/submission_summary_spec.rb +144 -0
  149. data/spec/models/submission_validation_spec.rb +54 -0
  150. data/spec/models/template_diff_spec.rb +72 -0
  151. data/spec/models/template_diff_summary_spec.rb +66 -0
  152. data/spec/models/template_document_spec.rb +5 -5
  153. data/spec/models/template_document_summary_spec.rb +54 -0
  154. data/spec/models/template_field_change_spec.rb +54 -0
  155. data/spec/models/template_field_changes_spec.rb +54 -0
  156. data/spec/models/template_field_move_spec.rb +48 -0
  157. data/spec/models/template_fields_spec.rb +48 -0
  158. data/spec/models/template_page_images_spec.rb +54 -0
  159. data/spec/models/template_preview_spec.rb +78 -0
  160. data/spec/models/template_preview_state_spec.rb +30 -0
  161. data/spec/models/template_spec.rb +34 -10
  162. data/spec/models/template_summary_spec.rb +0 -138
  163. data/spec/models/update_template_document_request_spec.rb +12 -0
  164. data/spec/models/update_template_fields_request_spec.rb +36 -0
  165. data/spec/models/update_template_request_spec.rb +24 -0
  166. data/spec/models/validate_submission_request_spec.rb +96 -0
  167. metadata +135 -1
@@ -11,5 +11,5 @@ Generator version: 7.26.0-DOCSPRING
11
11
  =end
12
12
 
13
13
  module DocSpring
14
- VERSION = '4.0.0'
14
+ VERSION = '4.2.0'
15
15
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+
5
+ module DocSpring
6
+ # The number of seconds a webhook request's signature stays valid (verify_webhook_signature)
7
+ WEBHOOK_SIGNATURE_TOLERANCE = 300
8
+
9
+ # Checks a webhook request's X-DocSpring-Signature header (https://docspring.com/docs/webhooks/verifying-signatures/).
10
+ # Returns true when one of its v1 signatures is the HMAC-SHA256 of "{t}.{payload}" with the webhook's secret, and its
11
+ # timestamp t is at most `tolerance` seconds from `now`. Returns false for anything else, including a missing or
12
+ # malformed header.
13
+ #
14
+ # payload: the request body exactly as it was received (Rails: request.raw_post), not parsed JSON.
15
+ # signature_header: the X-DocSpring-Signature header.
16
+ # secret: the webhook's signing secret.
17
+ # tolerance: how many seconds old (or early) the timestamp can be. 5 minutes by default.
18
+ # now: the current Unix time in seconds, for tests. The system clock by default.
19
+ def self.verify_webhook_signature(payload, signature_header, secret, tolerance: WEBHOOK_SIGNATURE_TOLERANCE, now: nil)
20
+ return false unless payload.is_a?(String) && signature_header.is_a?(String) && secret.is_a?(String) && !secret.empty?
21
+
22
+ parts = signature_header.split(',').map { |part| part.strip.split('=', 2) }
23
+ timestamp = parts.find { |key, _value| key == 't' }&.last
24
+ signatures = parts.filter_map { |key, value| value if key == 'v1' && value && !value.empty? }
25
+ return false unless timestamp&.match?(/\A\d+\z/) && !signatures.empty?
26
+
27
+ now = Time.now.to_i if now.nil?
28
+ return false if (now.to_i - timestamp.to_i).abs > tolerance
29
+
30
+ expected = OpenSSL::HMAC.hexdigest('SHA256', secret, "#{timestamp}.#{payload}")
31
+ signatures.any? { |signature| webhook_signature_equal?(signature, expected) }
32
+ end
33
+
34
+ # Compares two signatures in constant time, so a timing attack can't find a valid one byte by byte
35
+ def self.webhook_signature_equal?(signature, expected)
36
+ return false unless signature.bytesize == expected.bytesize
37
+ # OpenSSL 2.2 (Ruby 3.0) and later
38
+ return OpenSSL.fixed_length_secure_compare(signature, expected) if OpenSSL.respond_to?(:fixed_length_secure_compare)
39
+
40
+ difference = 0
41
+ signature.bytes.zip(expected.bytes) { |a, b| difference |= a ^ b }
42
+ difference == 0
43
+ end
44
+ private_class_method :webhook_signature_equal?
45
+ end
data/lib/docspring.rb CHANGED
@@ -14,11 +14,13 @@ Generator version: 7.26.0-DOCSPRING
14
14
  require 'docspring/api_client'
15
15
  require 'docspring/api_error'
16
16
  require 'docspring/request_validator'
17
+ require 'docspring/webhook_signature'
17
18
  require 'docspring/api_model_base'
18
19
  require 'docspring/version'
19
20
  require 'docspring/configuration'
20
21
 
21
22
  # Models
23
+ require 'docspring/models/add_template_fields_request'
22
24
  require 'docspring/models/ai_field_naming_language'
23
25
  require 'docspring/models/authentication_check'
24
26
  require 'docspring/models/barcode_symbology'
@@ -40,6 +42,7 @@ require 'docspring/models/create_signature_request_event_request'
40
42
  require 'docspring/models/create_signature_request_token_request'
41
43
  require 'docspring/models/create_submission_batch_request'
42
44
  require 'docspring/models/create_submission_request'
45
+ require 'docspring/models/create_template_preview_request'
43
46
  require 'docspring/models/create_template_request'
44
47
  require 'docspring/models/create_webhook_request'
45
48
  require 'docspring/models/custom_file'
@@ -50,12 +53,19 @@ require 'docspring/models/error_detail'
50
53
  require 'docspring/models/error_info'
51
54
  require 'docspring/models/error_response'
52
55
  require 'docspring/models/expiration_interval'
56
+ require 'docspring/models/field'
53
57
  require 'docspring/models/field_comparison_condition'
54
58
  require 'docspring/models/field_comparison_operator'
59
+ require 'docspring/models/field_dependency'
60
+ require 'docspring/models/field_dependency_input'
55
61
  require 'docspring/models/field_display_type'
56
62
  require 'docspring/models/field_equals_condition'
57
63
  require 'docspring/models/field_equals_operator'
64
+ require 'docspring/models/field_group'
65
+ require 'docspring/models/field_group_input'
66
+ require 'docspring/models/field_group_type'
58
67
  require 'docspring/models/field_in_condition'
68
+ require 'docspring/models/field_input'
59
69
  require 'docspring/models/field_override'
60
70
  require 'docspring/models/field_presence_condition'
61
71
  require 'docspring/models/field_presence_operator'
@@ -64,8 +74,11 @@ require 'docspring/models/field_reimport_state'
64
74
  require 'docspring/models/field_setup_logic'
65
75
  require 'docspring/models/field_setup_naming'
66
76
  require 'docspring/models/field_setup_source'
77
+ require 'docspring/models/field_type'
67
78
  require 'docspring/models/folder'
68
79
  require 'docspring/models/folder_list'
80
+ require 'docspring/models/generate_files_format'
81
+ require 'docspring/models/generate_submission_files_request'
69
82
  require 'docspring/models/generated_file'
70
83
  require 'docspring/models/generated_file_state'
71
84
  require 'docspring/models/html_engine_options'
@@ -76,9 +89,16 @@ require 'docspring/models/model_code_language'
76
89
  require 'docspring/models/move_folder_request'
77
90
  require 'docspring/models/move_template_request'
78
91
  require 'docspring/models/number_condition_type'
92
+ require 'docspring/models/output_format'
79
93
  require 'docspring/models/page_format'
94
+ require 'docspring/models/page_image'
95
+ require 'docspring/models/page_images'
96
+ require 'docspring/models/predefined_field'
97
+ require 'docspring/models/predefined_field_input'
80
98
  require 'docspring/models/publish_template_version_request'
99
+ require 'docspring/models/remove_template_fields_request'
81
100
  require 'docspring/models/rename_folder_request'
101
+ require 'docspring/models/reorder_template_fields_request'
82
102
  require 'docspring/models/restore_template_version_request'
83
103
  require 'docspring/models/shape_type'
84
104
  require 'docspring/models/signature_request'
@@ -104,13 +124,20 @@ require 'docspring/models/submission_list'
104
124
  require 'docspring/models/submission_source'
105
125
  require 'docspring/models/submission_source_pdf'
106
126
  require 'docspring/models/submission_state'
127
+ require 'docspring/models/submission_summary'
128
+ require 'docspring/models/submission_validation'
107
129
  require 'docspring/models/template'
108
130
  require 'docspring/models/template_actor'
109
131
  require 'docspring/models/template_actor_type'
110
132
  require 'docspring/models/template_defaults'
111
133
  require 'docspring/models/template_defaults_input'
134
+ require 'docspring/models/template_diff'
135
+ require 'docspring/models/template_diff_summary'
112
136
  require 'docspring/models/template_document'
113
137
  require 'docspring/models/template_document_state'
138
+ require 'docspring/models/template_document_summary'
139
+ require 'docspring/models/template_field_change'
140
+ require 'docspring/models/template_field_changes'
114
141
  require 'docspring/models/template_field_dependency'
115
142
  require 'docspring/models/template_field_dependency_action'
116
143
  require 'docspring/models/template_field_dependency_condition'
@@ -119,13 +146,18 @@ require 'docspring/models/template_field_dependency_input'
119
146
  require 'docspring/models/template_field_dependency_match'
120
147
  require 'docspring/models/template_field_dependency_operator'
121
148
  require 'docspring/models/template_field_logic_status'
149
+ require 'docspring/models/template_field_move'
150
+ require 'docspring/models/template_fields'
122
151
  require 'docspring/models/template_form_mode'
123
152
  require 'docspring/models/template_model_code'
124
153
  require 'docspring/models/template_page_ai_error'
125
154
  require 'docspring/models/template_page_ai_naming_status'
126
155
  require 'docspring/models/template_page_fields_status'
127
156
  require 'docspring/models/template_page_image_status'
157
+ require 'docspring/models/template_page_images'
128
158
  require 'docspring/models/template_page_processing_status'
159
+ require 'docspring/models/template_preview'
160
+ require 'docspring/models/template_preview_state'
129
161
  require 'docspring/models/template_source_pdf'
130
162
  require 'docspring/models/template_summary'
131
163
  require 'docspring/models/template_summary_list'
@@ -138,11 +170,13 @@ require 'docspring/models/text_vertical_alignment'
138
170
  require 'docspring/models/typeface'
139
171
  require 'docspring/models/update_signature_request_request'
140
172
  require 'docspring/models/update_template_document_request'
173
+ require 'docspring/models/update_template_fields_request'
141
174
  require 'docspring/models/update_template_request'
142
175
  require 'docspring/models/update_webhook_request'
143
176
  require 'docspring/models/upload_method'
144
177
  require 'docspring/models/upload_presign'
145
178
  require 'docspring/models/url_source_pdf'
179
+ require 'docspring/models/validate_submission_request'
146
180
  require 'docspring/models/webhook'
147
181
  require 'docspring/models/webhook_event_type'
148
182
  require 'docspring/models/webhook_list'
@@ -32,6 +32,19 @@ describe 'Client' do
32
32
  end
33
33
  end
34
34
 
35
+ # unit tests for add_template_fields
36
+ # Add fields to a template
37
+ # Adds fields to a template's draft and returns all of its fields. Publish a version for submissions of published versions to have them.
38
+ # @param template_id The template's ID.
39
+ # @param body The fields to add to the template's draft.
40
+ # @param [Hash] opts the optional parameters
41
+ # @return [TemplateFields]
42
+ describe 'add_template_fields test' do
43
+ it 'should work' do
44
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
45
+ end
46
+ end
47
+
35
48
  # unit tests for copy_template
36
49
  # Copy a template
37
50
  # Copies a template (its draft, or a published version) into a new template.
@@ -51,6 +64,7 @@ describe 'Client' do
51
64
  # @param body The PDFs to merge, and the combined PDF's settings.
52
65
  # @param [Hash] opts the optional parameters
53
66
  # @option opts [Boolean] :wait Wait until the PDF has been generated before responding. Default true on sync.api hosts.
67
+ # @option opts [String] :idempotency_key A key of your own, such as a UUID, that makes it safe to send this request again: for 24 hours, DocSpring answers a request with the same key from the same API token with the first request's response (and an `Idempotent-Replayed: true` header) instead of creating another combined PDF. Send a new key with each new combined PDF, and the same key each time you send the same request again, such as after a timeout, a network error or a 5xx. The same key with a different request is a 422 `idempotency_key_reused`. A 409 `idempotency_key_in_use` means the first request is still being processed: send the request again in a few seconds.
54
68
  # @return [CombinedPdf]
55
69
  describe 'create_combined_pdf test' do
56
70
  it 'should work' do
@@ -84,7 +98,7 @@ describe 'Client' do
84
98
 
85
99
  # unit tests for create_signature_request_event
86
100
  # Record a signature request event
87
- # Records something that happened outside DocSpring in the signature request's audit trail: you sent the request to the person (`send_request`). The audit trail shows it as reported by your account.
101
+ # Records something that happened outside DocSpring in the signature request's audit trail: you sent the request to the person (`send_request`). The audit trail shows it as reported by your account. A finished (completed, declined or expired) signature request's audit trail takes no more events, and a test API token can't record one for a live signature request.
88
102
  # @param signature_request_id The signature request's ID.
89
103
  # @param body The event to record.
90
104
  # @param [Hash] opts the optional parameters
@@ -115,7 +129,8 @@ describe 'Client' do
115
129
  # @param body The submission's data and settings.
116
130
  # @param [Hash] opts the optional parameters
117
131
  # @option opts [String] :version The template version to use: a published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `latest` (the draft when no version has been published).
118
- # @option opts [Boolean] :wait Wait until the PDF has been generated before responding. Default true on sync.api hosts.
132
+ # @option opts [Boolean] :wait Wait until the files have been generated before responding. Default true on sync.api hosts.
133
+ # @option opts [String] :idempotency_key A key of your own, such as a UUID, that makes it safe to send this request again: for 24 hours, DocSpring answers a request with the same key from the same API token with the first request's response (and an `Idempotent-Replayed: true` header) instead of creating another submission. Send a new key with each new submission, and the same key each time you send the same request again, such as after a timeout, a network error or a 5xx. The same key with a different request is a 422 `idempotency_key_reused`. A 409 `idempotency_key_in_use` means the first request is still being processed: send the request again in a few seconds.
119
134
  # @return [Submission]
120
135
  describe 'create_submission test' do
121
136
  it 'should work' do
@@ -129,6 +144,7 @@ describe 'Client' do
129
144
  # @param body The submissions to create, and the settings they share.
130
145
  # @param [Hash] opts the optional parameters
131
146
  # @option opts [Boolean] :wait Wait until every PDF in the batch has been generated before responding. Default true on sync.api hosts.
147
+ # @option opts [String] :idempotency_key A key of your own, such as a UUID, that makes it safe to send this request again: for 24 hours, DocSpring answers a request with the same key from the same API token with the first request's response (and an `Idempotent-Replayed: true` header) instead of creating another batch. Send a new key with each new batch, and the same key each time you send the same request again, such as after a timeout, a network error or a 5xx. The same key with a different request is a 422 `idempotency_key_reused`. A 409 `idempotency_key_in_use` means the first request is still being processed: send the request again in a few seconds.
132
148
  # @return [SubmissionBatch]
133
149
  describe 'create_submission_batch test' do
134
150
  it 'should work' do
@@ -141,7 +157,7 @@ describe 'Client' do
141
157
  # Creates an HTML template, or a PDF template from a PDF you uploaded with the presigned upload (GET /uploads/presign): pass its `fields.key` as `cache_id`. To send the PDF with the request instead, use POST /templates/upload. A PDF template is ready to generate PDFs once DocSpring has processed its PDF (`ready` is true). On sync.api hosts the request waits for that unless you pass `wait=false`.
142
158
  # @param body The template to create.
143
159
  # @param [Hash] opts the optional parameters
144
- # @option opts [Boolean] :wait Wait until the PDF has been processed before responding. Default true on sync.api hosts.
160
+ # @option opts [Boolean] :wait Wait until the PDF has been processed, and a `document_url` downloaded, before responding. Default true on sync.api hosts.
145
161
  # @return [Template]
146
162
  describe 'create_template test' do
147
163
  it 'should work' do
@@ -149,6 +165,20 @@ describe 'Client' do
149
165
  end
150
166
  end
151
167
 
168
+ # unit tests for create_template_preview
169
+ # Preview a template with data
170
+ # Makes PNG images of a template's pages filled in with the data you send (not a PDF), so you can check how an HTML or PDF template prints with your data before you publish a version or send live data. It renders the template's draft, or the published `version` you ask for. A preview makes no submission and uses no credits, and its pages are watermarked like a test submission's PDF. It's `pending` while it renders: get it with GET /templates/{template_id}/previews/{preview_id} until it's `processed`, with an image of each page, or `error`.
171
+ # @param template_id The template's ID.
172
+ # @param body The data to render the template with.
173
+ # @param [Hash] opts the optional parameters
174
+ # @option opts [String] :version A published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `draft`.
175
+ # @return [TemplatePreview]
176
+ describe 'create_template_preview test' do
177
+ it 'should work' do
178
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
179
+ end
180
+ end
181
+
152
182
  # unit tests for create_webhook
153
183
  # Create a webhook
154
184
  # Creates a webhook that sends a POST request to your endpoint whenever a subscribed event happens. Scope it to API tokens, templates or folders to receive only their events.
@@ -234,6 +264,20 @@ describe 'Client' do
234
264
  end
235
265
  end
236
266
 
267
+ # unit tests for generate_submission_files
268
+ # Generate more files
269
+ # Adds formats to a processed submission's files, in the background: `png`, a PNG image of each page of the PDF (up to 100 pages). To make them with the submission, add them to `output_formats` when you create it. Each new file is listed in `files` while it's made: on sync.api hosts the request waits for them (unless you pass `wait=false`), otherwise poll GET /submissions/{submission_id} until none of their `state` is `pending`. A file that couldn't be made has the state `error` and an `error_message`, and the submission stays processed. Asking for a format the submission already has (or is making) changes nothing.
270
+ # @param submission_id The submission's ID.
271
+ # @param body The formats to make.
272
+ # @param [Hash] opts the optional parameters
273
+ # @option opts [Boolean] :wait Wait until the files have been generated before responding. Default true on sync.api hosts.
274
+ # @return [Submission]
275
+ describe 'generate_submission_files test' do
276
+ it 'should work' do
277
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
278
+ end
279
+ end
280
+
237
281
  # unit tests for generate_submission_preview
238
282
  # Generate a preview PDF
239
283
  # Generates a preview of a submission's PDF in the background, such as for a submission still waiting for its signature requests. It's in `files.preview` once `preview_generated_at` changes.
@@ -343,13 +387,27 @@ describe 'Client' do
343
387
  end
344
388
  end
345
389
 
390
+ # unit tests for get_template_diff
391
+ # Compare a version of a template with the one before it
392
+ # Returns what changed in the template's draft since its latest published version (or in a published version since the one before it): fields added, removed, changed and moved, the settings that changed, and whether the document was replaced. Check it before you publish a version.
393
+ # @param template_id The template's ID.
394
+ # @param [Hash] opts the optional parameters
395
+ # @option opts [String] :version A published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `draft`.
396
+ # @return [TemplateDiff]
397
+ describe 'get_template_diff test' do
398
+ it 'should work' do
399
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
400
+ end
401
+ end
402
+
346
403
  # unit tests for get_template_model_code
347
404
  # Generate typed code for a template's submission data
348
- # Generates types for a template's submission data in TypeScript, JavaScript, Ruby, Python, PHP, Java, C#, Elixir or Go, so your app catches mistakes before it calls the API. `root_type_name` is the type of the whole `data` object. Java returns every class in `code`, each under a `// ClassName.java` comment. A template with no named fields returns 422.
405
+ # Generates types for a template's submission data in TypeScript, JavaScript, Ruby, Python, PHP, Java, C#, Elixir or Go, so your app catches mistakes before it calls the API. `root_type_name` is the type of the whole `data` object, and `just_types=true` leaves out the code that converts JSON to and from the types. Java returns every class in `code`, each under a `// ClassName.java` comment. A template with no named fields returns 422.
349
406
  # @param template_id The template's ID.
350
407
  # @param lang The language to generate the code in.
351
408
  # @param [Hash] opts the optional parameters
352
409
  # @option opts [String] :version The template version: a published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `latest` (the draft when no version has been published), the version a submission uses by default.
410
+ # @option opts [Boolean] :just_types Return only the types (interfaces, classes or structs), without the code that converts JSON to and from them. Default false. JavaScript has no types and PHP no types-only code, so theirs is the same either way.
353
411
  # @return [TemplateModelCode]
354
412
  describe 'get_template_model_code test' do
355
413
  it 'should work' do
@@ -357,6 +415,32 @@ describe 'Client' do
357
415
  end
358
416
  end
359
417
 
418
+ # unit tests for get_template_page_images
419
+ # Get images of a template's pages
420
+ # Returns a JPEG image of each page of a PDF template's PDF, with temporary links to download them: the draft's PDF, or a published version's. Use them to see the pages that fields are placed on.
421
+ # @param template_id The template's ID.
422
+ # @param [Hash] opts the optional parameters
423
+ # @option opts [String] :version A published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `draft`.
424
+ # @return [TemplatePageImages]
425
+ describe 'get_template_page_images test' do
426
+ it 'should work' do
427
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
428
+ end
429
+ end
430
+
431
+ # unit tests for get_template_preview
432
+ # Get a template preview
433
+ # Returns a preview made with POST /templates/{template_id}/previews. Once it's `processed`, `pages` has a PNG image of each page with a temporary link to download it: a preview has no PDF. Previews are deleted an hour after they're created.
434
+ # @param template_id The template's ID.
435
+ # @param preview_id The preview's ID.
436
+ # @param [Hash] opts the optional parameters
437
+ # @return [TemplatePreview]
438
+ describe 'get_template_preview test' do
439
+ it 'should work' do
440
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
441
+ end
442
+ end
443
+
360
444
  # unit tests for get_template_schema
361
445
  # Get the JSON Schema of a template's submission data
362
446
  # Returns the JSON Schema that a submission's `data` must match. Use it to check data before you create submissions, or to build a form for the template's fields.
@@ -424,7 +508,7 @@ describe 'Client' do
424
508
 
425
509
  # unit tests for list_submissions
426
510
  # List submissions
427
- # Returns the submissions in your account, newest first, one page at a time. Lists leave out each submission's `data` unless you pass `include_data=true`.
511
+ # Returns the submissions in your account, newest first, one page at a time. Each one is a summary: its `data` is null unless you pass `include_data=true`, and its `files` are empty unless you pass `include_files=true`. Get a submission by its ID for its signature requests, uploads and page images.
428
512
  # @param [Hash] opts the optional parameters
429
513
  # @option opts [String] :template_id Only list this template's submissions.
430
514
  # @option opts [Boolean] :test Only list test submissions (true) or live submissions (false).
@@ -433,6 +517,8 @@ describe 'Client' do
433
517
  # @option opts [Boolean] :include_data Include each submission's `data` (null without it).
434
518
  # @option opts [Integer] :limit How many items to return (1-100, default 50).
435
519
  # @option opts [String] :cursor The previous page's `next_cursor`, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.
520
+ # @option opts [SubmissionState] :state Only list submissions in this state (one state per request). The ones that failed are `invalid_data`, `error`, `syntax_error`, `image_download_failed` and `image_processing_failed`, and one still `pending` an hour after it was created is stuck.
521
+ # @option opts [Boolean] :include_files Include each submission's generated files and their download links (`files`, empty without it), without the page images' links.
436
522
  # @return [SubmissionList]
437
523
  describe 'list_submissions test' do
438
524
  it 'should work' do
@@ -440,6 +526,19 @@ describe 'Client' do
440
526
  end
441
527
  end
442
528
 
529
+ # unit tests for list_template_fields
530
+ # List a template's fields
531
+ # Returns a template's fields with all of their settings, page by page: the draft's fields, or a published version's. A PDF template's fields are placed on its pages: GET /templates/{template_id}/page_images has images of the pages.
532
+ # @param template_id The template's ID.
533
+ # @param [Hash] opts the optional parameters
534
+ # @option opts [String] :version A published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `draft`.
535
+ # @return [TemplateFields]
536
+ describe 'list_template_fields test' do
537
+ it 'should work' do
538
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
539
+ end
540
+ end
541
+
443
542
  # unit tests for list_template_submissions
444
543
  # List a template's submissions
445
544
  # Returns a template's submissions (from every version of the template), newest first.
@@ -451,6 +550,8 @@ describe 'Client' do
451
550
  # @option opts [Boolean] :include_data Include each submission's `data` (null without it).
452
551
  # @option opts [Integer] :limit How many items to return (1-100, default 50).
453
552
  # @option opts [String] :cursor The previous page's `next_cursor`, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.
553
+ # @option opts [SubmissionState] :state Only list submissions in this state (one state per request). The ones that failed are `invalid_data`, `error`, `syntax_error`, `image_download_failed` and `image_processing_failed`, and one still `pending` an hour after it was created is stuck.
554
+ # @option opts [Boolean] :include_files Include each submission's generated files and their download links (`files`, empty without it), without the page images' links.
454
555
  # @return [SubmissionList]
455
556
  describe 'list_template_submissions test' do
456
557
  it 'should work' do
@@ -460,7 +561,7 @@ describe 'Client' do
460
561
 
461
562
  # unit tests for list_templates
462
563
  # List templates
463
- # Returns the templates in your account (their drafts), newest first, one page at a time. Get a template by its ID for its HTML, defaults and published versions.
564
+ # Returns the templates in your account (their drafts), newest first, one page at a time. Each one is a summary: get a template by its ID for its settings, its PDF in full, its HTML, defaults and published versions.
464
565
  # @param [Hash] opts the optional parameters
465
566
  # @option opts [String] :query Only list templates whose name contains this text (ignoring case).
466
567
  # @option opts [String] :parent_folder_id Only list the templates in this folder (not in its subfolders).
@@ -519,7 +620,7 @@ describe 'Client' do
519
620
 
520
621
  # unit tests for publish_template_version
521
622
  # Publish a template version
522
- # Publishes the template's draft as a new version that doesn't change. `version_type` says which part of the latest version number goes up.
623
+ # Publishes the template's draft as a new version that doesn't change. `version_type` says which part of the latest version number goes up. While the template's PDF is downloading or being processed, or DocSpring is setting up its fields, it returns a 409 that says so.
523
624
  # @param template_id The template's ID.
524
625
  # @param body The version to publish.
525
626
  # @param [Hash] opts the optional parameters
@@ -530,6 +631,19 @@ describe 'Client' do
530
631
  end
531
632
  end
532
633
 
634
+ # unit tests for remove_template_fields
635
+ # Remove fields from a template
636
+ # Removes fields from a template's draft and returns the fields that are left. Conditional logic that used only the removed fields is removed too.
637
+ # @param template_id The template's ID.
638
+ # @param body The fields to remove from the template's draft.
639
+ # @param [Hash] opts the optional parameters
640
+ # @return [TemplateFields]
641
+ describe 'remove_template_fields test' do
642
+ it 'should work' do
643
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
644
+ end
645
+ end
646
+
533
647
  # unit tests for rename_folder
534
648
  # Rename a folder
535
649
  # Renames a folder. The name must be unique within its parent folder.
@@ -543,6 +657,19 @@ describe 'Client' do
543
657
  end
544
658
  end
545
659
 
660
+ # unit tests for reorder_template_fields
661
+ # Reorder a template's fields
662
+ # Changes the order of the fields in a template's draft and returns them in their new order. Send every field's ID: each field stays on its page, and a page's fields are printed in this order, so a later field prints over an earlier one where they overlap. Their values are in this order in the template's data schema and forms.
663
+ # @param template_id The template's ID.
664
+ # @param body The new order of the fields in the template's draft.
665
+ # @param [Hash] opts the optional parameters
666
+ # @return [TemplateFields]
667
+ describe 'reorder_template_fields test' do
668
+ it 'should work' do
669
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
670
+ end
671
+ end
672
+
546
673
  # unit tests for restore_template_version
547
674
  # Restore a template version
548
675
  # Replaces the template's draft with a copy of one of its published versions.
@@ -582,7 +709,7 @@ describe 'Client' do
582
709
 
583
710
  # unit tests for update_template
584
711
  # Update a template
585
- # Changes a template's draft. Properties left out keep their values. `defaults` and `html_engine_options` replace the whole object. Setting `parent_folder_id` moves the template and all of its published versions.
712
+ # Changes a template's draft. Properties left out keep their values. `defaults` and `html_engine_options` replace the whole object, and `field_groups` changes only the groups it lists. Setting `parent_folder_id` moves the template and all of its published versions.
586
713
  # @param template_id The template's ID.
587
714
  # @param body The settings to change. Properties left out keep their values.
588
715
  # @param [Hash] opts the optional parameters
@@ -595,11 +722,11 @@ describe 'Client' do
595
722
 
596
723
  # unit tests for update_template_document
597
724
  # Replace a template's PDF
598
- # Replaces a PDF template's PDF with one you uploaded with the presigned upload (GET /uploads/presign). The fields stay where they are, unless `reimport_fields` replaces them with the new PDF's fillable fields. To send the PDF with the request instead, use PUT /templates/{template_id}/document/upload.
725
+ # Replaces a PDF template's PDF with one you uploaded with the presigned upload (GET /uploads/presign) (`cache_id`), a link to download it from (`document_url`), or the file in base64 (`document_base64`). The fields stay where they are, unless `reimport_fields` replaces them with the new PDF's fillable fields. To send the PDF as `multipart/form-data` instead, use PUT /templates/{template_id}/document/upload.
599
726
  # @param template_id The template's ID.
600
- # @param body The new PDF.
727
+ # @param body The new PDF, as one of `cache_id`, `document_url` and `document_base64`.
601
728
  # @param [Hash] opts the optional parameters
602
- # @option opts [Boolean] :wait Wait until the PDF has been processed before responding. Default true on sync.api hosts.
729
+ # @option opts [Boolean] :wait Wait until the PDF has been processed, and a `document_url` downloaded, before responding. Default true on sync.api hosts.
603
730
  # @return [Template]
604
731
  describe 'update_template_document test' do
605
732
  it 'should work' do
@@ -607,6 +734,19 @@ describe 'Client' do
607
734
  end
608
735
  end
609
736
 
737
+ # unit tests for update_template_fields
738
+ # Update a template's fields
739
+ # Changes fields of a template's draft and returns all of its fields. Settings left out keep their values. A shared setting (`type`, `required`, `default`, ...) changes for every field with the same name.
740
+ # @param template_id The template's ID.
741
+ # @param body The fields to change in the template's draft.
742
+ # @param [Hash] opts the optional parameters
743
+ # @return [TemplateFields]
744
+ describe 'update_template_fields test' do
745
+ it 'should work' do
746
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
747
+ end
748
+ end
749
+
610
750
  # unit tests for update_webhook
611
751
  # Update a webhook
612
752
  # Updates a webhook. Only the properties you send change.
@@ -625,7 +765,7 @@ describe 'Client' do
625
765
  # Creates a PDF template from a PDF sent with the request (`multipart/form-data`). For large files, upload the PDF with the presigned upload (GET /uploads/presign) and create the template with POST /templates.
626
766
  # @param document The PDF.
627
767
  # @param [Hash] opts the optional parameters
628
- # @option opts [Boolean] :wait Wait until the PDF has been processed before responding. Default true on sync.api hosts.
768
+ # @option opts [Boolean] :wait Wait until the PDF has been processed, and a `document_url` downloaded, before responding. Default true on sync.api hosts.
629
769
  # @option opts [String] :name The template's name.
630
770
  # @option opts [String] :description The template's description.
631
771
  # @option opts [String] :parent_folder_id The folder to put the template in. Left out, it's created at the root.
@@ -647,7 +787,7 @@ describe 'Client' do
647
787
  # @param template_id The template's ID.
648
788
  # @param document The new PDF.
649
789
  # @param [Hash] opts the optional parameters
650
- # @option opts [Boolean] :wait Wait until the PDF has been processed before responding. Default true on sync.api hosts.
790
+ # @option opts [Boolean] :wait Wait until the PDF has been processed, and a `document_url` downloaded, before responding. Default true on sync.api hosts.
651
791
  # @option opts [Boolean] :reimport_fields Replace all of the template's fields with the fillable fields in the new PDF, once DocSpring has processed it (`document.field_reimport_state`). As on a first upload, the default typeface, font size, bold and color are taken from the PDF's fields; the template's other settings are kept. If the PDF has no fillable fields, the template keeps its fields. A locked template can't re-import its fields.
652
792
  # @return [Template]
653
793
  describe 'upload_template_document test' do
@@ -656,4 +796,18 @@ describe 'Client' do
656
796
  end
657
797
  end
658
798
 
799
+ # unit tests for validate_submission
800
+ # Check a submission without creating it
801
+ # Checks a submission as creating it would (its data against the template's fields, its settings and signature requests) without saving it, generating anything or using credits. It doesn't check your account's credits. The response says whether the submission is valid, and if not, has the error that creating it would return.
802
+ # @param template_id The template's ID.
803
+ # @param body The submission's data and settings.
804
+ # @param [Hash] opts the optional parameters
805
+ # @option opts [String] :version The template version to use: a published version (`1.2.0`, or `1` for the latest 1.x.x), `latest` or `draft`. Default `latest` (the draft when no version has been published).
806
+ # @return [SubmissionValidation]
807
+ describe 'validate_submission test' do
808
+ it 'should work' do
809
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
810
+ end
811
+ end
812
+
659
813
  end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #DocSpring API
3
+
4
+ #Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
5
+
6
+ The version of the OpenAPI document: v2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0-DOCSPRING
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for DocSpring::AddTemplateFieldsRequest
18
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
+ # Please update as you see appropriate
20
+ describe DocSpring::AddTemplateFieldsRequest do
21
+ #let(:instance) { DocSpring::AddTemplateFieldsRequest.new }
22
+
23
+ describe 'test an instance of AddTemplateFieldsRequest' do
24
+ it 'should create an instance of AddTemplateFieldsRequest' do
25
+ # uncomment below to test the instance creation
26
+ #expect(instance).to be_instance_of(DocSpring::AddTemplateFieldsRequest)
27
+ end
28
+ end
29
+
30
+ describe 'test attribute "fields"' do
31
+ it 'should work' do
32
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
33
+ end
34
+ end
35
+
36
+ end
@@ -51,6 +51,12 @@ describe DocSpring::CreateSubmissionBatchRequest do
51
51
  end
52
52
  end
53
53
 
54
+ describe 'test attribute "output_formats"' do
55
+ it 'should work' do
56
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
57
+ end
58
+ end
59
+
54
60
  describe 'test attribute "submissions"' do
55
61
  it 'should work' do
56
62
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
@@ -57,6 +57,12 @@ describe DocSpring::CreateSubmissionRequest do
57
57
  end
58
58
  end
59
59
 
60
+ describe 'test attribute "output_formats"' do
61
+ it 'should work' do
62
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
63
+ end
64
+ end
65
+
60
66
  describe 'test attribute "expires_in"' do
61
67
  it 'should work' do
62
68
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #DocSpring API
3
+
4
+ #Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
5
+
6
+ The version of the OpenAPI document: v2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0-DOCSPRING
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for DocSpring::CreateTemplatePreviewRequest
18
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
+ # Please update as you see appropriate
20
+ describe DocSpring::CreateTemplatePreviewRequest do
21
+ #let(:instance) { DocSpring::CreateTemplatePreviewRequest.new }
22
+
23
+ describe 'test an instance of CreateTemplatePreviewRequest' do
24
+ it 'should create an instance of CreateTemplatePreviewRequest' do
25
+ # uncomment below to test the instance creation
26
+ #expect(instance).to be_instance_of(DocSpring::CreateTemplatePreviewRequest)
27
+ end
28
+ end
29
+
30
+ describe 'test attribute "data"' do
31
+ it 'should work' do
32
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
33
+ end
34
+ end
35
+
36
+ end