webflow-api 1.1.1 → 1.2.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 +12 -1
- package/dist/api/collection.d.ts +85 -24
- package/dist/api/collection.js +88 -29
- package/dist/api/index.d.ts +7 -7
- package/dist/api/index.js +9 -19
- package/dist/api/item.d.ts +141 -107
- package/dist/api/item.js +145 -125
- package/dist/api/meta.d.ts +16 -14
- package/dist/api/meta.js +20 -19
- package/dist/api/oauth.d.ts +38 -36
- package/dist/api/oauth.js +59 -59
- package/dist/api/site.d.ts +118 -43
- package/dist/api/site.js +131 -53
- package/dist/{wrapper/membership.d.ts → api/user.d.ts} +59 -33
- package/dist/api/user.js +103 -0
- package/dist/api/webhook.d.ts +77 -55
- package/dist/api/webhook.js +74 -61
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +8 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/response.d.ts +32 -0
- package/dist/core/response.js +26 -0
- package/dist/{webflow.d.ts → core/webflow.d.ts} +57 -52
- package/dist/{webflow.js → core/webflow.js} +102 -61
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -4
- package/src/api/collection.ts +102 -35
- package/src/api/index.ts +7 -7
- package/src/api/item.ts +207 -176
- package/src/api/meta.ts +19 -18
- package/src/api/oauth.ts +62 -74
- package/src/api/site.ts +158 -55
- package/src/api/user.ts +152 -0
- package/src/api/webhook.ts +97 -80
- package/src/core/error.ts +8 -0
- package/src/core/index.ts +2 -2
- package/src/core/response.ts +50 -0
- package/src/{webflow.ts → core/webflow.ts} +132 -137
- package/src/index.ts +1 -1
- package/yarn.lock +0 -5
- package/dist/api/membership.d.ts +0 -91
- package/dist/api/membership.js +0 -80
- package/dist/core/client.d.ts +0 -40
- package/dist/core/client.js +0 -49
- package/dist/core/options.d.ts +0 -8
- package/dist/core/options.js +0 -5
- package/dist/wrapper/collection.d.ts +0 -85
- package/dist/wrapper/collection.js +0 -94
- package/dist/wrapper/index.d.ts +0 -6
- package/dist/wrapper/index.js +0 -22
- package/dist/wrapper/item.d.ts +0 -140
- package/dist/wrapper/item.js +0 -153
- package/dist/wrapper/membership.js +0 -106
- package/dist/wrapper/response.d.ts +0 -16
- package/dist/wrapper/response.js +0 -17
- package/dist/wrapper/site.d.ts +0 -119
- package/dist/wrapper/site.js +0 -136
- package/dist/wrapper/webhook.d.ts +0 -78
- package/dist/wrapper/webhook.js +0 -82
- package/src/api/membership.ts +0 -125
- package/src/core/client.ts +0 -76
- package/src/core/options.ts +0 -9
- package/src/wrapper/collection.ts +0 -115
- package/src/wrapper/index.ts +0 -6
- package/src/wrapper/item.ts +0 -218
- package/src/wrapper/membership.ts +0 -138
- package/src/wrapper/response.ts +0 -25
- package/src/wrapper/site.ts +0 -164
- package/src/wrapper/webhook.ts +0 -116
package/dist/api/site.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { Webhook, Collection, WebhookFilter } from ".";
|
|
3
|
+
import { WebflowRecord } from "../core";
|
|
2
4
|
/**************************************************************
|
|
3
5
|
* Interfaces
|
|
4
6
|
*************************************************************/
|
|
@@ -20,46 +22,119 @@ export interface IPublishSite {
|
|
|
20
22
|
queued: boolean;
|
|
21
23
|
}
|
|
22
24
|
/**************************************************************
|
|
23
|
-
*
|
|
25
|
+
* Class
|
|
24
26
|
**************************************************************/
|
|
25
|
-
|
|
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
|
-
|
|
27
|
+
export declare class Site extends WebflowRecord<ISite> implements ISite {
|
|
28
|
+
lastPublished: string;
|
|
29
|
+
previewUrl: string;
|
|
30
|
+
createdOn: string;
|
|
31
|
+
shortName: string;
|
|
32
|
+
timezone: string;
|
|
33
|
+
database: string;
|
|
34
|
+
name: string;
|
|
35
|
+
_id: string;
|
|
36
|
+
/**
|
|
37
|
+
* Get a list of Sites
|
|
38
|
+
* @param client The Axios client instance
|
|
39
|
+
* @returns a list of Sites
|
|
40
|
+
*/
|
|
41
|
+
static list(client: AxiosInstance): Promise<import("axios").AxiosResponse<ISite[], any>>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a single Site
|
|
44
|
+
* @param params The params for the request
|
|
45
|
+
* @param params.siteId The site ID
|
|
46
|
+
* @param params.params The query string parameters (optional)
|
|
47
|
+
* @param client The Axios client instance
|
|
48
|
+
* @returns A single Site
|
|
49
|
+
*/
|
|
50
|
+
static getOne({ siteId }: {
|
|
51
|
+
siteId: string;
|
|
52
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<ISite, any>>;
|
|
53
|
+
/**
|
|
54
|
+
* Publish a site
|
|
55
|
+
* @param params The params for the request
|
|
56
|
+
* @param params.siteId The site ID
|
|
57
|
+
* @param params.domains The domains to publish to
|
|
58
|
+
* @param client The Axios client instance
|
|
59
|
+
* @returns The publish result
|
|
60
|
+
*/
|
|
61
|
+
static publish({ siteId, domains }: {
|
|
62
|
+
siteId: string;
|
|
63
|
+
domains: string[];
|
|
64
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IPublishSite, any>>;
|
|
65
|
+
/**
|
|
66
|
+
* Get a list of domains for a site
|
|
67
|
+
* @param params The params for the request
|
|
68
|
+
* @param params.siteId The site ID
|
|
69
|
+
* @param client The Axios client instance
|
|
70
|
+
* @returns A list of domains
|
|
71
|
+
*/
|
|
72
|
+
static domains({ siteId }: {
|
|
73
|
+
siteId: string;
|
|
74
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IDomain[], any>>;
|
|
75
|
+
/**************************************************************
|
|
76
|
+
* Instance Methods
|
|
77
|
+
**************************************************************/
|
|
78
|
+
/**
|
|
79
|
+
* Get a list of domains for a site
|
|
80
|
+
* @returns A list of domains
|
|
81
|
+
*/
|
|
82
|
+
domains(): Promise<IDomain[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Publish a site
|
|
85
|
+
* @param domains The domains to publish to
|
|
86
|
+
* @returns The publish result
|
|
87
|
+
*/
|
|
88
|
+
publishSite(domains: string[]): Promise<IPublishSite>;
|
|
89
|
+
/**
|
|
90
|
+
* Get a single Collection
|
|
91
|
+
* @param params The params for the request
|
|
92
|
+
* @param params.collectionId The collection ID
|
|
93
|
+
* @returns A single Collection
|
|
94
|
+
*/
|
|
95
|
+
collection({ collectionId }: {
|
|
96
|
+
collectionId: string;
|
|
97
|
+
}): Promise<Collection>;
|
|
98
|
+
/**
|
|
99
|
+
* Get a list of Collections
|
|
100
|
+
* @returns A list of Collections
|
|
101
|
+
*/
|
|
102
|
+
collections(): Promise<Collection[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Get a single Webhook
|
|
105
|
+
* @param params The params for the request
|
|
106
|
+
* @param params.webhookId The webhook ID
|
|
107
|
+
* @returns A single Webhook
|
|
108
|
+
*/
|
|
109
|
+
webhook({ webhookId }: {
|
|
110
|
+
webhookId: string;
|
|
111
|
+
}): Promise<Webhook>;
|
|
112
|
+
/**
|
|
113
|
+
* Get a list of Webhooks
|
|
114
|
+
* @returns A list of Webhooks
|
|
115
|
+
*/
|
|
116
|
+
webhooks(): Promise<Webhook[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Remove a Webhook
|
|
119
|
+
* @param params The query string parameters (optional)
|
|
120
|
+
* @param params.webhookId The Webhook ID
|
|
121
|
+
* @returns The result of the removal
|
|
122
|
+
*/
|
|
123
|
+
removeWebhook({ webhookId }: {
|
|
124
|
+
webhookId: string;
|
|
125
|
+
}): Promise<import("./webhook").IRemoveResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Create a new Webhook
|
|
128
|
+
* @param params The params for the request
|
|
129
|
+
* @param params.url The URL to send the webhook to
|
|
130
|
+
* @param params.triggerType The event to trigger the webhook
|
|
131
|
+
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
132
|
+
* @returns The created webhook
|
|
133
|
+
*/
|
|
134
|
+
createWebhook({ triggerType, filter, url, }: {
|
|
135
|
+
url: string;
|
|
136
|
+
siteId: string;
|
|
137
|
+
triggerType: string;
|
|
138
|
+
filter?: WebhookFilter;
|
|
139
|
+
}): Promise<Webhook>;
|
|
140
|
+
}
|
package/dist/api/site.js
CHANGED
|
@@ -1,59 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Site = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
4
5
|
const core_1 = require("../core");
|
|
5
6
|
/**************************************************************
|
|
6
|
-
*
|
|
7
|
+
* Class
|
|
7
8
|
**************************************************************/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
class Site extends core_1.WebflowRecord {
|
|
10
|
+
/**
|
|
11
|
+
* Get a list of Sites
|
|
12
|
+
* @param client The Axios client instance
|
|
13
|
+
* @returns a list of Sites
|
|
14
|
+
*/
|
|
15
|
+
static list(client) {
|
|
16
|
+
const path = "/sites";
|
|
17
|
+
return client.get(path);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get a single Site
|
|
21
|
+
* @param params The params for the request
|
|
22
|
+
* @param params.siteId The site ID
|
|
23
|
+
* @param params.params The query string parameters (optional)
|
|
24
|
+
* @param client The Axios client instance
|
|
25
|
+
* @returns A single Site
|
|
26
|
+
*/
|
|
27
|
+
static getOne({ siteId }, client) {
|
|
28
|
+
(0, core_1.requireArgs)({ siteId });
|
|
29
|
+
const path = `/sites/${siteId}`;
|
|
30
|
+
return client.get(path);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Publish a site
|
|
34
|
+
* @param params The params for the request
|
|
35
|
+
* @param params.siteId The site ID
|
|
36
|
+
* @param params.domains The domains to publish to
|
|
37
|
+
* @param client The Axios client instance
|
|
38
|
+
* @returns The publish result
|
|
39
|
+
*/
|
|
40
|
+
static publish({ siteId, domains }, client) {
|
|
41
|
+
(0, core_1.requireArgs)({ siteId, domains });
|
|
42
|
+
const path = `/sites/${siteId}/publish`;
|
|
43
|
+
return client.post(path, { domains });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a list of domains for a site
|
|
47
|
+
* @param params The params for the request
|
|
48
|
+
* @param params.siteId The site ID
|
|
49
|
+
* @param client The Axios client instance
|
|
50
|
+
* @returns A list of domains
|
|
51
|
+
*/
|
|
52
|
+
static domains({ siteId }, client) {
|
|
53
|
+
(0, core_1.requireArgs)({ siteId });
|
|
54
|
+
const path = `/sites/${siteId}/domains`;
|
|
55
|
+
return client.get(path);
|
|
56
|
+
}
|
|
57
|
+
/**************************************************************
|
|
58
|
+
* Instance Methods
|
|
59
|
+
**************************************************************/
|
|
60
|
+
/**
|
|
61
|
+
* Get a list of domains for a site
|
|
62
|
+
* @returns A list of domains
|
|
63
|
+
*/
|
|
64
|
+
async domains() {
|
|
65
|
+
const res = await Site.domains({ siteId: this._id }, this.client);
|
|
66
|
+
return res.data;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Publish a site
|
|
70
|
+
* @param domains The domains to publish to
|
|
71
|
+
* @returns The publish result
|
|
72
|
+
*/
|
|
73
|
+
async publishSite(domains) {
|
|
74
|
+
const res = await Site.publish({ siteId: this._id, domains }, this.client);
|
|
75
|
+
return res.data;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get a single Collection
|
|
79
|
+
* @param params The params for the request
|
|
80
|
+
* @param params.collectionId The collection ID
|
|
81
|
+
* @returns A single Collection
|
|
82
|
+
*/
|
|
83
|
+
async collection({ collectionId }) {
|
|
84
|
+
const res = await _1.Collection.getOne({ collectionId }, this.client);
|
|
85
|
+
return new _1.Collection(this.client, res);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get a list of Collections
|
|
89
|
+
* @returns A list of Collections
|
|
90
|
+
*/
|
|
91
|
+
async collections() {
|
|
92
|
+
const res = await _1.Collection.list({ siteId: this._id }, this.client);
|
|
93
|
+
return res.data.map((data) => new _1.Collection(this.client, { ...res, data }));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get a single Webhook
|
|
97
|
+
* @param params The params for the request
|
|
98
|
+
* @param params.webhookId The webhook ID
|
|
99
|
+
* @returns A single Webhook
|
|
100
|
+
*/
|
|
101
|
+
async webhook({ webhookId }) {
|
|
102
|
+
const res = await _1.Webhook.getOne({ siteId: this._id, webhookId }, this.client);
|
|
103
|
+
return new _1.Webhook(this.client, res);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get a list of Webhooks
|
|
107
|
+
* @returns A list of Webhooks
|
|
108
|
+
*/
|
|
109
|
+
async webhooks() {
|
|
110
|
+
const res = await _1.Webhook.list({ siteId: this._id }, this.client);
|
|
111
|
+
return res.data.map((data) => new _1.Webhook(this.client, { ...res, data }));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Remove a Webhook
|
|
115
|
+
* @param params The query string parameters (optional)
|
|
116
|
+
* @param params.webhookId The Webhook ID
|
|
117
|
+
* @returns The result of the removal
|
|
118
|
+
*/
|
|
119
|
+
async removeWebhook({ webhookId }) {
|
|
120
|
+
const res = await _1.Webhook.remove({ siteId: this._id, webhookId }, this.client);
|
|
121
|
+
return res.data;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create a new Webhook
|
|
125
|
+
* @param params The params for the request
|
|
126
|
+
* @param params.url The URL to send the webhook to
|
|
127
|
+
* @param params.triggerType The event to trigger the webhook
|
|
128
|
+
* @param params.filter The filter to apply to the webhook (optional: form_submission only)
|
|
129
|
+
* @returns The created webhook
|
|
130
|
+
*/
|
|
131
|
+
async createWebhook({ triggerType, filter, url, }) {
|
|
132
|
+
const _params = { url, siteId: this._id, triggerType, filter };
|
|
133
|
+
const res = await _1.Webhook.create(_params, this.client);
|
|
134
|
+
return new _1.Webhook(this.client, res);
|
|
135
|
+
}
|
|
17
136
|
}
|
|
18
|
-
exports.
|
|
19
|
-
/**
|
|
20
|
-
* Get a single Site
|
|
21
|
-
* @param client The Webflow client
|
|
22
|
-
* @param params The params for the request
|
|
23
|
-
* @param params.siteId The site ID
|
|
24
|
-
* @param params.params The query string parameters (optional)
|
|
25
|
-
* @returns A single Site
|
|
26
|
-
*/
|
|
27
|
-
function getOne(client, { siteId, params }) {
|
|
28
|
-
(0, core_1.requireArgs)({ siteId });
|
|
29
|
-
const path = `/sites/${siteId}`;
|
|
30
|
-
return client.get(path, { params });
|
|
31
|
-
}
|
|
32
|
-
exports.getOne = getOne;
|
|
33
|
-
/**
|
|
34
|
-
* Publish a site
|
|
35
|
-
* @param client The Webflow client
|
|
36
|
-
* @param params The params for the request
|
|
37
|
-
* @param params.siteId The site ID
|
|
38
|
-
* @param params.domains The domains to publish to
|
|
39
|
-
* @returns The publish result
|
|
40
|
-
*/
|
|
41
|
-
function publish(client, { siteId, domains }) {
|
|
42
|
-
(0, core_1.requireArgs)({ siteId, domains });
|
|
43
|
-
const path = `/sites/${siteId}/publish`;
|
|
44
|
-
return client.post(path, { domains });
|
|
45
|
-
}
|
|
46
|
-
exports.publish = publish;
|
|
47
|
-
/**
|
|
48
|
-
* Get a list of domains for a site
|
|
49
|
-
* @param client The Webflow client
|
|
50
|
-
* @param params The params for the request
|
|
51
|
-
* @param params.siteId The site ID
|
|
52
|
-
* @returns A list of domains
|
|
53
|
-
*/
|
|
54
|
-
function domains(client, { siteId }) {
|
|
55
|
-
(0, core_1.requireArgs)({ siteId });
|
|
56
|
-
const path = `/sites/${siteId}/domains`;
|
|
57
|
-
return client.get(path);
|
|
58
|
-
}
|
|
59
|
-
exports.domains = domains;
|
|
137
|
+
exports.Site = Site;
|
|
@@ -1,79 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { PaginatedData, WebflowRecord } from "../core";
|
|
3
|
+
/**************************************************************
|
|
4
|
+
* Interfaces
|
|
5
|
+
**************************************************************/
|
|
6
|
+
export interface IUser {
|
|
6
7
|
emailVerified: boolean;
|
|
7
8
|
lastUpdated?: string;
|
|
8
9
|
createdOn: string;
|
|
9
10
|
_id: string;
|
|
10
11
|
data: any;
|
|
11
|
-
|
|
12
|
+
}
|
|
13
|
+
export interface IUserDelete {
|
|
14
|
+
deleted: number;
|
|
15
|
+
}
|
|
16
|
+
/**************************************************************
|
|
17
|
+
* Types
|
|
18
|
+
**************************************************************/
|
|
19
|
+
export declare type PaginatedUsers = PaginatedData & {
|
|
20
|
+
users: IUser[];
|
|
21
|
+
};
|
|
22
|
+
export declare type UserIdParam = {
|
|
23
|
+
siteId: string;
|
|
24
|
+
userId: string;
|
|
25
|
+
};
|
|
26
|
+
/**************************************************************
|
|
27
|
+
* Class
|
|
28
|
+
**************************************************************/
|
|
29
|
+
export declare class User extends WebflowRecord<IUser> implements IUser {
|
|
30
|
+
emailVerified: boolean;
|
|
31
|
+
lastUpdated?: string;
|
|
32
|
+
createdOn: string;
|
|
33
|
+
siteId: string;
|
|
34
|
+
_id: string;
|
|
35
|
+
data: any;
|
|
12
36
|
/**************************************************************
|
|
13
37
|
* Static Methods
|
|
14
38
|
**************************************************************/
|
|
15
39
|
/**
|
|
16
|
-
* Get a
|
|
17
|
-
* @param client The Webflow client
|
|
40
|
+
* Get a list of Users
|
|
18
41
|
* @param params The params for the request
|
|
19
42
|
* @param params.siteId The site ID
|
|
20
|
-
* @param params.
|
|
21
|
-
* @
|
|
43
|
+
* @param params.limit The number of items to return (optional)
|
|
44
|
+
* @param params.offset The number of items to skip (optional)
|
|
45
|
+
* @param client The Axios client instance
|
|
46
|
+
* @returns A list of Users
|
|
22
47
|
*/
|
|
23
|
-
static
|
|
48
|
+
static list({ siteId, limit, offset }: {
|
|
24
49
|
siteId: string;
|
|
25
|
-
|
|
26
|
-
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<PaginatedUsers, any>>;
|
|
27
53
|
/**
|
|
28
|
-
* Get a
|
|
29
|
-
* @param client The Webflow client
|
|
54
|
+
* Get a single User
|
|
30
55
|
* @param params The params for the request
|
|
31
56
|
* @param params.siteId The site ID
|
|
32
|
-
* @param params.
|
|
33
|
-
* @param
|
|
34
|
-
* @returns A
|
|
57
|
+
* @param params.userId The user ID
|
|
58
|
+
* @param client The Axios client instance
|
|
59
|
+
* @returns A single User
|
|
35
60
|
*/
|
|
36
|
-
static
|
|
61
|
+
static getOne({ siteId, userId }: {
|
|
37
62
|
siteId: string;
|
|
38
|
-
|
|
63
|
+
userId: string;
|
|
64
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
39
65
|
/**
|
|
40
66
|
* Update a User
|
|
41
|
-
* @param client The Webflow client
|
|
42
67
|
* @param params The params for the request
|
|
43
68
|
* @param params.siteId The site ID
|
|
44
69
|
* @param params.userId The user ID
|
|
45
70
|
* @param params.data The data to update
|
|
71
|
+
* @param client The Axios client instance
|
|
46
72
|
* @returns The updated User
|
|
47
73
|
*/
|
|
48
|
-
static update(
|
|
49
|
-
|
|
74
|
+
static update({ siteId, userId, data, }: {
|
|
75
|
+
data: object;
|
|
50
76
|
siteId: string;
|
|
51
|
-
|
|
52
|
-
}): Promise<
|
|
77
|
+
userId: string;
|
|
78
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
53
79
|
/**
|
|
54
80
|
* Invite a User to a site
|
|
55
|
-
* @param client The Webflow client
|
|
56
81
|
* @param params The params for the request
|
|
57
82
|
* @param params.siteId The site ID
|
|
58
83
|
* @param params.email The email address of the user to invite
|
|
84
|
+
* @param client The Axios client instance
|
|
59
85
|
* @returns The newly created User
|
|
60
86
|
*/
|
|
61
|
-
static invite(
|
|
87
|
+
static invite({ siteId, email }: {
|
|
62
88
|
siteId: string;
|
|
63
89
|
email: string;
|
|
64
|
-
}): Promise<import("
|
|
90
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
|
|
65
91
|
/**
|
|
66
92
|
* Remove a User
|
|
67
|
-
* @param client The Webflow client
|
|
68
93
|
* @param params The params for the request
|
|
69
94
|
* @param params.siteId The site ID
|
|
70
95
|
* @param params.userId The user ID
|
|
96
|
+
* @param client The Axios client instance
|
|
71
97
|
* @returns The result of the remove
|
|
72
98
|
*/
|
|
73
|
-
static remove(
|
|
99
|
+
static remove({ siteId, userId }: {
|
|
74
100
|
siteId: string;
|
|
75
101
|
userId: string;
|
|
76
|
-
}): Promise<import("
|
|
102
|
+
}, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUserDelete, any>>;
|
|
77
103
|
/**************************************************************
|
|
78
104
|
* Instance Methods
|
|
79
105
|
**************************************************************/
|
|
@@ -82,10 +108,10 @@ export declare class MembershipWrapper implements Membership.IUser {
|
|
|
82
108
|
* @param data The data to update
|
|
83
109
|
* @returns The updated User
|
|
84
110
|
*/
|
|
85
|
-
update(data: any): Promise<
|
|
111
|
+
update(data: any): Promise<User>;
|
|
86
112
|
/**
|
|
87
113
|
* Remove a User
|
|
88
114
|
* @returns The result of the remove
|
|
89
115
|
*/
|
|
90
|
-
remove(): Promise<
|
|
116
|
+
remove(): Promise<IUserDelete>;
|
|
91
117
|
}
|
package/dist/api/user.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.User = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* Class
|
|
7
|
+
**************************************************************/
|
|
8
|
+
class User extends core_1.WebflowRecord {
|
|
9
|
+
/**************************************************************
|
|
10
|
+
* Static Methods
|
|
11
|
+
**************************************************************/
|
|
12
|
+
/**
|
|
13
|
+
* Get a list of Users
|
|
14
|
+
* @param params The params for the request
|
|
15
|
+
* @param params.siteId The site ID
|
|
16
|
+
* @param params.limit The number of items to return (optional)
|
|
17
|
+
* @param params.offset The number of items to skip (optional)
|
|
18
|
+
* @param client The Axios client instance
|
|
19
|
+
* @returns A list of Users
|
|
20
|
+
*/
|
|
21
|
+
static list({ siteId, limit, offset }, client) {
|
|
22
|
+
(0, core_1.requireArgs)({ siteId });
|
|
23
|
+
const params = { limit, offset };
|
|
24
|
+
const path = `/sites/${siteId}/users`;
|
|
25
|
+
return client.get(path, { params });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get a single User
|
|
29
|
+
* @param params The params for the request
|
|
30
|
+
* @param params.siteId The site ID
|
|
31
|
+
* @param params.userId The user ID
|
|
32
|
+
* @param client The Axios client instance
|
|
33
|
+
* @returns A single User
|
|
34
|
+
*/
|
|
35
|
+
static getOne({ siteId, userId }, client) {
|
|
36
|
+
(0, core_1.requireArgs)({ siteId, userId });
|
|
37
|
+
const path = `/sites/${siteId}/users/${userId}`;
|
|
38
|
+
return client.get(path);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Update a User
|
|
42
|
+
* @param params The params for the request
|
|
43
|
+
* @param params.siteId The site ID
|
|
44
|
+
* @param params.userId The user ID
|
|
45
|
+
* @param params.data The data to update
|
|
46
|
+
* @param client The Axios client instance
|
|
47
|
+
* @returns The updated User
|
|
48
|
+
*/
|
|
49
|
+
static update({ siteId, userId, data, }, client) {
|
|
50
|
+
(0, core_1.requireArgs)({ siteId, userId });
|
|
51
|
+
const path = `/sites/${siteId}/users/${userId}`;
|
|
52
|
+
return client.patch(path, data);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Invite a User to a site
|
|
56
|
+
* @param params The params for the request
|
|
57
|
+
* @param params.siteId The site ID
|
|
58
|
+
* @param params.email The email address of the user to invite
|
|
59
|
+
* @param client The Axios client instance
|
|
60
|
+
* @returns The newly created User
|
|
61
|
+
*/
|
|
62
|
+
static async invite({ siteId, email }, client) {
|
|
63
|
+
(0, core_1.requireArgs)({ siteId, email });
|
|
64
|
+
const path = `/sites/${siteId}/users/invite`;
|
|
65
|
+
return client.post(path, { email });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Remove a User
|
|
69
|
+
* @param params The params for the request
|
|
70
|
+
* @param params.siteId The site ID
|
|
71
|
+
* @param params.userId The user ID
|
|
72
|
+
* @param client The Axios client instance
|
|
73
|
+
* @returns The result of the remove
|
|
74
|
+
*/
|
|
75
|
+
static remove({ siteId, userId }, client) {
|
|
76
|
+
(0, core_1.requireArgs)({ siteId, userId });
|
|
77
|
+
const path = `/sites/${siteId}/users/${userId}`;
|
|
78
|
+
return client.delete(path);
|
|
79
|
+
}
|
|
80
|
+
/**************************************************************
|
|
81
|
+
* Instance Methods
|
|
82
|
+
**************************************************************/
|
|
83
|
+
/**
|
|
84
|
+
* Update a User
|
|
85
|
+
* @param data The data to update
|
|
86
|
+
* @returns The updated User
|
|
87
|
+
*/
|
|
88
|
+
async update(data) {
|
|
89
|
+
const params = { siteId: this.siteId, userId: this._id, data };
|
|
90
|
+
const res = await User.update(params, this.client);
|
|
91
|
+
return new User(this.client, res);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Remove a User
|
|
95
|
+
* @returns The result of the remove
|
|
96
|
+
*/
|
|
97
|
+
async remove() {
|
|
98
|
+
const params = { siteId: this.siteId, userId: this._id };
|
|
99
|
+
const res = await User.remove(params, this.client);
|
|
100
|
+
return res.data;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.User = User;
|