1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 15:35:22 +02:00

Plaid sync domain improvements (#2267)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

Breaks our Plaid sync process out into more manageable classes. Notably, this moves the sync process to a distinct, 2-step flow:

1. Import stage - we first make API calls and import Plaid data to "mirror" tables
2. Processing stage - read the raw data, apply business rules, build internal domain models and sync balances

This provides several benefits:

- Plaid syncs can now be "replayed" without fetching API data again
- Mirror tables provide better audit and debugging capabilities
- Eliminates the "all or nothing" sync behavior that is currently in place, which is brittle
This commit is contained in:
Zach Gollwitzer 2025-05-23 18:58:22 -04:00 committed by GitHub
parent 5c82af0e8c
commit 03a146222d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 3763 additions and 706 deletions

View file

@ -0,0 +1,236 @@
---
http_interactions:
- request:
method: post
uri: https://sandbox.plaid.com/liabilities/get
body:
encoding: UTF-8
string: '{"access_token":"access-sandbox-0af2c971-41a6-4fc5-a97d-f2b27ab0a648"}'
headers:
Content-Type:
- application/json
User-Agent:
- Plaid Ruby v38.0.0
Accept:
- application/json
Plaid-Client-Id:
- "<PLAID_CLIENT_ID>"
Plaid-Version:
- '2020-09-14'
Plaid-Secret:
- "<PLAID_SECRET>"
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
response:
status:
code: 200
message: OK
headers:
Server:
- nginx
Date:
- Mon, 19 May 2025 17:24:04 GMT
Content-Type:
- application/json; charset=utf-8
Content-Length:
- '4907'
Connection:
- keep-alive
Plaid-Version:
- '2020-09-14'
Vary:
- Accept-Encoding
X-Envoy-Upstream-Service-Time:
- '253'
X-Envoy-Decorator-Operation:
- default.svc-apiv2:8080/*
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Xss-Protection:
- 1; mode=block
body:
encoding: ASCII-8BIT
string: |-
{
"accounts": [
{
"account_id": "vor45kgbDjfqa1BMD8QRU4om8adWNWtqbzQJe",
"balances": {
"available": 8000,
"current": 10000,
"iso_currency_code": "USD",
"limit": null,
"unofficial_currency_code": null
},
"holder_category": "personal",
"mask": "1122",
"name": "Test Brokerage Account",
"official_name": "Plaid brokerage",
"subtype": "brokerage",
"type": "investment"
},
{
"account_id": "RperV9wJMNiDWKljGMkPCkwDGJb7q7FaNlVMp",
"balances": {
"available": 9372.38,
"current": 1000,
"iso_currency_code": "USD",
"limit": 10500,
"unofficial_currency_code": null
},
"holder_category": "personal",
"mask": "1219",
"name": "Test Credit Card Account",
"official_name": "Plaid credit card",
"subtype": "credit card",
"type": "credit"
},
{
"account_id": "9mvxVZRW7LUD67QbEBm1CPZ6XlqkmkF4oGNBo",
"balances": {
"available": 10000,
"current": 10000,
"iso_currency_code": "USD",
"limit": null,
"unofficial_currency_code": null
},
"holder_category": "personal",
"mask": "4243",
"name": "Test Depository Account",
"official_name": "Plaid checking",
"subtype": "checking",
"type": "depository"
},
{
"account_id": "6Gwzm7nJ6ZU4VbqEyKzZszyPQ8keRet8Q97k7",
"balances": {
"available": 15000,
"current": 15000,
"iso_currency_code": "USD",
"limit": null,
"unofficial_currency_code": null
},
"holder_category": "personal",
"mask": "9572",
"name": "Test Student Loan Account",
"official_name": "Plaid student",
"subtype": "student",
"type": "loan"
}
],
"item": {
"available_products": [
"assets",
"auth",
"balance",
"credit_details",
"identity",
"identity_match",
"income",
"income_verification",
"recurring_transactions",
"signal",
"statements"
],
"billed_products": [
"investments",
"liabilities",
"transactions"
],
"consent_expiration_time": null,
"error": null,
"institution_id": "ins_109508",
"institution_name": "First Platypus Bank",
"item_id": "n7XKpjRmDkHENymaBw7rU71wxQnrW4i6DDrQP",
"products": [
"investments",
"liabilities",
"transactions"
],
"update_type": "background",
"webhook": ""
},
"liabilities": {
"credit": [
{
"account_id": "RperV9wJMNiDWKljGMkPCkwDGJb7q7FaNlVMp",
"aprs": [
{
"apr_percentage": 12.5,
"apr_type": "purchase_apr",
"balance_subject_to_apr": null,
"interest_charge_amount": null
},
{
"apr_percentage": 27.95,
"apr_type": "cash_apr",
"balance_subject_to_apr": null,
"interest_charge_amount": null
}
],
"is_overdue": false,
"last_payment_amount": null,
"last_payment_date": "2025-04-24",
"last_statement_balance": 1000,
"last_statement_issue_date": "2025-05-19",
"minimum_payment_amount": 50,
"next_payment_due_date": "2025-06-19"
}
],
"mortgage": null,
"student": [
{
"account_id": "6Gwzm7nJ6ZU4VbqEyKzZszyPQ8keRet8Q97k7",
"account_number": "3117529572",
"disbursement_dates": [
"2023-05-01"
],
"expected_payoff_date": "2036-05-01",
"guarantor": "DEPT OF ED",
"interest_rate_percentage": 5.25,
"is_overdue": false,
"last_payment_amount": null,
"last_payment_date": null,
"last_statement_balance": 16577.16,
"last_statement_issue_date": "2025-05-01",
"loan_name": "Consolidation",
"loan_status": {
"end_date": null,
"type": "in school"
},
"minimum_payment_amount": 25,
"next_payment_due_date": "2025-06-01",
"origination_date": "2023-05-01",
"origination_principal_amount": 15000,
"outstanding_interest_amount": 1577.16,
"payment_reference_number": "3117529572",
"pslf_status": {
"estimated_eligibility_date": null,
"payments_made": null,
"payments_remaining": null
},
"repayment_plan": {
"description": "Standard Repayment",
"type": "standard"
},
"sequence_number": "1",
"servicer_address": {
"city": "San Matias",
"country": "US",
"postal_code": "99415",
"region": "CA",
"street": "123 Relaxation Road"
},
"ytd_interest_paid": 0,
"ytd_principal_paid": 0
}
]
},
"request_id": "nFlL291sKIy1LkJ"
}
recorded_at: Mon, 19 May 2025 17:24:04 GMT
recorded_with: VCR 6.3.1