File tree Expand file tree Collapse file tree 7 files changed +1248
-45
lines changed Expand file tree Collapse file tree 7 files changed +1248
-45
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ import {
7171 type TenantTierMembershipPartsFragment ,
7272 TenantsDocument ,
7373 ThreadByExternalIdDocument ,
74+ ThreadByRefDocument ,
7475 ThreadDocument ,
7576 type ThreadEventPartsFragment ,
7677 type ThreadFieldPartsFragment ,
@@ -576,6 +577,20 @@ export class PlainClient {
576577 return unwrapData ( res , ( q ) => q . thread ) ;
577578 }
578579
580+ /**
581+ * Get a single thread by its ref (eg T-12345)
582+ */
583+ async getThreadByRef (
584+ variables : VariablesOf < typeof ThreadByRefDocument >
585+ ) : SDKResult < ThreadPartsFragment | null > {
586+ const res = await request ( this . #ctx, {
587+ query : ThreadByRefDocument ,
588+ variables,
589+ } ) ;
590+
591+ return unwrapData ( res , ( q ) => q . threadByRef ) ;
592+ }
593+
579594 /**
580595 * Get a single thread by external id. A thread's external id is unique per customer,
581596 * hence why the customer id is also required.
Original file line number Diff line number Diff line change 1+ import { PlainClient } from '../index' ;
2+
3+ export async function getThreadByRef ( ) {
4+ const client = new PlainClient ( { apiKey : process . env . API_KEY || '' } ) ;
5+
6+ const ref = 'T-12345' ;
7+ const res = await client . getThreadByRef ( {
8+ ref,
9+ } ) ;
10+ if ( res . error ) {
11+ console . error ( res . error ) ;
12+ } else if ( res . data === null ) {
13+ console . log ( `Thread with ref=${ ref } not found` ) ;
14+ } else {
15+ console . log ( `Thread with id=${ res . data . id } and ref=${ res . data . ref } found` ) ;
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,10 @@ export async function upsertThreadField() {
2525
2626export async function deleteThreadField ( ) {
2727 const res = await client . deleteThreadField ( {
28- threadFieldId : 'tf_01HVTN2VTNYP91P5XGDQ57M2ZX' ,
28+ identifier : {
29+ key : 'product_area' ,
30+ threadId : 'th_01HVNWFJS395XVPPBJNE6A8BHP' ,
31+ } ,
2932 } ) ;
3033
3134 if ( res . error ) {
Original file line number Diff line number Diff line change 11fragment ThreadParts on Thread {
22 __typename
33 id
4+ ref
45 externalId
56 customer {
67 id
Original file line number Diff line number Diff line change 1+ query threadByRef ($ref : String ! ) {
2+ threadByRef (ref : $ref ) {
3+ ... ThreadParts
4+ }
5+ }
You can’t perform that action at this time.
0 commit comments