Skip to content

Commit 9441dad

Browse files
Merge pull request #9 from blinkmobile/forms-search
Replaced organisationId search parameter with isAuthenticated and name…
2 parents fbd4df6 + c327a30 commit 9441dad

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

docs/forms.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ forms.getSubmissionData(formId, submissionId)
9898
### Example
9999

100100
```javascript
101-
const organisationId = '0101010101010'
102-
const isPublished = true
103-
forms.getSubmissionData(organisationId, isPublished)
101+
const options = {
102+
isPublished: true
103+
}
104+
forms.search(options)
104105
.then((result) => {
105106
const forms = result.forms
106107
})
@@ -113,8 +114,8 @@ forms.getSubmissionData(organisationId, isPublished)
113114

114115
| Parameter | Required | Type | Description
115116
|---|---|---|---|
116-
| `organisationId` | Yes | `string` | The exact id of the organisation you wish to return a list of forms from. This value is available from the OneBlink Console in the URL bar. |
117-
| `isPublished` | No | `boolean` | Return published forms or unpublished forms. If not supplied, all forms will be returned. |
117+
| `options` | No | `Object` | Search options. |
118+
| `options.isPublished` | No | `boolean` | Return published forms or unpublished forms. If not supplied, all forms will be returned. |
118119

119120
### Result (Resolved Promise)
120121

lib/forms.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ module.exports = class Forms extends OneBlinkAPI {
7171
.then((credentials) => submissionData.getSubmissionData(credentials))
7272
}
7373

74-
search (options /* : FormsSearchOptions */) /* : Promise<FormsSearchResult> */ {
74+
search (options /* : ?FormsSearchOptions */) /* : Promise<FormsSearchResult> */ {
7575
options = options || {}
7676

77-
if (!options.organisationId || typeof options.organisationId !== 'string') {
78-
return Promise.reject(new TypeError('Must supply "organisationId" as a string'))
79-
}
77+
let searchParams = {}
8078

81-
let searchParams = {
82-
organisationId: options.organisationId
79+
if (typeof options.isAuthenticated === 'boolean') {
80+
searchParams = Object.assign({}, searchParams, {
81+
isAuthenticated: options.isAuthenticated
82+
})
8383
}
8484

8585
if (typeof options.isPublished === 'boolean') {
@@ -88,6 +88,12 @@ module.exports = class Forms extends OneBlinkAPI {
8888
})
8989
}
9090

91+
if (typeof options.name === 'string') {
92+
searchParams = Object.assign({}, searchParams, {
93+
name: options.name
94+
})
95+
}
96+
9197
return super.searchRequest(`/forms`, searchParams)
9298
}
9399
}

types.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ export type FormsSearchResult = {
8383
} & BaseSearchResult
8484
8585
export type FormsSearchOptions = {
86-
organisationId?: mixed,
87-
isPublished?: mixed
86+
isAuthenticated?: mixed,
87+
isPublished?: mixed,
88+
name?: mixed
8889
}
8990
9091
*/

0 commit comments

Comments
 (0)