Skip to content

Commit

Permalink
Add createThread threadFields documentation (#49)
Browse files Browse the repository at this point in the history
* Add createThread threadFields documentation

* add example

* de-lint
  • Loading branch information
jordrake authored May 1, 2024
1 parent c444388 commit 4b49f04
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
28 changes: 27 additions & 1 deletion _snippets/graphql/create-thread.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ mutation createThread($input: CreateThreadInput!) {
title
previewText
priority
threadFields {
id
key
type
stringValue
booleanValue
}
}
error {
message
Expand Down Expand Up @@ -44,7 +51,26 @@ mutation createThread($input: CreateThreadInput!) {
}
}
],
"labelTypeIds": ["lt_01HB924PME9C0YWKW1N4AK3BZA"]
"labelTypeIds": ["lt_01HB924PME9C0YWKW1N4AK3BZA"],
"threadFields": [
{
"key": "my_string_field",
"type": "STRING",
"stringValue": "any value"
}
]
// You can also set other thread field types like boolean or enum.
// "threadFields": [{
// "key": "my_enum_field",
// "type": "ENUM",
// "stringValue": "any specified value",
// }],
//
// "threadFields": [{
// "key": "my_bool_field",
// "type": "BOOL",
// "booleanValue": true,
// }],
}
}
```
25 changes: 24 additions & 1 deletion _snippets/typescript-sdk/create-thread.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```ts
import { PlainClient } from '@team-plain/typescript-sdk';
import { PlainClient, ThreadFieldSchemaType } from '@team-plain/typescript-sdk';

const client = new PlainClient({ apiKey: 'plainApiKey_xxx' });

Expand All @@ -25,6 +25,29 @@ const res = await client.createThread({
// Label types are created in settings where you can also copy
// their ID.
labelTypeIds: ['lt_01HB924PME9C0YWKW1N4AK3BZA'],

// Thread fields are created in settings where you can also copy
// their key.
threadFields: [
{
key: 'my_string_field',
type: ThreadFieldSchemaType.String,
stringValue: 'any value',
},
],

// You can also set other thread field types like boolean or enum.
// threadFields: [{
// key: 'my_enum_field',
// type: ThreadFieldSchemaType.Enum,
// stringValue: 'any specified value',
// }]
//
// threadFields: [{
// key: 'my_bool_field',
// type: ThreadFieldSchemaType.Bool,
// booleanValue: true,
// }],
});

if (res.error) {
Expand Down
3 changes: 3 additions & 0 deletions api-reference/graphql/threads/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ To create a thread you need a `customerId`. You can get a customer id by [creati
- `thread:create`
- `thread:edit`
- `thread:read`
- `threadField:create`
- `threadField:update`
- `threadField:read`

<Snippet file="typescript-sdk/create-thread.mdx" />

Expand Down

0 comments on commit 4b49f04

Please sign in to comment.