webflow-api 0.8.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -17
- package/dist/ResponseWrapper.js +128 -197
- package/dist/Webflow.js +322 -466
- package/dist/WebflowClient.js +115 -0
- package/dist/index.js +8 -2
- package/index.d.ts +86 -50
- package/package.json +25 -27
- package/src/ResponseWrapper.js +25 -28
- package/src/Webflow.js +187 -235
- package/src/WebflowClient.js +98 -0
- package/src/index.js +3 -2
- package/yarn.lock +2056 -1933
- package/dist/WebflowError.js +0 -54
- package/dist/utils.js +0 -29
- package/src/WebflowError.js +0 -5
- package/src/utils.js +0 -13
package/README.md
CHANGED
|
@@ -1,39 +1,244 @@
|
|
|
1
1
|
# Webflow CMS API Client
|
|
2
2
|
|
|
3
|
-
## Requirements
|
|
4
|
-
|
|
5
|
-
* Node.js 4+
|
|
6
|
-
* NPM / YARN
|
|
7
|
-
* Webpack / Browserify (optional)
|
|
8
|
-
|
|
9
3
|
## Installation
|
|
10
4
|
|
|
11
|
-
|
|
5
|
+
Using npm:
|
|
12
6
|
|
|
13
7
|
```shell
|
|
14
|
-
$ npm install
|
|
8
|
+
$ npm install webflow-api
|
|
9
|
+
```
|
|
15
10
|
|
|
11
|
+
using yarn
|
|
12
|
+
```
|
|
16
13
|
$ yarn add webflow-api
|
|
17
14
|
```
|
|
18
15
|
|
|
19
16
|
## Usage
|
|
17
|
+
The constructor takes in a few optional parameters to initialize the API client
|
|
18
|
+
|
|
19
|
+
* `token` - the access token to use
|
|
20
|
+
* `headers` - additional headers to add to the request
|
|
21
|
+
* `version` - the version of the API you wish to use
|
|
22
|
+
* `mode` - the [sec-fetch-mode](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-Fetch-Mode) to use
|
|
23
|
+
|
|
24
|
+
``` javascript
|
|
25
|
+
const Webflow = require("webflow-api");
|
|
26
|
+
|
|
27
|
+
// initialize the client with the access token
|
|
28
|
+
const webflow = new Webflow({ token: "[ACCESS TOKEN]" });
|
|
29
|
+
|
|
30
|
+
// fully loaded
|
|
31
|
+
const webflow = new Webflow({
|
|
32
|
+
token: "[ACCESS TOKEN]"
|
|
33
|
+
version: "1.0.0",
|
|
34
|
+
mode: "cors",
|
|
35
|
+
headers: {
|
|
36
|
+
"User-Agent": "My Webflow App / 1.0"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
## Basic Usage
|
|
41
|
+
### Chaining Calls
|
|
42
|
+
You can retrieve child resources by chaining calls on the parent object.
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
// get the first site
|
|
46
|
+
const [site] = await webflow.sites();
|
|
47
|
+
|
|
48
|
+
// get the first collection in the site
|
|
49
|
+
const [collection] = await site.collections();
|
|
50
|
+
|
|
51
|
+
// get the first item in the collection
|
|
52
|
+
const [item] = await collection.items();
|
|
53
|
+
|
|
54
|
+
// get one item from the collection
|
|
55
|
+
const item = await collection.items({ itemId: "[ITEM ID]" });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Pagination
|
|
59
|
+
To paginate results, pass in the `limit` and `offset` options.
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// Get the first page of results
|
|
63
|
+
const page1 = await collection.items({ limit: 20 });
|
|
64
|
+
|
|
65
|
+
// Get the second page of results
|
|
66
|
+
const page2 = await collection.items({ limit: 20, offset: 20 });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Rate Limit
|
|
70
|
+
Check rate limit status on each call by checking the `_meta` property.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// make an api call
|
|
74
|
+
const site = await webflow.site({ siteId: "[SITE ID]" });
|
|
75
|
+
|
|
76
|
+
// check rate limit
|
|
77
|
+
const { rateLimit } = site._meta; // { limit: 60, remaining: 56 }
|
|
78
|
+
```
|
|
79
|
+
### Update Token
|
|
80
|
+
If you need to update the access token, you can set the `token` property at any time.
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
// token is unset
|
|
84
|
+
const webflow = new Webflow();
|
|
85
|
+
|
|
86
|
+
// set token
|
|
87
|
+
webflow.token = "[ACCESS TOKEN]";
|
|
88
|
+
```
|
|
89
|
+
### Calling APIs Directly
|
|
90
|
+
All Webflow API endpoints can be called directly using the `get`, `post`, `put`, and `delete` methods.
|
|
20
91
|
|
|
21
92
|
```javascript
|
|
22
|
-
|
|
93
|
+
// call the sites endpoint directly
|
|
94
|
+
const sites = await webflow.get("/sites");
|
|
95
|
+
|
|
96
|
+
// post to an endpoint directly
|
|
97
|
+
const result = await webflow.post("/sites/[SITE ID]/publish", {
|
|
98
|
+
domains: ["hello-webflow.com"]
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## OAuth
|
|
103
|
+
To implement OAuth, you'll need a Webflow App registered and a webserver running, that is publicly facing.
|
|
23
104
|
|
|
24
|
-
|
|
25
|
-
|
|
105
|
+
### Authorize
|
|
106
|
+
The first step in OAuth is to generate an authorization url to redirect the user to.
|
|
26
107
|
|
|
27
|
-
|
|
28
|
-
|
|
108
|
+
```javascript
|
|
109
|
+
// Get the authorization url to redirect users to
|
|
110
|
+
const url = webflow.authorizeUrl({
|
|
111
|
+
client_id: "[CLIENT ID]",
|
|
112
|
+
state: "1234567890", // optional
|
|
113
|
+
redirect_uri: "https://my.server.com/oauth/callback" // optional
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// redirect user from your server route
|
|
117
|
+
res.redirect(url);
|
|
29
118
|
```
|
|
30
119
|
|
|
31
|
-
|
|
120
|
+
### Access Token
|
|
121
|
+
Once a user has authorized their Webflow resource(s), Webflow will redirect back to your server with a `code`. Use this to get an access token.
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
const auth = await webflow.accessToken({
|
|
125
|
+
client_id,
|
|
126
|
+
client_secret,
|
|
127
|
+
code,
|
|
128
|
+
redirect_uri // optional - required if used in the authorize step
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// you now have the user's access token to make API requests with
|
|
132
|
+
const userWF = new Webflow({ token: auth.access_token });
|
|
133
|
+
|
|
134
|
+
// pull information for the installer
|
|
135
|
+
const installer = await userWF.installer();
|
|
136
|
+
```
|
|
32
137
|
|
|
33
|
-
|
|
34
|
-
|
|
138
|
+
### Revoke Token
|
|
139
|
+
If the user decides to disconnect from your server, you should call revoke token to remove the authorization.
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
const result = await webflow.revokeToken({
|
|
143
|
+
client_id,
|
|
144
|
+
client_secret,
|
|
145
|
+
access_token
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ensure it went through
|
|
149
|
+
if (result.didRevoke) {
|
|
150
|
+
// should equal true
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
### Sites
|
|
156
|
+
Get all sites available or lookup by site id.
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
// List all sites
|
|
160
|
+
const sites = await webflow.sites();
|
|
161
|
+
|
|
162
|
+
// Get a single site
|
|
163
|
+
const site = await webflow.sites({ siteId: "[SITE ID]" });
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Collections
|
|
167
|
+
Get all collections available for a site or lookup by collection id.
|
|
168
|
+
```javascript
|
|
169
|
+
// Get a site's collection from the site
|
|
170
|
+
const collections = await site.collections();
|
|
171
|
+
|
|
172
|
+
// Get a site's collection by passing in a site id
|
|
173
|
+
const collections = await webflow.collections({ siteId: "[SITE ID]" });
|
|
174
|
+
|
|
175
|
+
// Get a single collection
|
|
176
|
+
const collection = await webflow.collection({ collectionId: "[COLLECTION ID]" });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Collection Items
|
|
180
|
+
Get all collection items available for a collection or lookup by item id.
|
|
181
|
+
```javascript
|
|
182
|
+
// Get the items from a collection
|
|
183
|
+
const items = await collection.items();
|
|
184
|
+
|
|
185
|
+
// Get a subset of items
|
|
186
|
+
const items = await collection.items({ limit: 10, offset: 2 });
|
|
187
|
+
|
|
188
|
+
// Get a single item
|
|
189
|
+
const item = await webflow.item({ collectionId: "[COLLECTION ID]", itemId: "[ITEM ID]" });
|
|
190
|
+
```
|
|
191
|
+
### Update an Item
|
|
192
|
+
```javascript
|
|
193
|
+
// Set the fields to update
|
|
194
|
+
const fields = {
|
|
195
|
+
name: "New Name",
|
|
196
|
+
_archived: false,
|
|
197
|
+
_draft: false,
|
|
198
|
+
slug: "new-name",
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// call update
|
|
202
|
+
const updatedItem = await webflow.updateItem({
|
|
203
|
+
collectionId: "[COLLECTION ID]",
|
|
204
|
+
itemId: "[ITEM ID]",
|
|
205
|
+
fields,
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Memberships
|
|
210
|
+
```javascript
|
|
211
|
+
// Get the all users for a site
|
|
212
|
+
const users = await webflow.users({
|
|
213
|
+
siteId: "[SITE ID]"
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Get a single user
|
|
217
|
+
const user = await site.user({
|
|
218
|
+
siteId: "[SITE ID]",
|
|
219
|
+
userId: "[USER ID]"
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Webhooks
|
|
224
|
+
```javascript
|
|
225
|
+
// get webhooks for a site
|
|
226
|
+
const webhooks = await site.webhooks();
|
|
227
|
+
|
|
228
|
+
// create a webhook
|
|
229
|
+
const webhook = await site.createWebhook({
|
|
230
|
+
triggerType: "form_submission",
|
|
231
|
+
url: "https://webhook.site"
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Installer
|
|
237
|
+
```javascript
|
|
238
|
+
// pull information for the installer
|
|
239
|
+
const installer = await webflow.installer();
|
|
240
|
+
```
|
|
35
241
|
|
|
36
|
-
All of the API methods are documented in the [API documentation](https://developers.webflow.com).
|
|
37
242
|
|
|
38
243
|
## Contributing
|
|
39
244
|
|
package/dist/ResponseWrapper.js
CHANGED
|
@@ -3,202 +3,133 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
|
|
12
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
|
|
14
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
17
|
-
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
-
|
|
20
|
-
var ResponseWrapper = /*#__PURE__*/function () {
|
|
21
|
-
function ResponseWrapper(api) {
|
|
22
|
-
_classCallCheck(this, ResponseWrapper);
|
|
23
|
-
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class ResponseWrapper {
|
|
8
|
+
constructor(api) {
|
|
24
9
|
this.api = api;
|
|
25
10
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
collectionId: collectionId,
|
|
152
|
-
itemId: _item._id
|
|
153
|
-
})].concat(rest));
|
|
154
|
-
},
|
|
155
|
-
remove: this.api.updateItem.bind(this.api, {
|
|
156
|
-
collectionId: collectionId,
|
|
157
|
-
itemId: _item._id
|
|
158
|
-
})
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}, {
|
|
162
|
-
key: "user",
|
|
163
|
-
value: function user(_user, siteId) {
|
|
164
|
-
return _objectSpread(_objectSpread({}, _user), {}, {
|
|
165
|
-
update: function update(first) {
|
|
166
|
-
var _this$api9;
|
|
167
|
-
|
|
168
|
-
for (var _len9 = arguments.length, rest = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
|
|
169
|
-
rest[_key9 - 1] = arguments[_key9];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return (_this$api9 = this.api).updateUser.apply(_this$api9, [_objectSpread(_objectSpread({}, first), {}, {
|
|
173
|
-
siteId: siteId
|
|
174
|
-
})].concat(rest));
|
|
175
|
-
},
|
|
176
|
-
remove: function remove(first) {
|
|
177
|
-
var _this$api10;
|
|
178
|
-
|
|
179
|
-
for (var _len10 = arguments.length, rest = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
|
|
180
|
-
rest[_key10 - 1] = arguments[_key10];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return (_this$api10 = this.api).removeUser.apply(_this$api10, [_objectSpread(_objectSpread({}, first), {}, {
|
|
184
|
-
siteId: siteId
|
|
185
|
-
})].concat(rest));
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}, {
|
|
190
|
-
key: "webhook",
|
|
191
|
-
value: function webhook(_webhook, siteId) {
|
|
192
|
-
return _objectSpread(_objectSpread({}, _webhook), {}, {
|
|
193
|
-
remove: this.api.removeWebhook.bind(this.api, {
|
|
194
|
-
siteId: siteId,
|
|
195
|
-
webhookId: _webhook._id
|
|
196
|
-
})
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}]);
|
|
200
|
-
|
|
201
|
-
return ResponseWrapper;
|
|
202
|
-
}();
|
|
203
|
-
|
|
204
|
-
exports["default"] = ResponseWrapper;
|
|
11
|
+
site(site) {
|
|
12
|
+
return {
|
|
13
|
+
...site,
|
|
14
|
+
collections: this.api.collections.bind(this.api, {
|
|
15
|
+
siteId: site._id
|
|
16
|
+
}),
|
|
17
|
+
webhooks: this.api.webhooks.bind(this.api, {
|
|
18
|
+
siteId: site._id
|
|
19
|
+
}),
|
|
20
|
+
domains: this.api.domains.bind(this.api, {
|
|
21
|
+
siteId: site._id
|
|
22
|
+
}),
|
|
23
|
+
webhook: (first, ...rest) => {
|
|
24
|
+
return this.api.webhook({
|
|
25
|
+
...first,
|
|
26
|
+
siteId: site._id
|
|
27
|
+
}, ...rest);
|
|
28
|
+
},
|
|
29
|
+
createWebhook: (first, ...rest) => {
|
|
30
|
+
return this.api.createWebhook({
|
|
31
|
+
...first,
|
|
32
|
+
siteId: site._id
|
|
33
|
+
}, ...rest);
|
|
34
|
+
},
|
|
35
|
+
removeWebhook: (first, ...rest) => {
|
|
36
|
+
return this.api.removeWebhook({
|
|
37
|
+
...first,
|
|
38
|
+
siteId: site._id
|
|
39
|
+
}, ...rest);
|
|
40
|
+
},
|
|
41
|
+
publishSite: domains => {
|
|
42
|
+
return this.api.publishSite({
|
|
43
|
+
siteId: site._id,
|
|
44
|
+
domains
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
domain(domain) {
|
|
50
|
+
return {
|
|
51
|
+
...domain
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
collection(collection) {
|
|
55
|
+
return {
|
|
56
|
+
...collection,
|
|
57
|
+
items: this.api.items.bind(this.api, {
|
|
58
|
+
collectionId: collection._id
|
|
59
|
+
}),
|
|
60
|
+
item: (first, ...rest) => {
|
|
61
|
+
return this.api.item({
|
|
62
|
+
...first,
|
|
63
|
+
collectionId: collection._id
|
|
64
|
+
}, ...rest);
|
|
65
|
+
},
|
|
66
|
+
createItem: (first, ...rest) => {
|
|
67
|
+
return this.api.createItem({
|
|
68
|
+
...first,
|
|
69
|
+
collectionId: collection._id
|
|
70
|
+
}, ...rest);
|
|
71
|
+
},
|
|
72
|
+
updateItem: (first, ...rest) => {
|
|
73
|
+
return this.api.updateItem({
|
|
74
|
+
...first,
|
|
75
|
+
collectionId: collection._id
|
|
76
|
+
}, ...rest);
|
|
77
|
+
},
|
|
78
|
+
removeItem: (first, ...rest) => {
|
|
79
|
+
return this.api.removeItem({
|
|
80
|
+
...first,
|
|
81
|
+
collectionId: collection._id
|
|
82
|
+
}, ...rest);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
item(item, collectionId) {
|
|
87
|
+
const itemId = item._id;
|
|
88
|
+
const ids = {
|
|
89
|
+
itemId,
|
|
90
|
+
collectionId
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
...item,
|
|
94
|
+
update: (itemData, query) => {
|
|
95
|
+
return this.api.updateItem({
|
|
96
|
+
...itemData,
|
|
97
|
+
...ids
|
|
98
|
+
}, query);
|
|
99
|
+
},
|
|
100
|
+
remove: query => {
|
|
101
|
+
return this.api.removeItem(ids, query);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
user(user, siteId) {
|
|
106
|
+
const userId = user._id;
|
|
107
|
+
const ids = {
|
|
108
|
+
userId,
|
|
109
|
+
siteId
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
...user,
|
|
113
|
+
update: userData => {
|
|
114
|
+
return this.api.updateUser({
|
|
115
|
+
...ids,
|
|
116
|
+
...userData
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
remove: this.api.removeUser.bind(this.api, ids)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
webhook(webhook, siteId) {
|
|
123
|
+
const webhookId = webhook._id;
|
|
124
|
+
const ids = {
|
|
125
|
+
webhookId,
|
|
126
|
+
siteId
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
...webhook,
|
|
130
|
+
remove: this.api.removeWebhook.bind(this.api, ids)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.default = ResponseWrapper;
|
|
135
|
+
module.exports = exports.default;
|