webflow-api 1.1.2 → 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.
Files changed (70) hide show
  1. package/dist/api/collection.d.ts +85 -24
  2. package/dist/api/collection.js +88 -29
  3. package/dist/api/index.d.ts +7 -7
  4. package/dist/api/index.js +9 -19
  5. package/dist/api/item.d.ts +141 -107
  6. package/dist/api/item.js +145 -125
  7. package/dist/api/meta.d.ts +16 -14
  8. package/dist/api/meta.js +20 -19
  9. package/dist/api/oauth.d.ts +38 -36
  10. package/dist/api/oauth.js +59 -59
  11. package/dist/api/site.d.ts +118 -43
  12. package/dist/api/site.js +131 -53
  13. package/dist/{wrapper/membership.d.ts → api/user.d.ts} +59 -47
  14. package/dist/api/user.js +103 -0
  15. package/dist/api/webhook.d.ts +77 -55
  16. package/dist/api/webhook.js +74 -61
  17. package/dist/core/error.d.ts +2 -0
  18. package/dist/core/error.js +8 -1
  19. package/dist/core/index.d.ts +2 -2
  20. package/dist/core/index.js +2 -2
  21. package/dist/core/response.d.ts +32 -0
  22. package/dist/core/response.js +26 -0
  23. package/dist/{webflow.d.ts → core/webflow.d.ts} +56 -59
  24. package/dist/{webflow.js → core/webflow.js} +101 -68
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +2 -2
  27. package/package.json +2 -4
  28. package/src/api/collection.ts +102 -35
  29. package/src/api/index.ts +7 -7
  30. package/src/api/item.ts +207 -176
  31. package/src/api/meta.ts +19 -18
  32. package/src/api/oauth.ts +62 -74
  33. package/src/api/site.ts +158 -55
  34. package/src/api/user.ts +152 -0
  35. package/src/api/webhook.ts +97 -80
  36. package/src/core/error.ts +8 -0
  37. package/src/core/index.ts +2 -2
  38. package/src/core/response.ts +50 -0
  39. package/src/{webflow.ts → core/webflow.ts} +131 -145
  40. package/src/index.ts +1 -1
  41. package/yarn.lock +0 -5
  42. package/dist/api/membership.d.ts +0 -114
  43. package/dist/api/membership.js +0 -96
  44. package/dist/core/client.d.ts +0 -27
  45. package/dist/core/client.js +0 -60
  46. package/dist/core/options.d.ts +0 -8
  47. package/dist/core/options.js +0 -5
  48. package/dist/wrapper/collection.d.ts +0 -85
  49. package/dist/wrapper/collection.js +0 -94
  50. package/dist/wrapper/index.d.ts +0 -6
  51. package/dist/wrapper/index.js +0 -22
  52. package/dist/wrapper/item.d.ts +0 -140
  53. package/dist/wrapper/item.js +0 -153
  54. package/dist/wrapper/membership.js +0 -123
  55. package/dist/wrapper/response.d.ts +0 -16
  56. package/dist/wrapper/response.js +0 -17
  57. package/dist/wrapper/site.d.ts +0 -168
  58. package/dist/wrapper/site.js +0 -191
  59. package/dist/wrapper/webhook.d.ts +0 -78
  60. package/dist/wrapper/webhook.js +0 -82
  61. package/src/api/membership.ts +0 -155
  62. package/src/core/client.ts +0 -82
  63. package/src/core/options.ts +0 -9
  64. package/src/wrapper/collection.ts +0 -115
  65. package/src/wrapper/index.ts +0 -6
  66. package/src/wrapper/item.ts +0 -218
  67. package/src/wrapper/membership.ts +0 -163
  68. package/src/wrapper/response.ts +0 -25
  69. package/src/wrapper/site.ts +0 -228
  70. package/src/wrapper/webhook.ts +0 -116
@@ -1,4 +1,6 @@
1
- import { Client, QueryString } from "../core";
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
- * Functions
25
+ * Class
24
26
  **************************************************************/
25
- /**
26
- * Get a list of Sites
27
- * @param client The Webflow client
28
- * @param params The query string parameters (optional)
29
- * @returns
30
- */
31
- export declare function list(client: Client, params?: QueryString): Promise<import("axios").AxiosResponse<ISite[], any>>;
32
- /**
33
- * Get a single Site
34
- * @param client The Webflow client
35
- * @param params The params for the request
36
- * @param params.siteId The site ID
37
- * @param params.params The query string parameters (optional)
38
- * @returns A single Site
39
- */
40
- export declare function getOne(client: Client, { siteId, params }: {
41
- siteId: string;
42
- params?: QueryString;
43
- }): Promise<import("axios").AxiosResponse<ISite, any>>;
44
- /**
45
- * Publish a site
46
- * @param client The Webflow client
47
- * @param params The params for the request
48
- * @param params.siteId The site ID
49
- * @param params.domains The domains to publish to
50
- * @returns The publish result
51
- */
52
- export declare function publish(client: Client, { siteId, domains }: {
53
- siteId: string;
54
- domains: string[];
55
- }): Promise<import("axios").AxiosResponse<IPublishSite, any>>;
56
- /**
57
- * Get a list of domains for a site
58
- * @param client The Webflow client
59
- * @param params The params for the request
60
- * @param params.siteId The site ID
61
- * @returns A list of domains
62
- */
63
- export declare function domains(client: Client, { siteId }: {
64
- siteId: string;
65
- }): Promise<import("axios").AxiosResponse<IDomain[], any>>;
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.domains = exports.publish = exports.getOne = exports.list = void 0;
3
+ exports.Site = void 0;
4
+ const _1 = require(".");
4
5
  const core_1 = require("../core");
5
6
  /**************************************************************
6
- * Functions
7
+ * Class
7
8
  **************************************************************/
8
- /**
9
- * Get a list of Sites
10
- * @param client The Webflow client
11
- * @param params The query string parameters (optional)
12
- * @returns
13
- */
14
- function list(client, params) {
15
- const path = "/sites";
16
- return client.get(path, { params });
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.list = list;
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,93 +1,105 @@
1
- import { Client, PaginationFilter } from "../core";
2
- import { Membership } from "../api";
3
- export declare class MembershipWrapper implements Membership.IUser {
4
- private client;
5
- private siteId;
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
- constructor(client: Client, siteId: string, membership: Membership.IUser);
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 single User
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.userId The user ID
21
- * @returns A single User
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 getOne(client: Client, { userId, siteId }: {
48
+ static list({ siteId, limit, offset }: {
24
49
  siteId: string;
25
- userId: string;
26
- }): Promise<MembershipWrapper>;
50
+ limit?: number;
51
+ offset?: number;
52
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<PaginatedUsers, any>>;
27
53
  /**
28
- * Get a list of Users
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.limit The number of items to return (optional)
33
- * @param params.offset The number of items to skip (optional)
34
- * @returns A list of Users
57
+ * @param params.userId The user ID
58
+ * @param client The Axios client instance
59
+ * @returns A single User
35
60
  */
36
- static list(client: Client, { siteId, limit, offset }: {
61
+ static getOne({ siteId, userId }: {
37
62
  siteId: string;
38
- } & PaginationFilter): Promise<import("./response").MetaResponse<MembershipWrapper[]>>;
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(client: Client, { userId, siteId, data }: {
49
- userId: string;
74
+ static update({ siteId, userId, data, }: {
75
+ data: object;
50
76
  siteId: string;
51
- data: any;
52
- }): Promise<MembershipWrapper>;
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(client: Client, { siteId, email }: {
87
+ static invite({ siteId, email }: {
62
88
  siteId: string;
63
89
  email: string;
64
- }): Promise<import("./response").MetaResponse<Membership.IUser>>;
65
- /**
66
- * Get a list of Access Groups
67
- * @param client The Webflow client
68
- * @param params The params for the request
69
- * @param params.siteId The Site ID
70
- * @param params.limit The number of items to return (optional)
71
- * @param params.offset The number of items to skip (optional)
72
- * @returns A list of Access Groups
73
- */
74
- static accessGroups(client: Client, { siteId, limit, offset, }: {
75
- siteId: string;
76
- limit?: number;
77
- offset?: number;
78
- }): Promise<import("./response").MetaResponse<Membership.PaginatedAccessGroups>>;
90
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUser, any>>;
79
91
  /**
80
92
  * Remove a User
81
- * @param client The Webflow client
82
93
  * @param params The params for the request
83
94
  * @param params.siteId The site ID
84
95
  * @param params.userId The user ID
96
+ * @param client The Axios client instance
85
97
  * @returns The result of the remove
86
98
  */
87
- static remove(client: Client, { siteId, userId }: {
99
+ static remove({ siteId, userId }: {
88
100
  siteId: string;
89
101
  userId: string;
90
- }): Promise<import("./response").MetaResponse<Membership.IUserDelete>>;
102
+ }, client: AxiosInstance): Promise<import("axios").AxiosResponse<IUserDelete, any>>;
91
103
  /**************************************************************
92
104
  * Instance Methods
93
105
  **************************************************************/
@@ -96,10 +108,10 @@ export declare class MembershipWrapper implements Membership.IUser {
96
108
  * @param data The data to update
97
109
  * @returns The updated User
98
110
  */
99
- update(data: any): Promise<MembershipWrapper>;
111
+ update(data: any): Promise<User>;
100
112
  /**
101
113
  * Remove a User
102
114
  * @returns The result of the remove
103
115
  */
104
- remove(): Promise<import("./response").MetaResponse<Membership.IUserDelete>>;
116
+ remove(): Promise<IUserDelete>;
105
117
  }
@@ -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;