api_banking 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e63a465927362f8c7808ef15e1ab5d4d1c3a49d
4
+ data.tar.gz: a42ef24e251ca232fdb939f43a991bcab998f47e
5
+ SHA512:
6
+ metadata.gz: faec58c29f86519b8ee494dcfbb0f13faf6cd4044b2c4dd4369f887d26b7437b56ec5f3df155d31d294d3870283b2d650ae7754ae5da81c01d4100cd201f2d72
7
+ data.tar.gz: fe0860ea590bcb76a86021fdd632254ef2945ad967ce098860dbe7cab7ae7ffbe7f8ba600a2650f6f7c711d2dd807ea27cb446987368248175ec1f6e126ce89f
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/bundle
11
+ /lib/bundler/man/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in api_banking.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 akil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # ApiBanking
2
+
3
+ A simple way to get started wit the api's provided by leading banks in India.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'api_banking'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install api_banking
20
+
21
+ ## Usage
22
+
23
+ You'll need to sign up with your chosen bank to get your credentials.
24
+
25
+ Most banks require 3 factors, you'll need a certificate to esablish 2 way trust, and your bank will give you a client id/secret and also a user/password.
26
+
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/quantiguous/api_banking/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "lib"
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/test_*.rb']
8
+ t.verbose = true
9
+ end
10
+ task :default => :test
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'api_banking/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "api_banking"
8
+ spec.version = ApiBanking::VERSION
9
+ spec.authors = ["akil"]
10
+ spec.email = ["hello@quantiguous.com"]
11
+
12
+ spec.summary = %q{Ruby SDK to Connect to Banks}
13
+ spec.homepage = "http://apibanking.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+
25
+ spec.add_dependency "typhoeus"
26
+ spec.add_dependency "nokogiri"
27
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "api_banking"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module ApiBanking
2
+
3
+ end
@@ -0,0 +1,8 @@
1
+ module ApiBanking
2
+ module Environment
3
+ module RBL
4
+ UAT = Struct.new(:code, :subCode, :reasonText)
5
+ PRD = Struct.new(:code)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ module ApiBanking
2
+ module Environment
3
+ module YBL
4
+ UAT = Struct.new(:user, :password, :client_id, :client_secret, :url) do
5
+ def initialize(*)
6
+ super
7
+ self.url ||= 'https://uatsky.yesbank.in/app/uat/'
8
+ end
9
+ end
10
+
11
+ PRD = Struct.new(:user, :password, :client_id, :client_secret, :ssl_client_cert, :ssl_client_key, :ssl_ca_file, :url) do
12
+ def initialize(*)
13
+ super
14
+ self.ssl_ca_file ||= File.expand_path('./prd.pem', File.dirname(__FILE__))
15
+ self.url ||= 'https://sky.yesbank.in:444/app/live/ssl'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,74 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
3
+ MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
4
+ YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
5
+ EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3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ANEYoQmr7tv4ZcoGFo6NhTYSJzeWp4YiMnTLcXcMlBI
72
+ ncMZCZMVzCTA8xhK5JVRGupQS1bvMSiOTb83gXwj0CTWqIyeLb5kIpXJrTDTAzkx
73
+ CFXUTJSamDL3w/VBvXV01mp9C5VPQaC1Omt5xdMSBrWteIMFopr4Zg==
74
+ -----END CERTIFICATE-----
@@ -0,0 +1,3 @@
1
+ module ApiBanking
2
+ Fault = Struct.new(:code, :subCode, :reasonText)
3
+ end
@@ -0,0 +1,144 @@
1
+ module ApiBanking
2
+ class FundsTransferByCustomerService < SoapClient
3
+
4
+ SERVICE_NAMESPACE = 'http://www.quantiguous.com/services'
5
+ SERVICE_VERSION = 1
6
+
7
+ attr_accessor :request, :result
8
+
9
+ #transfer
10
+ module Transfer
11
+ Address = Struct.new(:address1, :address2, :address3, :postalCode, :city, :stateOrProvince, :country)
12
+ Beneficiary = Struct.new(:fullName, :address, :accountNo, :accountIFSC, :mobileNo, :mmid)
13
+ Request = Struct.new(:uniqueRequestNo, :customerID, :debitAccountNo, :beneficiary, :transferAmount, :transferType, :remitterToBeneficiaryInfo)
14
+ Result = Struct.new(:version, :uniqueResponseNo, :attemptNo, :transferType, :lowBalanceAlert, :transactionStatus)
15
+ TransactionStatus = Struct.new(:statusCode, :subStatusCode, :bankReferenceNo, :beneficiaryReferenceNo)
16
+ end
17
+
18
+ #getStatus
19
+ module GetStatus
20
+ Request = Struct.new(:version, :appID, :customerID, :requestReferenceNo)
21
+ TransactionStatus = Struct.new(:statusCode, :subStatusCode, :bankReferenceNo, :beneficiaryReferenceNo)
22
+ Result = Struct.new(:version, :transferType, :reqTransferType, :transactionDate, :transferAmount, :transferCurrencyCode, :transactionStatus)
23
+ end
24
+
25
+ class << self
26
+ attr_accessor :configuration
27
+ end
28
+
29
+ def self.configure
30
+ self.configuration ||= Configuration.new
31
+ yield(configuration)
32
+ end
33
+
34
+ class Configuration
35
+ attr_accessor :environment, :proxy, :timeout
36
+ end
37
+
38
+ def self.transfer(request)
39
+ reply = do_remote_call do |xml|
40
+ xml.transfer("xmlns:ns" => SERVICE_NAMESPACE ) do
41
+ xml.parent.namespace = xml.parent.namespace_definitions.first
42
+ xml['ns'].version SERVICE_VERSION
43
+ xml['ns'].uniqueRequestNo request.uniqueRequestNo
44
+ xml['ns'].customerID request.customerID
45
+ xml['ns'].debitAccountNo request.debitAccountNo
46
+ xml['ns'].beneficiary do |xml|
47
+ xml.beneficiaryDetail do |xml|
48
+ xml.beneficiaryName do |xml|
49
+ xml.fullName request.beneficiary.fullName
50
+ end
51
+ xml.beneficiaryAddress do |xml|
52
+ if request.beneficiary.address.kind_of? Transfer::Address
53
+ xml.address1 request.beneficiary.address.address1
54
+ xml.address2 request.beneficiary.address.address2 unless request.beneficiary.address.address2.nil?
55
+ xml.address3 request.beneficiary.address.address3 unless request.beneficiary.address.address3.nil?
56
+ xml.postalCode request.beneficiary.address.postalCode unless request.beneficiary.address.postalCode.nil?
57
+ xml.city request.beneficiary.address.city unless request.beneficiary.address.city.nil?
58
+ xml.stateOrProvince request.beneficiary.address.stateOrProvince unless request.beneficiary.address.stateOrProvince.nil?
59
+ xml.country request.beneficiary.address.country unless request.beneficiary.address.country.nil?
60
+ else
61
+ xml.address1 request.beneficiary.address
62
+ end
63
+ end
64
+ xml.beneficiaryContact do |xml|
65
+ end
66
+ xml.beneficiaryAccountNo request.beneficiary.accountNo
67
+ xml.beneficiaryIFSC request.beneficiary.accountIFSC
68
+ end
69
+ end
70
+ xml.transferType request.transferType
71
+ xml.transferCurrencyCode 'INR'
72
+ xml.transferAmount request.transferAmount
73
+ xml.remitterToBeneficiaryInfo request.remitterToBeneficiaryInfo
74
+ end
75
+ end
76
+
77
+ parse_reply(:transferResponse, reply)
78
+ end
79
+
80
+ def self.get_status(request)
81
+ reply = do_remote_call do |xml|
82
+ xml.getStatus("xmlns:ns" => SERVICE_NAMESPACE ) do
83
+ xml.parent.namespace = xml.parent.namespace_definitions.first
84
+ xml['ns'].version SERVICE_VERSION
85
+ xml['ns'].customerID request.customerID
86
+ xml['ns'].requestReferenceNo request.requestReferenceNo
87
+ end
88
+ end
89
+
90
+ parse_reply(:getStatus, reply)
91
+ end
92
+
93
+ private
94
+
95
+ def self.uri()
96
+ if self.configuration.environment.kind_of?ApiBanking::Environment::YBL::UAT
97
+ return '/fundsTransferByCustomerServiceHttpService'
98
+ else
99
+ return '/fundsTransferByCustomerService'
100
+ end
101
+ end
102
+
103
+ def self.parse_reply(operationName, reply)
104
+ if reply.kind_of?Fault
105
+ return reply
106
+ else
107
+ case operationName
108
+ when :transferResponse
109
+ transactionStatus = Transfer::TransactionStatus.new(
110
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:statusCode', 'ns' => SERVICE_NAMESPACE)),
111
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:subStatusCode', 'ns' => SERVICE_NAMESPACE)),
112
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:bankReferenceNo', 'ns' => SERVICE_NAMESPACE)),
113
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:beneficiaryReferenceNo', 'ns' => SERVICE_NAMESPACE))
114
+ )
115
+ return Transfer::Result.new(
116
+ content_at(reply.at_xpath('//ns:transferResponse/ns:version', 'ns' => SERVICE_NAMESPACE)),
117
+ content_at(reply.at_xpath('//ns:transferResponse/ns:uniqueResponseNo', 'ns' => SERVICE_NAMESPACE)),
118
+ content_at(reply.at_xpath('//ns:transferResponse/ns:attemptNo', 'ns' => SERVICE_NAMESPACE)),
119
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transferType', 'ns' => SERVICE_NAMESPACE)),
120
+ content_at(reply.at_xpath('//ns:transferResponse/ns:lowBalanceAlert', 'ns' => SERVICE_NAMESPACE)),
121
+ transactionStatus
122
+ )
123
+ when :getStatus
124
+ transactionStatus = GetStatus::TransactionStatus.new(
125
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:statusCode', 'ns' => SERVICE_NAMESPACE)),
126
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:subStatusCode', 'ns' => SERVICE_NAMESPACE)),
127
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:bankReferenceNo', 'ns' => SERVICE_NAMESPACE)),
128
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:beneficiaryReferenceNo', 'ns' => SERVICE_NAMESPACE))
129
+ )
130
+ return GetStatus::Result.new(
131
+ content_at(reply.at_xpath('//ns:getStatusResponse//ns:version', 'ns' => SERVICE_NAMESPACE)),
132
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transferType', 'ns' => SERVICE_NAMESPACE)),
133
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:reqTransferType', 'ns' => SERVICE_NAMESPACE)),
134
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionDate', 'ns' => SERVICE_NAMESPACE)),
135
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transferAmount', 'ns' => SERVICE_NAMESPACE)),
136
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transferCurrencyCode', 'ns' => SERVICE_NAMESPACE)),
137
+ transactionStatus
138
+ )
139
+ end
140
+ end
141
+ end
142
+
143
+ end
144
+ end
@@ -0,0 +1,148 @@
1
+ module ApiBanking
2
+ class FundsTransferByCustomerService2 < SoapClient
3
+
4
+ SERVICE_NAMESPACE = 'http://www.quantiguous.com/services'
5
+ SERVICE_VERSION = 1
6
+
7
+ attr_accessor :request, :result
8
+
9
+ #transfer
10
+ module Transfer
11
+ Address = Struct.new(:address1, :address2, :address3, :postalCode, :city, :stateOrProvince, :country)
12
+ Beneficiary = Struct.new(:fullName, :address, :accountNo, :accountIFSC, :mobileNo, :mmid)
13
+ Request = Struct.new(:uniqueRequestNo, :appID, :customerID, :debitAccountNo, :beneficiary, :transferAmount, :transferType, :purposeCode, :remitterToBeneficiaryInfo)
14
+
15
+ TransactionStatus = Struct.new(:statusCode, :subStatusCode, :bankReferenceNo, :beneficiaryReferenceNo)
16
+ Result = Struct.new(:version, :uniqueResponseNo, :attemptNo, :transferType, :lowBalanceAlert, :transactionStatus)
17
+ end
18
+
19
+ #getStatus
20
+ module GetStatus
21
+ Request = Struct.new(:version, :appID, :customerID, :requestReferenceNo)
22
+ TransactionStatus = Struct.new(:statusCode, :subStatusCode, :bankReferenceNo, :beneficiaryReferenceNo)
23
+ Result = Struct.new(:version, :transferType, :reqTransferType, :transactionDate, :transferAmount, :transferCurrencyCode, :transactionStatus)
24
+ end
25
+
26
+ class << self
27
+ attr_accessor :configuration
28
+ end
29
+
30
+ def self.configure
31
+ self.configuration ||= Configuration.new
32
+ yield(configuration)
33
+ end
34
+
35
+ class Configuration
36
+ attr_accessor :environment, :proxy, :timeout
37
+ end
38
+
39
+ def self.transfer(request)
40
+ reply = do_remote_call do |xml|
41
+ xml.transfer("xmlns:ns" => SERVICE_NAMESPACE ) do
42
+ xml.parent.namespace = xml.parent.namespace_definitions.first
43
+ xml['ns'].version SERVICE_VERSION
44
+ xml['ns'].uniqueRequestNo request.uniqueRequestNo
45
+ xml['ns'].appID request.appID
46
+ xml['ns'].purposeCode request.purposeCode
47
+ xml['ns'].customerID request.customerID
48
+ xml['ns'].debitAccountNo request.debitAccountNo
49
+ xml['ns'].beneficiary do |xml|
50
+ xml.beneficiaryDetail do |xml|
51
+ xml.beneficiaryName do |xml|
52
+ xml.fullName request.beneficiary.fullName
53
+ end
54
+ xml.beneficiaryAddress do |xml|
55
+ if request.beneficiary.address.kind_of? Transfer::Address
56
+ xml.address1 request.beneficiary.address.address1
57
+ xml.address2 request.beneficiary.address.address2 unless request.beneficiary.address.address2.nil?
58
+ xml.address3 request.beneficiary.address.address3 unless request.beneficiary.address.address3.nil?
59
+ xml.postalCode request.beneficiary.address.postalCode unless request.beneficiary.address.postalCode.nil?
60
+ xml.city request.beneficiary.address.city unless request.beneficiary.address.city.nil?
61
+ xml.stateOrProvince request.beneficiary.address.stateOrProvince unless request.beneficiary.address.stateOrProvince.nil?
62
+ xml.country request.beneficiary.address.country unless request.beneficiary.address.country.nil?
63
+ else
64
+ xml.address1 request.beneficiary.address
65
+ end
66
+ end
67
+ xml.beneficiaryContact do |xml|
68
+ end
69
+ xml.beneficiaryAccountNo request.beneficiary.accountNo
70
+ xml.beneficiaryIFSC request.beneficiary.accountIFSC
71
+ end
72
+ end
73
+ xml.transferType request.transferType
74
+ xml.transferCurrencyCode 'INR'
75
+ xml.transferAmount request.transferAmount
76
+ xml.remitterToBeneficiaryInfo request.remitterToBeneficiaryInfo
77
+ end
78
+ end
79
+
80
+ parse_reply(:transfer, reply)
81
+ end
82
+
83
+
84
+ def self.get_status(request)
85
+ reply = do_remote_call do |xml|
86
+ xml.getStatus("xmlns:ns" => SERVICE_NAMESPACE ) do
87
+ xml.parent.namespace = xml.parent.namespace_definitions.first
88
+ xml['ns'].version SERVICE_VERSION
89
+ xml['ns'].appID request.appID
90
+ xml['ns'].customerID request.customerID
91
+ xml['ns'].requestReferenceNo request.requestReferenceNo
92
+ end
93
+ end
94
+ parse_reply(:getStatus, reply)
95
+ end
96
+
97
+ private
98
+
99
+ def self.uri()
100
+ return '/fundsTransferByCustomerService2'
101
+ end
102
+
103
+ def self.parse_reply(operationName, reply)
104
+ if reply.kind_of?Fault
105
+ return reply
106
+ else
107
+ case operationName
108
+ when :transfer
109
+ transactionStatus = Transfer::TransactionStatus.new(
110
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:statusCode', 'ns' => SERVICE_NAMESPACE)),
111
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:subStatusCode', 'ns' => SERVICE_NAMESPACE)),
112
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:bankReferenceNo', 'ns' => SERVICE_NAMESPACE)),
113
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transactionStatus/ns:beneficiaryReferenceNo', 'ns' => SERVICE_NAMESPACE))
114
+ )
115
+ return Transfer::Result.new(
116
+ content_at(reply.at_xpath('//ns:transferResponse/ns:version', 'ns' => SERVICE_NAMESPACE)),
117
+ content_at(reply.at_xpath('//ns:transferResponse/ns:uniqueResponseNo', 'ns' => SERVICE_NAMESPACE)),
118
+ content_at(reply.at_xpath('//ns:transferResponse/ns:attemptNo', 'ns' => SERVICE_NAMESPACE)),
119
+ content_at(reply.at_xpath('//ns:transferResponse/ns:transferType', 'ns' => SERVICE_NAMESPACE)),
120
+ content_at(reply.at_xpath('//ns:transferResponse/ns:lowBalanceAlert', 'ns' => SERVICE_NAMESPACE)),
121
+ transactionStatus
122
+ )
123
+ when :getStatus
124
+ transactionStatus = GetStatus::TransactionStatus.new(
125
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:statusCode', 'ns' => SERVICE_NAMESPACE)),
126
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:subStatusCode', 'ns' => SERVICE_NAMESPACE)),
127
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:bankReferenceNo', 'ns' => SERVICE_NAMESPACE)),
128
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionStatus/ns:beneficiaryReferenceNo', 'ns' => SERVICE_NAMESPACE))
129
+ )
130
+ return GetStatus::Result.new(
131
+ content_at(reply.at_xpath('//ns:getStatusResponse//ns:version', 'ns' => SERVICE_NAMESPACE)),
132
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transferType', 'ns' => SERVICE_NAMESPACE)),
133
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:reqTransferType', 'ns' => SERVICE_NAMESPACE)),
134
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transactionDate', 'ns' => SERVICE_NAMESPACE)),
135
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transferAmount', 'ns' => SERVICE_NAMESPACE)),
136
+ content_at(reply.at_xpath('//ns:getStatusResponse/ns:transferCurrencyCode', 'ns' => SERVICE_NAMESPACE)),
137
+ transactionStatus
138
+ )
139
+ end
140
+ end
141
+ end
142
+
143
+ def url
144
+ return '/fundsTransferByCustomerService2'
145
+ end
146
+
147
+ end
148
+ end
@@ -0,0 +1,104 @@
1
+ module ApiBanking
2
+
3
+ class SoapClient
4
+
5
+ def self.do_remote_call(&block)
6
+ data = construct_envelope(&block)
7
+ options = {}
8
+ options[:method] = :post
9
+ options[:body] = data.to_xml
10
+
11
+ options[:headers] = {'Content-Type' => "application/xml; charset=utf-8"}
12
+
13
+ options[:proxy] = self.configuration.proxy
14
+ options[:timeout] = self.configuration.timeout
15
+
16
+ set_options_for_environment(options)
17
+
18
+ request = Typhoeus::Request.new(self.configuration.environment.url + uri, options)
19
+ response = request.run
20
+
21
+ parse_response(response)
22
+ end
23
+
24
+
25
+ private
26
+ def self.set_options_for_environment(options)
27
+ if self.configuration.environment.kind_of?ApiBanking::Environment::YBL::PRD
28
+ options[:userpwd] = "#{self.configuration.environment.user}:#{self.configuration.environment.password}"
29
+ options[:headers]["X-IBM-Client-Id"] = self.configuration.environment.client_id
30
+ options[:headers]["X-IBM-Client-Secret"] = self.configuration.environment.client_secret
31
+ options[:cainfo] = self.configuration.environment.ssl_ca_file
32
+ options[:sslkey] = self.configuration.environment.ssl_client_key
33
+ options[:sslcert] = self.configuration.environment.ssl_client_cert
34
+ options[:ssl_verifypeer] = true
35
+ elsif self.configuration.environment.kind_of?ApiBanking::Environment::YBL::UAT
36
+ options[:userpwd] = "#{self.configuration.environment.user}:#{self.configuration.environment.password}"
37
+ options[:headers]["X-IBM-Client-Id"] = self.configuration.environment.client_id
38
+ options[:headers]["X-IBM-Client-Secret"] = self.configuration.environment.client_secret
39
+ end
40
+ end
41
+
42
+ def self.construct_envelope(&block)
43
+ Nokogiri::XML::Builder.new do |xml|
44
+ xml.Envelope("xmlns:soap12" => "http://www.w3.org/2003/05/soap-envelope",
45
+ "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
46
+ "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema") do
47
+ xml.parent.namespace = xml.parent.namespace_definitions.first
48
+ xml['soap12'].Header
49
+ xml['soap12'].Body(&block)
50
+ end
51
+ end
52
+ end
53
+
54
+ def self.parse_response(response)
55
+ if response.success?
56
+ if response.headers['Content-Type'] =~ /xml/ then
57
+ return Nokogiri::XML(response.response_body)
58
+ end
59
+ elsif response.timed_out?
60
+ return Fault.new("502", "", "#{response.return_message}")
61
+ elsif response.code == 0
62
+ return Fault.new(response.code, "", response.return_message)
63
+ else
64
+ # http status indicating error
65
+ if response.headers['Content-Type'] =~ /xml/ then
66
+ reply = Nokogiri::XML(response.response_body)
67
+
68
+ # service failures return a fault
69
+ unless reply.at_xpath('//soapenv12:Fault', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope').nil? then
70
+ return parse_fault(reply)
71
+ end
72
+
73
+ # datapower failures return an xml
74
+ unless reply.at_xpath('//errorResponse').nil? then
75
+ return parse_dp_reply(reply)
76
+ end
77
+
78
+ end
79
+ return Fault.new("#{response.code.to_s}", "", response.status_message)
80
+ end
81
+ end
82
+
83
+ def self.parse_dp_reply(reply)
84
+ code = content_at(reply.at_xpath('/errorResponse/httpCode'))
85
+ reasonText = content_at(reply.at_xpath('/errorResponse/moreInformation'))
86
+ return Fault.new(code, "", reasonText)
87
+ end
88
+
89
+ def self.parse_fault(reply)
90
+ code = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Code/soapenv12:Subcode/soapenv12:Value', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
91
+ subcode = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Code/soapenv12:Subcode/soapenv12:Subcode/soapenv12:Value', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
92
+ reasonText = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Reason/soapenv12:Text', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
93
+ return Fault.new(code, subcode, reasonText)
94
+ end
95
+
96
+ def self.content_at(node)
97
+ node.content unless node.nil?
98
+ end
99
+
100
+ def self.part_name(message)
101
+ message.at_xpath('/soapenv12:Envelope/soapenv12:Body/*', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope').name
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,3 @@
1
+ module ApiBanking
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "nokogiri"
2
+ require "typhoeus"
3
+ require "api_banking/version"
4
+ require_relative "api_banking/config"
5
+ require_relative "api_banking/environment/rbl/env"
6
+ require_relative "api_banking/environment/ybl/env"
7
+ require_relative "api_banking/soap/fault"
8
+ require_relative "api_banking/soap/soap_client"
9
+ require_relative "api_banking/soap/fundsTransferByCustomerService"
10
+ require_relative "api_banking/soap/fundsTransferByCustomerService2"
11
+
12
+ module ApiBanking
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: api_banking
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - akil
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: typhoeus
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - hello@quantiguous.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - CODE_OF_CONDUCT.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - api_banking.gemspec
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/api_banking.rb
101
+ - lib/api_banking/config.rb
102
+ - lib/api_banking/environment/rbl/env.rb
103
+ - lib/api_banking/environment/ybl/env.rb
104
+ - lib/api_banking/environment/ybl/prd.pem
105
+ - lib/api_banking/soap/fault.rb
106
+ - lib/api_banking/soap/fundsTransferByCustomerService.rb
107
+ - lib/api_banking/soap/fundsTransferByCustomerService2.rb
108
+ - lib/api_banking/soap/soap_client.rb
109
+ - lib/api_banking/version.rb
110
+ homepage: http://apibanking.com
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.7
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Ruby SDK to Connect to Banks
134
+ test_files: []