File tree Expand file tree Collapse file tree 6 files changed +69
-13
lines changed Expand file tree Collapse file tree 6 files changed +69
-13
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @team-plain/typescript-sdk ' : minor
3+ ---
4+
5+ Add support for creating attachment upload urls via the SDK
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import type { Context } from './context';
44import type { PlainSDKError } from './error' ;
55import {
66 AddCustomerToCustomerGroupsDocument ,
7+ type AttachmentUploadUrlPartsFragment ,
8+ CreateAttachmentUploadUrlDocument ,
79 CreateIssueDocument ,
810 CustomerByEmailDocument ,
911 CustomerByIdDocument ,
@@ -223,4 +225,19 @@ export class PlainClient {
223225 return nonNullable ( q . replyToEmail . email ) ;
224226 } ) ;
225227 }
228+
229+ async createAttachmentUploadUrl (
230+ input : VariablesOf < typeof CreateAttachmentUploadUrlDocument > [ 'input' ]
231+ ) : SDKResult < AttachmentUploadUrlPartsFragment > {
232+ const res = await request ( this . #ctx, {
233+ query : CreateAttachmentUploadUrlDocument ,
234+ variables : {
235+ input,
236+ } ,
237+ } ) ;
238+
239+ return unwrapData ( res , ( q ) => {
240+ return nonNullable ( q . createAttachmentUploadUrl . attachmentUploadUrl ) ;
241+ } ) ;
242+ }
226243}
Original file line number Diff line number Diff line change 55
66import { PlainClient } from '../client' ;
77
8- export async function upsertCustomerExample ( ) {
9- const client = new PlainClient ( { apiKey : '' } ) ;
8+ export async function createCustomer ( ) {
9+ const client = new PlainClient ( { apiKey : 'XXX ' } ) ;
1010
1111 const res = await client . upsertCustomer ( {
1212 identifier : {
13- customerId : '' ,
13+ emailAddress : 'jane@gmail.com ' ,
1414 } ,
1515 onCreate : {
16- fullName : '' ,
16+ fullName : 'Jane Fargate ' ,
1717 email : {
18- email : '' ,
19- isVerified : false ,
18+ email : 'jane@gmail.com ' ,
19+ isVerified : true ,
2020 } ,
2121 } ,
2222 onUpdate : { } ,
2323 } ) ;
2424
2525 if ( res . error ) {
2626 console . error ( res . error ) ;
27- throw new Error ( res . error . message ) ;
27+ } else {
28+ console . log ( `Created customer with id=${ res . data . customer . id } ` ) ;
2829 }
29-
30- console . log ( `Created customer with id=${ res . data . customer . id } ` ) ;
3130}
Original file line number Diff line number Diff line change 1+ fragment AttachmentUploadUrlParts on AttachmentUploadUrl {
2+ __typename
3+ attachment {
4+ ... AttachmentParts
5+ }
6+ uploadFormUrl
7+ uploadFormData {
8+ key
9+ value
10+ }
11+ expiresAt {
12+ ... DateTimeParts
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ mutation createAttachmentUploadUrl ($input : CreateAttachmentUploadUrlInput ! ) {
2+ createAttachmentUploadUrl (input : $input ) {
3+ attachmentUploadUrl {
4+ ... AttachmentUploadUrlParts
5+ }
6+ error {
7+ ... MutationErrorParts
8+ }
9+ }
10+ }
You can’t perform that action at this time.
0 commit comments