merchant_e_solutions 0.4.2 → 0.4.3
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 +4 -4
- data/README.md +12 -0
- data/lib/merchant_e_solutions/detail_record.rb +24 -15
- data/lib/merchant_e_solutions/version.rb +1 -1
- data/spec/lib/merchant_e_solutions/detail_record_spec.rb +35 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2abad0c5d536f2fa6e9ff7368afdee52174dae7c
|
4
|
+
data.tar.gz: 14028295e458de893515dcf3f2533734c25b1bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3ff838a52c321221ceb1b2abf3dd396417243abff6d61e9cff2606c826141d4fbfabbc99e72b79453ca92f836cb43925aee546204c48ac3af52b86b53f16588
|
7
|
+
data.tar.gz: 621921e56c491b918869419beaf46e4d65d24ba113ba5e4e5e44dab9cd281796bad9d6dcd5f7955fd6b3a3ca48c219c47c9aac34ab07f4c1d0440da191ea7185
|
data/README.md
CHANGED
@@ -81,3 +81,15 @@ unchanged from a record thusly:
|
|
81
81
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
82
82
|
4. Push to the branch (`git push origin my-new-feature`)
|
83
83
|
5. Create new Pull Request
|
84
|
+
|
85
|
+
### Need a different report?
|
86
|
+
Adding new reports is easy! Each report consists of two classes, the report and the report record:
|
87
|
+
|
88
|
+
Creating a report requires the ```#report_type``` and ```#report_id``` methods to be defined as the params you would pass into the API. Additional default parameters can be specified in ```#report_specific_params```. ```includeTridentTranId```, ```includePurchaseId```, ```includeClientRefNum``` are turned on by default right now, because they would change the order of the columns in some reports. The report class must also specify its ```#record class```. If a report has both a summary and detail version, they should be defined as different classes. The [BatchDetailReport](https://github.com/harrystech/merchant_e_solutions/blob/master/lib/merchant_e_solutions/batch_detail_report.rb) is a good example to reference.
|
89
|
+
|
90
|
+
For each row in a report available in the web view there is an instance of a report's report record. Report records specify their attributes, and the order in which the attributes are pulled off of the report CSV. Report record classes also a good place to add co convenience methods. [DetailRecord](https://github.com/harrystech/merchant_e_solutions/blob/master/lib/merchant_e_solutions/detail_record.rb) is a good example to reference.
|
91
|
+
|
92
|
+
###TODO
|
93
|
+
1. Instances of reports can write out CSVs
|
94
|
+
2. Instances of reports can be generated by passing in CSVs(instead of having to pull CSVs directly from the API)
|
95
|
+
3. Report records pull their attributes from CSV column names instead of column orders
|
@@ -8,21 +8,21 @@ module MerchantESolutions
|
|
8
8
|
:entry_mode, :transaction_amount, :trident_transaction_id, :client_reference_number
|
9
9
|
|
10
10
|
def initialize(row)
|
11
|
-
@organization_id = row[
|
12
|
-
@organization_name = row[
|
13
|
-
@term_number = row[
|
14
|
-
@batch_number = row[
|
15
|
-
@batch_date = parse_date(row[
|
16
|
-
@transaction_date = parse_date(row[
|
17
|
-
@card_code = row[
|
18
|
-
@card_number = row[
|
19
|
-
@reference_number = row[
|
20
|
-
@purchase_id = row[
|
21
|
-
@auth_code = row[
|
22
|
-
@entry_mode = row[
|
23
|
-
@transaction_amount = row[
|
24
|
-
@trident_transaction_id = row[
|
25
|
-
@client_reference_number = row[
|
11
|
+
@organization_id = row["Merchant Id"]
|
12
|
+
@organization_name = row["DBA Name"]
|
13
|
+
@term_number = row["Term Num"]
|
14
|
+
@batch_number = row["Batch Num"]
|
15
|
+
@batch_date = parse_date(row["Batch Date"])
|
16
|
+
@transaction_date = parse_date(row["Tran Date"])
|
17
|
+
@card_code = row["Card Type"]
|
18
|
+
@card_number = row["Card Number"]
|
19
|
+
@reference_number = row["Reference"]
|
20
|
+
@purchase_id = row["Purchase Id"]
|
21
|
+
@auth_code = row["Auth Code"]
|
22
|
+
@entry_mode = row["Entry Mode"]
|
23
|
+
@transaction_amount = row["Tran Amount"]
|
24
|
+
@trident_transaction_id = row["Trident Tran Id"]
|
25
|
+
@client_reference_number = row["Client Ref Num"]
|
26
26
|
end
|
27
27
|
|
28
28
|
def reference_number(options={})
|
@@ -30,6 +30,11 @@ module MerchantESolutions
|
|
30
30
|
cleaned_reference_number
|
31
31
|
end
|
32
32
|
|
33
|
+
def purchase_id(options={})
|
34
|
+
return @purchase_id if options[:unchanged]
|
35
|
+
cleaned_purchase_id
|
36
|
+
end
|
37
|
+
|
33
38
|
def credit_company
|
34
39
|
{
|
35
40
|
"AM" => "American Express",
|
@@ -63,5 +68,9 @@ module MerchantESolutions
|
|
63
68
|
@reference_number
|
64
69
|
end
|
65
70
|
end
|
71
|
+
|
72
|
+
def cleaned_purchase_id
|
73
|
+
@purchase_id.strip
|
74
|
+
end
|
66
75
|
end
|
67
76
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe MerchantESolutions::DetailRecord do
|
4
|
+
let(:csv_header) { ["Merchant Id","DBA Name","Term Num","Batch Num","Batch Date","Tran Date","Card Type","Card Number","Reference","Purchase Id","Auth Code","Entry Mode","Tran Amount","Trident Tran Id","Client Ref Num"] }
|
5
|
+
|
4
6
|
describe "#initialize" do
|
5
7
|
subject { MerchantESolutions::DetailRecord.new(csv_row) }
|
6
8
|
|
7
9
|
# "Merchant Id","DBA Name","Term Num","Batch Num","Batch Date","Tran Date","Card Type","Card Number","Reference","Purchase Id","Auth Code","Entry Mode","Tran Amount","Trident Tran Id","Client Ref Num"
|
8
|
-
|
10
|
+
|
11
|
+
let(:csv_row) { CSV::Row.new(csv_header, [42, "Hamazon", 1, 220, "10/07/2013", "10/06/2013", "AM", "000000xxxxxx1234", "'0000213", "AAAAAAAAAAA0", "100000", "KEYED", 7.09, "T.T.ID", "clientRefNumber"]) }
|
9
12
|
|
10
13
|
its(:organization_id) { should == 42 }
|
11
14
|
its(:organization_name) { should == "Hamazon" }
|
@@ -35,7 +38,8 @@ describe MerchantESolutions::DetailRecord do
|
|
35
38
|
|
36
39
|
describe "#reference_number" do
|
37
40
|
let(:reference_number) { "'0000213" }
|
38
|
-
let(:
|
41
|
+
let(:csv_row) { CSV::Row.new(csv_header, [nil, nil, nil, nil, nil, nil, nil, nil, reference_number]) }
|
42
|
+
let(:record) { MerchantESolutions::DetailRecord.new(csv_row)}
|
39
43
|
|
40
44
|
context "when no arguments are given" do
|
41
45
|
it "removes the pre-pended apostrophe from the reference number" do
|
@@ -59,8 +63,36 @@ describe MerchantESolutions::DetailRecord do
|
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
66
|
+
describe "#purchase_id" do
|
67
|
+
let(:purchase_id) { " AAA0 " }
|
68
|
+
let(:csv_row) { CSV::Row.new(csv_header, [nil, nil, nil, nil, nil, nil, nil, nil, nil, purchase_id]) }
|
69
|
+
let(:record) { MerchantESolutions::DetailRecord.new(csv_row)}
|
70
|
+
|
71
|
+
context "when no arguments are given" do
|
72
|
+
it "strips whitespace from the purchase id" do
|
73
|
+
record.purchase_id.should == "AAA0"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when the :unchanged options is set to true" do
|
78
|
+
it "returns the purchase id verbatim, whitespace intact" do
|
79
|
+
record.purchase_id(:unchanged => true).should == purchase_id
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when the purchase id doesn't contains any spaces" do
|
84
|
+
let(:purchase_id) { "AAA0" }
|
85
|
+
|
86
|
+
it "returns the purchase id verbatim, regardless of the :unchanged argument" do
|
87
|
+
record.purchase_id.should == "AAA0"
|
88
|
+
record.purchase_id(:unchanged => true).should == "AAA0"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
62
93
|
describe "credit cards" do
|
63
|
-
|
94
|
+
let(:csv_row) { CSV::Row.new(csv_header, [nil, nil, nil, nil, nil, nil, card_code]) }
|
95
|
+
subject { MerchantESolutions::DetailRecord.new(csv_row) }
|
64
96
|
|
65
97
|
context "when the code is AM" do
|
66
98
|
let(:card_code) { "AM" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merchant_e_solutions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Ellis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.0.
|
140
|
+
rubygems_version: 2.0.14
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Wrapper for the Settlement Report API
|
@@ -161,3 +161,4 @@ test_files:
|
|
161
161
|
- spec/lib/merchant_e_solutions/summary_record_spec.rb
|
162
162
|
- spec/lib/merchant_e_solutions_spec.rb
|
163
163
|
- spec/spec_helper.rb
|
164
|
+
has_rdoc:
|