The personal finance app for everyone (by everyone)
Ruby
List Wise profiles from v2 so no business profile is missing (#4839)
Krish Wanchood4c27891383b
diff --git a/app/models/provider/wise.rb b/app/models/provider/wise.rbindex 45100eba76..518701d304 100644--- a/app/models/provider/wise.rb+++ b/app/models/provider/wise.rb@@ -55,8 +55,20 @@ class Provider::Wiseget("/v1/me")end+ # v1 leaves out some business profiles the token can read (one with an+ # empty companyRole); v2 lists them all. Each profile is returned in the v1+ # shape the profile picker reads: a lowercase type and the name in details.def get_profiles- get("/v1/profiles")+ Array(get("/v2/profiles")).map do |profile|+ business = profile["type"].to_s.casecmp?("business")+ name = business ? profile["businessName"] : profile["fullName"]++ {+ "id" => profile["id"],+ "type" => business ? "business" : "personal",+ "details" => profile["details"].presence || { "name" => name.presence }.compact+ }+ endenddef get_balances(profile_id)diff --git a/test/models/provider/wise_test.rb b/test/models/provider/wise_test.rbindex ca7415fd4d..a949b4f75b 100644--- a/test/models/provider/wise_test.rb+++ b/test/models/provider/wise_test.rb@@ -148,6 +148,23 @@ class Provider::WiseTest < ActiveSupport::TestCaseassert_equal({ profile: 123, limit: 100, offset: 200, createdDateStart: "2025-10-07" }, sent)end+ test "lists profiles from v2 in the shape the profile picker reads" do+ body = [+ { id: 1, type: "PERSONAL", fullName: "Jane Doe", profileRole: "DIRECT_CUSTOMER_PROFILE" },+ { id: 2, type: "BUSINESS", businessName: "Owned Ltd", companyRole: "OWNER" },+ { id: 3, type: "BUSINESS", businessName: "Missing From V1 Ltd", companyRole: "" }+ ].to_json+ Provider::Wise.expects(:get)+ .with { |url, _options| url == "https://api.wise.com/v2/profiles" }+ .returns(fake_response(code: 200, body: body))++ assert_equal [+ { "id" => 1, "type" => "personal", "details" => { "name" => "Jane Doe" } },+ { "id" => 2, "type" => "business", "details" => { "name" => "Owned Ltd" } },+ { "id" => 3, "type" => "business", "details" => { "name" => "Missing From V1 Ltd" } }+ ], @provider.get_profiles+ end+test "reads the multi-currency account from the v4 endpoint" doProvider::Wise.expects(:get).with { |url, _options| url == "https://api.wise.com/v4/profiles/123/multi-currency-account" }