File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### Added
6
+
7
+ - ` forms.getForm() ` function
8
+
5
9
## 0.2.2 (2018-09-25)
6
10
7
11
### Added
Original file line number Diff line number Diff line change @@ -100,6 +100,39 @@ forms.getSubmissionData(formId, submissionId)
100
100
}
101
101
```
102
102
103
+ ## Get Single Form
104
+
105
+ ### Example
106
+
107
+ ``` javascript
108
+ const formId = 1
109
+ forms .getForm (formId)
110
+ .then ((form ) => {
111
+ // Use form here...
112
+ })
113
+ ```
114
+
115
+ ### Parameters
116
+
117
+ | Parameter | Required | Type | Description
118
+ | ---| ---| ---| ---|
119
+ | ` formId ` | Yes | ` number ` | The exact id of the form you wish to get |
120
+
121
+ ### Result (Resolved Promise)
122
+
123
+ ``` json
124
+ {
125
+ "id" : 1 ,
126
+ "name" : " testsform" ,
127
+ "description" : " a form" ,
128
+ "organisationId" : " 0101010101010" ,
129
+ "elements" : [],
130
+ "isAuthenticated" : false ,
131
+ "isPublished" : true ,
132
+ "submissionEvents" : []
133
+ }
134
+ ```
135
+
103
136
## Search Forms
104
137
105
138
### Example
Original file line number Diff line number Diff line change 3
3
4
4
/* ::
5
5
import type {
6
+ Form,
6
7
ConstructorOptions,
7
8
FormsSearchOptions,
8
9
FormsSearchResult,
@@ -105,4 +106,12 @@ module.exports = class Forms extends OneBlinkAPI {
105
106
106
107
return super . searchRequest ( `/forms` , searchParams )
107
108
}
109
+
110
+ getForm ( formId /* : ?mixed */ ) /* : Promise<Form> */ {
111
+ if ( typeof formId !== 'number' ) {
112
+ return Promise . reject ( new TypeError ( 'Must supply "formId" as a number' ) )
113
+ }
114
+
115
+ return super . getRequest ( `/forms/${ formId } ` )
116
+ }
108
117
}
Original file line number Diff line number Diff line change @@ -97,4 +97,19 @@ describe('Forms SDK Class', () => {
97
97
} )
98
98
} )
99
99
} )
100
+
101
+ describe ( 'getForm()' , ( ) => {
102
+ const Forms = require ( '../../lib/forms.js' )
103
+ const forms = new Forms ( {
104
+ accessKey : '123' ,
105
+ secretKey : 'abc' ,
106
+ oneBlinkAPIOrigin : 'https://domain.api.com'
107
+ } )
108
+
109
+ describe ( 'should reject with correct validation errors for' , ( ) => {
110
+ test ( '"formId"' , ( ) => {
111
+ return expect ( forms . getForm ( '123' ) ) . rejects . toThrow ( 'Must supply "formId" as a number' )
112
+ } )
113
+ } )
114
+ } )
100
115
} )
You can’t perform that action at this time.
0 commit comments