diff --git a/packages/rest-api-client/src/client/AppClient.ts b/packages/rest-api-client/src/client/AppClient.ts index cf7c416bef..832a7a56a1 100644 --- a/packages/rest-api-client/src/client/AppClient.ts +++ b/packages/rest-api-client/src/client/AppClient.ts @@ -667,4 +667,16 @@ export class AppClient extends BaseClient { }); return this.client.get(path, rest); } + + public addPlugins(params: { + app: AppID; + ids: string[]; + revision?: Revision; + }): Promise<{ revision: string }> { + const path = this.buildPathWithGuestSpaceId({ + endpointName: "app/plugins", + preview: true, + }); + return this.client.post(path, params); + } } diff --git a/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts b/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts index a3d3fc9fdc..fa734ea17d 100644 --- a/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts +++ b/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts @@ -49,4 +49,22 @@ describe("AppClient: plugins", () => { }); }); }); + + describe("addPlugins", () => { + const params = { app: APP_ID, ids: ["abc", "xyz"], revision: 1 }; + beforeEach(async () => { + await appClient.addPlugins(params); + }); + it("should pass the path to the http client", () => { + expect(mockClient.getLogs()[0].path).toBe( + "/k/v1/preview/app/plugins.json", + ); + }); + it("should send a post request", () => { + expect(mockClient.getLogs()[0].method).toBe("post"); + }); + it("should pass the param to the http client", () => { + expect(mockClient.getLogs()[0].params).toEqual(params); + }); + }); });