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
29 changes: 29 additions & 0 deletions dev/apollo-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,26 @@ type BridgeCreateVirtualAccountPayload
virtualAccount: BridgeVirtualAccount
}

input BridgeDeleteExternalAccountInput
@join__type(graph: PUBLIC)
{
externalAccountId: ID!
}

type BridgeDeleteExternalAccountPayload
@join__type(graph: PUBLIC)
{
errors: [Error!]!
externalAccount: BridgeExternalAccount
}

type BridgeExternalAccount
@join__type(graph: PUBLIC)
{
accountNumberLast4: String!
bankName: String!
id: ID!
isDefault: Boolean!
status: String!
}

Expand Down Expand Up @@ -378,6 +392,19 @@ type BridgeRequestWithdrawalPayload
withdrawal: BridgeWithdrawal
}

input BridgeSetDefaultExternalAccountInput
@join__type(graph: PUBLIC)
{
externalAccountId: ID!
}

type BridgeSetDefaultExternalAccountPayload
@join__type(graph: PUBLIC)
{
errors: [Error!]!
externalAccount: BridgeExternalAccount
}

type BridgeVirtualAccount
@join__type(graph: PUBLIC)
{
Expand Down Expand Up @@ -1304,9 +1331,11 @@ type Mutation
bridgeCancelWithdrawalRequest(input: BridgeCancelWithdrawalRequestInput!): BridgeCancelWithdrawalRequestPayload!
bridgeCreateExternalAccount(input: BridgeCreateExternalAccountInput!): BridgeCreateExternalAccountPayload!
bridgeCreateVirtualAccount: BridgeCreateVirtualAccountPayload!
bridgeDeleteExternalAccount(input: BridgeDeleteExternalAccountInput!): BridgeDeleteExternalAccountPayload!
bridgeInitiateKyc(input: BridgeInitiateKycInput!): BridgeInitiateKycPayload!
bridgeInitiateWithdrawal(input: BridgeInitiateWithdrawalInput!): BridgeInitiateWithdrawalPayload!
bridgeRequestWithdrawal(input: BridgeRequestWithdrawalInput!): BridgeRequestWithdrawalPayload!
bridgeSetDefaultExternalAccount(input: BridgeSetDefaultExternalAccountInput!): BridgeSetDefaultExternalAccountPayload!
businessAccountUpgradeRequest(input: BusinessAccountUpgradeRequestInput!): AccountUpgradePayload!
callbackEndpointAdd(input: CallbackEndpointAddInput!): CallbackEndpointAddPayload!
callbackEndpointDelete(input: CallbackEndpointDeleteInput!): SuccessPayload!
Expand Down
4 changes: 4 additions & 0 deletions src/graphql/public/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ import BridgeInitiateKycMutation from "./root/mutation/bridge-initiate-kyc"
import BridgeCreateVirtualAccountMutation from "./root/mutation/bridge-create-virtual-account"
import BridgeAddExternalAccountMutation from "./root/mutation/bridge-add-external-account"
import BridgeCreateExternalAccountMutation from "./root/mutation/bridge-create-external-account"
import BridgeSetDefaultExternalAccountMutation from "./root/mutation/bridge-set-default-external-account"
import BridgeDeleteExternalAccountMutation from "./root/mutation/bridge-delete-external-account"
import BridgeRequestWithdrawalMutation from "./root/mutation/bridge-request-withdrawal"
import BridgeInitiateWithdrawalMutation from "./root/mutation/bridge-initiate-withdrawal"
import BridgeCancelWithdrawalRequestMutation from "./root/mutation/bridge-cancel-withdrawal-request"
Expand Down Expand Up @@ -127,6 +129,8 @@ export const mutationFields = {
bridgeCreateVirtualAccount: BridgeCreateVirtualAccountMutation,
bridgeAddExternalAccount: BridgeAddExternalAccountMutation,
bridgeCreateExternalAccount: BridgeCreateExternalAccountMutation,
bridgeSetDefaultExternalAccount: BridgeSetDefaultExternalAccountMutation,
bridgeDeleteExternalAccount: BridgeDeleteExternalAccountMutation,
bridgeRequestWithdrawal: BridgeRequestWithdrawalMutation,
bridgeInitiateWithdrawal: BridgeInitiateWithdrawalMutation,
bridgeCancelWithdrawalRequest: BridgeCancelWithdrawalRequestMutation,
Expand Down
54 changes: 54 additions & 0 deletions src/graphql/public/root/mutation/bridge-delete-external-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { GT } from "@graphql/index"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import IError from "@graphql/shared/types/abstract/error"
import BridgeExternalAccount from "@graphql/public/types/object/bridge-external-account"
import { BridgeConfig } from "@config"
import BridgeService from "@services/bridge"
import { BridgeDisabledError, BridgeAccountLevelError } from "@services/bridge/errors"

const BridgeDeleteExternalAccountInput = GT.Input({
name: "BridgeDeleteExternalAccountInput",
fields: () => ({
externalAccountId: { type: GT.NonNull(GT.ID) },
}),
})

const BridgeDeleteExternalAccountPayload = GT.Object({
name: "BridgeDeleteExternalAccountPayload",
fields: () => ({
errors: { type: GT.NonNullList(IError) },
externalAccount: { type: BridgeExternalAccount },
}),
})

const bridgeDeleteExternalAccount = GT.Field({
type: GT.NonNull(BridgeDeleteExternalAccountPayload),
args: {
input: { type: GT.NonNull(BridgeDeleteExternalAccountInput) },
},
resolve: async (
_,
{ input }: { input: { externalAccountId: string } },
{ domainAccount }: GraphQLPublicContextAuth,
) => {
if (!BridgeConfig.enabled) {
return { errors: [mapAndParseErrorForGqlResponse(new BridgeDisabledError())] }
}

if (!domainAccount || domainAccount.level <= 0) {
return { errors: [mapAndParseErrorForGqlResponse(new BridgeAccountLevelError())] }
}

const result = await BridgeService.deleteExternalAccount(
domainAccount.id,
input.externalAccountId,
)
if (result instanceof Error) {
return { errors: [mapAndParseErrorForGqlResponse(result)] }
}

return { externalAccount: result, errors: [] }
},
})

export default bridgeDeleteExternalAccount
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { GT } from "@graphql/index"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import IError from "@graphql/shared/types/abstract/error"
import BridgeExternalAccount from "@graphql/public/types/object/bridge-external-account"
import { BridgeConfig } from "@config"
import BridgeService from "@services/bridge"
import { BridgeDisabledError, BridgeAccountLevelError } from "@services/bridge/errors"

const BridgeSetDefaultExternalAccountInput = GT.Input({
name: "BridgeSetDefaultExternalAccountInput",
fields: () => ({
externalAccountId: { type: GT.NonNull(GT.ID) },
}),
})

const BridgeSetDefaultExternalAccountPayload = GT.Object({
name: "BridgeSetDefaultExternalAccountPayload",
fields: () => ({
errors: { type: GT.NonNullList(IError) },
externalAccount: { type: BridgeExternalAccount },
}),
})

const bridgeSetDefaultExternalAccount = GT.Field({
type: GT.NonNull(BridgeSetDefaultExternalAccountPayload),
args: {
input: { type: GT.NonNull(BridgeSetDefaultExternalAccountInput) },
},
resolve: async (
_,
{ input }: { input: { externalAccountId: string } },
{ domainAccount }: GraphQLPublicContextAuth,
) => {
if (!BridgeConfig.enabled) {
return { errors: [mapAndParseErrorForGqlResponse(new BridgeDisabledError())] }
}

if (!domainAccount || domainAccount.level <= 0) {
return { errors: [mapAndParseErrorForGqlResponse(new BridgeAccountLevelError())] }
}

const result = await BridgeService.setDefaultExternalAccount(
domainAccount.id,
input.externalAccountId,
)
if (result instanceof Error) {
return { errors: [mapAndParseErrorForGqlResponse(result)] }
}

return { externalAccount: result, errors: [] }
},
})

export default bridgeSetDefaultExternalAccount
21 changes: 21 additions & 0 deletions src/graphql/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,20 @@
virtualAccount: BridgeVirtualAccount
}

input BridgeDeleteExternalAccountInput {

Check notice on line 281 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Type 'BridgeDeleteExternalAccountInput' was added

Type 'BridgeDeleteExternalAccountInput' was added
externalAccountId: ID!

Check notice on line 282 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Input field 'externalAccountId' of type 'ID!' was added to input object type 'BridgeDeleteExternalAccountInput'

The field is being added to a new type.
}

type BridgeDeleteExternalAccountPayload {

Check notice on line 285 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Type 'BridgeDeleteExternalAccountPayload' was added

Type 'BridgeDeleteExternalAccountPayload' was added
errors: [Error!]!

Check notice on line 286 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'errors' was added to object type 'BridgeDeleteExternalAccountPayload'

Field 'errors' was added to object type 'BridgeDeleteExternalAccountPayload'
externalAccount: BridgeExternalAccount

Check notice on line 287 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'externalAccount' was added to object type 'BridgeDeleteExternalAccountPayload'

Field 'externalAccount' was added to object type 'BridgeDeleteExternalAccountPayload'
}

type BridgeExternalAccount {
accountNumberLast4: String!
bankName: String!
id: ID!
isDefault: Boolean!

Check notice on line 294 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'isDefault' was added to object type 'BridgeExternalAccount'

Field 'isDefault' was added to object type 'BridgeExternalAccount'
status: String!
}

Expand Down Expand Up @@ -325,6 +335,15 @@
withdrawal: BridgeWithdrawal
}

input BridgeSetDefaultExternalAccountInput {

Check notice on line 338 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Type 'BridgeSetDefaultExternalAccountInput' was added

Type 'BridgeSetDefaultExternalAccountInput' was added
externalAccountId: ID!

Check notice on line 339 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Input field 'externalAccountId' of type 'ID!' was added to input object type 'BridgeSetDefaultExternalAccountInput'

The field is being added to a new type.
}

type BridgeSetDefaultExternalAccountPayload {

Check notice on line 342 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Type 'BridgeSetDefaultExternalAccountPayload' was added

Type 'BridgeSetDefaultExternalAccountPayload' was added
errors: [Error!]!

Check notice on line 343 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'errors' was added to object type 'BridgeSetDefaultExternalAccountPayload'

Field 'errors' was added to object type 'BridgeSetDefaultExternalAccountPayload'
externalAccount: BridgeExternalAccount

Check notice on line 344 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'externalAccount' was added to object type 'BridgeSetDefaultExternalAccountPayload'

Field 'externalAccount' was added to object type 'BridgeSetDefaultExternalAccountPayload'
}

type BridgeVirtualAccount {
accountNumber: String
accountNumberLast4: String
Expand Down Expand Up @@ -1016,9 +1035,11 @@
bridgeCancelWithdrawalRequest(input: BridgeCancelWithdrawalRequestInput!): BridgeCancelWithdrawalRequestPayload!
bridgeCreateExternalAccount(input: BridgeCreateExternalAccountInput!): BridgeCreateExternalAccountPayload!
bridgeCreateVirtualAccount: BridgeCreateVirtualAccountPayload!
bridgeDeleteExternalAccount(input: BridgeDeleteExternalAccountInput!): BridgeDeleteExternalAccountPayload!

Check notice on line 1038 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'bridgeDeleteExternalAccount' was added to object type 'Mutation'

Field 'bridgeDeleteExternalAccount' was added to object type 'Mutation'

Check notice on line 1038 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Argument 'input: BridgeDeleteExternalAccountInput!' added to field 'Mutation.bridgeDeleteExternalAccount'

Argument 'input: BridgeDeleteExternalAccountInput!' added to field 'Mutation.bridgeDeleteExternalAccount'
bridgeInitiateKyc(input: BridgeInitiateKycInput!): BridgeInitiateKycPayload!
bridgeInitiateWithdrawal(input: BridgeInitiateWithdrawalInput!): BridgeInitiateWithdrawalPayload!
bridgeRequestWithdrawal(input: BridgeRequestWithdrawalInput!): BridgeRequestWithdrawalPayload!
bridgeSetDefaultExternalAccount(input: BridgeSetDefaultExternalAccountInput!): BridgeSetDefaultExternalAccountPayload!

Check notice on line 1042 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Field 'bridgeSetDefaultExternalAccount' was added to object type 'Mutation'

Field 'bridgeSetDefaultExternalAccount' was added to object type 'Mutation'

Check notice on line 1042 in src/graphql/public/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Argument 'input: BridgeSetDefaultExternalAccountInput!' added to field 'Mutation.bridgeSetDefaultExternalAccount'

Argument 'input: BridgeSetDefaultExternalAccountInput!' added to field 'Mutation.bridgeSetDefaultExternalAccount'
businessAccountUpgradeRequest(input: BusinessAccountUpgradeRequestInput!): AccountUpgradePayload!
callbackEndpointAdd(input: CallbackEndpointAddInput!): CallbackEndpointAddPayload!
callbackEndpointDelete(input: CallbackEndpointDeleteInput!): SuccessPayload!
Expand Down
1 change: 1 addition & 0 deletions src/graphql/public/types/object/bridge-external-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const BridgeExternalAccount = GT.Object({
bankName: { type: GT.NonNull(GT.String) },
accountNumberLast4: { type: GT.NonNull(GT.String) },
status: { type: GT.NonNull(GT.String) },
isDefault: { type: GT.NonNull(GT.Boolean) },
}),
})

Expand Down
11 changes: 11 additions & 0 deletions src/services/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BridgeConfig } from "@config"

import {
BridgeCustomerId,
BridgeExternalAccountId,
BridgeTransferId,
BridgeVirtualAccountId,
} from "@domain/primitives/bridge"
Expand Down Expand Up @@ -532,6 +533,16 @@ export class BridgeClient {
)
}

async deleteExternalAccount(
customerId: BridgeCustomerId,
externalAccountId: BridgeExternalAccountId,
): Promise<ExternalAccount> {
return this.request<ExternalAccount>(
"DELETE",
`/customers/${customerId}/external_accounts/${externalAccountId}`,
)
}

// ============ Transfers ============

async createTransfer(
Expand Down
Loading
Loading