Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion fundsTransferByCustomerService2/.bundle/config
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
---
BUNDLE_DISABLE_SHARED_GEMS: "true"
Binary file modified fundsTransferByCustomerService2/db/test.db
Binary file not shown.
83 changes: 66 additions & 17 deletions fundsTransferByCustomerService2/spec/ft2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -42,36 +84,43 @@ 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


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
7 changes: 3 additions & 4 deletions fundsTransferByCustomerService2/support/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down