diff --git a/fundsTransferByCustomerService2/.bundle/config b/fundsTransferByCustomerService2/.bundle/config index 9c61b5c..ed97d53 100644 --- a/fundsTransferByCustomerService2/.bundle/config +++ b/fundsTransferByCustomerService2/.bundle/config @@ -1,2 +1 @@ --- -BUNDLE_DISABLE_SHARED_GEMS: "true" diff --git a/fundsTransferByCustomerService2/db/test.db b/fundsTransferByCustomerService2/db/test.db index 4fd4583..03fdf26 100644 Binary files a/fundsTransferByCustomerService2/db/test.db and b/fundsTransferByCustomerService2/db/test.db differ diff --git a/fundsTransferByCustomerService2/spec/ft2_spec.rb b/fundsTransferByCustomerService2/spec/ft2_spec.rb index 9620955..72e3c70 100644 --- a/fundsTransferByCustomerService2/spec/ft2_spec.rb +++ b/fundsTransferByCustomerService2/spec/ft2_spec.rb @@ -3,7 +3,7 @@ class FundsTransferByCustomerService2 def initialize - @env = ::ApiBanking::Environment::LOCAL.new('10.211.55.6', 7800) + @env = ::ApiBanking::Environment::LOCAL.new('10.211.55.3', 7800) end def getBalance(appID, customerID, accountNo) @@ -15,13 +15,55 @@ def getBalance(appID, customerID, accountNo) ApiBanking::FundsTransferByCustomerService2.get_balance(@env, request) end + + def transfer(appID, customerID, accountNo) + address = ApiBanking::FundsTransferByCustomerService2::Transfer::Address.new() + beneficiary = ApiBanking::FundsTransferByCustomerService2::Transfer::Beneficiary.new() + request = ApiBanking::FundsTransferByCustomerService2::Transfer::Request.new() + + address.address1 = 'Mumbai' + + beneficiary.fullName = 'Quantiguous Solutions' + beneficiary.accountNo = '00001234567890' + beneficiary.accountIFSC = 'RBIB0123456' + beneficiary.address = address # can also be a string + + request.uniqueRequestNo = SecureRandom.uuid.gsub!('-','') + request.appID = appID + request.purposeCode = 'PC01' + request.customerID = customerID + request.debitAccountNo = accountNo + request.transferType = 'NEFT' + request.transferAmount = 20 + request.remitterToBeneficiaryInfo = 'FUND TRANSFER' + + request.beneficiary = beneficiary + + ApiBanking::FundsTransferByCustomerService2.transfer(@env, request) + end + end -module Flexcube - class Exception +class Exception + def initialize @db = SQLite3::Database.new("./db/test.db") @xml_doc = Nokogiri::XML(File.read('./fixtures/Exception.xml')) end + + def ErrorCode=(val) + @xml_doc.at_xpath('//ErrorCode').content = val + save + end + + def ErrorCode + @xml_doc.at_xpath('//ErrorCode').content + end + + private + + def save + @db.execute("update replies set reply = ?", @xml_doc.to_s) + end end class CasaAccountBalanceInquiryResponse @@ -42,7 +84,7 @@ def AvailableBalance private def save - @db.execute("update replies set reply = ? where op = ?", @xml_doc.to_s, 'CasaAccountBalanceInquiryResponse') + @db.execute("update replies set reply = ?", @xml_doc.to_s) end end @@ -50,28 +92,35 @@ def save describe FundsTransferByCustomerService2 do let (:ft2) { FundsTransferByCustomerService2.new } - let (:flex) { CasaAccountBalanceInquiryResponse.new } + let (:casaAccountBalanceInquiryResponse) { CasaAccountBalanceInquiryResponse.new } + let (:ex) { Exception.new } context "getBalance" do context "for an account" do # setup the flex response that will be sent to the service it "should return the account balance" do - flex.AvailableBalance = 1003 + casaAccountBalanceInquiryResponse.AvailableBalance = 1003 resp = ft2.getBalance('12345', '2424', '000190600002003') - expect(resp.accountBalanceAmount).to eq(flex.AvailableBalance) + expect(resp.accountBalanceAmount).to eq(casaAccountBalanceInquiryResponse.AvailableBalance) end end - # context "for a non-existant account" do - # # setup the flex response that will be sent to the service - # - # it "should return fault" do - # flex.AvailableBalance = 1003 - # resp = ft2.getBalance('12345', '2424', '000190600002003') - # expect(resp.accountBalanceAmount).to eq(flex.AvailableBalance) - # end - # end - + context "for a non-existant account" do + # setup the flex response that will be sent to the service + + it "should return fault" do + ex.ErrorCode = "2778" + resp = ft2.getBalance('12345', '2424', '000190600002003') + expect(resp.code).to eq("flex:E#{ex.ErrorCode}") + end + end end + + context "transfer" do + it "should do transfer" do + p ft2.transfer('12345', '2424', '000190600002003') + end + end + end diff --git a/fundsTransferByCustomerService2/support/config.ru b/fundsTransferByCustomerService2/support/config.ru index a569a23..2466684 100644 --- a/fundsTransferByCustomerService2/support/config.ru +++ b/fundsTransferByCustomerService2/support/config.ru @@ -3,23 +3,22 @@ require 'fileutils' class Application def initialize - FileUtils.rm('test.db', force: true) + FileUtils.rm('../db/test.db', force: true) @db = SQLite3::Database.new "../db/test.db" # Create a table rows = @db.execute <<-SQL create table replies ( - op text, reply text ); SQL - @db.execute("INSERT INTO replies ( op, reply ) VALUES ( ?, ? )", ['CasaAccountBalanceInquiryResponse', nil]) + @db.execute("INSERT INTO replies ( reply ) VALUES ( ? )", [nil]) end def call(env) request = Rack::Request.new env - reply = @db.get_first_value( "select reply from replies where op = ? ", 'CasaAccountBalanceInquiryResponse') + reply = @db.get_first_value( "select reply from replies") p reply