Skip to content

Commit

Permalink
feat: Map plaid account
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyxiao committed Jan 22, 2024
1 parent aa6b894 commit 83da50e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions verticals/vertical-banking/banking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const zBanking = {
account: z.object({
id: z.string(),
name: z.string(),
current_balance: z.number().optional(),
currency: z.string().optional(),
}),
merchant: z.object({
id: z.string(),
Expand Down Expand Up @@ -134,6 +136,20 @@ export function bankingLink(ctx: {
} satisfies PostgresInputPayload,
})
}
if (op.data.entityName === 'account') {
const mapped = applyMapper(
mappers.plaid.account,
op.data.entity as Plaid['schemas']['AccountBase'],
)
return rxjs.of({
...op,
data: {
id: mapped.id,
entityName: 'banking_account',
entity: {raw: op.data.entity, unified: mapped},
} satisfies PostgresInputPayload,
})
}
}
// Do not allow any other entities to pass through
return rxjs.EMPTY
Expand Down Expand Up @@ -199,5 +215,15 @@ const mappers = {
merchant_name: 'merchant_name',
},
),
account: mapper(
zCast<StrictObj<Plaid['schemas']['AccountBase']>>(),
zBanking.account,
{
id: 'account_id',
name: 'name',
current_balance: (a) => a.balances.current ?? undefined,
currency: (a) => a.balances.iso_currency_code ?? undefined,
},
),
},
}

1 comment on commit 83da50e

@vercel
Copy link

@vercel vercel bot commented on 83da50e Jan 22, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

venice – ./

venice-venice.vercel.app
venice-git-production-venice.vercel.app
usevenice.vercel.app
app.venice.is

Please sign in to comment.