Skip to content

Commit 79b99b3

Browse files
authored
Add ability to change customer status (#54)
* Add ability to change customer status * update changeset
1 parent e209bf7 commit 79b99b3

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

.changeset/gentle-planets-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@team-plain/typescript-sdk': minor
3+
---
4+
5+
Add ability to change customer status via `client.changeCustomerStatus()`

src/client.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { PlainSDKError } from './error';
55
import {
66
AddCustomerToCustomerGroupsDocument,
77
type AttachmentUploadUrlPartsFragment,
8+
ChangeCustomerStatusDocument,
89
CreateAttachmentUploadUrlDocument,
910
CreateCustomerCardConfigDocument,
1011
CreateIssueDocument,
@@ -156,6 +157,23 @@ export class PlainClient {
156157
});
157158
}
158159

160+
async changeCustomerStatus(
161+
input: VariablesOf<typeof ChangeCustomerStatusDocument>['input']
162+
): SDKResult<{ customer: CustomerPartsFragment }> {
163+
const res = await request(this.#ctx, {
164+
query: ChangeCustomerStatusDocument,
165+
variables: {
166+
input,
167+
},
168+
});
169+
170+
return unwrapData(res, (q) => {
171+
return {
172+
customer: nonNullable(q.changeCustomerStatus.customer),
173+
};
174+
});
175+
}
176+
159177
/**
160178
* Create an issue for a customer. If you want you can override the default issue priority
161179
* in your settings by specifying a priority manually here.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mutation changeCustomerStatus($input: ChangeCustomerStatusInput!) {
2+
changeCustomerStatus(input: $input) {
3+
customer {
4+
...CustomerParts
5+
}
6+
error {
7+
...MutationErrorParts
8+
}
9+
}
10+
}

src/graphql/types.ts

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,26 @@ export type {
3030

3131
// Input types
3232
AddCustomerToCustomerGroupsInput,
33+
ChangeCustomerStatusInput,
34+
CommunicationChannelInput,
35+
CreateCustomerCardConfigInput,
3336
CreateIssueInput,
34-
ResolveIssueInput,
37+
DeleteCustomerCardConfigInput,
3538
RemoveCustomerFromCustomerGroupsInput,
3639
ReplyToEmailInput,
40+
ResolveIssueInput,
3741
SendNewEmailInput,
42+
UpdateCustomerCardConfigInput,
3843
UpsertCustomerInput,
3944
UpsertCustomTimelineEntryInput,
40-
CommunicationChannelInput,
41-
CreateCustomerCardConfigInput,
42-
UpdateCustomerCardConfigInput,
43-
DeleteCustomerCardConfigInput,
4445

4546
// Fragment types
4647
ActorPartsFragment,
4748
AttachmentPartsFragment,
4849
CustomerActorPartsFragment,
49-
CustomerPartsFragment,
50-
CustomerGroupPartsFragment,
5150
CustomerGroupMembershipPartsFragment,
51+
CustomerGroupPartsFragment,
52+
CustomerPartsFragment,
5253
DateTimePartsFragment,
5354
DeletedCustomerActorPartsFragment,
5455
EmailActorPartsFragment,
@@ -69,10 +70,10 @@ export type {
6970
} from './graphql/types';
7071

7172
export type {
72-
PlainSDKError,
73-
ForbiddenError,
7473
BadRequestError,
74+
ForbiddenError,
7575
InternalServerError,
7676
MutationError,
77+
PlainSDKError,
7778
UnknownError,
7879
} from './error';

0 commit comments

Comments
 (0)