@@ -73,29 +73,14 @@ export default {
7373 } ,
7474 } ,
7575 methods : {
76- /**
77- * Get the auth access token;
78- *
79- * @returns {string } The base auth access token.
80- */
8176 _authToken ( ) {
8277 return this . $auth . oauth_access_token ;
8378 } ,
84- _createApiClient ( ) {
79+ webflowClient ( ) {
8580 return new WebflowClient ( {
8681 accessToken : this . _authToken ( ) ,
8782 } ) ;
8883 } ,
89- /**
90- * Create a Webflow webhook;
91- *
92- * @param {siteId } ID of the site to be monitored.
93- * @param {url } URL to webhook return.
94- * @param {triggerType } Type of event that will be triggered.
95- * @param {filter } Filters to be applied in webhook.
96- *
97- * @returns {params } The Webflow webhook.
98- */
9984 async createWebhook ( siteId , url , triggerType , filter = { } ) {
10085 const apiClient = this . _createApiClient ( ) ;
10186
@@ -106,41 +91,21 @@ export default {
10691 filter,
10792 } ) ;
10893 } ,
109- /**
110- * Remove a Webflow webhook;
111- *
112- * @param {siteId } ID of the site.
113- * @param {webhookId } ID of the webhook.
114- */
11594 async removeWebhook ( siteId , webhookId ) {
11695 const apiClient = this . _createApiClient ( ) ;
11796 return apiClient . removeWebhook ( {
11897 siteId,
11998 webhookId,
12099 } ) ;
121100 } ,
122- /**
123- * Get an order;
124- *
125- * @param {options } Options to filter the order.
126- *
127- * @returns {params } An order.
128- */
129101 async getOrder ( {
130102 siteId, orderId,
131103 } ) {
132104 const apiClient = this . _createApiClient ( ) ;
133105
134106 return apiClient . get ( `/sites/${ siteId } /order/${ orderId } ` ) ;
135107 } ,
136- /**
137- * Get a list of orders;
138- *
139- * @param {options } Options to filter the orders.
140- *
141- * @returns {params } A list of orders.
142- */
143- async getOrders ( {
108+ async listOrders ( {
144109 page, siteId, status,
145110 } ) {
146111 const apiClient = this . _createApiClient ( ) ;
@@ -151,92 +116,38 @@ export default {
151116 limit : constants . LIMIT ,
152117 } ) ;
153118 } ,
154- /**
155- * Get a list of domains;
156- *
157- * @param {options } Options to filter the domains.
158- *
159- * @returns {params } A list of domains.
160- */
161- async getDomains ( siteId ) {
162- const webflow = this . _createApiClient ( ) ;
163-
164- return await webflow . domains ( {
165- siteId,
166- } ) ;
119+ async listDomains ( siteId ) {
120+ const response = await this . webflowClient ( ) . sites . getCustomDomain ( siteId ) ;
121+ return response ?. customDomains ;
167122 } ,
168- /**
169- * Get a site;
170- *
171- * @param {options } Options to filter the site.
172- *
173- * @returns {params } A site.
174- */
175123 async getSite ( siteId ) {
176- const webflow = this . _createApiClient ( ) ;
177-
178- return await webflow . site ( {
179- siteId,
180- } ) ;
124+ return this . webflowClient ( ) . sites . get ( siteId ) ;
181125 } ,
182- /**
183- * Get a list of sites;
184- *
185- * @param {options } Options to filter the sites.
186- *
187- * @returns {params } A list of sites.
188- */
189- async getSites ( ) {
190- const webflow = this . _createApiClient ( ) ;
191-
192- const response = await webflow . sites . list ( ) ;
126+ async listSites ( ) {
127+ const response = await this . webflowClient ( ) . sites . list ( ) ;
193128 return response ?. sites ;
194129 } ,
195- /**
196- * Get a collection;
197- *
198- * @param {options } Options to filter the collection.
199- *
200- * @returns {params } A collection.
201- */
202130 async getCollection ( collectionId ) {
203- const webflow = this . _createApiClient ( ) ;
204-
205- return await webflow . collections . get ( collectionId ) ;
206- } ,
207- /**
208- * Get a list of collections;
209- *
210- * @param {options } Options to filter the collections.
211- *
212- * @returns {params } A list of collections.
213- */
214- async getCollections ( siteId ) {
215- const webflow = this . _createApiClient ( ) ;
216-
131+ return this . webflowClient ( ) . collections . get ( collectionId ) ;
132+ } ,
133+ async listCollections ( siteId ) {
217134 if ( ! siteId ) return [ ] ;
218135
219- const response = await webflow . collections . list ( siteId ) ;
136+ const response = await this . webflowClient ( ) . collections . list ( siteId ) ;
220137 return response ?. collections ;
221138 } ,
222- /**
223- * Get a list of items;
224- *
225- * @param {options } Options to filter the items.
226- *
227- * @returns {params } A list of items.
228- */
229- async getItems ( page = 0 , collectionId ) {
230- const webflow = this . _createApiClient ( ) ;
231-
139+ async listCollectionItems ( page = 0 , collectionId ) {
232140 if ( ! collectionId ) return [ ] ;
233141
234- const response = await webflow . collections . items . listItems ( collectionId , {
142+ const response = await this . webflowClient ( ) . collections . items . listItems ( collectionId , {
235143 limit : constants . LIMIT ,
236144 offset : page ,
237145 } ) ;
238146
239147 return response ?. items ;
240148 } ,
149+ async getCollectionItem ( collectionId , itemId ) {
150+ return this . webflowClient ( ) . collections . items . getItem ( collectionId , itemId ) ;
151+ }
241152 } ,
242153} ;
0 commit comments