const swanSdk = getSdk( new GraphQLClient("https://api.swan.io/live-partner/graphql") ); swanSdk .AddCard({ input: { accountMembershipId: myAccountMembershipId, consentRedirectUrl: myConsentRedirectUrl, international: true, eCommerce: true, nonMainCurrencyTransactions: true, withdrawal: true, }, }) .then(({ addCard: data }) => { match(data) .with({ __typename: "AddCardSuccessPayload" }, ({ card }) => { // Note that `card` is only available here! // … }) .with({ __typename: "ValidationRejection" }, ({ fields }) => { // … }) .with( { __typename: "AccountMembershipNotAllowedRejection" }, { __typename: "BadAccountStatusRejection" }, { __typename: "CardProductDisabledRejection" }, { __typename: "CardProductSuspendedRejection" }, { __typename: "EnabledCardDesignNotFoundRejection" }, { __typename: "ForbiddenRejection" }, { __typename: "MissingMandatoryFieldRejection" }, ({ message }) => { console.error(`rejected with "${message}"`); } ) .exhaustive(); });