Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-planets-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@team-plain/typescript-sdk': minor
---

Add ability to change customer status via `client.changeCustomerStatus()`
18 changes: 18 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { PlainSDKError } from './error';
import {
AddCustomerToCustomerGroupsDocument,
type AttachmentUploadUrlPartsFragment,
ChangeCustomerStatusDocument,
CreateAttachmentUploadUrlDocument,
CreateCustomerCardConfigDocument,
CreateIssueDocument,
Expand Down Expand Up @@ -156,6 +157,23 @@ export class PlainClient {
});
}

async changeCustomerStatus(
input: VariablesOf<typeof ChangeCustomerStatusDocument>['input']
): SDKResult<{ customer: CustomerPartsFragment }> {
const res = await request(this.#ctx, {
query: ChangeCustomerStatusDocument,
variables: {
input,
},
});

return unwrapData(res, (q) => {
return {
customer: nonNullable(q.changeCustomerStatus.customer),
};
});
}

/**
* Create an issue for a customer. If you want you can override the default issue priority
* in your settings by specifying a priority manually here.
Expand Down
10 changes: 10 additions & 0 deletions src/graphql/mutations/changeCustomerStatus.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mutation changeCustomerStatus($input: ChangeCustomerStatusInput!) {
changeCustomerStatus(input: $input) {
customer {
...CustomerParts
}
error {
...MutationErrorParts
}
}
}
8 changes: 8 additions & 0 deletions src/graphql/types.ts

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@ export type {

// Input types
AddCustomerToCustomerGroupsInput,
ChangeCustomerStatusInput,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new export (for the newly added mutation).

CommunicationChannelInput,
CreateCustomerCardConfigInput,
CreateIssueInput,
ResolveIssueInput,
DeleteCustomerCardConfigInput,
RemoveCustomerFromCustomerGroupsInput,
ReplyToEmailInput,
ResolveIssueInput,
SendNewEmailInput,
UpdateCustomerCardConfigInput,
UpsertCustomerInput,
UpsertCustomTimelineEntryInput,
CommunicationChannelInput,
CreateCustomerCardConfigInput,
UpdateCustomerCardConfigInput,
DeleteCustomerCardConfigInput,

// Fragment types
ActorPartsFragment,
AttachmentPartsFragment,
CustomerActorPartsFragment,
CustomerPartsFragment,
CustomerGroupPartsFragment,
CustomerGroupMembershipPartsFragment,
CustomerGroupPartsFragment,
CustomerPartsFragment,
DateTimePartsFragment,
DeletedCustomerActorPartsFragment,
EmailActorPartsFragment,
Expand All @@ -69,10 +70,10 @@ export type {
} from './graphql/types';

export type {
PlainSDKError,
ForbiddenError,
BadRequestError,
ForbiddenError,
InternalServerError,
MutationError,
PlainSDKError,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are sorted alphabetically but are otherwise unchanged!

UnknownError,
} from './error';