@@ -14,6 +14,7 @@ import {
1414 CreateCustomerEventDocument ,
1515 CreateThreadDocument ,
1616 CreateThreadEventDocument ,
17+ CreateWebhookTargetDocument ,
1718 CustomerByEmailDocument ,
1819 CustomerByIdDocument ,
1920 type CustomerCardConfigPartsFragment ,
@@ -26,6 +27,7 @@ import {
2627 CustomersDocument ,
2728 DeleteCustomerCardConfigDocument ,
2829 DeleteCustomerDocument ,
30+ DeleteWebhookTargetDocument ,
2931 type EmailPartsFragment ,
3032 type LabelPartsFragment ,
3133 LabelTypeDocument ,
@@ -49,10 +51,14 @@ import {
4951 ThreadsDocument ,
5052 UnassignThreadDocument ,
5153 UpdateCustomerCardConfigDocument ,
54+ UpdateWebhookTargetDocument ,
5255 UpsertCustomerDocument ,
5356 type UpsertResult ,
5457 UserByEmailDocument ,
5558 type UserPartsFragment ,
59+ WebhookTargetDocument ,
60+ type WebhookTargetPartsFragment ,
61+ WebhookTargetsDocument ,
5662 type WorkspacePartsFragment ,
5763} from './graphql/types' ;
5864import { request } from './request' ;
@@ -729,4 +735,74 @@ export class PlainClient {
729735
730736 return unwrapData ( res , ( q ) => nonNullable ( q . createThreadEvent . threadEvent ) ) ;
731737 }
738+
739+ async createWebhookTarget (
740+ input : VariablesOf < typeof CreateWebhookTargetDocument > [ 'input' ]
741+ ) : SDKResult < WebhookTargetPartsFragment > {
742+ const res = await request ( this . #ctx, {
743+ query : CreateWebhookTargetDocument ,
744+ variables : {
745+ input,
746+ } ,
747+ } ) ;
748+
749+ return unwrapData ( res , ( q ) => nonNullable ( q . createWebhookTarget . webhookTarget ) ) ;
750+ }
751+
752+ async updateWebhookTarget (
753+ input : VariablesOf < typeof UpdateWebhookTargetDocument > [ 'input' ]
754+ ) : SDKResult < WebhookTargetPartsFragment > {
755+ const res = await request ( this . #ctx, {
756+ query : UpdateWebhookTargetDocument ,
757+ variables : {
758+ input,
759+ } ,
760+ } ) ;
761+
762+ return unwrapData ( res , ( q ) => nonNullable ( q . updateWebhookTarget . webhookTarget ) ) ;
763+ }
764+
765+ async deleteWebhookTarget (
766+ input : VariablesOf < typeof DeleteWebhookTargetDocument > [ 'input' ]
767+ ) : SDKResult < null > {
768+ const res = await request ( this . #ctx, {
769+ query : DeleteWebhookTargetDocument ,
770+ variables : {
771+ input,
772+ } ,
773+ } ) ;
774+
775+ return unwrapData ( res , ( ) => null ) ;
776+ }
777+
778+ async getWebhookTargets ( variables : VariablesOf < typeof WebhookTargetsDocument > ) : SDKResult < {
779+ webhookTargets : WebhookTargetPartsFragment [ ] ;
780+ pageInfo : PageInfoPartsFragment ;
781+ } > {
782+ const res = await request ( this . #ctx, {
783+ query : WebhookTargetsDocument ,
784+ variables,
785+ } ) ;
786+
787+ return unwrapData ( res , ( q ) => ( {
788+ pageInfo : q . webhookTargets . pageInfo ,
789+ webhookTargets : q . webhookTargets . edges . map ( ( edge ) => edge . node ) ,
790+ } ) ) ;
791+ }
792+
793+ /**
794+ * If the webhook target is not found it will return null
795+ */
796+ async getWebhookTargetById (
797+ variables : VariablesOf < typeof WebhookTargetDocument >
798+ ) : SDKResult < WebhookTargetPartsFragment | null > {
799+ const res = await request ( this . #ctx, {
800+ query : WebhookTargetDocument ,
801+ variables,
802+ } ) ;
803+
804+ return unwrapData ( res , ( q ) => {
805+ return q . webhookTarget ;
806+ } ) ;
807+ }
732808}
0 commit comments