docspring 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +39 -0
  3. data/.openapi-generator-ignore +23 -0
  4. data/.openapi-generator/VERSION +1 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +154 -0
  7. data/.swagger-codegen-ignore +31 -0
  8. data/.swagger-codegen/VERSION +1 -0
  9. data/.swagger-revision +1 -0
  10. data/.travis.yml +8 -0
  11. data/CHANGELOG.md +48 -0
  12. data/Gemfile +8 -0
  13. data/Gemfile.lock +80 -0
  14. data/LICENSE +7 -0
  15. data/README.md +162 -0
  16. data/Rakefile +10 -0
  17. data/docs/AuthenticationError.md +9 -0
  18. data/docs/AuthenticationSuccessResponse.md +8 -0
  19. data/docs/CombinePdfsData.md +12 -0
  20. data/docs/CombinedSubmission.md +16 -0
  21. data/docs/CombinedSubmissionAction.md +13 -0
  22. data/docs/CombinedSubmissionData.md +11 -0
  23. data/docs/CreateCombinedSubmissionResponse.md +10 -0
  24. data/docs/CreateCustomFileData.md +8 -0
  25. data/docs/CreateCustomFileResponse.md +10 -0
  26. data/docs/CreateFolderData.md +8 -0
  27. data/docs/CreateSubmissionBatchResponse.md +12 -0
  28. data/docs/CreateSubmissionBatchSubmissionsResponse.md +10 -0
  29. data/docs/CreateSubmissionDataRequestData.md +20 -0
  30. data/docs/CreateSubmissionDataRequestTokenResponse.md +10 -0
  31. data/docs/CreateSubmissionDataRequestTokenResponseToken.md +11 -0
  32. data/docs/CreateSubmissionResponse.md +10 -0
  33. data/docs/CreateTemplateData.md +8 -0
  34. data/docs/CustomFile.md +9 -0
  35. data/docs/Error.md +9 -0
  36. data/docs/Folder.md +11 -0
  37. data/docs/FoldersFolder.md +9 -0
  38. data/docs/InvalidRequest.md +9 -0
  39. data/docs/MoveFolderData.md +8 -0
  40. data/docs/MoveTemplateData.md +8 -0
  41. data/docs/PDFApi.md +1385 -0
  42. data/docs/PendingTemplate.md +22 -0
  43. data/docs/RenameFolderData.md +8 -0
  44. data/docs/Submission.md +21 -0
  45. data/docs/SubmissionAction.md +13 -0
  46. data/docs/SubmissionBatch.md +16 -0
  47. data/docs/SubmissionBatchData.md +11 -0
  48. data/docs/SubmissionData.md +13 -0
  49. data/docs/SubmissionDataBatchRequest.md +13 -0
  50. data/docs/SubmissionDataRequest.md +24 -0
  51. data/docs/Template.md +25 -0
  52. data/docs/Templatesv2Template.md +19 -0
  53. data/docs/Templatesv2TemplateDocument.md +10 -0
  54. data/docs/Templatesv2TemplateDocumentMetadata.md +10 -0
  55. data/docs/UpdateDataRequestResponse.md +10 -0
  56. data/docs/UpdateSubmissionDataRequestData.md +20 -0
  57. data/docspring.gemspec +47 -0
  58. data/git_push.sh +55 -0
  59. data/lib/docspring.rb +82 -0
  60. data/lib/docspring/api/client.rb +174 -0
  61. data/lib/docspring/api/pdf_api.rb +1481 -0
  62. data/lib/docspring/api_client.rb +406 -0
  63. data/lib/docspring/api_error.rb +38 -0
  64. data/lib/docspring/configuration.rb +230 -0
  65. data/lib/docspring/models/authentication_error.rb +231 -0
  66. data/lib/docspring/models/authentication_success_response.rb +217 -0
  67. data/lib/docspring/models/combine_pdfs_data.rb +226 -0
  68. data/lib/docspring/models/combined_submission.rb +295 -0
  69. data/lib/docspring/models/combined_submission_action.rb +316 -0
  70. data/lib/docspring/models/combined_submission_data.rb +217 -0
  71. data/lib/docspring/models/create_combined_submission_response.rb +237 -0
  72. data/lib/docspring/models/create_custom_file_data.rb +207 -0
  73. data/lib/docspring/models/create_custom_file_response.rb +237 -0
  74. data/lib/docspring/models/create_folder_data.rb +188 -0
  75. data/lib/docspring/models/create_submission_batch_response.rb +257 -0
  76. data/lib/docspring/models/create_submission_batch_submissions_response.rb +237 -0
  77. data/lib/docspring/models/create_submission_data_request_data.rb +339 -0
  78. data/lib/docspring/models/create_submission_data_request_token_response.rb +237 -0
  79. data/lib/docspring/models/create_submission_data_request_token_response_token.rb +210 -0
  80. data/lib/docspring/models/create_submission_response.rb +237 -0
  81. data/lib/docspring/models/create_template_data.rb +188 -0
  82. data/lib/docspring/models/custom_file.rb +192 -0
  83. data/lib/docspring/models/error.rb +236 -0
  84. data/lib/docspring/models/folder.rb +210 -0
  85. data/lib/docspring/models/folders_folder.rb +192 -0
  86. data/lib/docspring/models/invalid_request.rb +238 -0
  87. data/lib/docspring/models/move_folder_data.rb +183 -0
  88. data/lib/docspring/models/move_template_data.rb +183 -0
  89. data/lib/docspring/models/pending_template.rb +343 -0
  90. data/lib/docspring/models/rename_folder_data.rb +188 -0
  91. data/lib/docspring/models/submission.rb +358 -0
  92. data/lib/docspring/models/submission_action.rb +316 -0
  93. data/lib/docspring/models/submission_batch.rb +291 -0
  94. data/lib/docspring/models/submission_batch_data.rb +217 -0
  95. data/lib/docspring/models/submission_data.rb +235 -0
  96. data/lib/docspring/models/submission_data_batch_request.rb +228 -0
  97. data/lib/docspring/models/submission_data_request.rb +422 -0
  98. data/lib/docspring/models/template.rb +372 -0
  99. data/lib/docspring/models/templatesv2_template.rb +316 -0
  100. data/lib/docspring/models/templatesv2_template_document.rb +235 -0
  101. data/lib/docspring/models/templatesv2_template_document_metadata.rb +235 -0
  102. data/lib/docspring/models/update_data_request_response.rb +237 -0
  103. data/lib/docspring/models/update_submission_data_request_data.rb +339 -0
  104. data/lib/docspring/version.rb +15 -0
  105. data/spec/api/client_integration_spec.rb +259 -0
  106. data/spec/api/pdf_api_integration_spec.rb +377 -0
  107. data/spec/api/pdf_api_spec_original.skipped.rb +397 -0
  108. data/spec/api_client_spec.rb +226 -0
  109. data/spec/configuration_spec.rb +53 -0
  110. data/spec/models/authentication_error_spec.rb +51 -0
  111. data/spec/models/authentication_success_response_spec.rb +45 -0
  112. data/spec/models/combine_pdfs_data_spec.rb +65 -0
  113. data/spec/models/combined_submission_action_spec.rb +83 -0
  114. data/spec/models/combined_submission_data_spec.rb +59 -0
  115. data/spec/models/combined_submission_spec.rb +93 -0
  116. data/spec/models/create_combined_submission_response_spec.rb +57 -0
  117. data/spec/models/create_custom_file_data_spec.rb +41 -0
  118. data/spec/models/create_custom_file_response_spec.rb +57 -0
  119. data/spec/models/create_folder_data_spec.rb +41 -0
  120. data/spec/models/create_submission_batch_response_spec.rb +69 -0
  121. data/spec/models/create_submission_batch_submissions_response_spec.rb +57 -0
  122. data/spec/models/create_submission_data_request_data_spec.rb +121 -0
  123. data/spec/models/create_submission_data_request_token_response_spec.rb +57 -0
  124. data/spec/models/create_submission_data_request_token_response_token_spec.rb +59 -0
  125. data/spec/models/create_submission_response_spec.rb +57 -0
  126. data/spec/models/create_template_data_spec.rb +41 -0
  127. data/spec/models/custom_file_spec.rb +47 -0
  128. data/spec/models/error_spec.rb +51 -0
  129. data/spec/models/folder_spec.rb +59 -0
  130. data/spec/models/folders_folder_spec.rb +47 -0
  131. data/spec/models/invalid_request_spec.rb +51 -0
  132. data/spec/models/move_folder_data_spec.rb +41 -0
  133. data/spec/models/move_template_data_spec.rb +41 -0
  134. data/spec/models/pending_template_spec.rb +129 -0
  135. data/spec/models/rename_folder_data_spec.rb +41 -0
  136. data/spec/models/submission_action_spec.rb +83 -0
  137. data/spec/models/submission_batch_data_spec.rb +59 -0
  138. data/spec/models/submission_batch_spec.rb +93 -0
  139. data/spec/models/submission_data_batch_request_spec.rb +71 -0
  140. data/spec/models/submission_data_request_spec.rb +149 -0
  141. data/spec/models/submission_data_spec.rb +71 -0
  142. data/spec/models/submission_spec.rb +123 -0
  143. data/spec/models/template_spec.rb +147 -0
  144. data/spec/models/templatesv2_template_document_metadata_spec.rb +57 -0
  145. data/spec/models/templatesv2_template_document_spec.rb +57 -0
  146. data/spec/models/templatesv2_template_spec.rb +111 -0
  147. data/spec/models/update_data_request_response_spec.rb +57 -0
  148. data/spec/models/update_submission_data_request_data_spec.rb +121 -0
  149. data/spec/spec_helper.rb +117 -0
  150. metadata +430 -0
@@ -0,0 +1,15 @@
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
+ module DocSpring
14
+ VERSION = '1.0.0'
15
+ end
@@ -0,0 +1,259 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe DocSpring::Client do
5
+ before do
6
+ DocSpring.configure do |c|
7
+ c.api_token_id = 'api_token123'
8
+ c.api_token_secret = 'testsecret123'
9
+ c.host = 'http://api.docspring.local:31337'
10
+ end
11
+ end
12
+
13
+ describe '#generate_pdf' do
14
+ it 'should generate a PDF and wait for the submission to be processed' do
15
+ client = DocSpring::Client.new
16
+ template_id = 'tpl_000000000000000001'
17
+
18
+ expect(client).to receive(:sleep).with(1).once
19
+
20
+ response = client.generate_pdf(
21
+ template_id: template_id,
22
+ data: {
23
+ title: 'Test PDF',
24
+ description: 'This PDF is great!',
25
+ }
26
+ )
27
+
28
+ expect(response.status).to eq 'success'
29
+ submission = response.submission
30
+ expect(submission.id).to start_with 'sub_'
31
+ expect(submission.expired).to eq false
32
+ expect(submission.state).to eq 'processed'
33
+ expect(submission.download_url).to include 'submissions/submission.pdf'
34
+ end
35
+
36
+ it 'should handle invalid data errors' do
37
+ client = DocSpring::Client.new
38
+ template_id = 'tpl_000000000000000001'
39
+
40
+ expect(client).to_not receive(:sleep)
41
+
42
+ expect {
43
+ client.generate_pdf(
44
+ template_id: template_id,
45
+ data: {
46
+ title: 'Test PDF'
47
+ }
48
+ )
49
+ }.to raise_error(
50
+ DocSpring::ApiError,
51
+ 'Unprocessable Entity: The root object did not contain a ' \
52
+ "required property of 'description'"
53
+ )
54
+ end
55
+ end
56
+
57
+ describe '#batch_generate_pdfs' do
58
+ it 'should submit a batch job and wait for all jobs to be processed' do
59
+ client = DocSpring::Client.new
60
+ template_id = 'tpl_000000000000000001'
61
+
62
+ expect(client).to receive(:sleep).with(1).once
63
+
64
+ response = client.batch_generate_pdfs(
65
+ metadata: { user_id: 123 },
66
+ test: true,
67
+ submissions: [
68
+ {
69
+ template_id: template_id,
70
+ data: {
71
+ title: 'Test PDF',
72
+ description: 'This PDF is great!',
73
+ }
74
+ },
75
+ {
76
+ template_id: template_id,
77
+ data: {
78
+ title: 'Test PDF 2',
79
+ description: 'This PDF is also great!',
80
+ }
81
+ }
82
+ ]
83
+ )
84
+
85
+ expect(response.status).to eq 'success'
86
+ batch = response.submission_batch
87
+ expect(batch.id).to start_with 'sbb_'
88
+ expect(batch.state).to eq 'processed'
89
+ expect(batch.total_count).to eq 2
90
+ expect(batch.pending_count).to eq 0
91
+ expect(batch.error_count).to eq 0
92
+ expect(batch.completion_percentage).to eq 100
93
+
94
+ expect(response.submissions.size).to eq 2
95
+ submission_response1 = response.submissions[0]
96
+ expect(submission_response1.status).to eq 'success'
97
+ submission1 = submission_response1.submission
98
+ expect(submission1.id).to start_with 'sub_'
99
+ expect(submission1.expired).to eq false
100
+ expect(submission1.state).to eq 'processed'
101
+ expect(submission1.download_url).to include 'submissions/submission.pdf'
102
+
103
+ submission_response2 = response.submissions[1]
104
+ expect(submission_response2.status).to eq 'success'
105
+ submission2 = submission_response2.submission
106
+ expect(submission2.id).to start_with 'sub_'
107
+ expect(submission2.expired).to eq false
108
+ expect(submission2.state).to eq 'processed'
109
+ end
110
+
111
+ it 'generates no PDFs if there are any errors' do
112
+ client = DocSpring::Client.new
113
+ template_id = 'tpl_000000000000000001'
114
+
115
+ # Response is immediately an error so no need to poll
116
+ expect(client).to_not receive(:sleep)
117
+
118
+ response = client.batch_generate_pdfs(
119
+ metadata: { user_id: 123 },
120
+ test: true,
121
+ submissions: [
122
+ {
123
+ template_id: template_id,
124
+ data: {
125
+ title: 'Test PDF',
126
+ description: 'This PDF is great!',
127
+ }
128
+ },
129
+ {
130
+ template_id: template_id,
131
+ data: {
132
+ description: 'This PDF is also great!',
133
+ }
134
+ }
135
+ ]
136
+ )
137
+
138
+ expect(response.status).to eq 'error'
139
+ batch = response.submission_batch
140
+ expect(batch.id).to start_with 'sbb_'
141
+ expect(batch.state).to eq 'error'
142
+ expect(batch.total_count).to eq 2
143
+ expect(batch.pending_count).to eq 0
144
+ expect(batch.error_count).to eq 1
145
+ expect(batch.completion_percentage).to eq 100
146
+
147
+ expect(response.submissions.size).to eq 2
148
+ submission_response1 = response.submissions[0]
149
+ expect(submission_response1.status).to eq 'valid_but_not_saved'
150
+ expect(submission_response1.submission).to be_nil
151
+
152
+ submission_response2 = response.submissions[1]
153
+ expect(submission_response2.status).to eq 'error'
154
+ submission2 = submission_response2.submission
155
+ expect(submission2.id).to start_with 'sub_'
156
+ expect(submission2.expired).to eq false
157
+ expect(submission2.state).to eq 'invalid_data'
158
+ end
159
+ end
160
+
161
+ describe '#combine_submissions with submission_ids' do
162
+ it 'should merge multiple PDFs and wait for the job to be processed' do
163
+ client = DocSpring::Client.new
164
+ expect(client).to receive(:sleep).with(1).once
165
+
166
+ response = client.combine_submissions(
167
+ submission_ids: %w[sub_000000000000000001 sub_000000000000000002])
168
+
169
+ expect(response.status).to eq 'success'
170
+ combined_submission = response.combined_submission
171
+ expect(combined_submission.id).to start_with 'com_'
172
+ expect(combined_submission.expired).to eq false
173
+ expect(combined_submission.state).to eq 'processed'
174
+ expect(combined_submission.source_pdfs).to eq(
175
+ [
176
+ { type: 'submission', id: 'sub_000000000000000001' },
177
+ { type: 'submission', id: 'sub_000000000000000002' }
178
+ ]
179
+ )
180
+ # Backwards compatibility - We still set submission_ids
181
+ expect(combined_submission.submission_ids).to eq(
182
+ %w[sub_000000000000000001 sub_000000000000000002])
183
+ expect(combined_submission.download_url).to include(
184
+ 'combined_submissions/combined_submission.pdf')
185
+ end
186
+ end
187
+
188
+ describe '#combine_pdfs with source_pdfs' do
189
+ it 'should merge multiple PDFs and wait for the job to be processed' do
190
+ client = DocSpring::Client.new
191
+ expect(client).to receive(:sleep).with(1).once
192
+
193
+ response = client.combine_pdfs(
194
+ source_pdfs: [
195
+ { type: 'submission', id: 'sub_000000000000000001' },
196
+ { type: 'template', id: 'tpl_000000000000000001' },
197
+ { type: 'submission', id: 'sub_000000000000000002' }
198
+ ]
199
+ )
200
+
201
+ expect(response.status).to eq 'success'
202
+ combined_submission = response.combined_submission
203
+ expect(combined_submission.id).to start_with 'com_'
204
+ expect(combined_submission.expired).to eq false
205
+ expect(combined_submission.state).to eq 'processed'
206
+ expect(combined_submission.source_pdfs).to eq(
207
+ [
208
+ { type: 'submission', id: 'sub_000000000000000001' },
209
+ { type: 'template', id: 'tpl_000000000000000001' },
210
+ { type: 'submission', id: 'sub_000000000000000002' }
211
+ ]
212
+ )
213
+ expect(combined_submission.download_url).to include(
214
+ 'combined_submissions/combined_submission.pdf')
215
+ end
216
+ end
217
+
218
+ describe '#batch_generate_and_combine_pdfs' do
219
+ it 'should submit a batch job and combine the PDFs into a single PDF' do
220
+ client = DocSpring::Client.new
221
+ template_id = 'tpl_000000000000000001'
222
+
223
+ expect(client).to receive(:sleep).with(1).twice
224
+
225
+ response = client.batch_generate_and_combine_pdfs(
226
+ metadata: { user_id: 123 },
227
+ test: true,
228
+ submissions: [
229
+ {
230
+ template_id: template_id,
231
+ data: {
232
+ title: 'Test PDF',
233
+ description: 'This PDF is great!',
234
+ }
235
+ },
236
+ {
237
+ template_id: template_id,
238
+ data: {
239
+ title: 'Test PDF 2',
240
+ description: 'This PDF is also great!',
241
+ }
242
+ }
243
+ ]
244
+ )
245
+
246
+ expect(response.status).to eq 'success'
247
+ combined_submission = response.combined_submission
248
+ expect(combined_submission.id).to start_with 'com_'
249
+ expect(combined_submission.expired).to eq false
250
+ expect(combined_submission.state).to eq 'processed'
251
+ expect(combined_submission.submission_ids.count).to eq 2
252
+ combined_submission.submission_ids.each do |sub_id|
253
+ expect(sub_id).to start_with 'sub_'
254
+ end
255
+ expect(combined_submission.download_url).to include(
256
+ 'combined_submissions/combined_submission.pdf')
257
+ end
258
+ end
259
+ end
@@ -0,0 +1,377 @@
1
+ =begin
2
+ #API V1
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for DocSpring::PDFApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'PDFApi' do
20
+ before do
21
+ DocSpring.configure do |c|
22
+ c.api_token_id = 'api_token123'
23
+ c.api_token_secret = 'testsecret123'
24
+ c.host = 'http://api.docspring.local:31337'
25
+ end
26
+ end
27
+
28
+ let(:api_instance) { DocSpring::PDFApi.new }
29
+
30
+ after do
31
+ # run after each test
32
+ end
33
+
34
+ # integration tests for batch_generate_pdf (v1)
35
+ # Generates multiple PDFs
36
+ # @param template_id
37
+ # @param create_submission_data
38
+ # @param [Hash] opts the optional parameters
39
+ # @return [Array<CreateSubmissionResponse>]
40
+ describe 'batch_generate_pdf v1 test' do
41
+ it 'should work' do
42
+ template_id = 'tpl_000000000000000001'
43
+ responses = api_instance.batch_generate_pdf_v1(template_id, [
44
+ {
45
+ data: {
46
+ title: 'Test PDF',
47
+ description: 'This PDF is great!',
48
+ }
49
+ },
50
+ {
51
+ data: {
52
+ title: 'Test PDF 2',
53
+ description: 'This PDF is also great!',
54
+ }
55
+ }
56
+ ])
57
+ expect(responses.size).to eq 2
58
+ expect(responses.first.status).to eq 'success'
59
+ submission = responses.first.submission
60
+ expect(submission.id).to start_with 'sub_'
61
+ expect(submission.expired).to eq false
62
+ expect(submission.state).to eq 'pending'
63
+ end
64
+ end
65
+
66
+ # Integration tests for batch_generate_pdf (v2)
67
+ describe 'batch_generate_pdfs v2 test' do
68
+ it 'should work' do
69
+ template_id = 'tpl_000000000000000001'
70
+ response = api_instance.batch_generate_pdfs(
71
+ metadata: { user_id: 123 },
72
+ test: true,
73
+ submissions: [
74
+ {
75
+ template_id: template_id,
76
+ data: {
77
+ title: 'Test PDF',
78
+ description: 'This PDF is great!',
79
+ }
80
+ },
81
+ {
82
+ template_id: template_id,
83
+ data: {
84
+ title: 'Test PDF 2',
85
+ description: 'This PDF is also great!',
86
+ }
87
+ }
88
+ ]
89
+ )
90
+ expect(response.status).to eq 'success'
91
+ batch = response.submission_batch
92
+ expect(batch.id).to start_with 'sbb_'
93
+ expect(batch.state).to eq 'pending'
94
+ expect(batch.total_count).to eq 2
95
+ expect(batch.pending_count).to eq 2
96
+ expect(batch.error_count).to eq 0
97
+ expect(batch.completion_percentage).to eq 0
98
+
99
+ expect(response.submissions.size).to eq 2
100
+ submission_response = response.submissions.first
101
+ expect(submission_response.status).to eq 'success'
102
+ submission = submission_response.submission
103
+ expect(submission.id).to start_with 'sub_'
104
+ expect(submission.expired).to eq false
105
+ expect(submission.state).to eq 'pending'
106
+ end
107
+ end
108
+
109
+ describe 'get_submission_batch test' do
110
+ it 'should get the batch including submissions' do
111
+ submission_batch_id = 'sbb_000000000000000001'
112
+ batch = api_instance.get_submission_batch(submission_batch_id, include_submissions: true)
113
+ expect(batch.id).to eq 'sbb_000000000000000001'
114
+ expect(batch.total_count).to eq 2
115
+ expect(batch.pending_count).to eq 0
116
+ expect(batch.completion_percentage).to eq 100
117
+ expect(batch.state).to eq 'processed'
118
+ expect(batch.submissions.count).to eq 2
119
+ end
120
+
121
+ it 'should get the batch without submissions' do
122
+ submission_batch_id = 'sbb_000000000000000001'
123
+ batch = api_instance.get_submission_batch(submission_batch_id)
124
+ expect(batch.id).to eq 'sbb_000000000000000001'
125
+ expect(batch.submissions).to be_nil
126
+ end
127
+ end
128
+
129
+ # integration tests for combine_submissions
130
+ # Merge generated PDFs together
131
+ # @param [Hash] opts the optional parameters
132
+ # @option opts [CombinedSubmissionData] :combined_submission_data
133
+ # @return [CreateCombinedSubmissionResponse]
134
+ describe 'combine_submissions test' do
135
+ it 'should work' do
136
+ response = api_instance.combine_submissions(
137
+ submission_ids: %w[sub_000000000000000001 sub_000000000000000002])
138
+ expect(response.status).to eq 'success'
139
+ expect(response.combined_submission.id).to start_with 'com_'
140
+ expect(response.combined_submission.state).to eq 'pending'
141
+ end
142
+ end
143
+ # integration tests for create_data_request_token
144
+ # Creates a new data request token for form authentication
145
+ # @param data_request_id
146
+ # @param [Hash] opts the optional parameters
147
+ # @return [CreateSubmissionDataRequestTokenResponse]
148
+ describe 'create_data_request_token test' do
149
+ it 'should work' do
150
+ data_request_id = 'drq_000000000000000001' # String |
151
+ response = api_instance.create_data_request_token(data_request_id)
152
+ expect(response.status).to eq 'success'
153
+ expect(response.token.id).to_not be_nil
154
+ expect(response.token.secret).to_not be_nil
155
+ expect(response.token.data_request_url).to start_with \
156
+ 'http://app.docspring.local/data_requests/drq_000000000000000001?token_id='
157
+ expect(response.token.data_request_url).to include \
158
+ "?token_id=#{response.token.id}" \
159
+ "&token_secret=#{response.token.secret}"
160
+ end
161
+ end
162
+ # integration tests for expire_combined_submission
163
+ # Expire a combined submission
164
+ # @param combined_submission_id
165
+ # @param [Hash] opts the optional parameters
166
+ # @return [CombinedSubmission]
167
+ describe 'expire_combined_submission test' do
168
+ it 'should work' do
169
+ combined_submission_id = 'com_000000000000000001'
170
+ combined_submission = api_instance.expire_combined_submission(combined_submission_id)
171
+ expect(combined_submission.expired).to eq true
172
+ end
173
+ end
174
+ # integration tests for expire_submission
175
+ # Expire a PDF submission
176
+ # @param submission_id
177
+ # @param [Hash] opts the optional parameters
178
+ # @return [Submission]
179
+ describe 'expire_submission test' do
180
+ it 'should work' do
181
+ submission_id = 'sub_000000000000000001'
182
+ submission = api_instance.expire_submission(submission_id)
183
+ expect(submission.expired).to eq true
184
+ end
185
+ end
186
+ # integration tests for generate_pdf
187
+ # Generates a new PDF
188
+ # @param template_id
189
+ # @param create_submission_data
190
+ # @param [Hash] opts the optional parameters
191
+ # @return [CreateSubmissionResponse]
192
+ describe 'generate_pdf test' do
193
+ it 'should work' do
194
+ template_id = 'tpl_000000000000000001'
195
+ response = api_instance.generate_pdf(template_id,
196
+ data: {
197
+ title: 'Test PDF',
198
+ description: 'This PDF is great!',
199
+ })
200
+ expect(response.status).to eq 'success'
201
+ submission = response.submission
202
+ expect(submission.id).to start_with 'sub_'
203
+ expect(submission.expired).to eq false
204
+ expect(submission.state).to eq 'pending'
205
+ end
206
+ end
207
+ # integration tests for generate_pdf with data requests
208
+ # Generates a new PDF
209
+ # @param template_id
210
+ # @param create_submission_data
211
+ # @param [Hash] opts the optional parameters
212
+ # @return [CreateSubmissionResponse]
213
+ describe 'generate_pdf test with data_requests' do
214
+ it 'should work' do
215
+ template_id = 'tpl_000000000000000001'
216
+ response = api_instance.generate_pdf(template_id,
217
+ data: {
218
+ title: 'Test PDF',
219
+ },
220
+ data_requests: [
221
+ {
222
+ name: 'John Smith',
223
+ email: 'jsmith@example.com',
224
+ fields: ['description'],
225
+ order: 1,
226
+ auth_type: 'email_link',
227
+ }
228
+ ]
229
+ )
230
+ expect(response.status).to eq 'success'
231
+ submission = response.submission
232
+ expect(submission.id).to start_with 'sub_'
233
+ expect(submission.expired).to eq false
234
+ expect(submission.state).to eq 'waiting_for_data_requests'
235
+
236
+ data_requests = submission.data_requests
237
+ expect(data_requests.count).to eq 1
238
+ data_request = data_requests.first
239
+
240
+ expect(data_request.id).to start_with 'drq_'
241
+ expect(data_request.state).to eq 'pending'
242
+ expect(data_request.fields).to eq ['description']
243
+ expect(data_request.order).to eq 1
244
+ expect(data_request.name).to eq 'John Smith'
245
+ expect(data_request.email).to eq 'jsmith@example.com'
246
+ end
247
+ end
248
+
249
+ # integration tests for get_combined_submission
250
+ # Check the status of a combined submission (merged PDFs)
251
+ # @param combined_submission_id
252
+ # @param [Hash] opts the optional parameters
253
+ # @return [CombinedSubmission]
254
+ describe 'get_combined_submission test' do
255
+ it 'should work' do
256
+ combined_submission_id = 'com_000000000000000001'
257
+ combined_submission = api_instance.get_combined_submission(combined_submission_id)
258
+ expect(combined_submission.id).to start_with 'com_'
259
+ end
260
+ end
261
+ # integration tests for get_data_request
262
+ # Look up a submission data request
263
+ # @param data_request_id
264
+ # @param [Hash] opts the optional parameters
265
+ # @return [SubmissionDataRequest]
266
+ describe 'get_data_request test' do
267
+ it 'should work' do
268
+ data_request_id = 'drq_000000000000000001' # String |
269
+ data_request = api_instance.get_data_request(data_request_id)
270
+ expect(data_request.id).to start_with 'drq_'
271
+ expect(data_request.order).to eq 1
272
+ expect(data_request.name).to eq 'John Doe'
273
+ expect(data_request.email).to eq 'jdoe@example.com'
274
+ expect(data_request.fields).to eq ['description']
275
+ expect(data_request.metadata).to eq(user_id: 123)
276
+ expect(data_request.state).to eq 'pending'
277
+ expect(data_request.viewed_at).to be_nil
278
+ expect(data_request.completed_at).to be_nil
279
+ end
280
+ end
281
+
282
+ # integration tests for update_data_request
283
+ # Update a submission data request
284
+ # @param data_request_id
285
+ # @param [Hash] opts the optional parameters
286
+ # @return [SubmissionDataRequest]
287
+ describe 'update_data_request test' do
288
+ it 'should work' do
289
+ data_request_id = 'drq_000000000000000001' # String |
290
+ response = api_instance.update_data_request(
291
+ data_request_id,
292
+ name: 'Harry Smith',
293
+ email: 'hsmith@example.com',
294
+ order: 2,
295
+ fields: ['title'],
296
+ metadata: { user_id: 345 },
297
+ auth_type: 'oauth',
298
+ auth_provider: 'twitter',
299
+ auth_session_started_at: '2018-10-23T13:00:00Z'
300
+ )
301
+ expect(response.status).to eq 'success'
302
+ data_request = response.data_request
303
+ expect(data_request.id).to start_with 'drq_'
304
+ # Not allowed to update order, name, email, fields
305
+ expect(data_request.order).to eq 1
306
+ expect(data_request.name).to eq 'John Doe'
307
+ expect(data_request.email).to eq 'jdoe@example.com'
308
+ expect(data_request.fields).to eq ['description']
309
+ expect(data_request.metadata).to eq(user_id: 345)
310
+ expect(data_request.state).to eq 'pending'
311
+ expect(data_request.viewed_at).to be_nil
312
+ expect(data_request.completed_at).to be_nil
313
+ expect(data_request.auth_type).to eq 'oauth'
314
+ expect(data_request.auth_provider).to eq 'twitter'
315
+ expect(data_request.auth_session_started_at).to eq '2018-10-23T13:00:00Z'
316
+ end
317
+ end
318
+ # integration tests for get_submission
319
+ # Check the status of a PDF
320
+ # @param submission_id
321
+ # @param [Hash] opts the optional parameters
322
+ # @return [Submission]
323
+ describe 'get_submission test' do
324
+ it 'should work' do
325
+ submission_id = 'sub_000000000000000001'
326
+ submission = api_instance.get_submission(submission_id)
327
+ expect(submission.id).to start_with 'sub_'
328
+ end
329
+ end
330
+ # integration tests for list_templates
331
+ # Get a list of all templates
332
+ # @param [Hash] opts the optional parameters
333
+ # @option opts [Integer] :page Default: 1
334
+ # @option opts [Integer] :per_page Default: 50
335
+ # @return [Array<Template>]
336
+ describe 'list_templates test' do
337
+ it 'should work' do
338
+ opts = {
339
+ query: 'API Client Test Template 2', # String | Search By Name
340
+ page: 1, # Integer | Default: 1
341
+ per_page: 10 # Integer | Default: 50
342
+ }
343
+ templates = api_instance.list_templates(opts)
344
+ expect(templates.size).to eq 1
345
+ expect(templates.first.id).to eq 'tpl_000000000000000002'
346
+ end
347
+ end
348
+ # integration tests for list_templates
349
+ # Get a list of all templates
350
+ # @param [Hash] opts the optional parameters
351
+ # @option opts [String] :query Search By Name
352
+ # @option opts [Integer] :page Default: 1
353
+ # @option opts [Integer] :per_page Default: 50
354
+ # @return [Array<Template>]
355
+ describe 'list_templates test' do
356
+ it 'should work' do
357
+ opts = {
358
+ query: '2', # String | Search By Name
359
+ page: 2, # Integer | Default: 1
360
+ per_page: 1 # Integer | Default: 50
361
+ }
362
+ result = api_instance.list_templates(opts)
363
+ expect(result).to_not be_nil
364
+ end
365
+ end
366
+
367
+ # integration tests for test_authentication
368
+ # Test Authentication
369
+ # @param [Hash] opts the optional parameters
370
+ # @return [AuthenticationSuccessResponse]
371
+ describe 'test_authentication test' do
372
+ it 'should work' do
373
+ response = api_instance.test_authentication
374
+ expect(response.status).to eq 'success'
375
+ end
376
+ end
377
+ end