Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rest-api-client): Add method for uninstall plugin #2950

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/rest-api-client/docs/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [getApps](#getApps)
- [updatePlugin](#updatePlugin)
- [installPlugin](#installPlugin)
- [uninstallPlugin](#uninstallPlugin)

## Overview

Expand Down Expand Up @@ -141,3 +142,21 @@ Install an imported plug-in in the Kintone environment.
#### Reference

- https://kintone.dev/en/docs/kintone/rest-api/plugins/install-plugin/

### uninstallPlugin

Uninstalls a plug-in from the Kintone environment.

#### Parameters

| Name | Type | Required | Description |
| ---- | :----: | :------: | ---------------------- |
| id | String | Yes | The ID of the plug-in. |

#### Returns

An empty object.

#### Reference

- https://kintone.dev/en/docs/kintone/rest-api/plugins/uninstall-plugin/
6 changes: 6 additions & 0 deletions packages/rest-api-client/src/client/PluginClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
UpdatePluginForResponse,
InstallPluginForRequest,
InstallPluginForResponse,
UninstallPluginForRequest,
} from "./types/plugin";

export class PluginClient extends BaseClient {
Expand Down Expand Up @@ -45,4 +46,9 @@ export class PluginClient extends BaseClient {
const path = this.buildPath({ endpointName: "plugin" });
return this.client.post(path, params);
}

public uninstallPlugin(params: UninstallPluginForRequest): Promise<{}> {
const path = this.buildPath({ endpointName: "plugin" });
return this.client.delete(path, params);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,22 @@ describe("PluginClient", () => {
expect(mockClient.getLogs()[0].params).toEqual(params);
});
});

describe("uninstallPlugin", () => {
const params = {
id: "pluginId",
};
beforeEach(async () => {
await pluginClient.uninstallPlugin(params);
});
it("should pass the path to the http client", () => {
expect(mockClient.getLogs()[0].path).toBe("/k/v1/plugin.json");
});
it("should send a DELETE request", () => {
expect(mockClient.getLogs()[0].method).toBe("delete");
});
it("should pass the param to the http client", () => {
expect(mockClient.getLogs()[0].params).toEqual(params);
});
});
});
4 changes: 4 additions & 0 deletions packages/rest-api-client/src/client/types/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ export type InstallPluginForResponse = {
id: PluginID;
version: string;
};

export type UninstallPluginForRequest = {
id: PluginID;
};