Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions classes/Forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ module.exports = class Forms extends OneBlinkAPI {
if (typeof expiryInSeconds !== 'number') {
return Promise.reject(new TypeError('Must supply "expiryInSeconds" as a number'))
}
if (expiryInSeconds < 900) {
return Promise.reject(new TypeError('"expiryInSeconds" must be greater than or equal to 900'))
}

return super.postRequest(`/forms/${formId}/retrieval-url/${submissionId}?expirySeconds=${expiryInSeconds}`)
}
Expand Down
4 changes: 2 additions & 2 deletions docs/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ forms.generateFormUrl(formId, externalId, preFilledData)
```javascript
const formId = 1
const submissionId = 'c1f0f27b-4289-4ce5-9807-bf84971991aa'
const expiryInSeconds = 300
const expiryInSeconds = 900
forms.generateSubmissionDataUrl(formId, submissionId, expiryInSeconds)
.then((result) => {
const submissionDataUrl = result.url
Expand All @@ -75,7 +75,7 @@ forms.generateSubmissionDataUrl(formId, submissionId, expiryInSeconds)
|---|---|---|---|
| `formId` | Yes | `number` | The exact id of the form you wish to generate a URL for |
| `submissionId` | Yes | `string` | The submission identifier generated after a successful form submission, this will be return to you after a successful forms submission via a callback URL |
| `expiryInSeconds` | Yes | `number` | The number of seconds the signed URL should be valid for |
| `expiryInSeconds` | Yes | `number` | The number of seconds the signed URL should be valid for, must be greater than or equal to `900` |

### Result (Resolved Promise)

Expand Down
4 changes: 4 additions & 0 deletions tests/lib/forms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ describe('Forms SDK Class', () => {
test('"expiryInSeconds"', () => {
return expect(forms.generateSubmissionDataUrl(1, '123')).rejects.toThrow('Must supply "expiryInSeconds" as a number')
})

test('minimum "expiryInSeconds"', () => {
return expect(forms.generateSubmissionDataUrl(1, '123', 600)).rejects.toThrow('"expiryInSeconds" must be greater than or equal to 900')
})
})
})

Expand Down