Skip to content

Commit 4f7dc07

Browse files
committed
feat(rest-api-client): add space.addThread() method
1 parent 4377953 commit 4f7dc07

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

examples/rest-api-client-demo/src/space.ts

+11
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ export class Space {
8383
}
8484
}
8585

86+
public async addThread() {
87+
const name = "Added Thread Name";
88+
try {
89+
console.log(
90+
await this.client.space.addThread({ space: SPACE_ID, name }),
91+
);
92+
} catch (error) {
93+
console.log(error);
94+
}
95+
}
96+
8697
public async updateThread() {
8798
const body = "<b>This is an updated thread body</b>";
8899
const name = "Updated Thread Name";

packages/rest-api-client/docs/space.md

+21
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [updateSpaceBody](#updateSpaceBody)
66
- [getSpaceMembers](#getSpaceMembers)
77
- [updateSpaceMembers](#updateSpaceMembers)
8+
- [addThread](#addThread)
89
- [updateThread](#updateThread)
910
- [addThreadComment](#addThreadComment)
1011
- [addGuests](#addGuests)
@@ -175,6 +176,26 @@ An empty object.
175176

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

179+
### addThread
180+
181+
Adds a Thread of a Space.<br />
182+
The Enable multiple threads option must be enabled in the space settings.
183+
184+
#### Parameters
185+
186+
| Name | Type | Required | Description |
187+
| ---- | :--------------: | :------: | -------------------------------------------------------------------- |
188+
| space | Number or String | Yes | The space ID. |
189+
| name | String | Yes | The new name of the Thread.<br />Must be between 1 - 128 characters. |
190+
191+
#### Returns
192+
193+
An empty object.
194+
195+
#### Reference
196+
197+
- https://kintone.dev/en/docs/kintone/rest-api/spaces/add-thread/
198+
178199
### updateThread
179200

180201
Updates a Thread of a Space.

packages/rest-api-client/src/client/SpaceClient.ts

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ export class SpaceClient extends BaseClient {
5252
return this.client.put(path, params);
5353
}
5454

55+
public addThread(params: { space: SpaceID; name: string }): Promise<{id: string}> {
56+
const path = this.buildPathWithGuestSpaceId({
57+
endpointName: "space/thread",
58+
});
59+
return this.client.post(path, params);
60+
}
61+
5562
public updateThread(params: {
5663
id: ThreadID;
5764
name?: string;

packages/rest-api-client/src/client/__tests__/SpaceClient.test.ts

+19
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,25 @@ describe("SpaceClient", () => {
136136
});
137137
});
138138

139+
describe("addThread", () => {
140+
const params = {
141+
space: SPACE_ID,
142+
name: "Added Thread Name",
143+
};
144+
beforeEach(async () => {
145+
await spaceClient.addThread(params);
146+
});
147+
it("should pass the path to the http client", () => {
148+
expect(mockClient.getLogs()[0].path).toBe("/k/v1/space/thread.json");
149+
});
150+
it("should send a POST request", () => {
151+
expect(mockClient.getLogs()[0].method).toBe("post");
152+
});
153+
it("should pass id, name to the http client", () => {
154+
expect(mockClient.getLogs()[0].params).toEqual(params);
155+
});
156+
});
157+
139158
describe("updateThread", () => {
140159
const params = {
141160
id: THREAD_ID,

0 commit comments

Comments
 (0)