starkit_banking 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86a2b09250a0adfa32c784c8dc50b868d50dcd2d
4
- data.tar.gz: e9d2e32b3cc8c32ac535ca20dcfdde22f0cbbe8d
3
+ metadata.gz: cdffd1bc3462bd19f302e078cfd230f5db1cdf12
4
+ data.tar.gz: 393f243dbd352c61fb7cfda3e23bbad89642b21e
5
5
  SHA512:
6
- metadata.gz: 14034114643179888adf1cf8c5b5c5f48adc493d6fe5a3a14b5eca3f5d11758814db46af84d47e6bce34f14f6db2932a9faf271f9e935c8d524d98083b375eb5
7
- data.tar.gz: 1c2b66c00fb8ae3494ca9b2ee82c21c6f1b6fa14f232a2ddbfaf436eee45d1a9dc7c01d85570787a3b336ee6e697aefc68a99fc010b247b4e4480910cc7f3b09
6
+ metadata.gz: f4cd1a4f2549e1760b717070f0e5c46225c267f53f137a075c6b34a3d7d7beed80a878fe4a7e1988bddb760353b9a6bb84d901a39d528280c6f786183df14742
7
+ data.tar.gz: a79002f92d08889dec21fedd41cacb8fa51aa8f40a090c586baf4d4d781eb57af6cbfdaeeed1c734376d26ff64eae3b3f2796df93446a57c34228cfa79e9d213
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ starkit_banking (0.1.3)
5
+ activerecord
6
+ activesupport
7
+ api_banking
8
+ money
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (5.0.0.1)
14
+ activesupport (= 5.0.0.1)
15
+ activerecord (5.0.0.1)
16
+ activemodel (= 5.0.0.1)
17
+ activesupport (= 5.0.0.1)
18
+ arel (~> 7.0)
19
+ activesupport (5.0.0.1)
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ i18n (~> 0.7)
22
+ minitest (~> 5.1)
23
+ tzinfo (~> 1.1)
24
+ addressable (2.5.0)
25
+ public_suffix (~> 2.0, >= 2.0.2)
26
+ api_banking (0.1.16)
27
+ nokogiri
28
+ typhoeus
29
+ arel (7.1.4)
30
+ concurrent-ruby (1.0.2)
31
+ crack (0.4.3)
32
+ safe_yaml (~> 1.0.0)
33
+ ethon (0.9.1)
34
+ ffi (>= 1.3.0)
35
+ ffi (1.9.14)
36
+ hashdiff (0.3.0)
37
+ i18n (0.7.0)
38
+ mini_portile2 (2.1.0)
39
+ minitest (5.9.1)
40
+ money (6.7.1)
41
+ i18n (>= 0.6.4, <= 0.7.0)
42
+ sixarm_ruby_unaccent (>= 1.1.1, < 2)
43
+ nokogiri (1.6.8.1)
44
+ mini_portile2 (~> 2.1.0)
45
+ public_suffix (2.0.4)
46
+ rake (10.5.0)
47
+ safe_yaml (1.0.4)
48
+ sixarm_ruby_unaccent (1.1.1)
49
+ thread_safe (0.3.5)
50
+ typhoeus (1.1.0)
51
+ ethon (>= 0.9.0)
52
+ tzinfo (1.2.2)
53
+ thread_safe (~> 0.1)
54
+ vcr (3.0.3)
55
+ webmock (2.1.0)
56
+ addressable (>= 2.3.6)
57
+ crack (>= 0.3.2)
58
+ hashdiff
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ bundler (~> 1.9)
65
+ minitest
66
+ rake (~> 10.0)
67
+ starkit_banking!
68
+ vcr
69
+ webmock
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Assumptions
2
2
 
3
- 1. ApiBankingCred has 'password'
3
+ ~~1. ApiBankingCred has 'password'~~
4
4
  2. Payment should have IMT passcode (to resend email)
5
5
  ~~3. Payment Account to have credential method, that will return the ApiBankingCred (basis the envronment/star/bank_name of self)~~
6
6
 
@@ -9,7 +9,10 @@ module StarkitBanking
9
9
 
10
10
  def exec(model)
11
11
  env = Environment.build(credentials(model))
12
- req = request(model)
12
+ subscription = subscription(model)
13
+ raise ApiFault.new(OpenStruct.new(code: 'sb:412', subCode: nil, reasonText: "#{service_name} is not subscribed")) if subscription.nil?
14
+
15
+ req = request(subscription, model)
13
16
 
14
17
  res = invoke(env, req)
15
18
 
@@ -5,6 +5,10 @@ module StarkitBanking
5
5
  include ApiClient
6
6
 
7
7
  private
8
+
9
+ def service_name
10
+ 'BALANCE ENQUIRY'
11
+ end
8
12
 
9
13
  def invoke(env, req)
10
14
  ApiBanking::FundsTransferByCustomerService2.get_balance(env, req)
@@ -18,19 +22,19 @@ module StarkitBanking
18
22
  payment_account.credentials
19
23
  end
20
24
 
21
- def request(payment_account)
25
+ def request(subscription, payment_account)
22
26
 
23
27
  request = ApiBanking::FundsTransferByCustomerService2::GetBalance::Request.new()
24
28
 
25
- request.appID = app_id(payment_account)
29
+ request.appID = subscription.app_id
26
30
  request.customerID = payment_account.customer_id
27
31
  request.AccountNumber = payment_account.account_number
28
32
 
29
33
  request
30
34
  end
31
35
 
32
- def app_id(payment_account)
33
- payment_account.service_subscriptions.find_by(service_name: 'BALANCE ENQUIRY').app_id
36
+ def subscription(payment_account)
37
+ payment_account.service_subscriptions.find_by(service_name: service_name)
34
38
  end
35
39
 
36
40
  end
@@ -4,7 +4,11 @@ module StarkitBanking
4
4
  class GetMiniStatement
5
5
  include ApiClient
6
6
 
7
- private
7
+ private
8
+
9
+ def service_name
10
+ 'GET TRANSACTIONS'
11
+ end
8
12
 
9
13
  def invoke(env, req)
10
14
  ApiBanking::SocialBankingService.getTransactions(env, req)
@@ -30,7 +34,7 @@ module StarkitBanking
30
34
  payment_account.credentials
31
35
  end
32
36
 
33
- def request(payment_account)
37
+ def request(subscription, payment_account)
34
38
  customerIdentity = ApiBanking::SocialBankingService::GetTransactions::CustomerIdentity.new()
35
39
  accountIdentity = ApiBanking::SocialBankingService::GetTransactions::AccountIdentity.new()
36
40
  request = ApiBanking::SocialBankingService::GetTransactions::Request.new()
@@ -39,7 +43,7 @@ module StarkitBanking
39
43
 
40
44
  accountIdentity.accountNo = payment_account.account_number
41
45
 
42
- request.appID = app_id(payment_account)
46
+ request.appID = subscription.app_id
43
47
 
44
48
  request.customerIdentity = customerIdentity
45
49
  request.deviceID = rand(1000..9999).to_s
@@ -49,8 +53,8 @@ module StarkitBanking
49
53
  request
50
54
  end
51
55
 
52
- def app_id(payment_account)
53
- payment_account.service_subscriptions.find_by(service_name: 'GET TRANSACTIONS').app_id
56
+ def subscription(payment_account)
57
+ payment_account.service_subscriptions.find_by(service_name: service_name)
54
58
  end
55
59
  end
56
60
  end
@@ -4,7 +4,11 @@ module StarkitBanking
4
4
  class ByFT2
5
5
  include ApiClient
6
6
 
7
- private
7
+ private
8
+
9
+ def service_name
10
+ 'FUNDS TRANSFER'
11
+ end
8
12
 
9
13
  def invoke(env, req)
10
14
  ApiBanking::FundsTransferByCustomerService2.transfer(env, req)
@@ -18,7 +22,7 @@ module StarkitBanking
18
22
  payment.payment_account.credentials
19
23
  end
20
24
 
21
- def request(payment)
25
+ def request(subscription, payment)
22
26
 
23
27
  address = ApiBanking::FundsTransferByCustomerService2::Transfer::Address.new()
24
28
  beneficiary = ApiBanking::FundsTransferByCustomerService2::Transfer::Beneficiary.new()
@@ -27,7 +31,7 @@ module StarkitBanking
27
31
  # every payment is identified by its ID, repeated API attempts can be identified when the ID is used as the URN
28
32
  @req_reference = request.uniqueRequestNo = payment.id
29
33
 
30
- request.appID = app_id(payment)
34
+ request.appID = subscription.app_id
31
35
  request.customerID = payment.payment_account.customer_id
32
36
  request.debitAccountNo = payment.payment_account.account_number
33
37
  request.transferType = payment.transfer_type || payment.transfer_type
@@ -44,8 +48,8 @@ module StarkitBanking
44
48
  request
45
49
  end
46
50
 
47
- def app_id(payment)
48
- payment.payment_account.service_subscriptions.find_by(service_name: 'FUNDS TRANSFER').app_id
51
+ def subscription(payment)
52
+ payment.payment_account.service_subscriptions.find_by(service_name: service_name)
49
53
  end
50
54
 
51
55
  end
@@ -5,6 +5,10 @@ module StarkitBanking
5
5
  include ApiClient
6
6
 
7
7
  private
8
+
9
+ def service_name
10
+ 'STATUS ENQUIRY'
11
+ end
8
12
 
9
13
  def invoke(env, req)
10
14
  ApiBanking::FundsTransferByCustomerService2.get_status(env, req)
@@ -18,19 +22,19 @@ module StarkitBanking
18
22
  payment.payment_account.credentials
19
23
  end
20
24
 
21
- def request(payment)
25
+ def request(subscription, payment)
22
26
 
23
27
  request = ApiBanking::FundsTransferByCustomerService2::GetStatus::Request.new()
24
28
 
25
- request.appID = app_id(payment)
29
+ request.appID = subscription.app_id
26
30
  request.customerID = payment.payment_account.customer_id
27
31
  request.requestReferenceNo = payment.id
28
32
 
29
33
  request
30
34
  end
31
35
 
32
- def app_id(payment)
33
- payment.payment_account.service_subscriptions.find_by(service_name: 'STATUS ENQUIRY').app_id
36
+ def subscription(payment)
37
+ payment.payment_account.service_subscriptions.find_by(service_name: service_name)
34
38
  end
35
39
 
36
40
  end
@@ -5,6 +5,10 @@ module StarkitBanking
5
5
  include ApiClient
6
6
 
7
7
  private
8
+
9
+ def service_name
10
+ 'IMT TRANSFER'
11
+ end
8
12
 
9
13
  def invoke(env, req)
10
14
  ApiBanking::InstantMoneyTransferService.transfer(env, req)
@@ -19,13 +23,13 @@ module StarkitBanking
19
23
  Transfer::Status.new('INITIATED', res.initiateTransferResult.bankReferenceNo, 'IMT')
20
24
  end
21
25
 
22
- def request(payment)
26
+ def request(subscription, payment)
23
27
  request = ApiBanking::InstantMoneyTransferService::InitiateTransfer::Request.new()
24
28
 
25
29
  # every payment is identified by its ID, repeated API attempts can be identified when the ID is used as the URN
26
30
  @req_reference = request.uniqueRequestNo = payment.id
27
31
 
28
- request.appID = app_id(payment)
32
+ request.appID = subscription.app_id
29
33
  request.customerID = payment.payment_account.customer_id
30
34
  request.beneficiaryMobileNo = payment.beneficiary_mobile_no
31
35
  request.transferAmount = payment.transfer_amount
@@ -35,8 +39,8 @@ module StarkitBanking
35
39
  request
36
40
  end
37
41
 
38
- def app_id(payment)
39
- payment.payment_account.service_subscriptions.find_by(service_name: 'IMT TRANSFER').app_id
42
+ def subscription(payment)
43
+ payment.payment_account.service_subscriptions.find_by(service_name: service_name)
40
44
  end
41
45
 
42
46
  end
@@ -16,6 +16,7 @@ module StarkitBanking
16
16
 
17
17
  def credentials
18
18
  c = Finance::ApiBankingCred.find_by(environment: self.environment, bank_name: self.bank_name)
19
+ raise ApiFault.new(OpenStruct.new(code: 'sb:412', subCode: nil, reasonText: "Api Banking Credentials Not Available For #{self.bank_name}, #{self.environment}")) if c.nil?
19
20
  c.password = @password unless @password.nil?
20
21
  c
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module StarkitBanking
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starkit_banking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - akil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -147,6 +147,7 @@ files:
147
147
  - ".travis.yml"
148
148
  - CODE_OF_CONDUCT.md
149
149
  - Gemfile
150
+ - Gemfile.lock
150
151
  - LICENSE.txt
151
152
  - README.md
152
153
  - Rakefile