diff --git a/test/plaid/asset_report_test.exs b/test/plaid/asset_report_test.exs index 3b51ab0..ab5ca28 100644 --- a/test/plaid/asset_report_test.exs +++ b/test/plaid/asset_report_test.exs @@ -49,6 +49,33 @@ defmodule Plaid.AssetReportTest do ) end + test "POST /asset_report/create without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/asset_report/create", fn conn -> + Conn.resp(conn, 200, ~s<{ + "asset_report_token": "assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a", + "asset_report_id": "1f414183-220c-44f5-b0c8-bc0e6d4053bb", + "request_id": "Iam3b" + }>) + end) + + {:ok, + %Plaid.AssetReport.AsyncResponse{ + asset_report_token: "assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a", + asset_report_id: "1f414183-220c-44f5-b0c8-bc0e6d4053bb", + request_id: "Iam3b" + }} = + Plaid.AssetReport.create( + [ + "access-prod-123xxx", + "access-prod-456xxx" + ], + 5, + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "POST /asset_report/get", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/asset_report/get", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -301,6 +328,257 @@ defmodule Plaid.AssetReportTest do ) end + test "POST /asset_report/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/asset_report/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "report": { + "asset_report_id": "bf3a0490-344c-4620-a219-2693162e4b1d", + "client_report_id": "123abc", + "date_generated": "2020-06-05T22:47:53Z", + "days_requested": 3, + "items": [ + { + "accounts": [ + { + "account_id": "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr", + "balances": { + "available": 200, + "current": 210, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "days_available": 3, + "historical_balances": [ + { + "current": 210, + "date": "2020-06-04", + "iso_currency_code": "USD", + "unofficial_currency_code": null + } + ], + "mask": "1111", + "name": "Plaid Saving", + "official_name": "Plaid Silver Standard 0.1% Interest Saving", + "owners": [ + { + "addresses": [ + { + "data": { + "city": "Malakoff", + "country": "US", + "postal_code": "14236", + "region": "NY", + "street": "2992 Cameron Road" + }, + "primary": true + } + ], + "emails": [ + { + "data": "accountholder0@example.com", + "primary": true, + "type": "primary" + } + ], + "names": [ + "Alberta Bobbeth Charleson" + ], + "phone_numbers": [ + { + "data": "1112223333", + "primary": false, + "type": "home" + } + ] + } + ], + "ownership_type": null, + "subtype": "savings", + "transactions": [ + { + "account_id": "DAeG5XMnP3snZxNZJ1z3hMgbKRgM3BTz7AWnk", + "amount": 25, + "date": "2021-01-10", + "iso_currency_code": "USD", + "original_description": "CREDIT CARD 3333 PAYMENT *//", + "pending": false, + "transaction_id": "x1jm7MPDA3ijNveNwg8lhq5dmqJjr3U9WmD3G", + "unofficial_currency_code": null + } + ], + "type": "depository" + } + ], + "date_last_updated": "2020-06-05T22:47:52Z", + "institution_id": "ins_3", + "institution_name": "Chase", + "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6" + } + ], + "user": { + "client_user_id": "123456789", + "email": "accountholder0@example.com", + "first_name": "Alberta", + "last_name": "Charleson", + "middle_name": "Bobbeth", + "phone_number": "111-222-3333", + "ssn": "123-45-6789" + } + }, + "warnings": [ + { + "warning_type": "ASSET_REPORT_WARNING", + "warning_code": "OWNERS_UNAVAILABLE", + "cause": { + "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + "error": { + "error_type": "ASSET_REPORT_ERROR", + "error_code": "USER_SETUP_REQUIRED", + "error_message": "the account has not been fully set up. prompt the user to visit the issuing institution's site and finish the setup process", + "display_message": "The given account is not fully setup. Please visit your financial institution's website to setup your account.", + "request_id": "eYupqX1mZkEuQRx", + "causes": [], + "status": 400, + "documentation_url": "https://plaid.com/docs/api/error", + "suggested_action": "Prompt the user to setup their account." + } + } + } + ], + "request_id": "eYupqX1mZkEuQRx" + }>) + end) + + {:ok, + %Plaid.AssetReport.GetResponse{ + report: %Plaid.AssetReport.Report{ + asset_report_id: "bf3a0490-344c-4620-a219-2693162e4b1d", + client_report_id: "123abc", + date_generated: "2020-06-05T22:47:53Z", + days_requested: 3, + items: [ + %Plaid.AssetReport.Report.Item{ + accounts: [ + %Plaid.Account{ + account_id: "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr", + balances: %Plaid.Account.Balances{ + available: 200, + current: 210, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + days_available: 3, + historical_balances: [ + %Plaid.Account.HistoricalBalances{ + current: 210, + date: "2020-06-04", + iso_currency_code: "USD", + unofficial_currency_code: nil + } + ], + mask: "1111", + name: "Plaid Saving", + official_name: "Plaid Silver Standard 0.1% Interest Saving", + owners: [ + %Plaid.Identity{ + addresses: [ + %Plaid.Identity.Address{ + data: %Plaid.Address{ + city: "Malakoff", + country: "US", + postal_code: "14236", + region: "NY", + street: "2992 Cameron Road" + }, + primary: true + } + ], + emails: [ + %Plaid.Identity.Email{ + data: "accountholder0@example.com", + primary: true, + type: "primary" + } + ], + names: [ + "Alberta Bobbeth Charleson" + ], + phone_numbers: [ + %Plaid.Identity.PhoneNumber{ + data: "1112223333", + primary: false, + type: "home" + } + ] + } + ], + ownership_type: nil, + subtype: "savings", + transactions: [ + %Plaid.Transactions.Transaction{ + account_id: "DAeG5XMnP3snZxNZJ1z3hMgbKRgM3BTz7AWnk", + amount: 25, + date: "2021-01-10", + iso_currency_code: "USD", + original_description: "CREDIT CARD 3333 PAYMENT *//", + pending: false, + transaction_id: "x1jm7MPDA3ijNveNwg8lhq5dmqJjr3U9WmD3G", + unofficial_currency_code: nil + } + ], + type: "depository" + } + ], + date_last_updated: "2020-06-05T22:47:52Z", + institution_id: "ins_3", + institution_name: "Chase", + item_id: "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6" + } + ], + user: %Plaid.AssetReport.User{ + client_user_id: "123456789", + email: "accountholder0@example.com", + first_name: "Alberta", + last_name: "Charleson", + middle_name: "Bobbeth", + phone_number: "111-222-3333", + ssn: "123-45-6789" + } + }, + warnings: [ + %Plaid.AssetReport.Warning{ + warning_type: "ASSET_REPORT_WARNING", + warning_code: "OWNERS_UNAVAILABLE", + cause: %Plaid.AssetReport.Warning.Cause{ + item_id: "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + error: %Plaid.Error{ + error_type: "ASSET_REPORT_ERROR", + error_code: "USER_SETUP_REQUIRED", + error_message: + "the account has not been fully set up. prompt the user to visit the issuing institution's site and finish the setup process", + display_message: + "The given account is not fully setup. Please visit your financial institution's website to setup your account.", + request_id: "eYupqX1mZkEuQRx", + causes: [], + status: 400, + documentation_url: "https://plaid.com/docs/api/error", + suggested_action: "Prompt the user to setup their account." + } + } + } + ], + request_id: "eYupqX1mZkEuQRx" + }} = + Plaid.AssetReport.get( + "assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "POST /asset_report/pdf/get", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/asset_report/pdf/get", fn conn -> conn @@ -356,6 +634,29 @@ defmodule Plaid.AssetReportTest do ) end + test "POST /asset_report/refresh without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/asset_report/refresh", fn conn -> + Conn.resp(conn, 200, ~s<{ + "asset_report_token": "assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a", + "asset_report_id": "1f414183-220c-44f5-b0c8-bc0e6d4053bb", + "request_id": "Iam3b" + }>) + end) + + {:ok, + %Plaid.AssetReport.AsyncResponse{ + asset_report_token: "assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a", + asset_report_id: "1f414183-220c-44f5-b0c8-bc0e6d4053bb", + request_id: "Iam3b" + }} = + Plaid.AssetReport.refresh( + "assets-prod-123xxx", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "POST /asset_report/filter", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/asset_report/filter", fn conn -> Conn.resp(conn, 200, ~s<{ diff --git a/test/plaid/identity_test.exs b/test/plaid/identity_test.exs index bcd63b0..ead968a 100644 --- a/test/plaid/identity_test.exs +++ b/test/plaid/identity_test.exs @@ -9,7 +9,7 @@ defmodule Plaid.IdentityTest do {:ok, bypass: bypass, api_host: api_host} end - test "POST /identity/get", %{bypass: bypass, api_host: api_host} do + test "/identity/get", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/identity/get", fn conn -> Conn.resp(conn, 200, ~s<{ "accounts": [ @@ -385,4 +385,375 @@ defmodule Plaid.IdentityTest do secret: "abc" ) end + + test "/identity/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/identity/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "accounts": [ + { + "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + "balances": { + "available": 100, + "current": 110, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "0000", + "name": "Plaid Checking", + "official_name": "Plaid Gold Standard 0% Interest Checking", + "owners": [ + { + "addresses": [ + { + "data": { + "city": "Malakoff", + "country": "US", + "postal_code": "14236", + "region": "NY", + "street": "2992 Cameron Road" + }, + "primary": true + }, + { + "data": { + "city": "San Matias", + "country": "US", + "postal_code": "93405-2255", + "region": "CA", + "street": "2493 Leisure Lane" + }, + "primary": false + } + ], + "emails": [ + { + "data": "accountholder0@example.com", + "primary": true, + "type": "primary" + }, + { + "data": "accountholder1@example.com", + "primary": false, + "type": "secondary" + }, + { + "data": "extraordinarily.long.email.username.123456@reallylonghostname.com", + "primary": false, + "type": "other" + } + ], + "names": [ + "Alberta Bobbeth Charleson" + ], + "phone_numbers": [ + { + "data": "1112223333", + "primary": false, + "type": "home" + }, + { + "data": "1112224444", + "primary": false, + "type": "work" + }, + { + "data": "1112225555", + "primary": false, + "type": "mobile" + } + ] + } + ], + "subtype": "checking", + "type": "depository" + }, + { + "account_id": "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr", + "balances": { + "available": 200, + "current": 210, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "1111", + "name": "Plaid Saving", + "official_name": "Plaid Silver Standard 0.1% Interest Saving", + "owners": [ + { + "addresses": [ + { + "data": { + "city": "Malakoff", + "country": "US", + "postal_code": "14236", + "region": "NY", + "street": "2992 Cameron Road" + }, + "primary": true + }, + { + "data": { + "city": "San Matias", + "country": "US", + "postal_code": "93405-2255", + "region": "CA", + "street": "2493 Leisure Lane" + }, + "primary": false + } + ], + "emails": [ + { + "data": "accountholder0@example.com", + "primary": true, + "type": "primary" + }, + { + "data": "accountholder1@example.com", + "primary": false, + "type": "secondary" + }, + { + "data": "extraordinarily.long.email.username.123456@reallylonghostname.com", + "primary": false, + "type": "other" + } + ], + "names": [ + "Alberta Bobbeth Charleson" + ], + "phone_numbers": [ + { + "data": "1112223333", + "primary": false, + "type": "home" + }, + { + "data": "1112224444", + "primary": false, + "type": "work" + }, + { + "data": "1112225555", + "primary": false, + "type": "mobile" + } + ] + } + ], + "subtype": "savings", + "type": "depository" + } + ], + "item": { + "available_products": [ + "balance", + "investments" + ], + "billed_products": [ + "assets", + "auth", + "identity", + "liabilities", + "transactions" + ], + "consent_expiration_time": null, + "error": null, + "institution_id": "ins_3", + "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + "webhook": "https://www.genericwebhookurl.com/webhook" + }, + "request_id": "3nARps6TOYtbACO" + }>) + end) + + {:ok, + %Plaid.Identity.GetResponse{ + accounts: [ + %Plaid.Account{ + account_id: "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + balances: %Plaid.Account.Balances{ + available: 100, + current: 110, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "0000", + name: "Plaid Checking", + official_name: "Plaid Gold Standard 0% Interest Checking", + owners: [ + %Plaid.Identity{ + addresses: [ + %Plaid.Identity.Address{ + data: %Plaid.Address{ + city: "Malakoff", + country: "US", + postal_code: "14236", + region: "NY", + street: "2992 Cameron Road" + }, + primary: true + }, + %Plaid.Identity.Address{ + data: %Plaid.Address{ + city: "San Matias", + country: "US", + postal_code: "93405-2255", + region: "CA", + street: "2493 Leisure Lane" + }, + primary: false + } + ], + emails: [ + %Plaid.Identity.Email{ + data: "accountholder0@example.com", + primary: true, + type: "primary" + }, + %Plaid.Identity.Email{ + data: "accountholder1@example.com", + primary: false, + type: "secondary" + }, + %Plaid.Identity.Email{ + data: "extraordinarily.long.email.username.123456@reallylonghostname.com", + primary: false, + type: "other" + } + ], + names: [ + "Alberta Bobbeth Charleson" + ], + phone_numbers: [ + %Plaid.Identity.PhoneNumber{ + data: "1112223333", + primary: false, + type: "home" + }, + %Plaid.Identity.PhoneNumber{ + data: "1112224444", + primary: false, + type: "work" + }, + %Plaid.Identity.PhoneNumber{ + data: "1112225555", + primary: false, + type: "mobile" + } + ] + } + ], + subtype: "checking", + type: "depository" + }, + %Plaid.Account{ + account_id: "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr", + balances: %Plaid.Account.Balances{ + available: 200, + current: 210, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "1111", + name: "Plaid Saving", + official_name: "Plaid Silver Standard 0.1% Interest Saving", + owners: [ + %Plaid.Identity{ + addresses: [ + %Plaid.Identity.Address{ + data: %Plaid.Address{ + city: "Malakoff", + country: "US", + postal_code: "14236", + region: "NY", + street: "2992 Cameron Road" + }, + primary: true + }, + %Plaid.Identity.Address{ + data: %Plaid.Address{ + city: "San Matias", + country: "US", + postal_code: "93405-2255", + region: "CA", + street: "2493 Leisure Lane" + }, + primary: false + } + ], + emails: [ + %Plaid.Identity.Email{ + data: "accountholder0@example.com", + primary: true, + type: "primary" + }, + %Plaid.Identity.Email{ + data: "accountholder1@example.com", + primary: false, + type: "secondary" + }, + %Plaid.Identity.Email{ + data: "extraordinarily.long.email.username.123456@reallylonghostname.com", + primary: false, + type: "other" + } + ], + names: [ + "Alberta Bobbeth Charleson" + ], + phone_numbers: [ + %Plaid.Identity.PhoneNumber{ + data: "1112223333", + primary: false, + type: "home" + }, + %Plaid.Identity.PhoneNumber{ + data: "1112224444", + primary: false, + type: "work" + }, + %Plaid.Identity.PhoneNumber{ + data: "1112225555", + primary: false, + type: "mobile" + } + ] + } + ], + subtype: "savings", + type: "depository" + } + ], + item: %Plaid.Item{ + available_products: [ + "balance", + "investments" + ], + billed_products: [ + "assets", + "auth", + "identity", + "liabilities", + "transactions" + ], + consent_expiration_time: nil, + error: nil, + institution_id: "ins_3", + item_id: "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + webhook: "https://www.genericwebhookurl.com/webhook" + }, + request_id: "3nARps6TOYtbACO" + }} = + Plaid.Identity.get( + "access-prod-123xxx", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end end diff --git a/test/plaid/institutions_test.exs b/test/plaid/institutions_test.exs index 7dcda55..2de7feb 100644 --- a/test/plaid/institutions_test.exs +++ b/test/plaid/institutions_test.exs @@ -82,6 +82,73 @@ defmodule Plaid.InstitutionsTest do ) end + test "/institutions/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/institutions/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "institutions": [ + { + "country_codes": [ + "US" + ], + "institution_id": "ins_1", + "name": "Bank of America", + "oauth": false, + "products": [ + "assets", + "auth", + "balance", + "transactions", + "identity", + "liabilities" + ], + "routing_numbers": [ + "011000138", + "011200365", + "011400495" + ] + } + ], + "request_id": "tbFyCEqkU774ZGG", + "total": 11384 + }>) + end) + + {:ok, + %Plaid.Institutions.GetResponse{ + institutions: [ + %Plaid.Institution{ + country_codes: [ + "US" + ], + institution_id: "ins_1", + name: "Bank of America", + oauth: false, + products: [ + "assets", + "auth", + "balance", + "transactions", + "identity", + "liabilities" + ], + routing_numbers: [ + "011000138", + "011200365", + "011400495" + ] + } + ], + request_id: "tbFyCEqkU774ZGG", + total: 11_384 + }} = + Plaid.Institutions.get( + %{count: 3, offset: 2, country_codes: ["US", "CA"]}, + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/institutions/get_by_id", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/institutions/get_by_id", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -300,6 +367,220 @@ defmodule Plaid.InstitutionsTest do ) end + test "/institutions/get_by_id without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/institutions/get_by_id", fn conn -> + Conn.resp(conn, 200, ~s<{ + "institution": { + "country_codes": [ + "US" + ], + "institution_id": "ins_109512", + "name": "Houndstooth Bank", + "products": [ + "auth", + "balance", + "identity", + "transactions" + ], + "routing_numbers": [ + "110000000" + ], + "oauth": false, + "status": { + "item_logins": { + "status": "HEALTHY", + "last_status_change": "2019-02-15T15:53:00Z", + "breakdown": { + "success": 0.9, + "error_plaid": 0.01, + "error_institution": 0.09 + } + }, + "transactions_updates": { + "status": "HEALTHY", + "last_status_change": "2019-02-12T08:22:00Z", + "breakdown": { + "success": 0.95, + "error_plaid": 0.02, + "error_institution": 0.03, + "refresh_interval": "NORMAL" + } + }, + "auth": { + "status": "HEALTHY", + "last_status_change": "2019-02-15T15:53:00Z", + "breakdown": { + "success": 0.91, + "error_plaid": 0.01, + "error_institution": 0.08 + } + }, + "balance": { + "status": "HEALTHY", + "last_status_change": "2019-02-15T15:53:00Z", + "breakdown": { + "success": 0.89, + "error_plaid": 0.02, + "error_institution": 0.09 + } + }, + "identity": { + "status": "DEGRADED", + "last_status_change": "2019-02-15T15:50:00Z", + "breakdown": { + "success": 0.42, + "error_plaid": 0.08, + "error_institution": 0.5 + } + }, + "investments_updates": { + "status": "HEALTHY", + "last_status_change": "2019-02-12T08:22:00Z", + "breakdown": { + "success": 0.95, + "error_plaid": 0.02, + "error_institution": 0.03, + "refresh_interval": "NORMAL" + } + }, + "health_incidents": [ + { + "start_date": "2021-01-01T15:26:48Z", + "end_date": "2021-01-02T15:26:48Z", + "title": "Site Down", + "incident_updates": [ + { + "description": "Site is not down", + "status": "RESOLVED", + "updated_date": "2020-10-30T15:26:48Z" + }, + { + "description": "Site is down", + "status": "INVESTIGATING", + "updated_date": "2020-10-30T14:26:48Z" + } + ] + } + ] + }, + "primary_color": "#004966", + "url": "https://plaid.com", + "logo": null + }, + "request_id": "m8MDnv9okwxFNBV" + }>) + end) + + {:ok, + %Plaid.Institutions.GetByIdResponse{ + institution: %Plaid.Institution{ + country_codes: [ + "US" + ], + institution_id: "ins_109512", + name: "Houndstooth Bank", + products: [ + "auth", + "balance", + "identity", + "transactions" + ], + routing_numbers: [ + "110000000" + ], + oauth: false, + status: %Plaid.Institution.Status{ + item_logins: %Plaid.Institution.Status.ItemLogins{ + status: "HEALTHY", + last_status_change: "2019-02-15T15:53:00Z", + breakdown: %Plaid.Institution.Status.Breakdown{ + success: 0.9, + error_plaid: 0.01, + error_institution: 0.09 + } + }, + transactions_updates: %Plaid.Institution.Status.TransactionsUpdates{ + status: "HEALTHY", + last_status_change: "2019-02-12T08:22:00Z", + breakdown: %Plaid.Institution.Status.Breakdown{ + success: 0.95, + error_plaid: 0.02, + error_institution: 0.03, + refresh_interval: "NORMAL" + } + }, + auth: %Plaid.Institution.Status.Auth{ + status: "HEALTHY", + last_status_change: "2019-02-15T15:53:00Z", + breakdown: %Plaid.Institution.Status.Breakdown{ + success: 0.91, + error_plaid: 0.01, + error_institution: 0.08 + } + }, + balance: %Plaid.Institution.Status.Balance{ + status: "HEALTHY", + last_status_change: "2019-02-15T15:53:00Z", + breakdown: %Plaid.Institution.Status.Breakdown{ + success: 0.89, + error_plaid: 0.02, + error_institution: 0.09 + } + }, + identity: %Plaid.Institution.Status.Identity{ + status: "DEGRADED", + last_status_change: "2019-02-15T15:50:00Z", + breakdown: %Plaid.Institution.Status.Breakdown{ + success: 0.42, + error_plaid: 0.08, + error_institution: 0.5 + } + }, + investments_updates: %Plaid.Institution.Status.InvestmentsUpdates{ + status: "HEALTHY", + last_status_change: "2019-02-12T08:22:00Z", + breakdown: %Plaid.Institution.Status.Breakdown{ + success: 0.95, + error_plaid: 0.02, + error_institution: 0.03, + refresh_interval: "NORMAL" + } + }, + health_incidents: [ + %Plaid.Institution.Status.HealthIncident{ + start_date: "2021-01-01T15:26:48Z", + end_date: "2021-01-02T15:26:48Z", + title: "Site Down", + incident_updates: [ + %Plaid.Institution.Status.HealthIncidentUpdate{ + description: "Site is not down", + status: "RESOLVED", + updated_date: "2020-10-30T15:26:48Z" + }, + %Plaid.Institution.Status.HealthIncidentUpdate{ + description: "Site is down", + status: "INVESTIGATING", + updated_date: "2020-10-30T14:26:48Z" + } + ] + } + ] + }, + primary_color: "#004966", + url: "https://plaid.com", + logo: nil + }, + request_id: "m8MDnv9okwxFNBV" + }} = + Plaid.Institutions.get_by_id( + "ins_1", + ["US", "CA"], + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/institutions/search", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/institutions/search", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -365,4 +646,63 @@ defmodule Plaid.InstitutionsTest do secret: "abc" ) end + + test "/institutions/search without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/institutions/search", fn conn -> + Conn.resp(conn, 200, ~s<{ + "institutions": [ + { + "country_codes": [ + "US" + ], + "institution_id": "ins_25", + "name": "Ally Bank", + "oauth": false, + "products": [ + "assets", + "auth", + "balance", + "transactions", + "identity" + ], + "routing_numbers": ["1100000"] + } + ], + "request_id": "Ggmk0enW4smO2Tp" + }>) + end) + + {:ok, + %Plaid.Institutions.SearchResponse{ + institutions: [ + %Plaid.Institution{ + country_codes: [ + "US" + ], + institution_id: "ins_25", + name: "Ally Bank", + oauth: false, + products: [ + "assets", + "auth", + "balance", + "transactions", + "identity" + ], + routing_numbers: ["1100000"] + } + ], + request_id: "Ggmk0enW4smO2Tp" + }} = + Plaid.Institutions.search( + %{ + query: "Ally", + products: ["auth", "liabilities"], + country_codes: ["US"] + }, + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end end diff --git a/test/plaid/investments_test.exs b/test/plaid/investments_test.exs index 5d6c126..ba53b0c 100644 --- a/test/plaid/investments_test.exs +++ b/test/plaid/investments_test.exs @@ -525,6 +525,159 @@ defmodule Plaid.InvestmentsTest do ) end + test "POST /investments/holdings/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/investments/holdings/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "accounts": [ + { + "account_id": "5Bvpj4QknlhVWk7GygpwfVKdd133GoCxB814g", + "balances": { + "available": 43200, + "current": 43200, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "4444", + "name": "Plaid Money Market", + "official_name": "Plaid Platinum Standard 1.85% Interest Money Market", + "subtype": "money market", + "type": "depository" + } + ], + "holdings": [ + { + "account_id": "k67E4xKvMlhmleEa4pg9hlwGGNnnEeixPolGm", + "cost_basis": 1, + "institution_price": 1, + "institution_price_as_of": null, + "institution_value": 12345.67, + "iso_currency_code": "USD", + "quantity": 12345.67, + "security_id": "d6ePmbPxgWCWmMVv66q9iPV94n91vMtov5Are", + "unofficial_currency_code": null + } + ], + "item": { + "available_products": [ + "balance", + "identity", + "liabilities", + "transactions" + ], + "billed_products": [ + "assets", + "auth", + "investments" + ], + "consent_expiration_time": null, + "error": null, + "institution_id": "ins_3", + "item_id": "4z9LPae1nRHWy8pvg9jrsgbRP4ZNQvIdbLq7g", + "webhook": "https://www.genericwebhookurl.com/webhook" + }, + "request_id": "l68wb8zpS0hqmsJ", + "securities": [ + { + "close_price": 13.73, + "close_price_as_of": null, + "cusip": null, + "institution_id": "ins_3", + "institution_security_id": "NHX105509", + "is_cash_equivalent": false, + "isin": null, + "iso_currency_code": "USD", + "name": "NH PORTFOLIO 1055 (FIDELITY INDEX)", + "proxy_security_id": null, + "security_id": "nnmo8doZ4lfKNEDe3mPJipLGkaGw3jfPrpxoN", + "sedol": null, + "ticker_symbol": "NHX105509", + "type": "etf", + "unofficial_currency_code": null + } + ] + }>) + end) + + {:ok, + %Plaid.Investments.GetHoldingsResponse{ + accounts: [ + %Plaid.Account{ + account_id: "5Bvpj4QknlhVWk7GygpwfVKdd133GoCxB814g", + balances: %Plaid.Account.Balances{ + available: 43_200, + current: 43_200, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "4444", + name: "Plaid Money Market", + official_name: "Plaid Platinum Standard 1.85% Interest Money Market", + subtype: "money market", + type: "depository" + } + ], + holdings: [ + %Plaid.Investments.Holding{ + account_id: "k67E4xKvMlhmleEa4pg9hlwGGNnnEeixPolGm", + cost_basis: 1, + institution_price: 1, + institution_price_as_of: nil, + institution_value: 12_345.67, + iso_currency_code: "USD", + quantity: 12_345.67, + security_id: "d6ePmbPxgWCWmMVv66q9iPV94n91vMtov5Are", + unofficial_currency_code: nil + } + ], + item: %Plaid.Item{ + available_products: [ + "balance", + "identity", + "liabilities", + "transactions" + ], + billed_products: [ + "assets", + "auth", + "investments" + ], + consent_expiration_time: nil, + error: nil, + institution_id: "ins_3", + item_id: "4z9LPae1nRHWy8pvg9jrsgbRP4ZNQvIdbLq7g", + webhook: "https://www.genericwebhookurl.com/webhook" + }, + request_id: "l68wb8zpS0hqmsJ", + securities: [ + %Plaid.Investments.Security{ + close_price: 13.73, + close_price_as_of: nil, + cusip: nil, + institution_id: "ins_3", + institution_security_id: "NHX105509", + is_cash_equivalent: false, + isin: nil, + iso_currency_code: "USD", + name: "NH PORTFOLIO 1055 (FIDELITY INDEX)", + proxy_security_id: nil, + security_id: "nnmo8doZ4lfKNEDe3mPJipLGkaGw3jfPrpxoN", + sedol: nil, + ticker_symbol: "NHX105509", + type: "etf", + unofficial_currency_code: nil + } + ] + }} = + Plaid.Investments.get_holdings( + "access-prod-123xxx", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "POST /investments/transactions/get", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/investments/transactions/get", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -886,4 +1039,169 @@ defmodule Plaid.InvestmentsTest do secret: "abc" ) end + + test "POST /investments/transactions/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/investments/transactions/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "accounts": [ + { + "account_id": "rz99ex9ZQotvnjXdgQLEsR81e3ArPgulVWjGj", + "balances": { + "available": null, + "current": 23631.9805, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "6666", + "name": "Plaid 401k", + "official_name": null, + "subtype": "401k", + "type": "investment" + } + ], + "investment_transactions": [ + { + "account_id": "rz99ex9ZQotvnjXdgQLEsR81e3ArPgulVWjGj", + "amount": 7.7, + "cancel_transaction_id": null, + "date": "2020-05-27", + "fees": 7.99, + "investment_transaction_id": "LKoo1ko93wtreBwM7yQnuQ3P5DNKbKSPRzBNv", + "iso_currency_code": "USD", + "name": "BUY DoubleLine Total Return Bond Fund", + "price": 10.42, + "quantity": 0.7388014749727547, + "security_id": "NDVQrXQoqzt5v3bAe8qRt4A7mK7wvZCLEBBJk", + "subtype": "buy", + "type": "buy", + "unofficial_currency_code": null + } + ], + "item": { + "available_products": [ + "assets", + "balance", + "identity", + "transactions" + ], + "billed_products": [ + "auth", + "investments" + ], + "consent_expiration_time": null, + "error": null, + "institution_id": "ins_12", + "item_id": "8Mqq5rqQ7Pcxq9MGDv3JULZ6yzZDLMCwoxGDq", + "webhook": "https://www.genericwebhookurl.com/webhook" + }, + "request_id": "iv4q3ZlytOOthkv", + "securities": [ + { + "close_price": 34.73, + "close_price_as_of": null, + "cusip": "84470P109", + "institution_id": null, + "institution_security_id": null, + "is_cash_equivalent": false, + "isin": "US84470P1093", + "iso_currency_code": "USD", + "name": "Southside Bancshares Inc.", + "proxy_security_id": null, + "security_id": "eW4jmnjd6AtjxXVrjmj6SX1dNEdZp3Cy8RnRQ", + "sedol": null, + "ticker_symbol": "SBSI", + "type": "equity", + "unofficial_currency_code": null + } + ], + "total_investment_transactions": 3 + }>) + end) + + {:ok, + %Plaid.Investments.GetTransactionsResponse{ + accounts: [ + %Plaid.Account{ + account_id: "rz99ex9ZQotvnjXdgQLEsR81e3ArPgulVWjGj", + balances: %Plaid.Account.Balances{ + available: nil, + current: 23_631.9805, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "6666", + name: "Plaid 401k", + official_name: nil, + subtype: "401k", + type: "investment" + } + ], + investment_transactions: [ + %Plaid.Investments.Transaction{ + account_id: "rz99ex9ZQotvnjXdgQLEsR81e3ArPgulVWjGj", + amount: 7.7, + cancel_transaction_id: nil, + date: "2020-05-27", + fees: 7.99, + investment_transaction_id: "LKoo1ko93wtreBwM7yQnuQ3P5DNKbKSPRzBNv", + iso_currency_code: "USD", + name: "BUY DoubleLine Total Return Bond Fund", + price: 10.42, + quantity: 0.7388014749727547, + security_id: "NDVQrXQoqzt5v3bAe8qRt4A7mK7wvZCLEBBJk", + subtype: "buy", + type: "buy", + unofficial_currency_code: nil + } + ], + item: %Plaid.Item{ + available_products: [ + "assets", + "balance", + "identity", + "transactions" + ], + billed_products: [ + "auth", + "investments" + ], + consent_expiration_time: nil, + error: nil, + institution_id: "ins_12", + item_id: "8Mqq5rqQ7Pcxq9MGDv3JULZ6yzZDLMCwoxGDq", + webhook: "https://www.genericwebhookurl.com/webhook" + }, + request_id: "iv4q3ZlytOOthkv", + securities: [ + %Plaid.Investments.Security{ + close_price: 34.73, + close_price_as_of: nil, + cusip: "84470P109", + institution_id: nil, + institution_security_id: nil, + is_cash_equivalent: false, + isin: "US84470P1093", + iso_currency_code: "USD", + name: "Southside Bancshares Inc.", + proxy_security_id: nil, + security_id: "eW4jmnjd6AtjxXVrjmj6SX1dNEdZp3Cy8RnRQ", + sedol: nil, + ticker_symbol: "SBSI", + type: "equity", + unofficial_currency_code: nil + } + ], + total_investment_transactions: 3 + }} = + Plaid.Investments.get_transactions( + "access-prod-123xxx", + "2020-01-01", + "2020-01-31", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end end diff --git a/test/plaid/item_test.exs b/test/plaid/item_test.exs index 39d774c..427de97 100644 --- a/test/plaid/item_test.exs +++ b/test/plaid/item_test.exs @@ -29,6 +29,10 @@ defmodule Plaid.ItemTest do "consent_expiration_time": null }, "status": { + "investments": { + "last_successful_update": "2019-02-15T15:52:39.000Z", + "last_failed_update": "2019-01-22T04:32:00.000Z" + }, "transactions": { "last_successful_update": "2019-02-15T15:52:39.000Z", "last_failed_update": "2019-01-22T04:32:00.000Z" @@ -61,6 +65,10 @@ defmodule Plaid.ItemTest do consent_expiration_time: nil }, status: %Plaid.Item.Status{ + investments: %Plaid.Item.Status.Investments{ + last_successful_update: "2019-02-15T15:52:39.000Z", + last_failed_update: "2019-01-22T04:32:00.000Z" + }, transactions: %Plaid.Item.Status.Transactions{ last_successful_update: "2019-02-15T15:52:39.000Z", last_failed_update: "2019-01-22T04:32:00.000Z" diff --git a/test/plaid/liabilities_test.exs b/test/plaid/liabilities_test.exs index eea1e25..607329f 100644 --- a/test/plaid/liabilities_test.exs +++ b/test/plaid/liabilities_test.exs @@ -428,4 +428,423 @@ defmodule Plaid.LiabilitiesTest do secret: "abc" ) end + + test "/liabilities/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/liabilities/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "accounts": [ + { + "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + "balances": { + "available": 100, + "current": 110, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "0000", + "name": "Plaid Checking", + "official_name": "Plaid Gold Standard 0% Interest Checking", + "subtype": "checking", + "type": "depository" + }, + { + "account_id": "dVzbVMLjrxTnLjX4G66XUp5GLklm4oiZy88yK", + "balances": { + "available": null, + "current": 410, + "iso_currency_code": "USD", + "limit": 2000, + "unofficial_currency_code": null + }, + "mask": "3333", + "name": "Plaid Credit Card", + "official_name": "Plaid Diamond 12.5% APR Interest Credit Card", + "subtype": "credit card", + "type": "credit" + }, + { + "account_id": "Pp1Vpkl9w8sajvK6oEEKtr7vZxBnGpf7LxxLE", + "balances": { + "available": null, + "current": 65262, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "7777", + "name": "Plaid Student Loan", + "official_name": null, + "subtype": "student", + "type": "loan" + }, + { + "account_id": "BxBXxLj1m4HMXBm9WZJyUg9XLd4rKEhw8Pb1J", + "balances": { + "available": null, + "current": 56302.06, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "8888", + "name": "Plaid Mortgage", + "official_name": null, + "subtype": "mortgage", + "type": "loan" + } + ], + "item": { + "available_products": [ + "balance", + "investments" + ], + "billed_products": [ + "assets", + "auth", + "identity", + "liabilities", + "transactions" + ], + "consent_expiration_time": null, + "error": null, + "institution_id": "ins_3", + "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + "webhook": "https://www.genericwebhookurl.com/webhook" + }, + "liabilities": { + "credit": [ + { + "account_id": "dVzbVMLjrxTnLjX4G66XUp5GLklm4oiZy88yK", + "aprs": [ + { + "apr_percentage": 15.24, + "apr_type": "balance_transfer_apr", + "balance_subject_to_apr": 1562.32, + "interest_charge_amount": 130.22 + }, + { + "apr_percentage": 27.95, + "apr_type": "cash_apr", + "balance_subject_to_apr": 56.22, + "interest_charge_amount": 14.81 + }, + { + "apr_percentage": 12.5, + "apr_type": "purchase_apr", + "balance_subject_to_apr": 157.01, + "interest_charge_amount": 25.66 + }, + { + "apr_percentage": 0, + "apr_type": "special", + "balance_subject_to_apr": 1000, + "interest_charge_amount": 0 + } + ], + "is_overdue": false, + "last_payment_amount": 168.25, + "last_payment_date": "2019-05-22", + "last_statement_balance": 1708.77, + "last_statement_issue_date": "2019-05-28", + "minimum_payment_amount": 20, + "next_payment_due_date": "2020-05-28" + } + ], + "mortgage": [ + { + "account_id": "BxBXxLj1m4HMXBm9WZJyUg9XLd4rKEhw8Pb1J", + "account_number": "3120194154", + "current_late_fee": 25, + "escrow_balance": 3141.54, + "has_pmi": true, + "has_prepayment_penalty": true, + "interest_rate": { + "percentage": 3.99, + "type": "fixed" + }, + "last_payment_amount": 3141.54, + "last_payment_date": "2019-08-01", + "loan_term": "30 year", + "loan_type_description": "conventional", + "maturity_date": "2045-07-31", + "next_monthly_payment": 3141.54, + "next_payment_due_date": "2019-11-15", + "origination_date": "2015-08-01", + "origination_principal_amount": 425000, + "past_due_amount": 2304, + "property_address": { + "city": "Malakoff", + "country": "US", + "postal_code": "14236", + "region": "NY", + "street": "2992 Cameron Road" + }, + "ytd_interest_paid": 12300.4, + "ytd_principal_paid": 12340.5 + } + ], + "student": [ + { + "account_id": "Pp1Vpkl9w8sajvK6oEEKtr7vZxBnGpf7LxxLE", + "account_number": "4277075694", + "disbursement_dates": [ + "2002-08-28" + ], + "expected_payoff_date": "2032-07-28", + "guarantor": "DEPT OF ED", + "interest_rate_percentage": 5.25, + "is_overdue": false, + "last_payment_amount": 138.05, + "last_payment_date": "2019-04-22", + "last_statement_balance": 138.05, + "last_statement_issue_date": "2019-04-28", + "loan_name": "Consolidation", + "loan_status": { + "end_date": "2032-07-28", + "type": "repayment" + }, + "minimum_payment_amount": 25, + "next_payment_due_date": "2019-05-28", + "origination_date": "2002-08-28", + "origination_principal_amount": 25000, + "outstanding_interest_amount": 6227.36, + "payment_reference_number": "4277075694", + "pslf_status": { + "estimated_eligibility_date": "2021-01-01", + "payments_made": 200, + "payments_remaining": 160 + }, + "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": 280.55, + "ytd_principal_paid": 271.65 + } + ] + }, + "request_id": "dTnnm60WgKGLnKL" + }>) + end) + + {:ok, + %Plaid.Liabilities.GetResponse{ + accounts: [ + %Plaid.Account{ + account_id: "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + balances: %Plaid.Account.Balances{ + available: 100, + current: 110, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "0000", + name: "Plaid Checking", + official_name: "Plaid Gold Standard 0% Interest Checking", + subtype: "checking", + type: "depository" + }, + %Plaid.Account{ + account_id: "dVzbVMLjrxTnLjX4G66XUp5GLklm4oiZy88yK", + balances: %Plaid.Account.Balances{ + available: nil, + current: 410, + iso_currency_code: "USD", + limit: 2000, + unofficial_currency_code: nil + }, + mask: "3333", + name: "Plaid Credit Card", + official_name: "Plaid Diamond 12.5% APR Interest Credit Card", + subtype: "credit card", + type: "credit" + }, + %Plaid.Account{ + account_id: "Pp1Vpkl9w8sajvK6oEEKtr7vZxBnGpf7LxxLE", + balances: %Plaid.Account.Balances{ + available: nil, + current: 65_262, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "7777", + name: "Plaid Student Loan", + official_name: nil, + subtype: "student", + type: "loan" + }, + %Plaid.Account{ + account_id: "BxBXxLj1m4HMXBm9WZJyUg9XLd4rKEhw8Pb1J", + balances: %Plaid.Account.Balances{ + available: nil, + current: 56_302.06, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "8888", + name: "Plaid Mortgage", + official_name: nil, + subtype: "mortgage", + type: "loan" + } + ], + item: %Plaid.Item{ + available_products: [ + "balance", + "investments" + ], + billed_products: [ + "assets", + "auth", + "identity", + "liabilities", + "transactions" + ], + consent_expiration_time: nil, + error: nil, + institution_id: "ins_3", + item_id: "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + webhook: "https://www.genericwebhookurl.com/webhook" + }, + liabilities: %Plaid.Liabilities{ + credit: [ + %Plaid.Liabilities.Credit{ + account_id: "dVzbVMLjrxTnLjX4G66XUp5GLklm4oiZy88yK", + aprs: [ + %Plaid.Liabilities.Credit.APR{ + apr_percentage: 15.24, + apr_type: "balance_transfer_apr", + balance_subject_to_apr: 1562.32, + interest_charge_amount: 130.22 + }, + %Plaid.Liabilities.Credit.APR{ + apr_percentage: 27.95, + apr_type: "cash_apr", + balance_subject_to_apr: 56.22, + interest_charge_amount: 14.81 + }, + %Plaid.Liabilities.Credit.APR{ + apr_percentage: 12.5, + apr_type: "purchase_apr", + balance_subject_to_apr: 157.01, + interest_charge_amount: 25.66 + }, + %Plaid.Liabilities.Credit.APR{ + apr_percentage: 0, + apr_type: "special", + balance_subject_to_apr: 1000, + interest_charge_amount: 0 + } + ], + is_overdue: false, + last_payment_amount: 168.25, + last_payment_date: "2019-05-22", + last_statement_balance: 1708.77, + last_statement_issue_date: "2019-05-28", + minimum_payment_amount: 20, + next_payment_due_date: "2020-05-28" + } + ], + mortgage: [ + %Plaid.Liabilities.Mortgage{ + account_id: "BxBXxLj1m4HMXBm9WZJyUg9XLd4rKEhw8Pb1J", + account_number: "3120194154", + current_late_fee: 25, + escrow_balance: 3141.54, + has_pmi: true, + has_prepayment_penalty: true, + interest_rate: %Plaid.Liabilities.Mortgage.InterestRate{ + percentage: 3.99, + type: "fixed" + }, + last_payment_amount: 3141.54, + last_payment_date: "2019-08-01", + loan_term: "30 year", + loan_type_description: "conventional", + maturity_date: "2045-07-31", + next_monthly_payment: 3141.54, + next_payment_due_date: "2019-11-15", + origination_date: "2015-08-01", + origination_principal_amount: 425_000, + past_due_amount: 2304, + property_address: %Plaid.Address{ + city: "Malakoff", + country: "US", + postal_code: "14236", + region: "NY", + street: "2992 Cameron Road" + }, + ytd_interest_paid: 12_300.4, + ytd_principal_paid: 12_340.5 + } + ], + student: [ + %Plaid.Liabilities.Student{ + account_id: "Pp1Vpkl9w8sajvK6oEEKtr7vZxBnGpf7LxxLE", + account_number: "4277075694", + disbursement_dates: [ + "2002-08-28" + ], + expected_payoff_date: "2032-07-28", + guarantor: "DEPT OF ED", + interest_rate_percentage: 5.25, + is_overdue: false, + last_payment_amount: 138.05, + last_payment_date: "2019-04-22", + last_statement_balance: 138.05, + last_statement_issue_date: "2019-04-28", + loan_name: "Consolidation", + loan_status: %Plaid.Liabilities.Student.LoanStatus{ + end_date: "2032-07-28", + type: "repayment" + }, + minimum_payment_amount: 25, + next_payment_due_date: "2019-05-28", + origination_date: "2002-08-28", + origination_principal_amount: 25_000, + outstanding_interest_amount: 6227.36, + payment_reference_number: "4277075694", + pslf_status: %Plaid.Liabilities.Student.PSLFStatus{ + estimated_eligibility_date: "2021-01-01", + payments_made: 200, + payments_remaining: 160 + }, + repayment_plan: %Plaid.Liabilities.Student.RepaymentPlan{ + description: "Standard Repayment", + type: "standard" + }, + sequence_number: "1", + servicer_address: %Plaid.Address{ + city: "San Matias", + country: "US", + postal_code: "99415", + region: "CA", + street: "123 Relaxation Road" + }, + ytd_interest_paid: 280.55, + ytd_principal_paid: 271.65 + } + ] + }, + request_id: "dTnnm60WgKGLnKL" + }} = + Plaid.Liabilities.get( + "access-prod-123xxx", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end end diff --git a/test/plaid/payment_initiation_test.exs b/test/plaid/payment_initiation_test.exs index 66a570f..84f4e7f 100644 --- a/test/plaid/payment_initiation_test.exs +++ b/test/plaid/payment_initiation_test.exs @@ -46,12 +46,40 @@ defmodule Plaid.PaymentInitiationTest do ) end + test "/payment_initiation/recipient/create without options", %{ + bypass: bypass, + api_host: api_host + } do + Bypass.expect_once(bypass, "POST", "/payment_initiation/recipient/create", fn conn -> + Conn.resp(conn, 200, ~s<{ + "recipient_id": "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", + "request_id": "4zlKapIkTm8p5KM" + }>) + end) + + {:ok, + %Plaid.PaymentInitiation.CreateRecipientResponse{ + recipient_id: "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", + request_id: "4zlKapIkTm8p5KM" + }} = + Plaid.PaymentInitiation.create_recipient( + "Wonder Wallet", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/payment_initiation/recipient/get", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/payment_initiation/recipient/get", fn conn -> Conn.resp(conn, 200, ~s<{ "recipient_id": "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", "name": "Wonder Wallet", "iban": "GB29NWBK60161331926819", + "bacs": { + "account": "2930499299", + "sort_code": "601613" + }, "address": { "street": [ "96 Guild Street", @@ -70,6 +98,10 @@ defmodule Plaid.PaymentInitiationTest do recipient_id: "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", name: "Wonder Wallet", iban: "GB29NWBK60161331926819", + bacs: %Plaid.PaymentInitiation.BACS{ + account: "2930499299", + sort_code: "601613" + }, address: %Plaid.PaymentInitiation.Address{ street: [ "96 Guild Street", @@ -175,6 +207,37 @@ defmodule Plaid.PaymentInitiationTest do ) end + test "/payment_initiation/payment/create without options", %{ + bypass: bypass, + api_host: api_host + } do + Bypass.expect_once(bypass, "POST", "/payment_initiation/payment/create", fn conn -> + Conn.resp(conn, 200, ~s<{ + "payment_id": "payment-id-sandbox-feca8a7a-5591-4aef-9297-f3062bb735d3", + "status": "PAYMENT_STATUS_INPUT_NEEDED", + "request_id": "4ciYVmesrySiUAB" + }>) + end) + + {:ok, + %Plaid.PaymentInitiation.CreatePaymentResponse{ + payment_id: "payment-id-sandbox-feca8a7a-5591-4aef-9297-f3062bb735d3", + status: "PAYMENT_STATUS_INPUT_NEEDED", + request_id: "4ciYVmesrySiUAB" + }} = + Plaid.PaymentInitiation.create_payment( + "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", + "Account Funding 99744", + %Plaid.PaymentInitiation.Amount{ + currency: "GBP", + value: 100 + }, + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/payment_initiation/payment/get", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/payment_initiation/payment/get", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -274,4 +337,62 @@ defmodule Plaid.PaymentInitiationTest do secret: "abc" ) end + + test "/payment_initiation/payment/list without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/payment_initiation/payment/list", fn conn -> + Conn.resp(conn, 200, ~s<{ + "payments": [ + { + "payment_id": "payment-id-sandbox-feca8a7a-5591-4aef-9297-f3062bb735d3", + "reference": "Account Funding 99744", + "amount": { + "currency": "GBP", + "value": 100 + }, + "status": "PAYMENT_STATUS_INPUT_NEEDED", + "last_status_update": "2019-11-06T21:10:52Z", + "recipient_id": "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", + "schedule": { + "interval": "WEEKLY", + "interval_execution_day": 2, + "start_date": "2021-01-01", + "end_date": "2021-01-31" + } + } + ], + "next_cursor": "2020-01-01T00:00:00Z", + "request_id": "aEAQmewMzlVa1k6" + }>) + end) + + {:ok, + %Plaid.PaymentInitiation.ListPaymentsResponse{ + payments: [ + %Plaid.PaymentInitiation.Payment{ + payment_id: "payment-id-sandbox-feca8a7a-5591-4aef-9297-f3062bb735d3", + reference: "Account Funding 99744", + amount: %Plaid.PaymentInitiation.Amount{ + currency: "GBP", + value: 100 + }, + status: "PAYMENT_STATUS_INPUT_NEEDED", + last_status_update: "2019-11-06T21:10:52Z", + recipient_id: "recipient-id-sandbox-9b6b4679-914b-445b-9450-efbdb80296f6", + schedule: %Plaid.PaymentInitiation.Schedule{ + interval: "WEEKLY", + interval_execution_day: 2, + start_date: "2021-01-01", + end_date: "2021-01-31" + } + } + ], + next_cursor: "2020-01-01T00:00:00Z", + request_id: "aEAQmewMzlVa1k6" + }} = + Plaid.PaymentInitiation.list_payments( + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end end diff --git a/test/plaid/sandbox_test.exs b/test/plaid/sandbox_test.exs index e90d44f..bccf860 100644 --- a/test/plaid/sandbox_test.exs +++ b/test/plaid/sandbox_test.exs @@ -40,6 +40,28 @@ defmodule Plaid.SandboxTest do ) end + test "/sandbox/public_token/create without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/sandbox/public_token/create", fn conn -> + Conn.resp(conn, 200, ~s<{ + "public_token": "public-sandbox-b0e2c4ee-a763-4df5-bfe9-46a46bce993d", + "request_id": "Aim3b" + }>) + end) + + {:ok, + %Plaid.Sandbox.CreatePublicTokenResponse{ + public_token: "public-sandbox-b0e2c4ee-a763-4df5-bfe9-46a46bce993d", + request_id: "Aim3b" + }} = + Plaid.Sandbox.create_public_token( + "ins_1", + ["assets", "auth", "balance"], + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/sandbox/item/reset_login", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/sandbox/item/reset_login", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -130,6 +152,26 @@ defmodule Plaid.SandboxTest do ) end + test "/sandbox/bank_transfer/simulate without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/sandbox/bank_transfer/simulate", fn conn -> + Conn.resp(conn, 200, ~s<{ + "request_id": "1vwmF5TBQwiqfwP" + }>) + end) + + {:ok, + %Plaid.SimpleResponse{ + request_id: "1vwmF5TBQwiqfwP" + }} = + Plaid.Sandbox.simulate_bank_transfer( + "bt_123xxx", + "failed", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/sandbox/bank_transfer/fire_webhook", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/sandbox/bank_transfer/fire_webhook", fn conn -> Conn.resp(conn, 200, ~s<{ @@ -152,9 +194,9 @@ defmodule Plaid.SandboxTest do test "/sandbox/processor_token/create", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/sandbox/processor_token/create", fn conn -> Conn.resp(conn, 200, ~s<{ - "processor_token": "processor-sandbox-b0e2c4ee-a763-4df5-bfe9-46a46bce993d", - "request_id": "Aim3b" - }>) + "processor_token": "processor-sandbox-b0e2c4ee-a763-4df5-bfe9-46a46bce993d", + "request_id": "Aim3b" + }>) end) {:ok, @@ -170,4 +212,25 @@ defmodule Plaid.SandboxTest do secret: "abc" ) end + + test "/sandbox/processor_token/create without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/sandbox/processor_token/create", fn conn -> + Conn.resp(conn, 200, ~s<{ + "processor_token": "processor-sandbox-b0e2c4ee-a763-4df5-bfe9-46a46bce993d", + "request_id": "Aim3b" + }>) + end) + + {:ok, + %Plaid.Sandbox.CreateProcessorTokenResponse{ + processor_token: "processor-sandbox-b0e2c4ee-a763-4df5-bfe9-46a46bce993d", + request_id: "Aim3b" + }} = + Plaid.Sandbox.create_processor_token( + "ins_1", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end end diff --git a/test/plaid/transactions_test.exs b/test/plaid/transactions_test.exs index c555a74..86d38ff 100644 --- a/test/plaid/transactions_test.exs +++ b/test/plaid/transactions_test.exs @@ -191,6 +191,187 @@ defmodule Plaid.TransactionsTest do ) end + test "/transactions/get without options", %{bypass: bypass, api_host: api_host} do + Bypass.expect_once(bypass, "POST", "/transactions/get", fn conn -> + Conn.resp(conn, 200, ~s<{ + "accounts": [ + { + "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + "balances": { + "available": 110, + "current": 110, + "iso_currency_code": "USD", + "limit": null, + "unofficial_currency_code": null + }, + "mask": "0000", + "name": "Plaid Checking", + "official_name": "Plaid Gold Standard 0% Interest Checking", + "subtype": "checking", + "type": "depository" + } + ], + "transactions": [ + { + "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + "amount": 2307.21, + "iso_currency_code": "USD", + "unofficial_currency_code": null, + "category": [ + "Shops", + "Computers and Electronics" + ], + "category_id": "19013000", + "date": "2017-01-29", + "authorized_date": "2017-01-27", + "location": { + "address": "300 Post St", + "city": "San Francisco", + "region": "CA", + "postal_code": "94108", + "country": "US", + "lat": 40.740352, + "lon": -74.001761, + "store_number": "1235" + }, + "name": "Apple Store", + "merchant_name": "Apple", + "payment_meta": { + "by_order_of": null, + "payee": null, + "payer": null, + "payment_method": null, + "payment_processor": null, + "ppd_id": null, + "reason": null, + "reference_number": null + }, + "payment_channel": "in store", + "pending": false, + "pending_transaction_id": null, + "account_owner": null, + "transaction_id": "lPNjeW1nR6CDn5okmGQ6hEpMo4lLNoSrzqDje", + "transaction_code": null, + "transaction_type": "place" + } + ], + "item": { + "available_products": [ + "balance", + "identity", + "investments" + ], + "billed_products": [ + "assets", + "auth", + "liabilities", + "transactions" + ], + "consent_expiration_time": null, + "error": null, + "institution_id": "ins_3", + "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + "webhook": "https://www.genericwebhookurl.com/webhook" + }, + "total_transactions": 1, + "request_id": "45QSn" + }>) + end) + + {:ok, + %Plaid.Transactions.GetResponse{ + accounts: [ + %Plaid.Account{ + account_id: "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + balances: %Plaid.Account.Balances{ + available: 110, + current: 110, + iso_currency_code: "USD", + limit: nil, + unofficial_currency_code: nil + }, + mask: "0000", + name: "Plaid Checking", + official_name: "Plaid Gold Standard 0% Interest Checking", + subtype: "checking", + type: "depository" + } + ], + transactions: [ + %Plaid.Transactions.Transaction{ + account_id: "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp", + amount: 2307.21, + iso_currency_code: "USD", + unofficial_currency_code: nil, + category: [ + "Shops", + "Computers and Electronics" + ], + category_id: "19013000", + date: "2017-01-29", + authorized_date: "2017-01-27", + location: %Plaid.Transactions.Transaction.Location{ + address: "300 Post St", + city: "San Francisco", + region: "CA", + postal_code: "94108", + country: "US", + lat: 40.740352, + lon: -74.001761, + store_number: "1235" + }, + name: "Apple Store", + merchant_name: "Apple", + payment_meta: %Plaid.Transactions.Transaction.PaymentMeta{ + by_order_of: nil, + payee: nil, + payer: nil, + payment_method: nil, + payment_processor: nil, + ppd_id: nil, + reason: nil, + reference_number: nil + }, + payment_channel: "in store", + pending: false, + pending_transaction_id: nil, + account_owner: nil, + transaction_id: "lPNjeW1nR6CDn5okmGQ6hEpMo4lLNoSrzqDje", + transaction_code: nil, + transaction_type: "place" + } + ], + item: %Plaid.Item{ + available_products: [ + "balance", + "identity", + "investments" + ], + billed_products: [ + "assets", + "auth", + "liabilities", + "transactions" + ], + consent_expiration_time: nil, + error: nil, + institution_id: "ins_3", + item_id: "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6", + webhook: "https://www.genericwebhookurl.com/webhook" + }, + total_transactions: 1, + request_id: "45QSn" + }} = + Plaid.Transactions.get( + "access-prod-123xxx", + "2021-01-01", + "2021-01-10", + test_api_host: api_host, + client_id: "123", + secret: "abc" + ) + end + test "/transactions/refresh", %{bypass: bypass, api_host: api_host} do Bypass.expect_once(bypass, "POST", "/transactions/refresh", fn conn -> Conn.resp(conn, 200, ~s<{"request_id": "1vwmF5TBQwiqfwP"}>)