require "spec_helper" RSpec.describe PortalConnectors::SaviClient do describe "#sync_user_level", :vcr do it "calls savi portal" do client = described_class.singleton response, ok = client.sync_user_level( savi_user_ref: "ref", remi_user_level: 1 ) # we only verify that it can calls savi-portal correctly expect(ok).to eq(false) expect(response["error"]).to include("user not found") end end describe "#sync", :vcr do it "calls savi portal" do client = described_class.singleton response, ok = client.sync( savi_user_ref: "ref", remi_user_level: 1, remi_authorized_app_permissions: ["read_kyc_level", "quick_transfer"] ) # we only verify that it can calls savi-portal correctly expect(ok).to eq(false) expect(response["error"]).to include("user not found") end end describe "#unlink_account", :vcr do it "calls savi portal" do client = described_class.singleton response, ok = client.unlink_account(savi_user_ref: "ref") # we only verify that it can calls savi-portal correctly expect(ok).to eq(false) expect(response["error"]).to include("user not found") end end describe "#is_valid_savi_user_ref", :vcr do it "calls savi portal" do client = described_class.singleton response, ok = client.is_valid_savi_user_ref( savi_user_ref: "ref", ) # we only verify that it can calls savi-portal correctly expect(ok).to eq(true) expect(response["is_valid"]).to eq(false) end end describe "#check_valid_user_ref", :vcr do it "calls savi portal" do client = described_class.singleton response, ok = client.check_valid_user_ref( savi_user_ref: "ref", ) # we only verify that it can calls savi-portal correctly expect(ok).to eq(true) expect(response["is_valid"]).to eq(false) end end describe "#handle_fund_transfer", :vcr do it "calls handling fund transfer in savi portal" do client = described_class.singleton response, ok = client.handle_fund_transfer( remi_authorized_app_app_user_ref: "5f0c611f-2be6-4cfb-8719-b4e2fbb1788b", remi_authorized_app_fund_transfer_id: 9 ) expect(ok).to eq(true) expect(response).to eq({ "app_request_id" => 1 }) end end describe "#fund_transfer_data", :vcr do it "return fund transfer data in savi portal" do client = described_class.singleton response, ok = client.fund_transfer_data( savi_fund_transfer_id: 1 ) expect(ok).to eq(true) expect(response).to eq({ "savi_fund_transfer_amount" => "1001.0", "savi_fund_transfer_coin" => "USDT", "savi_fund_transfer_created_at" => 1682666840, "savi_fund_transfer_from" => "REMITANO", "savi_fund_transfer_id" => 1, "savi_fund_transfer_remi_authorized_app_fund_transfer_id" => 9, "savi_fund_transfer_status" => "pending", "savi_fund_transfer_from_status" => "debit_pending", "savi_fund_transfer_to" => "SPOT", "savi_user_ref" => "5f0c611f-2be6-4cfb-8719-b4e2fbb1788b", }) end end describe "#get_address", :vcr do it "return deposit address" do client = described_class.singleton response, ok = client.get_address( remi_user_id: 1, remi_coin: "BTC", remi_network: "BTC-Bitcoin" ) expect(ok).to eq(true) expect(response).to eq({ "address" => "33Ygav6dqgY29A2svEzprxk79EF14CH19G" }) end end describe "#fetch_deposit", :vcr do it "return deposit data in savi portal" do client = described_class.singleton response, ok = client.fetch_deposit( savi_deposit_id: 3, ) expect(ok).to eq(true) expect(response).to eq({ "savi_deposit_id" => 3, "savi_coin" => "BTC", "savi_network" => "BTC-Bitcoin", "savi_amount" => "0.12345", "savi_status" => "successful", "savi_tx_hash" => "642736120127a697344c61960e5e9d0e4ff6e13a76feed6fb9a8ecfb3677ee55", "savi_address" => "3Kuvw9Zm6jFrRxaCTRjRT1YfwjmB8a6fUi" }) end end describe "#resync_missing_deposits", :vcr do it "resync missing deposits in savi portal" do client = described_class.singleton response, ok = client.resync_missing_deposits( remi_user_id: 1, start_date: "2024-01-10", end_date: "2024-01-14" ) expect(ok).to eq(true) expect(response).to eq({ "status" => "success", }) end end describe "#perform_onoff_ramp_pool_mission", :vcr do it "return success" do client = described_class.singleton response, ok = client.perform_onoff_ramp_pool_mission( savi_user_ref: "ref", symbol: "USDT/NGN", usdt_volume: 20, order_created_at: 1711431098173 ) expect(ok).to eq(true) expect(response).to eq({ "status" => "success" }) end end end