File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "extends": "airbnb-base",
33 "rules": {
4- "no-underscore-dangle": 0
4+ "no-underscore-dangle": 0,
5+ "class-methods-use-this": 0
56 }
67}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default class ResponseWrapper {
99
1010 collections : this . api . collections . bind ( this . api , { siteId : site . _id } ) ,
1111 webhooks : this . api . webhooks . bind ( this . api , { siteId : site . _id } ) ,
12+ domains : this . api . domains . bind ( this . api , { siteId : site . _id } ) ,
1213 webhook ( first , ...rest ) {
1314 return this . api . webhook ( { ...first , siteId : site . _id } , ...rest ) ;
1415 } ,
@@ -18,6 +19,15 @@ export default class ResponseWrapper {
1819 removeWebhook ( first , ...rest ) {
1920 return this . api . removeWebhook ( { ...first , siteId : site . _id } , ...rest ) ;
2021 } ,
22+ publishSite ( domains ) {
23+ return this . api . publishSite ( { siteId : site . _id , domains } ) ;
24+ } ,
25+ } ;
26+ }
27+
28+ domain ( domain ) {
29+ return {
30+ ...domain ,
2131 } ;
2232 }
2333
Original file line number Diff line number Diff line change @@ -128,6 +128,23 @@ export default class Webflow {
128128 return this . get ( `/sites/${ siteId } ` , query ) . then ( site => this . responseWrapper . site ( site ) ) ;
129129 }
130130
131+ publishSite ( { siteId, domains } ) {
132+ if ( ! siteId ) return Promise . reject ( buildRequiredArgError ( 'siteId' ) ) ;
133+ if ( ! domains ) return Promise . reject ( buildRequiredArgError ( 'domains' ) ) ;
134+
135+ return this . post ( `/sites/${ siteId } /publish` , { domains } ) ;
136+ }
137+
138+ // Domains
139+
140+ domains ( { siteId } ) {
141+ if ( ! siteId ) return Promise . reject ( buildRequiredArgError ( 'siteId' ) ) ;
142+
143+ return this . get ( `/sites/${ siteId } /domains` ) . then (
144+ domains => domains . map ( domain => this . responseWrapper . domain ( domain , siteId ) ) ,
145+ ) ;
146+ }
147+
131148 // Collections
132149
133150 collections ( { siteId } , query = { } ) {
Original file line number Diff line number Diff line change @@ -161,6 +161,24 @@ test('Responds with a list of webhooks', (t) => {
161161 } ) ;
162162} ) ;
163163
164+ test ( 'Responds with a list of domains' , ( t ) => {
165+ const scope = nock ( 'https://api.webflow.com' )
166+ . get ( '/sites/123/domains' )
167+ . reply ( 200 , [
168+ {
169+ _id : '321' ,
170+ } ,
171+ ] ) ;
172+
173+ const api = new Webflow ( { token : 'token' } ) ;
174+
175+ return api . domains ( { siteId : '123' } ) . then ( ( domains ) => {
176+ scope . done ( ) ;
177+ t . is ( domains . length , 1 ) ;
178+ t . is ( domains [ 0 ] . _id , '321' ) ;
179+ } ) ;
180+ } ) ;
181+
164182test ( 'Responds with a single webhook' , ( t ) => {
165183 const scope = nock ( 'https://api.webflow.com' )
166184 . get ( '/sites/123/webhooks/321' )
You can’t perform that action at this time.
0 commit comments