merchant_e_solutions 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e767aa0bd99777d38ddc626e68de1bf4e6ba6081
4
- data.tar.gz: 438be6695dfc51170b25d9488152cd9042dea91b
3
+ metadata.gz: 0e98e8dda31cee47dca4fa9abbf168ebabd009d3
4
+ data.tar.gz: 433d2c8db0bc33f1a7b10b9dc8b3f09480128872
5
5
  SHA512:
6
- metadata.gz: 66057cc796b9f806c0de9e9eeeccbe92b327d69bd8c60e8a52438d747d8797f1e367e3aa7fdb0e46ecf21657d8515be0efad4d2d063d36cefa596ba60c5f80d1
7
- data.tar.gz: c69957292063d26c1f8bfd0f46e8bf50a5dbbe2abc6ab769bd9381e1f54dc6f43e0ba4c76745645f880ff6f13e3ab3775259d00206802de0bfe559154fdc91ff
6
+ metadata.gz: 3d8f5c46dc6e91b9b323826703ab56eb3167b960dd001ccbc1118a4e11d860e189c2db9e4b2fbc0a6133fcab23669cc1424800766f2cab7baab5b3c1b00b1418
7
+ data.tar.gz: cc4c67fb1604fbf8fe392e86f7f9d4e020dc781b3fc69bfc40c4b2f98ad8f96ac0f67e63df4b40e12ba23188e35361a229130bde746b7ed2c4f7786be2201168
@@ -1,10 +1,12 @@
1
1
  require 'merchant_e_solutions/configuration'
2
2
  require 'merchant_e_solutions/report'
3
3
  require 'merchant_e_solutions/request'
4
+ require 'merchant_e_solutions/detail_record'
5
+ require 'merchant_e_solutions/batch_detail_report'
6
+ require 'merchant_e_solutions/batch_summary_report'
4
7
  require 'merchant_e_solutions/settlement_detail_report'
5
- require 'merchant_e_solutions/settlement_detail_record'
6
- require 'merchant_e_solutions/settlement_summary_record'
7
8
  require 'merchant_e_solutions/settlement_summary_report'
9
+ require 'merchant_e_solutions/summary_record'
8
10
 
9
11
  module MerchantESolutions
10
12
 
@@ -0,0 +1,21 @@
1
+ require 'csv'
2
+
3
+ module MerchantESolutions
4
+ class BatchDetailReport < Report
5
+
6
+
7
+ private
8
+
9
+ def report_id
10
+ 1
11
+ end
12
+
13
+ def report_type
14
+ 1
15
+ end
16
+
17
+ def record_class
18
+ DetailRecord
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'csv'
2
+
3
+ module MerchantESolutions
4
+ class BatchSummaryReport < Report
5
+
6
+
7
+ private
8
+
9
+ def report_id
10
+ 1
11
+ end
12
+
13
+ def report_type
14
+ 0
15
+ end
16
+
17
+ def record_class
18
+ SummaryRecord
19
+ end
20
+ end
21
+ end
@@ -1,7 +1,7 @@
1
1
  module MerchantESolutions
2
- class SettlementDetailRecord
2
+ class DetailRecord
3
3
 
4
- attr_accessor :organization_id, :organization_name, :term_number, :batch_number, :batch_date,
4
+ attr_reader :organization_id, :organization_name, :term_number, :batch_number, :batch_date,
5
5
  :transaction_date, :card_code, :card_number, :reference_number, :purchase_id, :auth_code,
6
6
  :entry_mode, :transaction_amount, :trident_transaction_id, :client_reference_number
7
7
 
@@ -1,17 +1,20 @@
1
1
  module MerchantESolutions
2
2
  class Report
3
- attr_reader :request, :records
3
+ attr_reader :records, :request
4
4
 
5
5
  def initialize(params = {})
6
6
  self.options = params
7
- @request = Request.new(request_params).body
8
- parse_records(request)
7
+ @request = Request.new(request_params)
8
+ parse_records(request.body)
9
9
  end
10
10
 
11
11
  def request_params
12
12
  {
13
13
  dsReportId: report_id,
14
- reportType: report_type
14
+ reportType: report_type,
15
+ includeTridentTranId: true,
16
+ includePurchaseId: true,
17
+ includeClientRefNum: true
15
18
  }.merge(report_specific_params)
16
19
  end
17
20
 
@@ -15,7 +15,7 @@ module MerchantESolutions
15
15
  end
16
16
 
17
17
  def record_class
18
- SettlementDetailRecord
18
+ DetailRecord
19
19
  end
20
20
  end
21
21
  end
@@ -15,7 +15,7 @@ module MerchantESolutions
15
15
  end
16
16
 
17
17
  def record_class
18
- SettlementSummaryRecord
18
+ SummaryRecord
19
19
  end
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module MerchantESolutions
2
- class SettlementSummaryRecord
2
+ class SummaryRecord
3
3
 
4
4
  attr_reader :organization_id, :organization_name, :credit_company,
5
5
  :sales_count, :sales_amount, :credits_count, :credits_amount, :net_amount
@@ -1,3 +1,3 @@
1
1
  module MerchantESolutions
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,9 @@
1
+ "Org Id","Org Name","Card Type","Sales Cnt","Sales Amt","Credits Cnt","Credits Amt","Net Amt"
2
+ 42,"Hamazon",Visa,27,3049.24,122,-43.61,30005.63
3
+ 42,"Hamazon",Mastercard,10,3656.910000000003,57,-430.44,3226.470000000005
4
+ 42,"Hamazon",Debit/EBT,0,0.0,0,0.0,0.0
5
+ 42,"Hamazon",Bill Me Later,0,0.0,0,0.0,0.0
6
+ 42,"Hamazon",American Express,9,469.96,30,-54.63,415.329999999998
7
+ 42,"Hamazon",Discover,2,959.95,11,-33.09000000000003,926.8599999999997
8
+ 42,"Hamazon",Diners Club,0,0.0,0,0.0,0.0
9
+ 42,"Hamazon",JCB,0,0.0,0,0.0,0.0
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe MerchantESolutions::BatchDetailReport do
4
+ before { stub_net_http_requests }
5
+
6
+ describe "#initialize" do
7
+ let(:request) { double(:request, body: request_fixture('settlement_detail')) }
8
+
9
+ before { MerchantESolutions::Request.stub(:new).and_return(request) }
10
+
11
+ it "parses the body of the request as a CSV" do
12
+ report = MerchantESolutions::BatchDetailReport.new
13
+
14
+ report.records.size.should be > 0
15
+
16
+ report.records.each do |record|
17
+ record.should be_a MerchantESolutions::DetailRecord
18
+ end
19
+ end
20
+ end
21
+
22
+ describe "#request_params" do
23
+ let(:request_params) { MerchantESolutions::BatchDetailReport.new(options).request_params }
24
+ let(:options) { Hash.new }
25
+
26
+ it "knows its dsReportId" do
27
+ request_params[:dsReportId].should == 1
28
+ end
29
+
30
+ it "knows its reportType" do
31
+ request_params[:reportType].should == 1
32
+ end
33
+
34
+ context "when options are passed in" do
35
+ let(:options) { {test: 'params'} }
36
+
37
+ it "merges in the options" do
38
+ request_params[:test].should == 'params'
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe MerchantESolutions::BatchSummaryReport do
4
+ before { stub_net_http_requests }
5
+
6
+ describe "#initialize" do
7
+ let(:request) { double(:request, body: request_fixture('settlement_summary')) }
8
+
9
+ before { MerchantESolutions::Request.stub(:new).and_return(request) }
10
+
11
+ it "parses the body of the request as a CSV" do
12
+ report = MerchantESolutions::BatchSummaryReport.new
13
+
14
+ report.records.size.should be > 0
15
+
16
+ report.records.each do |record|
17
+ record.should be_a MerchantESolutions::SummaryRecord
18
+ end
19
+ end
20
+ end
21
+
22
+ describe "#request_params" do
23
+ let(:request_params) { MerchantESolutions::BatchSummaryReport.new(options).request_params }
24
+ let(:options) { Hash.new }
25
+
26
+ it "knows its dsReportId" do
27
+ request_params[:dsReportId].should == 1
28
+ end
29
+
30
+ it "knows its reportType" do
31
+ request_params[:reportType].should == 0
32
+ end
33
+
34
+ context "when options are passed in" do
35
+ let(:options) { {test: 'params'} }
36
+
37
+ it "merges in the options" do
38
+ request_params[:test].should == 'params'
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MerchantESolutions::SettlementDetailRecord do
3
+ describe MerchantESolutions::DetailRecord do
4
4
  describe "#initialize" do
5
- subject { MerchantESolutions::SettlementDetailRecord.new(csv_row) }
5
+ subject { MerchantESolutions::DetailRecord.new(csv_row) }
6
6
 
7
7
  # "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
8
  let(:csv_row) { [42, "Hamazon", 1, 220, "10/07/2013", "10/06/2013", "AM", "000000xxxxxx1234", "'0000213", "AAAAAAAAAAA0", "100000", "KEYED", 7.09, "T.T.ID", "clientRefNumber"] }
@@ -34,7 +34,7 @@ describe MerchantESolutions::SettlementDetailRecord do
34
34
  end
35
35
 
36
36
  describe "credit cards" do
37
- subject { MerchantESolutions::SettlementDetailRecord.new([nil, nil, nil, nil, nil, nil, card_code]) }
37
+ subject { MerchantESolutions::DetailRecord.new([nil, nil, nil, nil, nil, nil, card_code]) }
38
38
 
39
39
  context "when the code is AM" do
40
40
  let(:card_code) { "AM" }
@@ -1,5 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MerchantESolutions::Report do
4
- #Abstract class, tested in each subclass
4
+
5
+ class TestRecord
6
+ def initialize(row);end
7
+ end
8
+
9
+ class TestSubReport < MerchantESolutions::Report
10
+ def report_id; 0; end
11
+ def report_type; 9; end
12
+ def record_class; TestRecord; end
13
+ end
14
+
15
+ before { stub_net_http_requests }
16
+
17
+ describe "#initialize" do
18
+ let(:request) { double(:request, body: request_fixture('settlement_detail')) }
19
+
20
+ it "gets a new report from the MerchantESolutions API" do
21
+ MerchantESolutions::Request.should_receive(:new).and_return(request)
22
+
23
+ TestSubReport.new
24
+ end
25
+ end
26
+
27
+ describe "#request_params" do
28
+ let(:report) { TestSubReport.new(testing: "tested", includeClientRefNum: false) }
29
+
30
+ it "includes a dsReportID and reportType set in the subclass" do
31
+ report.request_params[:dsReportId].should == report.report_id
32
+ report.request_params[:reportType].should == report.report_type
33
+ end
34
+
35
+ it "pulls in the params from the report specific params" do
36
+ report.request_params[:testing].should == "tested"
37
+ end
38
+
39
+ it "allows it's options to be overwritten" do
40
+ report.request_params[:includeClientRefNum].should be_false
41
+ end
42
+ end
5
43
  end
@@ -5,22 +5,15 @@ describe MerchantESolutions::SettlementDetailReport do
5
5
 
6
6
  describe "#initialize" do
7
7
  let(:request) { double(:request, body: request_fixture('settlement_detail')) }
8
-
9
8
  before { MerchantESolutions::Request.stub(:new).and_return(request) }
10
9
 
11
- it "gets a new report from the MerchantESolutions API" do
12
- MerchantESolutions::Request.should_receive(:new).and_return(request)
13
-
14
- MerchantESolutions::SettlementDetailReport.new
15
- end
16
-
17
10
  it "parses the body of the request as a CSV" do
18
11
  report = MerchantESolutions::SettlementDetailReport.new
19
12
 
20
13
  report.records.size.should be > 0
21
14
 
22
15
  report.records.each do |record|
23
- record.should be_a MerchantESolutions::SettlementDetailRecord
16
+ record.should be_a MerchantESolutions::DetailRecord
24
17
  end
25
18
  end
26
19
  end
@@ -8,19 +8,13 @@ describe MerchantESolutions::SettlementSummaryReport do
8
8
 
9
9
  before { MerchantESolutions::Request.stub(:new).and_return(request) }
10
10
 
11
- it "gets a new report from the MerchantESolutions API" do
12
- MerchantESolutions::Request.should_receive(:new).and_return(request)
13
-
14
- MerchantESolutions::SettlementSummaryReport.new
15
- end
16
-
17
11
  it "parses the body of the request as a CSV" do
18
12
  report = MerchantESolutions::SettlementSummaryReport.new
19
13
 
20
14
  report.records.size.should be > 0
21
15
 
22
16
  report.records.each do |record|
23
- record.should be_a MerchantESolutions::SettlementSummaryRecord
17
+ record.should be_a MerchantESolutions::SummaryRecord
24
18
  end
25
19
  end
26
20
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MerchantESolutions::SettlementSummaryRecord do
3
+ describe MerchantESolutions::SummaryRecord do
4
4
  describe "#initialize" do
5
- subject { MerchantESolutions::SettlementSummaryRecord.new(csv_row) }
5
+ subject { MerchantESolutions::SummaryRecord.new(csv_row) }
6
6
  # "Org Id","Org Name","Card Type","Sales Cnt","Sales Amt","Credits Cnt","Credits Amt","Net Amt"
7
7
  let(:csv_row) { ['42', "Hamazon", "Visa", 1337, 1000000000.0, 1, 0.01, 999999999.99] }
8
8
 
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.1.0
4
+ version: 0.2.0
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: 2013-10-09 00:00:00.000000000 Z
12
+ date: 2013-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -82,23 +82,28 @@ files:
82
82
  - README.md
83
83
  - Rakefile
84
84
  - lib/merchant_e_solutions.rb
85
+ - lib/merchant_e_solutions/batch_detail_report.rb
86
+ - lib/merchant_e_solutions/batch_summary_report.rb
85
87
  - lib/merchant_e_solutions/configuration.rb
88
+ - lib/merchant_e_solutions/detail_record.rb
86
89
  - lib/merchant_e_solutions/report.rb
87
90
  - lib/merchant_e_solutions/request.rb
88
- - lib/merchant_e_solutions/settlement_detail_record.rb
89
91
  - lib/merchant_e_solutions/settlement_detail_report.rb
90
- - lib/merchant_e_solutions/settlement_summary_record.rb
91
92
  - lib/merchant_e_solutions/settlement_summary_report.rb
93
+ - lib/merchant_e_solutions/summary_record.rb
92
94
  - lib/merchant_e_solutions/version.rb
93
95
  - merchant_e_solutions.gemspec
96
+ - spec/fixtures/batch_summary.csv
94
97
  - spec/fixtures/settlement_detail.csv
95
98
  - spec/fixtures/settlement_summary.csv
99
+ - spec/lib/merchant_e_solutions/batch_detail_report_spec.rb
100
+ - spec/lib/merchant_e_solutions/batch_summary_report_spec.rb
101
+ - spec/lib/merchant_e_solutions/detail_record_spec.rb
96
102
  - spec/lib/merchant_e_solutions/report_spec.rb
97
103
  - spec/lib/merchant_e_solutions/request_spec.rb
98
- - spec/lib/merchant_e_solutions/settlement_detail_record_spec.rb
99
104
  - spec/lib/merchant_e_solutions/settlement_detail_report_spec.rb
100
- - spec/lib/merchant_e_solutions/settlement_summary_record_spec.rb
101
105
  - spec/lib/merchant_e_solutions/settlement_summary_report_spec.rb
106
+ - spec/lib/merchant_e_solutions/summary_record_spec.rb
102
107
  - spec/lib/merchant_e_solutions_spec.rb
103
108
  - spec/spec_helper.rb
104
109
  homepage: http://github.com/harrystech/merchant_e_solutions
@@ -126,13 +131,16 @@ signing_key:
126
131
  specification_version: 4
127
132
  summary: Wrapper for the Settlement Report API
128
133
  test_files:
134
+ - spec/fixtures/batch_summary.csv
129
135
  - spec/fixtures/settlement_detail.csv
130
136
  - spec/fixtures/settlement_summary.csv
137
+ - spec/lib/merchant_e_solutions/batch_detail_report_spec.rb
138
+ - spec/lib/merchant_e_solutions/batch_summary_report_spec.rb
139
+ - spec/lib/merchant_e_solutions/detail_record_spec.rb
131
140
  - spec/lib/merchant_e_solutions/report_spec.rb
132
141
  - spec/lib/merchant_e_solutions/request_spec.rb
133
- - spec/lib/merchant_e_solutions/settlement_detail_record_spec.rb
134
142
  - spec/lib/merchant_e_solutions/settlement_detail_report_spec.rb
135
- - spec/lib/merchant_e_solutions/settlement_summary_record_spec.rb
136
143
  - spec/lib/merchant_e_solutions/settlement_summary_report_spec.rb
144
+ - spec/lib/merchant_e_solutions/summary_record_spec.rb
137
145
  - spec/lib/merchant_e_solutions_spec.rb
138
146
  - spec/spec_helper.rb