absa-h2h 0.0.11

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.
Files changed (49) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +3 -0
  3. data/Gemfile +7 -0
  4. data/README +0 -0
  5. data/Rakefile +7 -0
  6. data/absa-h2h.gemspec +23 -0
  7. data/lib/absa-h2h/account_holder_verification.rb +22 -0
  8. data/lib/absa-h2h/account_holder_verification_output.rb +22 -0
  9. data/lib/absa-h2h/eft/rejection_code.rb +30 -0
  10. data/lib/absa-h2h/eft.rb +200 -0
  11. data/lib/absa-h2h/eft_output.rb +12 -0
  12. data/lib/absa-h2h/eft_redirect.rb +13 -0
  13. data/lib/absa-h2h/eft_unpaid.rb +13 -0
  14. data/lib/absa-h2h/reply.rb +27 -0
  15. data/lib/absa-h2h/transmission/document.rb +26 -0
  16. data/lib/absa-h2h/transmission/record.rb +18 -0
  17. data/lib/absa-h2h/transmission/set.rb +168 -0
  18. data/lib/absa-h2h/version.rb +5 -0
  19. data/lib/absa-h2h.rb +22 -0
  20. data/lib/config/account_holder_verification.yml +196 -0
  21. data/lib/config/account_holder_verification_output.yml +182 -0
  22. data/lib/config/document.yml +54 -0
  23. data/lib/config/eft.yml +284 -0
  24. data/lib/config/eft_output.yml +65 -0
  25. data/lib/config/eft_redirect.yml +129 -0
  26. data/lib/config/eft_rejection_codes.yml +321 -0
  27. data/lib/config/eft_unpaid.yml +125 -0
  28. data/lib/config/reply.yml +222 -0
  29. data/lib/tmp/test.txt +0 -0
  30. data/spec/examples/ahv_input_file.txt +7 -0
  31. data/spec/examples/ahv_output_file.txt +7 -0
  32. data/spec/examples/eft_input_credit_file.txt +166 -0
  33. data/spec/examples/eft_input_credit_file2.txt +0 -0
  34. data/spec/examples/eft_input_file.txt +20 -0
  35. data/spec/examples/eft_output_file.txt +35 -0
  36. data/spec/examples/reply_file.txt +5 -0
  37. data/spec/examples/transmission_header_file.txt +1 -0
  38. data/spec/lib/account_holder_verification_spec.rb +157 -0
  39. data/spec/lib/eft/rejection_code_spec.rb +37 -0
  40. data/spec/lib/eft_output_spec.rb +9 -0
  41. data/spec/lib/eft_spec.rb +369 -0
  42. data/spec/lib/eft_transaction_standard_spec.rb +88 -0
  43. data/spec/lib/string_spec.rb +9 -0
  44. data/spec/lib/transmission/document_spec.rb +152 -0
  45. data/spec/lib/transmission/header_spec.rb +28 -0
  46. data/spec/lib/transmission/record_spec.rb +24 -0
  47. data/spec/lib/transmission/trailer_spec.rb +26 -0
  48. data/spec/spec_helper.rb +9 -0
  49. metadata +135 -0
@@ -0,0 +1,152 @@
1
+ require 'spec_helper'
2
+
3
+ describe Absa::H2h::Transmission::Document do
4
+
5
+ before(:each) do
6
+ @internal_section_content = [
7
+ {type: 'header', data: {
8
+ rec_id: "030",
9
+ rec_status: "T",
10
+ gen_no: "5",
11
+ dept_code: "000006"
12
+ }},
13
+ {type: 'internal_account_detail', data: {
14
+ rec_id: "031",
15
+ rec_status: "T",
16
+ seq_no: "1",
17
+ account_number: "1094402524",
18
+ id_number: "6703085829086",
19
+ initials: "M",
20
+ surname: "CHAUKE",
21
+ return_code_1: "00",
22
+ return_code_2: "00",
23
+ return_code_3: "00",
24
+ return_code_4: "00",
25
+ user_ref: "1495050000600002236"
26
+ }},
27
+ {type: 'trailer', data: {
28
+ rec_id: "039",
29
+ rec_status: "T",
30
+ no_det_recs: "1",
31
+ acc_total: "6554885370"
32
+ }}
33
+ ]
34
+
35
+ @hash = {type: 'document', data: [
36
+ {type: 'header', data: {
37
+ rec_id: "000",
38
+ rec_status: "T",
39
+ date: Time.now.strftime("%Y%m%d"),
40
+ client_code: "345",
41
+ client_name: "DOUGLAS ANDERSON",
42
+ transmission_no: "1234567",
43
+ destination: "0",
44
+ th_for_use_of_ld_user: "SPECIAL TOKEN HERE"
45
+ }},
46
+ {
47
+ type: 'account_holder_verification',
48
+ data: @internal_section_content
49
+ },
50
+ {type: 'trailer', data: {
51
+ rec_id: "999",
52
+ rec_status: "T",
53
+ no_of_recs: "7",
54
+ }}
55
+ ]
56
+ }
57
+ end
58
+
59
+ it "should only accept 0 for the destination in the document header when building an input document" do
60
+ pending
61
+ end
62
+
63
+ it "should accept any number for the destination in the document header when building an output document" do
64
+ pending
65
+ end
66
+
67
+ it "should raise an exception is any of the provided arguments are not strings" do
68
+ @internal_section_content[-1][:data][:no_det_recs] = 1
69
+ lambda {document = Absa::H2h::Transmission::Document.build(@hash[:data])}.should raise_error("no_det_recs: Argument is not a string")
70
+ end
71
+
72
+ it "should raise an exception if a provided field exceeds the allowed length" do
73
+ @hash[:data][0][:data][:rec_id] = "0000"
74
+ lambda {document = Absa::H2h::Transmission::Document.build(@hash[:data])}.should raise_error("rec_id: Input too long")
75
+ end
76
+
77
+ it "should raise an exception if a provided field fails to pass a specified field format" do
78
+ @hash[:data][0][:data][:rec_id] = "100"
79
+ lambda {document = Absa::H2h::Transmission::Document.build(@hash[:data])}.should raise_error("rec_id: Invalid data - expected 000, got 100")
80
+ end
81
+
82
+ it "should raise an exception if an alpha character is passed into a numeric-only field" do
83
+ @hash[:data][0][:data][:client_code] = "1234A"
84
+ lambda {document = Absa::H2h::Transmission::Document.build(@hash[:data])}.should raise_error("client_code: Numeric value required")
85
+ end
86
+
87
+ it "should be able to build a complete document" do
88
+ document = Absa::H2h::Transmission::Document.build(@hash[:data])
89
+
90
+ string = "000T#{Time.now.strftime("%Y%m%d")}00345DOUGLAS ANDERSON 123456700000 SPECIAL TOKEN HERE \r
91
+ 030T0000005000006 \r
92
+ 031T00000010000000010944025246703085829086M CHAUKE 000000001495050000600002236 \r
93
+ 039T0000001000000006554885370 \r
94
+ 999T000000007 \r
95
+ "
96
+
97
+ document.to_s.should == string
98
+ end
99
+
100
+ context "when parsing an input file" do
101
+
102
+ it "should build a valid document" do
103
+ file_names = ['ahv_input_file.txt','eft_input_file.txt']
104
+
105
+ file_names.each do |file_name|
106
+ input_string = File.open("./spec/examples/#{file_name}", "rb").read
107
+ document = Absa::H2h::Transmission::Document.from_s(input_string, "input")
108
+
109
+ output_string = document.to_s
110
+ output_string.should == input_string
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ context "when parsing an output file" do
117
+
118
+ it "should build a valid document" do
119
+ file_names = ['ahv_output_file.txt','eft_output_file.txt']
120
+
121
+ file_names.each do |file_name|
122
+ input_string = File.open("./spec/examples/#{file_name}", "rb").read
123
+ document = Absa::H2h::Transmission::Document.from_s(input_string, "output")
124
+
125
+ output_string = document.to_s
126
+ output_string.should == input_string
127
+ end
128
+ end
129
+
130
+ it "should build a valid eft credit document" do
131
+ input_string = File.open("./spec/examples/eft_input_credit_file.txt", "rb").read
132
+ document = Absa::H2h::Transmission::Document.from_s(input_string, "output")
133
+
134
+ output_string = document.to_s
135
+ output_string.should == input_string
136
+ end
137
+
138
+ end
139
+
140
+ context "when parsing a reply file" do
141
+
142
+ it "should build a valid document" do
143
+ input_string = File.open("./spec/examples/reply_file.txt", "rb").read
144
+ document = Absa::H2h::Transmission::Document.from_s(input_string, "reply")
145
+
146
+ output_string = document.to_s
147
+ output_string.should == input_string
148
+ end
149
+
150
+ end
151
+
152
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Absa::H2h do
4
+
5
+ before(:each) do
6
+ @hash = {
7
+ transmission: {
8
+ header: {
9
+ rec_id: "000",
10
+ rec_status: "T",
11
+ date: "20111221",
12
+ client_code: "345",
13
+ client_name: "DOUGLAS ANDERSON",
14
+ transmission_no: "1234567",
15
+ destination: "0",
16
+ th_for_use_of_ld_user: "SPECIAL TOKEN HERE"
17
+ }
18
+ }
19
+ }
20
+ end
21
+
22
+ it "should be able to build a document header" do
23
+ header = Absa::H2h::Transmission::Document::Header.new(@hash[:transmission][:header])
24
+ expected_string = File.open('./spec/examples/transmission_header_file.txt', "rb").read
25
+ header.to_s.should == expected_string
26
+ end
27
+
28
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Absa::H2h::Transmission::Record do
4
+
5
+ it "should provide the default options for an input record" do
6
+ record_class = Absa::H2h::Transmission::AccountHolderVerification.record_type('internal_account_detail')
7
+
8
+ record_class.template_options.should == {
9
+ :rec_id=>"031",
10
+ :rec_status=>nil,
11
+ :seq_no=>nil,
12
+ :account_number=>nil,
13
+ :id_number=>nil,
14
+ :initials=>nil,
15
+ :surname=>nil,
16
+ :return_code_1=>"00",
17
+ :return_code_2=>"00",
18
+ :return_code_3=>"00",
19
+ :return_code_4=>"00",
20
+ :user_ref=>nil
21
+ }
22
+ end
23
+
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Absa::H2h do
4
+
5
+ before(:each) do
6
+ @hash = {
7
+ transmission: {
8
+ trailer: {
9
+ rec_id: "999",
10
+ rec_status: "T",
11
+ no_of_recs: "7",
12
+ }
13
+ }
14
+ }
15
+ end
16
+
17
+ it "should be able to build a document trailer" do
18
+ trailer = Absa::H2h::Transmission::Document::Trailer.new(@hash[:transmission][:trailer])
19
+
20
+ string = " " * 198 + "\r\n"
21
+ string[0,13] = "999T000000007"
22
+
23
+ trailer.to_s.should == string
24
+ end
25
+
26
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'strata'
5
+ require 'absa-h2h'
6
+
7
+ RSpec.configure do |config|
8
+ # some (optional) config here
9
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: absa-h2h
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.11
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeffrey van Aswegen, Douglas Anderson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-04 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70127987767900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70127987767900
25
+ - !ruby/object:Gem::Dependency
26
+ name: i18n
27
+ requirement: &70127983108320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70127983108320
36
+ description: The interface supports Account holder verifications, EFT payments, Debit
37
+ orders, collecting statements.
38
+ email:
39
+ - jeffmess@gmail.com, i.am.douglas.anderson@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - .rspec
46
+ - Gemfile
47
+ - README
48
+ - Rakefile
49
+ - absa-h2h.gemspec
50
+ - lib/absa-h2h.rb
51
+ - lib/absa-h2h/account_holder_verification.rb
52
+ - lib/absa-h2h/account_holder_verification_output.rb
53
+ - lib/absa-h2h/eft.rb
54
+ - lib/absa-h2h/eft/rejection_code.rb
55
+ - lib/absa-h2h/eft_output.rb
56
+ - lib/absa-h2h/eft_redirect.rb
57
+ - lib/absa-h2h/eft_unpaid.rb
58
+ - lib/absa-h2h/reply.rb
59
+ - lib/absa-h2h/transmission/document.rb
60
+ - lib/absa-h2h/transmission/record.rb
61
+ - lib/absa-h2h/transmission/set.rb
62
+ - lib/absa-h2h/version.rb
63
+ - lib/config/account_holder_verification.yml
64
+ - lib/config/account_holder_verification_output.yml
65
+ - lib/config/document.yml
66
+ - lib/config/eft.yml
67
+ - lib/config/eft_output.yml
68
+ - lib/config/eft_redirect.yml
69
+ - lib/config/eft_rejection_codes.yml
70
+ - lib/config/eft_unpaid.yml
71
+ - lib/config/reply.yml
72
+ - lib/tmp/test.txt
73
+ - spec/examples/ahv_input_file.txt
74
+ - spec/examples/ahv_output_file.txt
75
+ - spec/examples/eft_input_credit_file.txt
76
+ - spec/examples/eft_input_credit_file2.txt
77
+ - spec/examples/eft_input_file.txt
78
+ - spec/examples/eft_output_file.txt
79
+ - spec/examples/reply_file.txt
80
+ - spec/examples/transmission_header_file.txt
81
+ - spec/lib/account_holder_verification_spec.rb
82
+ - spec/lib/eft/rejection_code_spec.rb
83
+ - spec/lib/eft_output_spec.rb
84
+ - spec/lib/eft_spec.rb
85
+ - spec/lib/eft_transaction_standard_spec.rb
86
+ - spec/lib/string_spec.rb
87
+ - spec/lib/transmission/document_spec.rb
88
+ - spec/lib/transmission/header_spec.rb
89
+ - spec/lib/transmission/record_spec.rb
90
+ - spec/lib/transmission/trailer_spec.rb
91
+ - spec/spec_helper.rb
92
+ homepage: ''
93
+ licenses: []
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project: absa-h2h
112
+ rubygems_version: 1.8.6
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: A ruby interface to commumicate with the ABSA Host 2 Host platform
116
+ test_files:
117
+ - spec/examples/ahv_input_file.txt
118
+ - spec/examples/ahv_output_file.txt
119
+ - spec/examples/eft_input_credit_file.txt
120
+ - spec/examples/eft_input_credit_file2.txt
121
+ - spec/examples/eft_input_file.txt
122
+ - spec/examples/eft_output_file.txt
123
+ - spec/examples/reply_file.txt
124
+ - spec/examples/transmission_header_file.txt
125
+ - spec/lib/account_holder_verification_spec.rb
126
+ - spec/lib/eft/rejection_code_spec.rb
127
+ - spec/lib/eft_output_spec.rb
128
+ - spec/lib/eft_spec.rb
129
+ - spec/lib/eft_transaction_standard_spec.rb
130
+ - spec/lib/string_spec.rb
131
+ - spec/lib/transmission/document_spec.rb
132
+ - spec/lib/transmission/header_spec.rb
133
+ - spec/lib/transmission/record_spec.rb
134
+ - spec/lib/transmission/trailer_spec.rb
135
+ - spec/spec_helper.rb