absa-notify-me 0.0.3 → 0.0.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.
- data/lib/absa-notify-me/version.rb +1 -1
- data/lib/absa-notify-me/xml_statement.rb +61 -27
- metadata +6 -6
@@ -3,6 +3,32 @@ module Absa
|
|
3
3
|
|
4
4
|
class XmlStatement
|
5
5
|
|
6
|
+
def self.convert_hash(hash)
|
7
|
+
# Recursive function to convert a nested hashes keys to
|
8
|
+
# downcased sym links. Caters for values being Arrays of
|
9
|
+
# Hashes.
|
10
|
+
|
11
|
+
new_hash = {}
|
12
|
+
hash.each do |k,v|
|
13
|
+
new_hash.merge!({k.downcase.to_sym => v}) unless (v.is_a? Array) or (v.is_a? Hash)
|
14
|
+
|
15
|
+
if v.is_a? Array
|
16
|
+
v.each do |h|
|
17
|
+
if new_hash.has_key? k.downcase.to_sym
|
18
|
+
new_hash[k.downcase.to_sym] << convert_hash(h)
|
19
|
+
else
|
20
|
+
new_hash.merge!({k.downcase.to_sym => [convert_hash(h)]})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if v.is_a? Hash
|
26
|
+
new_hash.merge!({k.downcase.to_sym => convert_hash(v)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
new_hash
|
30
|
+
end
|
31
|
+
|
6
32
|
def self.file_to_hash(file)
|
7
33
|
input_string = File.open(file, "rb").read
|
8
34
|
self.string_to_hash(input_string)
|
@@ -13,50 +39,58 @@ module Absa
|
|
13
39
|
|
14
40
|
Nori.parser = :nokogiri
|
15
41
|
xml_doc = Nori.parse(string)
|
16
|
-
|
17
|
-
|
42
|
+
converted_xml_doc = self.convert_hash(xml_doc)
|
43
|
+
|
44
|
+
converted_xml_doc.each do |k,v|
|
18
45
|
v.each do |key, value|
|
19
|
-
if key ==
|
46
|
+
if key == :notif_header
|
20
47
|
hash[:data][:data] << {
|
21
48
|
type: 'header',
|
22
49
|
data: {
|
23
|
-
daily_no: value[
|
24
|
-
client_code: value[
|
25
|
-
client_name: value[
|
26
|
-
processing_date: value[
|
27
|
-
processing_time: value[
|
28
|
-
buss_dir_code: value[
|
50
|
+
daily_no: value[:daily_no],
|
51
|
+
client_code: value[:client_id],
|
52
|
+
client_name: value[:sname],
|
53
|
+
processing_date: value[:creation_date],
|
54
|
+
processing_time: value[:creation_time],
|
55
|
+
buss_dir_code: value[:buss_dir_code]
|
29
56
|
}
|
30
57
|
}
|
31
58
|
end
|
32
|
-
if key ==
|
33
|
-
value["TRANSACTION"]
|
59
|
+
if key == :details
|
60
|
+
transactions = value[:transaction].blank? ? value["TRANSACTION"] : value[:transaction]
|
61
|
+
transactions.each do |transaction|
|
62
|
+
amount = (transaction[:amt].to_f * 100).to_i.to_s
|
63
|
+
account_balance = (transaction[:acc_bal].to_f * 100).to_i.to_s
|
64
|
+
|
34
65
|
hash[:data][:data] << {
|
35
66
|
type: "detail",
|
36
67
|
data: {
|
37
|
-
account_number: transaction[
|
38
|
-
event_number: transaction[
|
39
|
-
customer_reference: transaction[
|
40
|
-
currency: transaction[
|
41
|
-
amount:
|
42
|
-
account_balance_after_transaction:
|
43
|
-
transaction_type: transaction[
|
44
|
-
transaction_processing_date: transaction[
|
45
|
-
clearance_payment_indicator: transaction[
|
46
|
-
transaction_description: transaction[
|
47
|
-
checksum: transaction[
|
68
|
+
account_number: transaction[:trg_acc],
|
69
|
+
event_number: transaction[:event_no],
|
70
|
+
customer_reference: transaction[:clref],
|
71
|
+
currency: transaction[:curr],
|
72
|
+
amount: amount,
|
73
|
+
account_balance_after_transaction: account_balance,
|
74
|
+
transaction_type: transaction[:tran_type],
|
75
|
+
transaction_processing_date: transaction[:pdate],
|
76
|
+
clearance_payment_indicator: transaction[:clr_paym_ind],
|
77
|
+
transaction_description: transaction[:paym_desc],
|
78
|
+
checksum: transaction[:checksum]
|
48
79
|
}
|
49
80
|
}
|
50
81
|
end
|
51
82
|
end
|
52
|
-
if key ==
|
83
|
+
if key == :notif_trailer
|
84
|
+
total_credit = (value[:total_cr].to_f * 100).to_i.to_s
|
85
|
+
total_debit = (value[:total_dt].to_f * 100).to_i.to_s
|
86
|
+
|
53
87
|
hash[:data][:data] << {
|
54
88
|
type: "trailer",
|
55
89
|
data: {
|
56
|
-
total_credit:
|
57
|
-
total_debit:
|
58
|
-
total_recs: value[
|
59
|
-
check_sum: value[
|
90
|
+
total_credit: total_credit,
|
91
|
+
total_debit: total_debit,
|
92
|
+
total_recs: value[:total_recs],
|
93
|
+
check_sum: value[:check_sum]
|
60
94
|
}
|
61
95
|
}
|
62
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: absa-notify-me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nori
|
16
|
-
requirement: &
|
16
|
+
requirement: &70254756082060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70254756082060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &70254756081640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70254756081640
|
36
36
|
description: ! "\n This is just a rapidly prototyped proof of concept gem for \n
|
37
37
|
\ bankserv gem and those who can afford to use the ABSA NotifyMe \n Platform.
|
38
38
|
\n \n For a production ready gem please rather use absa-esd with the \n bankserv
|