File tree Expand file tree Collapse file tree 10 files changed +250
-1
lines changed Expand file tree Collapse file tree 10 files changed +250
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### Added
6
+
7
+ - ` Organisations ` classes
8
+ - ` Keys ` class
9
+
5
10
## 0.2.1 (2018-09-04)
6
11
7
12
### Added
Original file line number Diff line number Diff line change 3
3
## Classes
4
4
5
5
- [ Forms] ( ./forms.md )
6
+
7
+ - [ Keys] ( ./keys.md )
8
+
9
+ - [ Organisations] ( ./organisations.md )
Original file line number Diff line number Diff line change
1
+ # OneBlink SDK | Keys Class
2
+
3
+ ## Constructor
4
+
5
+ | Parameter | Required | Type | Description
6
+ | ---| ---| ---| ---|
7
+ | ` options.accessKey ` | Yes | ` string ` | Access key provided by OneBlink. |
8
+ | ` options.secretKey ` | Yes | ` string ` | Secret key provided by OneBlink. |
9
+
10
+ ### Example
11
+
12
+ ``` javascript
13
+ const OneBlink = require (' @oneblink/sdk' )
14
+
15
+ const options = {
16
+ accessKey: ' 123455678901ABCDEFGHIJKL' ,
17
+ secretKey: ' 123455678901ABCDEFGHIJKL123455678901ABCDEFGHIJKL'
18
+ }
19
+ const keys = new OneBlink.Keys (options)
20
+ ```
21
+
22
+ ## Get Single Key
23
+
24
+ ### Example
25
+
26
+ ``` javascript
27
+ const keyId = ' 123455678901ABCDEFGHIJKL'
28
+ keys .getKey (keyId)
29
+ .then ((key ) => {
30
+ // Use key here...
31
+ })
32
+ ```
33
+
34
+ ### Parameters
35
+
36
+ | Parameter | Required | Type | Description
37
+ | ---| ---| ---| ---|
38
+ | ` keyId ` | Yes | ` string ` | The exact id of the key you wish to get |
39
+
40
+ ### Result (Resolved Promise)
41
+
42
+ ``` json
43
+ {
44
+ "id" : " 123455678901ABCDEFGHIJKL" ,
45
+ "name" : " API Key" ,
46
+ "privilege" : {
47
+ "API HOSTING" : " DEPLOYMENT" ,
48
+ "FORMS" : " FaaS" ,
49
+ "PDF" : " BUILDER" ,
50
+ "WEB APP HOSTING" : " DEPLOYMENT"
51
+ },
52
+ "links" : {
53
+ "organisations" : " ABCDEFGHIJKL123455678901"
54
+ }
55
+ }
56
+ ```
Original file line number Diff line number Diff line change
1
+ # OneBlink SDK | Organisations Class
2
+
3
+ ## Constructor
4
+
5
+ | Parameter | Required | Type | Description
6
+ | ---| ---| ---| ---|
7
+ | ` options.accessKey ` | Yes | ` string ` | Access key provided by OneBlink. |
8
+ | ` options.secretKey ` | Yes | ` string ` | Secret key provided by OneBlink. |
9
+
10
+ ### Example
11
+
12
+ ``` javascript
13
+ const OneBlink = require (' @oneblink/sdk' )
14
+
15
+ const options = {
16
+ accessKey: ' 123455678901ABCDEFGHIJKL' ,
17
+ secretKey: ' 123455678901ABCDEFGHIJKL123455678901ABCDEFGHIJKL'
18
+ }
19
+ const organisations = new OneBlink.Organisations (options)
20
+ ```
21
+
22
+ ## Get Single Organisation
23
+
24
+ ### Example
25
+
26
+ ``` javascript
27
+ const organisationId = ' ABCDEFGHIJKL123455678901'
28
+ organisations .getOrganisations (organisationId)
29
+ .then ((organisation ) => {
30
+ // Use organisation here...
31
+ })
32
+ ```
33
+
34
+ ### Parameters
35
+
36
+ | Parameter | Required | Type | Description
37
+ | ---| ---| ---| ---|
38
+ | ` organisationId ` | Yes | ` string ` | The exact id of the organisation you wish to get |
39
+
40
+ ### Result (Resolved Promise)
41
+
42
+ ``` json
43
+ {
44
+ "id" : " ABCDEFGHIJKL123455678901" ,
45
+ "name" : " Organisation Name" ,
46
+ "createdAt" : " 2017-09-28T05:28:43.000Z" ,
47
+ "links" : {
48
+ "awsAccounts" : [
49
+ " ABCDEFG55678901HIJKL1234"
50
+ ]
51
+ },
52
+ "tags" : [
53
+ " Organisation Tag"
54
+ ],
55
+ "formsHostname" : " example.forms.oneblink.io" ,
56
+ "beeFormsCustomer" : false
57
+ }
58
+ ```
Original file line number Diff line number Diff line change 2
2
'use strict'
3
3
4
4
const Forms = require ( './lib/forms.js' )
5
+ const Keys = require ( './lib/keys.js' )
6
+ const Organisations = require ( './lib/organisations.js' )
5
7
6
8
module . exports = {
7
- Forms
9
+ Forms,
10
+ Keys,
11
+ Organisations
8
12
}
Original file line number Diff line number Diff line change
1
+ // @flow
2
+ 'use strict'
3
+
4
+ /* ::
5
+ import type {
6
+ ConstructorOptions,
7
+ Key
8
+ } from '../types.js'
9
+ */
10
+
11
+ const OneBlinkAPI = require ( './one-blink-api.js' )
12
+
13
+ module . exports = class Keys extends OneBlinkAPI {
14
+ constructor (
15
+ options /* : ConstructorOptions */
16
+ ) {
17
+ options = options || { }
18
+ super (
19
+ options . oneBlinkAPIOrigin ,
20
+ options . accessKey ,
21
+ options . secretKey
22
+ )
23
+ }
24
+
25
+ getKey ( keyId /* : ?mixed */ ) /* : Promise<Key> */ {
26
+ if ( typeof keyId !== 'string' ) {
27
+ return Promise . reject ( new TypeError ( 'Must supply "keyId" as a string' ) )
28
+ }
29
+
30
+ return super . getRequest ( `/keys/${ keyId } ` )
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ // @flow
2
+ 'use strict'
3
+
4
+ /* ::
5
+ import type {
6
+ ConstructorOptions,
7
+ Organisation
8
+ } from '../types.js'
9
+ */
10
+
11
+ const OneBlinkAPI = require ( './one-blink-api.js' )
12
+
13
+ module . exports = class Organisations extends OneBlinkAPI {
14
+ constructor (
15
+ options /* : ConstructorOptions */
16
+ ) {
17
+ options = options || { }
18
+ super (
19
+ options . oneBlinkAPIOrigin ,
20
+ options . accessKey ,
21
+ options . secretKey
22
+ )
23
+ }
24
+
25
+ getOrganisation ( organisationId /* : ?mixed */ ) /* : Promise<Organisation> */ {
26
+ if ( typeof organisationId !== 'string' ) {
27
+ return Promise . reject ( new TypeError ( 'Must supply "organisationId" as a string' ) )
28
+ }
29
+
30
+ return super . getRequest ( `/organisations/${ organisationId } ` )
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+
2
+ // @flow
3
+ 'use strict'
4
+
5
+ describe ( 'Keys SDK Class' , ( ) => {
6
+ const Keys = require ( '../../lib/keys.js' )
7
+ const keys = new Keys ( {
8
+ accessKey : '123' ,
9
+ secretKey : 'abc'
10
+ } )
11
+
12
+ test ( 'should reject with correct validation errors for "keyId"' , ( ) => {
13
+ return expect ( keys . getKey ( ) ) . rejects . toThrow ( 'Must supply "keyId" as a string' )
14
+ } )
15
+ } )
Original file line number Diff line number Diff line change
1
+
2
+ // @flow
3
+ 'use strict'
4
+
5
+ describe ( 'Organisations SDK Class' , ( ) => {
6
+ const Organisations = require ( '../../lib/organisations.js' )
7
+ const organisations = new Organisations ( {
8
+ accessKey : '123' ,
9
+ secretKey : 'abc'
10
+ } )
11
+
12
+ test ( 'should reject with correct validation errors for "organisationId"' , ( ) => {
13
+ return expect ( organisations . getOrganisation ( ) ) . rejects . toThrow ( 'Must supply "organisationId" as a string' )
14
+ } )
15
+ } )
Original file line number Diff line number Diff line change @@ -103,4 +103,32 @@ export type S3SubmissionData = {
103
103
definition: Form,
104
104
submissionTimestamp: string
105
105
}
106
+
107
+ export type Key = {
108
+ id: string,
109
+ secret: string | void,
110
+ name: string,
111
+ privilege: {
112
+ 'API HOSTING'?: 'DEPLOYMENT',
113
+ 'PDF'?: 'BUILDER',
114
+ 'WEB APP HOSTING'?: 'DEPLOYMENT',
115
+ 'FORMS'?: 'FaaS'
116
+ },
117
+ links: {
118
+ organisations: string
119
+ }
120
+ }
121
+
122
+ export type Organisation = {
123
+ id: string,
124
+ name: string,
125
+ formsHostname: string,
126
+ formsCloudFrontDistributionOrigin?: string,
127
+ beeFormsCustomer: boolean,
128
+ createdAt: string,
129
+ tags: string[],
130
+ links: {
131
+ awsAccounts: string[]
132
+ }
133
+ }
106
134
*/
You can’t perform that action at this time.
0 commit comments