-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add resource_id * Add resource_id * Add resource_id * Save account reference * Sync account ref * Sync account ref
- Loading branch information
Showing
15 changed files
with
2,013 additions
and
1,943 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
apps/dashboard/jobs/tasks/bank/accounts/update-reference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { client } from "@midday/engine/client"; | ||
import { createClient } from "@midday/supabase/job"; | ||
import { schemaTask } from "@trigger.dev/sdk/v3"; | ||
import { z } from "zod"; | ||
|
||
export const updateReference = schemaTask({ | ||
id: "update-reference", | ||
maxDuration: 300, | ||
schema: z.object({ | ||
connectionId: z.string(), | ||
}), | ||
run: async ({ connectionId }) => { | ||
const supabase = createClient(); | ||
|
||
const accountsResponse = await client.accounts.$get({ | ||
query: { | ||
id: connectionId, | ||
provider: "gocardless", | ||
}, | ||
}); | ||
|
||
const { data: accountsData } = await accountsResponse.json(); | ||
|
||
await Promise.all( | ||
accountsData.map(async (account) => { | ||
return supabase | ||
.from("bank_accounts") | ||
.update({ | ||
account_reference: account.resource_id, | ||
}) | ||
.eq("account_id", account.id); | ||
}), | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.