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 space.addThread() method #2846

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions examples/rest-api-client-demo/src/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ export class Space {
}
}

public async addThread() {
const name = "Added Thread Name";
tasshi-me marked this conversation as resolved.
Show resolved Hide resolved
try {
console.log(await this.client.space.addThread({ space: SPACE_ID, name }));
} catch (error) {
console.log(error);
}
}

public async updateThread() {
const body = "<b>This is an updated thread body</b>";
const name = "Updated Thread Name";
Expand Down
21 changes: 21 additions & 0 deletions packages/rest-api-client/docs/space.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [updateSpaceBody](#updateSpaceBody)
- [getSpaceMembers](#getSpaceMembers)
- [updateSpaceMembers](#updateSpaceMembers)
- [addThread](#addThread)
- [updateThread](#updateThread)
- [addThreadComment](#addThreadComment)
- [addGuests](#addGuests)
Expand Down Expand Up @@ -175,6 +176,26 @@ An empty object.

- https://kintone.dev/en/docs/kintone/rest-api/spaces/update-space-members/

### addThread

Adds a Thread of a Space.<br />
The Enable multiple threads option must be enabled in the space settings.

#### Parameters

| Name | Type | Required | Description |
| ----- | :--------------: | :------: | -------------------------------------------------------------------- |
| space | Number or String | Yes | The space ID. |
| name | String | Yes | The new name of the Thread.<br />Must be between 1 - 128 characters. |

#### Returns

An empty object.
tasshi-me marked this conversation as resolved.
Show resolved Hide resolved

#### Reference

- https://kintone.dev/en/docs/kintone/rest-api/spaces/add-thread/

### updateThread

Updates a Thread of a Space.
Expand Down
10 changes: 10 additions & 0 deletions packages/rest-api-client/src/client/SpaceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ export class SpaceClient extends BaseClient {
return this.client.put(path, params);
}

public addThread(params: {
space: SpaceID;
name: string;
}): Promise<{ id: string }> {
const path = this.buildPathWithGuestSpaceId({
endpointName: "space/thread",
});
return this.client.post(path, params);
}

public updateThread(params: {
id: ThreadID;
name?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ describe("SpaceClient", () => {
});
});

describe("addThread", () => {
const params = {
space: SPACE_ID,
name: "Added Thread Name",
};
beforeEach(async () => {
await spaceClient.addThread(params);
});
it("should pass the path to the http client", () => {
expect(mockClient.getLogs()[0].path).toBe("/k/v1/space/thread.json");
});
it("should send a POST request", () => {
expect(mockClient.getLogs()[0].method).toBe("post");
});
it("should pass space, name to the http client", () => {
expect(mockClient.getLogs()[0].params).toEqual(params);
});
});

describe("updateThread", () => {
const params = {
id: THREAD_ID,
Expand Down