docspring 1.4.0 → 1.5.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 (69) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +3 -1
  3. package/docs/CombinedSubmission.md +2 -0
  4. package/docs/PDFApi.md +101 -1
  5. package/docs/SubmissionData.md +1 -0
  6. package/docs/SubmissionDataRequest.md +1 -0
  7. package/package.json +1 -1
  8. package/src/ApiClient.js +1 -1
  9. package/src/api/Client.js +263 -250
  10. package/src/api/PDFApi.js +94 -1
  11. package/src/index.js +1 -1
  12. package/src/model/AddFieldsData.js +1 -1
  13. package/src/model/AddFieldsTemplateResponse.js +1 -1
  14. package/src/model/AuthenticationError.js +1 -1
  15. package/src/model/AuthenticationSuccessResponse.js +1 -1
  16. package/src/model/CombinePdfsData.js +1 -1
  17. package/src/model/CombinedSubmission.js +17 -1
  18. package/src/model/CombinedSubmissionAction.js +1 -1
  19. package/src/model/CombinedSubmissionData.js +1 -1
  20. package/src/model/CopyTemplateData.js +1 -1
  21. package/src/model/CreateCombinedSubmissionResponse.js +1 -1
  22. package/src/model/CreateCustomFileData.js +1 -1
  23. package/src/model/CreateCustomFileResponse.js +1 -1
  24. package/src/model/CreateFolderData.js +1 -1
  25. package/src/model/CreateHtmlTemplateData.js +1 -1
  26. package/src/model/CreateSubmissionBatchResponse.js +1 -1
  27. package/src/model/CreateSubmissionBatchSubmissionsResponse.js +1 -1
  28. package/src/model/CreateSubmissionDataRequestData.js +1 -1
  29. package/src/model/CreateSubmissionDataRequestTokenResponse.js +1 -1
  30. package/src/model/CreateSubmissionDataRequestTokenResponseToken.js +1 -1
  31. package/src/model/CreateSubmissionResponse.js +1 -1
  32. package/src/model/CreateTemplateFromUploadData.js +1 -1
  33. package/src/model/CustomFile.js +1 -1
  34. package/src/model/Error.js +1 -1
  35. package/src/model/Folder.js +1 -1
  36. package/src/model/FoldersFolder.js +1 -1
  37. package/src/model/FullTemplate.js +1 -1
  38. package/src/model/FullTemplateDefaults.js +1 -1
  39. package/src/model/HtmlTemplateData.js +1 -1
  40. package/src/model/InvalidRequest.js +1 -1
  41. package/src/model/ListSubmissionsResponse.js +1 -1
  42. package/src/model/MoveFolderData.js +1 -1
  43. package/src/model/MoveTemplateData.js +1 -1
  44. package/src/model/PendingTemplate.js +1 -1
  45. package/src/model/RenameFolderData.js +1 -1
  46. package/src/model/Submission.js +1 -1
  47. package/src/model/SubmissionAction.js +1 -1
  48. package/src/model/SubmissionBatch.js +1 -1
  49. package/src/model/SubmissionBatchData.js +1 -1
  50. package/src/model/SubmissionData.js +9 -1
  51. package/src/model/SubmissionDataBatchRequest.js +1 -1
  52. package/src/model/SubmissionDataRequest.js +9 -1
  53. package/src/model/Template.js +1 -1
  54. package/src/model/TemplateData.js +1 -1
  55. package/src/model/TemplatestemplateIdaddFieldsFields.js +1 -1
  56. package/src/model/UpdateDataRequestResponse.js +1 -1
  57. package/src/model/UpdateSubmissionDataRequestData.js +1 -1
  58. package/src/model/UpdateTemplateData.js +1 -1
  59. package/src/model/UpdateTemplateResponse.js +1 -1
  60. package/src/model/UploadTemplateData.js +1 -1
  61. package/src/model/UploadTemplateDataDocument.js +1 -1
  62. package/src/model/UploadTemplateDataDocumentMetadata.js +1 -1
  63. package/test/api/ClientIntegration.spec.js +64 -58
  64. package/test/api/PDFApi.spec.js.original +20 -0
  65. package/test/api/PDFApiIntegration.spec.js +99 -95
  66. package/test/model/CombinedSubmission.spec.js +12 -0
  67. package/test/model/SubmissionData.spec.js +6 -0
  68. package/test/model/SubmissionDataRequest.spec.js +6 -0
  69. package/yarn.lock +0 -263
@@ -125,37 +125,39 @@
125
125
  var submission_data = {
126
126
  editable: false,
127
127
  data: {
128
- title: 'Test PDF',
129
- description: 'This PDF is great!',
128
+ first_name: 'John',
129
+ last_name: 'Smith',
130
+ phone_number: '+11234567890',
130
131
  },
131
132
  metadata: {
132
133
  user_id: 123,
133
134
  },
134
135
  field_overrides: {
135
- title: {
136
+ phone_number: {
136
137
  required: false,
137
138
  },
138
139
  },
139
140
  wait: true,
140
141
  }
141
- docspring.generatePDF(template_id, submission_data, function (
142
- error,
143
- response
144
- ) {
145
- if (error) {
146
- console.log(response, error)
147
- throw error
142
+ docspring.generatePDF(
143
+ template_id,
144
+ submission_data,
145
+ function (error, response) {
146
+ if (error) {
147
+ console.log(response, error)
148
+ throw error
149
+ }
150
+ var submission = response.submission
151
+ expect(response.status).to.be('success')
152
+ expect(submission.id).to.match(/^sub_/)
153
+ expect(submission.expired).to.be(false)
154
+ expect(submission.editable).to.be(false)
155
+ expect(submission.state).to.be('processed')
156
+ expect(submission.download_url).to.not.be(null)
157
+ expect(submission.download_url).to.not.be('')
158
+ done()
148
159
  }
149
- var submission = response.submission
150
- expect(response.status).to.be('success')
151
- expect(submission.id).to.match(/^sub_/)
152
- expect(submission.expired).to.be(false)
153
- expect(submission.editable).to.be(false)
154
- expect(submission.state).to.be('processed')
155
- expect(submission.download_url).to.not.be(null)
156
- expect(submission.download_url).to.not.be('')
157
- done()
158
- })
160
+ )
159
161
  })
160
162
 
161
163
  it('should call generatePDF and not wait for the PDF', function (done) {
@@ -164,35 +166,37 @@
164
166
  var submission_data = {
165
167
  editable: false,
166
168
  data: {
167
- title: 'Test PDF',
168
- description: 'This PDF is great!',
169
+ first_name: 'John',
170
+ last_name: 'Smith',
171
+ phone_number: '+11234567890',
169
172
  },
170
173
  metadata: {
171
174
  user_id: 123,
172
175
  },
173
176
  field_overrides: {
174
- title: {
177
+ phone_number: {
175
178
  required: false,
176
179
  },
177
180
  },
178
181
  wait: false,
179
182
  }
180
- docspring.generatePDF(template_id, submission_data, function (
181
- error,
182
- response
183
- ) {
184
- if (error) {
185
- console.log(response, error)
186
- throw error
183
+ docspring.generatePDF(
184
+ template_id,
185
+ submission_data,
186
+ function (error, response) {
187
+ if (error) {
188
+ console.log(response, error)
189
+ throw error
190
+ }
191
+ var submission = response.submission
192
+ expect(response.status).to.be('success')
193
+ expect(submission.id).to.match(/^sub_/)
194
+ expect(submission.expired).to.be(false)
195
+ expect(submission.editable).to.be(false)
196
+ expect(submission.state).to.be('pending')
197
+ done()
187
198
  }
188
- var submission = response.submission
189
- expect(response.status).to.be('success')
190
- expect(submission.id).to.match(/^sub_/)
191
- expect(submission.expired).to.be(false)
192
- expect(submission.editable).to.be(false)
193
- expect(submission.state).to.be('pending')
194
- done()
195
- })
199
+ )
196
200
  })
197
201
  })
198
202
 
@@ -224,14 +228,15 @@
224
228
  html: '<html><body>New HTML</html></body>',
225
229
  },
226
230
  }
227
- docspring.updateTemplate(template_id, template_data, function (
228
- error,
229
- response
230
- ) {
231
- if (error) throw error
232
- expect(response.status).to.be('success')
233
- done()
234
- })
231
+ docspring.updateTemplate(
232
+ template_id,
233
+ template_data,
234
+ function (error, response) {
235
+ if (error) throw error
236
+ expect(response.status).to.be('success')
237
+ done()
238
+ }
239
+ )
235
240
  })
236
241
  })
237
242
 
@@ -256,19 +261,20 @@
256
261
  },
257
262
  ],
258
263
  }
259
- docspring.addFieldsToTemplate(template_id, newFieldData, function (
260
- error,
261
- response
262
- ) {
263
- if (error) {
264
- console.log(response, error)
265
- throw error
264
+ docspring.addFieldsToTemplate(
265
+ template_id,
266
+ newFieldData,
267
+ function (error, response) {
268
+ if (error) {
269
+ console.log(response, error)
270
+ throw error
271
+ }
272
+ expect(response.status).to.be('success')
273
+ expect(response.new_field_ids).to.eql([4, 5])
274
+ expect(response.errors).to.be(undefined)
275
+ done()
266
276
  }
267
- expect(response.status).to.be('success')
268
- expect(response.new_field_ids).to.eql([3, 4])
269
- expect(response.errors).to.be(undefined)
270
- done()
271
- })
277
+ )
272
278
  })
273
279
  })
274
280
  })
@@ -180,6 +180,16 @@
180
180
  done();
181
181
  });
182
182
  });
183
+ describe('deleteTemplate', function() {
184
+ it('should call deleteTemplate successfully', function(done) {
185
+ //uncomment below and update the code to test deleteTemplate
186
+ //instance.deleteTemplate(function(error) {
187
+ // if (error) throw error;
188
+ //expect().to.be();
189
+ //});
190
+ done();
191
+ });
192
+ });
183
193
  describe('expireCombinedSubmission', function() {
184
194
  it('should call expireCombinedSubmission successfully', function(done) {
185
195
  //uncomment below and update the code to test expireCombinedSubmission
@@ -290,6 +300,16 @@
290
300
  done();
291
301
  });
292
302
  });
303
+ describe('listCombinedSubmissions', function() {
304
+ it('should call listCombinedSubmissions successfully', function(done) {
305
+ //uncomment below and update the code to test listCombinedSubmissions
306
+ //instance.listCombinedSubmissions(function(error) {
307
+ // if (error) throw error;
308
+ //expect().to.be();
309
+ //});
310
+ done();
311
+ });
312
+ });
293
313
  describe('listFolders', function() {
294
314
  it('should call listFolders successfully', function(done) {
295
315
  //uncomment below and update the code to test listFolders
@@ -50,46 +50,48 @@
50
50
  submissions: [
51
51
  {
52
52
  data: {
53
- title: 'Test PDF',
54
- description: 'This PDF is great!',
53
+ first_name: 'John',
54
+ last_name: 'Smith',
55
+ phone_number: '+11234567890',
55
56
  },
56
57
  },
57
58
  {
58
59
  data: {
59
- title: 'Test PDF 2',
60
- description: 'This PDF is also great!',
60
+ first_name: 'Jane',
61
+ last_name: 'Doe',
62
+ phone_number: '+64215556789',
61
63
  },
62
64
  },
63
65
  ],
64
66
  }
65
67
 
66
- instance.batchGeneratePdfs(submissionBatchData, function (
67
- error,
68
- response
69
- ) {
70
- if (error) {
71
- console.log(response, error)
72
- throw error
68
+ instance.batchGeneratePdfs(
69
+ submissionBatchData,
70
+ function (error, response) {
71
+ if (error) {
72
+ console.log(response, error)
73
+ throw error
74
+ }
75
+ expect(response.status).to.be('success')
76
+ expect(response.submissions.length).to.be(2)
77
+ var firstSubmission = response.submissions[0]
78
+ expect(firstSubmission.status).to.be('success')
79
+ expect(firstSubmission.submission.id).to.match(/^sub_/)
80
+ expect(firstSubmission.submission.expired).to.be(false)
81
+ expect(firstSubmission.submission.state).to.be('pending')
82
+ var secondSubmission = response.submissions[1]
83
+ expect(secondSubmission.status).to.be('success')
84
+ expect(secondSubmission.submission.id).to.match(/^sub_/)
85
+ expect(secondSubmission.submission.expired).to.be(false)
86
+ expect(secondSubmission.submission.state).to.be('pending')
87
+ var batch = response.submission_batch
88
+ expect(batch.id).to.match(/^sbb_/)
89
+ expect(batch.state).to.be('pending')
90
+ expect(batch.total_count).to.be(2)
91
+ expect(batch.pending_count).to.be(2)
92
+ done()
73
93
  }
74
- expect(response.status).to.be('success')
75
- expect(response.submissions.length).to.be(2)
76
- var firstSubmission = response.submissions[0]
77
- expect(firstSubmission.status).to.be('success')
78
- expect(firstSubmission.submission.id).to.match(/^sub_/)
79
- expect(firstSubmission.submission.expired).to.be(false)
80
- expect(firstSubmission.submission.state).to.be('pending')
81
- var secondSubmission = response.submissions[1]
82
- expect(secondSubmission.status).to.be('success')
83
- expect(secondSubmission.submission.id).to.match(/^sub_/)
84
- expect(secondSubmission.submission.expired).to.be(false)
85
- expect(secondSubmission.submission.state).to.be('pending')
86
- var batch = response.submission_batch
87
- expect(batch.id).to.match(/^sbb_/)
88
- expect(batch.state).to.be('pending')
89
- expect(batch.total_count).to.be(2)
90
- expect(batch.pending_count).to.be(2)
91
- done()
92
- })
94
+ )
93
95
  })
94
96
  })
95
97
 
@@ -110,14 +112,14 @@
110
112
  describe('expireCombinedSubmission', function () {
111
113
  it('should call expireCombinedSubmission successfully', function (done) {
112
114
  var combinedSubmissionId = 'com_000000000000000001'
113
- instance.expireCombinedSubmission(combinedSubmissionId, function (
114
- error,
115
- response
116
- ) {
117
- if (error) throw error
118
- expect(response.expired).to.be(true)
119
- done()
120
- })
115
+ instance.expireCombinedSubmission(
116
+ combinedSubmissionId,
117
+ function (error, response) {
118
+ if (error) throw error
119
+ expect(response.expired).to.be(true)
120
+ done()
121
+ }
122
+ )
121
123
  })
122
124
  })
123
125
  describe('expireSubmission', function () {
@@ -135,22 +137,24 @@
135
137
  var templateId = 'tpl_000000000000000001'
136
138
  var submissionData = {
137
139
  data: {
138
- title: 'Test PDF',
139
- description: 'This PDF is great!',
140
+ first_name: 'John',
141
+ last_name: 'Smith',
142
+ phone_number: '+11234567890',
140
143
  },
141
144
  }
142
- instance.generatePDF(templateId, submissionData, function (
143
- error,
144
- response
145
- ) {
146
- if (error) throw error
147
- expect(response.status).to.be('success')
148
- var submission = response.submission
149
- expect(submission.id).to.match(/^sub_/)
150
- expect(submission.expired).to.be(false)
151
- expect(submission.state).to.be('pending')
152
- done()
153
- })
145
+ instance.generatePDF(
146
+ templateId,
147
+ submissionData,
148
+ function (error, response) {
149
+ if (error) throw error
150
+ expect(response.status).to.be('success')
151
+ var submission = response.submission
152
+ expect(submission.id).to.match(/^sub_/)
153
+ expect(submission.expired).to.be(false)
154
+ expect(submission.state).to.be('pending')
155
+ done()
156
+ }
157
+ )
154
158
  })
155
159
  })
156
160
  describe('generatePDF with data_requests', function () {
@@ -158,56 +162,57 @@
158
162
  var templateId = 'tpl_000000000000000001'
159
163
  var submissionData = {
160
164
  data: {
161
- title: 'Test PDF',
162
- description: 'This PDF is great!',
165
+ first_name: 'John',
166
+ last_name: 'Smith',
163
167
  },
164
168
  data_requests: [
165
169
  {
166
170
  name: 'John Smith',
167
171
  email: 'jsmith@example.com',
168
- fields: ['description'],
172
+ fields: ['phone_number'],
169
173
  order: 1,
170
174
  auth_type: 'email_link',
171
175
  },
172
176
  ],
173
177
  }
174
- instance.generatePDF(templateId, submissionData, function (
175
- error,
176
- response
177
- ) {
178
- if (error) throw error
179
- expect(response.status).to.be('success')
180
- var submission = response.submission
181
- expect(submission.id).to.match(/^sub_/)
182
- expect(submission.expired).to.be(false)
183
- expect(submission.state).to.be('waiting_for_data_requests')
178
+ instance.generatePDF(
179
+ templateId,
180
+ submissionData,
181
+ function (error, response) {
182
+ if (error) throw error
183
+ expect(response.status).to.be('success')
184
+ var submission = response.submission
185
+ expect(submission.id).to.match(/^sub_/)
186
+ expect(submission.expired).to.be(false)
187
+ expect(submission.state).to.be('waiting_for_data_requests')
184
188
 
185
- var data_requests = submission.data_requests
186
- expect(data_requests.length).to.be(1)
187
- var data_request = data_requests[0]
189
+ var data_requests = submission.data_requests
190
+ expect(data_requests.length).to.be(1)
191
+ var data_request = data_requests[0]
188
192
 
189
- expect(data_request.id).to.match(/^drq_/)
190
- expect(data_request.state).to.be('pending')
191
- expect(data_request.fields).to.eql(['description'])
192
- expect(data_request.order).to.be(1)
193
- expect(data_request.name).to.be('John Smith')
194
- expect(data_request.email).to.be('jsmith@example.com')
193
+ expect(data_request.id).to.match(/^drq_/)
194
+ expect(data_request.state).to.be('pending')
195
+ expect(data_request.fields).to.eql(['phone_number'])
196
+ expect(data_request.order).to.be(1)
197
+ expect(data_request.name).to.be('John Smith')
198
+ expect(data_request.email).to.be('jsmith@example.com')
195
199
 
196
- done()
197
- })
200
+ done()
201
+ }
202
+ )
198
203
  })
199
204
  })
200
205
  describe('getCombinedSubmission', function () {
201
206
  it('should call getCombinedSubmission successfully', function (done) {
202
207
  var combinedSubmissionId = 'com_000000000000000001'
203
- instance.getCombinedSubmission(combinedSubmissionId, function (
204
- error,
205
- response
206
- ) {
207
- if (error) throw error
208
- expect(response.id).to.match(/^com_/)
209
- done()
210
- })
208
+ instance.getCombinedSubmission(
209
+ combinedSubmissionId,
210
+ function (error, response) {
211
+ if (error) throw error
212
+ expect(response.id).to.match(/^com_/)
213
+ done()
214
+ }
215
+ )
211
216
  })
212
217
  })
213
218
  describe('getSubmission', function () {
@@ -284,17 +289,16 @@
284
289
  footer_html: 'Test Footer',
285
290
  },
286
291
  }
287
- instance.createHTMLTemplate(templateData, function (
288
- error,
289
- data,
290
- response
291
- ) {
292
- if (error) throw error
293
- expect(data.name).to.be('Test HTML Template')
294
- expect(data.description).to.be('HTML template created via API')
295
- expect(data.id).to.match(/^tpl_/)
296
- done()
297
- })
292
+ instance.createHTMLTemplate(
293
+ templateData,
294
+ function (error, data, response) {
295
+ if (error) throw error
296
+ expect(data.name).to.be('Test HTML Template')
297
+ expect(data.description).to.be('HTML template created via API')
298
+ expect(data.id).to.match(/^tpl_/)
299
+ done()
300
+ }
301
+ )
298
302
  })
299
303
  })
300
304
  })
@@ -56,6 +56,12 @@
56
56
  //expect(instance).to.be.a(DocSpring.CombinedSubmission);
57
57
  });
58
58
 
59
+ it('should have the property errorMessage (base name: "error_message")', function() {
60
+ // uncomment below and update the code to test the property errorMessage
61
+ //var instance = new DocSpring.CombinedSubmission();
62
+ //expect(instance).to.be();
63
+ });
64
+
59
65
  it('should have the property metadata (base name: "metadata")', function() {
60
66
  // uncomment below and update the code to test the property metadata
61
67
  //var instance = new DocSpring.CombinedSubmission();
@@ -116,6 +122,12 @@
116
122
  //expect(instance).to.be();
117
123
  });
118
124
 
125
+ it('should have the property expiresIn (base name: "expires_in")', function() {
126
+ // uncomment below and update the code to test the property expiresIn
127
+ //var instance = new DocSpring.CombinedSubmission();
128
+ //expect(instance).to.be();
129
+ });
130
+
119
131
  it('should have the property actions (base name: "actions")', function() {
120
132
  // uncomment below and update the code to test the property actions
121
133
  //var instance = new DocSpring.CombinedSubmission();
@@ -74,6 +74,12 @@
74
74
  //expect(instance).to.be();
75
75
  });
76
76
 
77
+ it('should have the property expiresIn (base name: "expires_in")', function() {
78
+ // uncomment below and update the code to test the property expiresIn
79
+ //var instance = new DocSpring.SubmissionData();
80
+ //expect(instance).to.be();
81
+ });
82
+
77
83
  it('should have the property fieldOverrides (base name: "field_overrides")', function() {
78
84
  // uncomment below and update the code to test the property fieldOverrides
79
85
  //var instance = new DocSpring.SubmissionData();
@@ -62,6 +62,12 @@
62
62
  //expect(instance).to.be();
63
63
  });
64
64
 
65
+ it('should have the property submissionId (base name: "submission_id")', function() {
66
+ // uncomment below and update the code to test the property submissionId
67
+ //var instance = new DocSpring.SubmissionDataRequest();
68
+ //expect(instance).to.be();
69
+ });
70
+
65
71
  it('should have the property name (base name: "name")', function() {
66
72
  // uncomment below and update the code to test the property name
67
73
  //var instance = new DocSpring.SubmissionDataRequest();