mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Plaid EU webhooks migration task (#1825)
* Add data migration for EU Plaid webhooks * Fix task
This commit is contained in:
parent
5eb5ec7aef
commit
0dc25cda22
1 changed files with 23 additions and 0 deletions
23
lib/tasks/data_migration.rake
Normal file
23
lib/tasks/data_migration.rake
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
namespace :data_migration do
|
||||||
|
desc "Migrate EU Plaid webhooks"
|
||||||
|
# 2025-02-07: EU Plaid items need to be moved over to a new webhook URL so that we can
|
||||||
|
# instantiate the correct Plaid client for verification based on which Plaid instance it comes from
|
||||||
|
task eu_plaid_webhooks: :environment do
|
||||||
|
provider = Provider::Plaid.new(Rails.application.config.plaid_eu, region: :eu)
|
||||||
|
|
||||||
|
eu_items = PlaidItem.where(plaid_region: "eu")
|
||||||
|
|
||||||
|
eu_items.find_each do |item|
|
||||||
|
request = Plaid::ItemWebhookUpdateRequest.new(
|
||||||
|
access_token: item.access_token,
|
||||||
|
webhook: "https://app.maybefinance.com/webhooks/plaid_eu"
|
||||||
|
)
|
||||||
|
|
||||||
|
provider.client.item_webhook_update(request)
|
||||||
|
|
||||||
|
puts "Updated webhook for Plaid item #{item.plaid_id}"
|
||||||
|
rescue => error
|
||||||
|
puts "Error updating webhook for Plaid item #{item.plaid_id}: #{error.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue