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/funny-starfishes-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@team-plain/typescript-sdk': minor
---

Add support for getCustomerByExternalId
20 changes: 20 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CreateThreadEventDocument,
CreateWebhookTargetDocument,
CustomerByEmailDocument,
CustomerByExternalIdDocument,
CustomerByIdDocument,
type CustomerCardConfigPartsFragment,
CustomerCustomerGroupsDocument,
Expand Down Expand Up @@ -221,6 +222,25 @@ export class PlainClient {
});
}

/**
* If the customer is not found this will return null.
*/
async getCustomerByExternalId(
variables: VariablesOf<typeof CustomerByExternalIdDocument>
): SDKResult<CustomerPartsFragment | null> {
const res = await request(this.#ctx, {
query: CustomerByExternalIdDocument,
variables,
});

return unwrapData(res, (q) => {
if (!q.customerByExternalId) {
return null;
}
return q.customerByExternalId;
});
}

/**
* If the customer is not found this will return null.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/graphql/queries/customerByExternalId.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query customerByExternalId($externalId: ID!) {
customerByExternalId(externalId: $externalId) {
...CustomerParts
}
}
Loading
Loading