require 'spec_helper' RSpec.describe PortalConnectors::RemitanoClient do before do PortalConnectors.configure do |config| config.requester = "staff" end end def client PortalConnectors::RemitanoClient.singleton end describe "#get_fiat_balance", vcr: true do context "valid params" do it "returns data" do params = { username_or_email: 9, currency: "vnd", } result, ok = client.get_fiat_balance(params) expect(result["balance"]).to eq [123.0, 0.0] expect(ok).to be_truthy end end end describe "#get_coin_balance", vcr: true do context "valid params" do it "returns data" do params = { username_or_email: 9, currency: "btc", } result, ok = client.get_coin_balance(params) expect(result["balance"]).to eq [1.0, 0.0] expect(ok).to be_truthy end end end describe "#get_main_fiat_currency", vcr: true do context "valid params" do it "returns data" do params = { username_or_email: 9, } result, ok = client.get_main_fiat_currency(params) expect(result["currency"]).to eq "VND" expect(ok).to be_truthy end end end describe "#get_fiat_currency_rate", vcr: true do context "valid params" do it "returns data" do params = { fiat_currency: "vnd", } result, ok = client.get_fiat_currency_rate(params) expect(result["rate"]).to eq 23000.0 expect(ok).to be_truthy end end end describe "#get_list_rates", vcr: true do context "valid params" do it "returns data" do params = { currency: "vnd", } result, ok = client.get_list_rates(params) expect(result["data"]["USDTVND"]["bid"]).to eq 25697.595 expect(ok).to be_truthy end end end describe "#get_site_country_info", vcr: true do context "valid params without attributes" do it "returns data" do params = { method: "country2currency", } result, ok = client.get_site_country_info(params) expect(result["data"]["au"]).to eq "AUD" expect(ok).to be_truthy end end context "valid params with attributes" do it "returns data" do params = { method: "timezone", attributes: ["vn"], } result, ok = client.get_site_country_info(params) expect(result["data"]).to eq "Asia/Ho_Chi_Minh" expect(ok).to be_truthy end end end describe "#get_user_info", vcr: true do context "valid params" do it "returns data" do params = { username_or_email: "thuannguyen", } result, ok = client.get_user_info(params) expect(result["user"]["username"]).to eq "thuannguyen" expect(result["user"]["doc_verified"]).to eq false expect(ok).to be_truthy end end end end