Skip to content

Commit 1c3167e

Browse files
authored
Add createNote method (#113)
* addNoteToThread function - close but not quite there * update method name to match schema * re-order imports to appease the linter * add changeset * remove deprecated method
1 parent 4e9e8fa commit 1c3167e

File tree

6 files changed

+716
-56
lines changed

6 files changed

+716
-56
lines changed

.changeset/thin-brooms-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@team-plain/typescript-sdk': minor
3+
---
4+
5+
Add `createNote` method to the SDK

src/client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
CreateAttachmentUploadUrlDocument,
1313
CreateCustomerCardConfigDocument,
1414
CreateCustomerEventDocument,
15+
CreateNoteDocument,
1516
CreateThreadDocument,
1617
CreateThreadEventDocument,
1718
CreateWebhookTargetDocument,
@@ -36,6 +37,7 @@ import {
3637
MarkThreadAsDoneDocument,
3738
MarkThreadAsTodoDocument,
3839
MyWorkspaceDocument,
40+
type NotePartsFragment,
3941
type PageInfo,
4042
type PageInfoPartsFragment,
4143
RemoveCustomerFromCustomerGroupsDocument,
@@ -805,4 +807,16 @@ export class PlainClient {
805807
return q.webhookTarget;
806808
});
807809
}
810+
811+
/** Create a note on a thread */
812+
async createNote(
813+
input: VariablesOf<typeof CreateNoteDocument>['input']
814+
): SDKResult<NotePartsFragment> {
815+
const res = await request(this.#ctx, {
816+
query: CreateNoteDocument,
817+
variables: { input },
818+
});
819+
820+
return unwrapData(res, (d) => nonNullable(d.createNote.note));
821+
}
808822
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fragment NoteParts on Note {
2+
__typename
3+
id
4+
markdown
5+
text
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mutation createNote($input: CreateNoteInput!) {
2+
createNote(input: $input) {
3+
note {
4+
...NoteParts
5+
}
6+
error {
7+
...MutationErrorParts
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)