exact4r 0.5.2 → 0.6
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/CHANGELOG +8 -0
- data/README +8 -8
- data/VERSION +1 -1
- data/doc/classes/EWS/Transaction/FakeResponse.html +451 -0
- data/doc/classes/EWS/Transaction/Request.html +54 -81
- data/doc/classes/EWS/Transaction/Response.html +182 -14
- data/doc/classes/EWS/Transaction/Validator.html +168 -0
- data/doc/classes/EWS/Transporter.html +271 -0
- data/doc/created.rid +1 -1
- data/doc/files/CHANGELOG.html +15 -2
- data/doc/files/README.html +17 -9
- data/doc/files/VERSION.html +2 -2
- data/doc/files/lib/ews/transaction/fake_response_rb.html +101 -0
- data/doc/files/lib/ews/transaction/mapping_rb.html +1 -1
- data/doc/files/lib/ews/transaction/request_rb.html +8 -1
- data/doc/files/lib/ews/transaction/response_rb.html +1 -1
- data/doc/files/lib/ews/transaction/validator_rb.html +101 -0
- data/doc/files/lib/ews/{transaction/transporter_rb.html → transporter_rb.html} +3 -3
- data/doc/files/lib/exact4r_rb.html +4 -2
- data/doc/fr_class_index.html +3 -1
- data/doc/fr_file_index.html +3 -1
- data/doc/fr_method_index.html +18 -7
- data/lib/ews/transaction/fake_response.rb +137 -0
- data/lib/ews/transaction/mapping.rb +38 -15
- data/lib/ews/transaction/request.rb +10 -58
- data/lib/ews/transaction/response.rb +3 -3
- data/lib/ews/transaction/validator.rb +230 -0
- data/lib/ews/transporter.rb +143 -0
- data/lib/exact4r.rb +4 -1
- data/spec/donncha_spec.rb +13 -0
- data/spec/mapping_spec.rb +45 -4
- data/spec/request_spec.rb +96 -69
- data/spec/spec_helper.rb +20 -8
- data/spec/transporter_spec.rb +26 -2
- data/spec/validator_spec.rb +145 -0
- metadata +16 -7
- data/doc/classes/EWS/Transaction/Transporter.html +0 -250
- data/lib/ews/transaction/transporter.rb +0 -120
- data/output.log +0 -368
data/spec/spec_helper.rb
CHANGED
@@ -5,25 +5,38 @@ require 'lib/exact4r'
|
|
5
5
|
|
6
6
|
REPLICATION_TIME = 20
|
7
7
|
|
8
|
+
# address & authentication for testing against api.e-xact.com
|
9
|
+
# LOCATION = "https://api.e-xact.com/"
|
10
|
+
# BASIC_AUTH = {:gateway_id => "A00049-01", :password => "test1"}
|
11
|
+
|
12
|
+
# address & authentication for local testing
|
13
|
+
LOCATION = "http://localhost:3000/"
|
14
|
+
BASIC_AUTH = {:gateway_id => "AD0008-01", :password => "7nfcpc7n"}
|
15
|
+
|
16
|
+
Spec::Runner.configure do |config|
|
17
|
+
include EWS::Transaction
|
18
|
+
|
19
|
+
config.mock_with :mocha
|
20
|
+
|
21
|
+
end
|
22
|
+
|
8
23
|
def basic_params(options = {})
|
9
24
|
{
|
10
25
|
:transaction_type => :purchase,
|
11
26
|
:amount => "10.13",
|
12
27
|
:cardholder_name => "Simon Brown",
|
13
28
|
:cc_number => "4111111111111111",
|
14
|
-
:cc_expiry => "
|
15
|
-
:gateway_id => "someone",
|
16
|
-
:password => "somehow"
|
29
|
+
:cc_expiry => "1012",
|
30
|
+
:gateway_id => "someone", :password => "somehow"
|
17
31
|
}.merge(options)
|
18
32
|
end
|
19
33
|
|
20
34
|
def basic_find_transaction(options = {})
|
21
35
|
params = {
|
22
36
|
:transaction_type => :transaction_details,
|
23
|
-
:gateway_id => "A00049-01", :password => "test1"
|
24
37
|
}.merge(options)
|
25
38
|
|
26
|
-
::EWS::Transaction::Request.new(params)
|
39
|
+
::EWS::Transaction::Request.new(params.merge(BASIC_AUTH))
|
27
40
|
end
|
28
41
|
|
29
42
|
def basic_new_transaction(options = {})
|
@@ -32,10 +45,9 @@ def basic_new_transaction(options = {})
|
|
32
45
|
:amount => "10.13",
|
33
46
|
:cardholder_name => "Simon Brown",
|
34
47
|
:cc_number => "4111111111111111",
|
35
|
-
:cc_expiry => "
|
48
|
+
:cc_expiry => "1012",
|
36
49
|
:reference_no => "987987",
|
37
|
-
:gateway_id => "A00049-01", :password => "test1"
|
38
50
|
}.merge(options)
|
39
51
|
|
40
|
-
::EWS::Transaction::Request.new(params)
|
52
|
+
::EWS::Transaction::Request.new(params.merge(BASIC_AUTH))
|
41
53
|
end
|
data/spec/transporter_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe "Transporter creating transactions" do
|
|
4
4
|
|
5
5
|
it "should raise an exception when transport_type is not one of :json, :rest or :soap" do
|
6
6
|
lambda {
|
7
|
-
tr = ::EWS::
|
7
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
8
8
|
tr.submit(basic_new_transaction, :banana)
|
9
9
|
}.should raise_error
|
10
10
|
end
|
@@ -13,9 +13,33 @@ describe "Transporter creating transactions" do
|
|
13
13
|
txn = basic_new_transaction
|
14
14
|
|
15
15
|
lambda {
|
16
|
-
tr = ::EWS::
|
16
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
17
17
|
tr.submit(txn)
|
18
18
|
}.should_not raise_error(RuntimeError)
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should return a Response object on server failure" do
|
22
|
+
req = basic_find_transaction
|
23
|
+
req.transaction_tag = 9000 # non-existent txn
|
24
|
+
|
25
|
+
puts req.errors.inspect unless req.valid?
|
26
|
+
|
27
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
28
|
+
resp = tr.submit(req, :json)
|
29
|
+
|
30
|
+
resp.should_not be_nil
|
31
|
+
resp.error_number.should == 404
|
32
|
+
resp.error_description.should == "Not Found"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should throw an exception when parsing a response to sending nonsense SOAP" do
|
36
|
+
req = basic_find_transaction
|
37
|
+
|
38
|
+
EWS::Transaction::Mapping.stubs(:request_to_soap).returns("Complete and utter rubbish. It's not even XML!!")
|
39
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
40
|
+
lambda {
|
41
|
+
tr.submit(req, :soap)
|
42
|
+
}.should raise_error
|
43
|
+
end
|
44
|
+
|
21
45
|
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
describe "length validation" do
|
4
|
+
it "should invalidate strings which are too long" do
|
5
|
+
EWS::Transaction::Request.new(basic_params).should be_valid
|
6
|
+
EWS::Transaction::Request.new(basic_params(:authorization_num => 'a'*8)).should be_valid
|
7
|
+
EWS::Transaction::Request.new(basic_params(:authorization_num => 'a'*9)).should_not be_valid
|
8
|
+
|
9
|
+
EWS::Transaction::Request.new(basic_params(:cardholder_name => 'a'*30)).should be_valid
|
10
|
+
EWS::Transaction::Request.new(basic_params(:cardholder_name => 'a'*31)).should_not be_valid
|
11
|
+
|
12
|
+
EWS::Transaction::Request.new(basic_params(:cc_number => 'a'*19)).should be_valid
|
13
|
+
EWS::Transaction::Request.new(basic_params(:cc_number => 'a'*20)).should_not be_valid
|
14
|
+
|
15
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "0909")).should be_valid
|
16
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "09091")).should_not be_valid
|
17
|
+
|
18
|
+
EWS::Transaction::Request.new(basic_params(:cavv => 'a'*40)).should be_valid
|
19
|
+
EWS::Transaction::Request.new(basic_params(:cavv => 'a'*41)).should_not be_valid
|
20
|
+
|
21
|
+
EWS::Transaction::Request.new(basic_params(:client_email => 'a'*30)).should be_valid
|
22
|
+
EWS::Transaction::Request.new(basic_params(:client_email => 'a'*31)).should_not be_valid
|
23
|
+
|
24
|
+
EWS::Transaction::Request.new(basic_params(:customer_ref => 'a'*20)).should be_valid
|
25
|
+
EWS::Transaction::Request.new(basic_params(:customer_ref => 'a'*21)).should_not be_valid
|
26
|
+
|
27
|
+
EWS::Transaction::Request.new(basic_params(:gateway_id => 'a'*10)).should be_valid
|
28
|
+
EWS::Transaction::Request.new(basic_params(:gateway_id => 'a'*11)).should_not be_valid
|
29
|
+
|
30
|
+
EWS::Transaction::Request.new(basic_params(:pan => 'a'*39)).should be_valid
|
31
|
+
EWS::Transaction::Request.new(basic_params(:pan => 'a'*40)).should_not be_valid
|
32
|
+
|
33
|
+
EWS::Transaction::Request.new(basic_params(:password => 'a'*30)).should be_valid
|
34
|
+
EWS::Transaction::Request.new(basic_params(:password => 'a'*31)).should_not be_valid
|
35
|
+
|
36
|
+
EWS::Transaction::Request.new(basic_params(:reference_3 => 'a'*30)).should be_valid
|
37
|
+
EWS::Transaction::Request.new(basic_params(:reference_3 => 'a'*31)).should_not be_valid
|
38
|
+
|
39
|
+
EWS::Transaction::Request.new(basic_params(:reference_no => 'a'*20)).should be_valid
|
40
|
+
EWS::Transaction::Request.new(basic_params(:reference_no => 'a'*21)).should_not be_valid
|
41
|
+
|
42
|
+
EWS::Transaction::Request.new(basic_params(:tax1_number => 'a'*20)).should be_valid
|
43
|
+
EWS::Transaction::Request.new(basic_params(:tax1_number => 'a'*21)).should_not be_valid
|
44
|
+
|
45
|
+
EWS::Transaction::Request.new(basic_params(:tax2_number => 'a'*20)).should be_valid
|
46
|
+
EWS::Transaction::Request.new(basic_params(:tax2_number => 'a'*21)).should_not be_valid
|
47
|
+
|
48
|
+
EWS::Transaction::Request.new(basic_params(:track1 => 'a'*79)).should be_valid
|
49
|
+
EWS::Transaction::Request.new(basic_params(:track1 => 'a'*80)).should_not be_valid
|
50
|
+
|
51
|
+
EWS::Transaction::Request.new(basic_params(:track2 => 'a'*40)).should be_valid
|
52
|
+
EWS::Transaction::Request.new(basic_params(:track2 => 'a'*41)).should_not be_valid
|
53
|
+
|
54
|
+
EWS::Transaction::Request.new(basic_params(:cc_verification_str1 => 'a'*40)).should be_valid
|
55
|
+
EWS::Transaction::Request.new(basic_params(:cc_verification_str1 => 'a'*41)).should_not be_valid
|
56
|
+
|
57
|
+
EWS::Transaction::Request.new(basic_params(:cc_verification_str2 => 'a'*4)).should be_valid
|
58
|
+
EWS::Transaction::Request.new(basic_params(:cc_verification_str2 => 'a'*5)).should_not be_valid
|
59
|
+
|
60
|
+
EWS::Transaction::Request.new(basic_params(:xid => 'a'*40)).should be_valid
|
61
|
+
EWS::Transaction::Request.new(basic_params(:xid => 'a'*41)).should_not be_valid
|
62
|
+
|
63
|
+
EWS::Transaction::Request.new(basic_params(:zip_code => 'a'*10)).should be_valid
|
64
|
+
EWS::Transaction::Request.new(basic_params(:zip_code => 'a'*11)).should_not be_valid
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "authentication info validation" do
|
69
|
+
it "should require gateway_id and password " do
|
70
|
+
EWS::Transaction::Request.new(basic_params).should be_valid
|
71
|
+
|
72
|
+
EWS::Transaction::Request.new(basic_params(:gateway_id => nil)).should_not be_valid
|
73
|
+
EWS::Transaction::Request.new(basic_params(:gateway_id => "")).should_not be_valid
|
74
|
+
|
75
|
+
EWS::Transaction::Request.new(basic_params(:password => nil)).should_not be_valid
|
76
|
+
EWS::Transaction::Request.new(basic_params(:password => "")).should_not be_valid
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "amount validation" do
|
81
|
+
it "should validate amounts" do
|
82
|
+
# validation: amounts
|
83
|
+
[:amount, :surcharge_amount, :tax1_amount, :tax2_amount].each do |amount_attr|
|
84
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => "10.13")).should be_valid
|
85
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => "10.")).should be_valid
|
86
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => "0.13")).should be_valid
|
87
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => 10.13)).should be_valid
|
88
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => 0.13)).should be_valid
|
89
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => 10)).should be_valid
|
90
|
+
|
91
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => "10.1s3"))
|
92
|
+
r.should_not be_valid
|
93
|
+
r.errors[amount_attr].should_not be_blank
|
94
|
+
|
95
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => "1s0.13"))
|
96
|
+
r.should_not be_valid
|
97
|
+
r.errors[amount_attr].should_not be_blank
|
98
|
+
|
99
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => "dopey"))
|
100
|
+
r.should_not be_valid
|
101
|
+
r.errors[amount_attr].should_not be_blank
|
102
|
+
|
103
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => 100000))
|
104
|
+
r.should_not be_valid
|
105
|
+
r.errors[amount_attr].should_not be_blank
|
106
|
+
|
107
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => 99999.99)).should be_valid
|
108
|
+
|
109
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => -0.01))
|
110
|
+
r.should_not be_valid
|
111
|
+
r.errors[amount_attr].should_not be_blank
|
112
|
+
|
113
|
+
EWS::Transaction::Request.new(basic_params(amount_attr => 0.0)).should be_valid
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "credit card validation" do
|
119
|
+
it "should validate cc_number and cc_expiry" do
|
120
|
+
# validation: card number
|
121
|
+
EWS::Transaction::Request.new(basic_params(:cc_number => "4111111111111111")).should be_valid
|
122
|
+
EWS::Transaction::Request.new(basic_params(:cc_number => "4111111111111112")).should_not be_valid
|
123
|
+
|
124
|
+
# validation: card expiry (should be in MMYY format)
|
125
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "1009")).should be_valid
|
126
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => nil)).should_not be_valid
|
127
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "")).should_not be_valid
|
128
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "708")).should_not be_valid
|
129
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "07089")).should_not be_valid
|
130
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "07f")).should_not be_valid
|
131
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => "1308")).should_not be_valid # invalid month
|
132
|
+
|
133
|
+
# ensure we don't accept dates in the past
|
134
|
+
t = Time.new
|
135
|
+
month = t.month
|
136
|
+
year = t.year - 2000
|
137
|
+
# in the past
|
138
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year-1))).should_not be_valid
|
139
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month-1, year))).should_not be_valid
|
140
|
+
# in the present or future
|
141
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year))).should be_valid
|
142
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month+1, year))).should be_valid
|
143
|
+
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year+1))).should be_valid
|
144
|
+
end
|
145
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exact4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.6"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E-xact Transactions Ltd.
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-14 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -23,6 +24,7 @@ dependencies:
|
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: builder
|
27
|
+
type: :runtime
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
@@ -50,19 +52,23 @@ files:
|
|
50
52
|
- ./doc/classes
|
51
53
|
- ./doc/classes/EWS
|
52
54
|
- ./doc/classes/EWS/Transaction
|
55
|
+
- ./doc/classes/EWS/Transaction/FakeResponse.html
|
53
56
|
- ./doc/classes/EWS/Transaction/Request.html
|
54
57
|
- ./doc/classes/EWS/Transaction/Response.html
|
55
|
-
- ./doc/classes/EWS/Transaction/
|
58
|
+
- ./doc/classes/EWS/Transaction/Validator.html
|
59
|
+
- ./doc/classes/EWS/Transporter.html
|
56
60
|
- ./doc/created.rid
|
57
61
|
- ./doc/files
|
58
62
|
- ./doc/files/CHANGELOG.html
|
59
63
|
- ./doc/files/lib
|
60
64
|
- ./doc/files/lib/ews
|
61
65
|
- ./doc/files/lib/ews/transaction
|
66
|
+
- ./doc/files/lib/ews/transaction/fake_response_rb.html
|
62
67
|
- ./doc/files/lib/ews/transaction/mapping_rb.html
|
63
68
|
- ./doc/files/lib/ews/transaction/request_rb.html
|
64
69
|
- ./doc/files/lib/ews/transaction/response_rb.html
|
65
|
-
- ./doc/files/lib/ews/transaction/
|
70
|
+
- ./doc/files/lib/ews/transaction/validator_rb.html
|
71
|
+
- ./doc/files/lib/ews/transporter_rb.html
|
66
72
|
- ./doc/files/lib/exact4r_rb.html
|
67
73
|
- ./doc/files/LICENCE.html
|
68
74
|
- ./doc/files/README.html
|
@@ -75,20 +81,23 @@ files:
|
|
75
81
|
- ./lib
|
76
82
|
- ./lib/ews
|
77
83
|
- ./lib/ews/transaction
|
84
|
+
- ./lib/ews/transaction/fake_response.rb
|
78
85
|
- ./lib/ews/transaction/mapping.rb
|
79
86
|
- ./lib/ews/transaction/request.rb
|
80
87
|
- ./lib/ews/transaction/response.rb
|
81
|
-
- ./lib/ews/transaction/
|
88
|
+
- ./lib/ews/transaction/validator.rb
|
89
|
+
- ./lib/ews/transporter.rb
|
82
90
|
- ./lib/exact4r.rb
|
83
91
|
- ./LICENCE
|
84
|
-
- ./output.log
|
85
92
|
- ./Rakefile
|
86
93
|
- ./README
|
87
94
|
- ./spec
|
95
|
+
- ./spec/donncha_spec.rb
|
88
96
|
- ./spec/mapping_spec.rb
|
89
97
|
- ./spec/request_spec.rb
|
90
98
|
- ./spec/spec_helper.rb
|
91
99
|
- ./spec/transporter_spec.rb
|
100
|
+
- ./spec/validator_spec.rb
|
92
101
|
- ./VERSION
|
93
102
|
- CHANGELOG
|
94
103
|
- LICENCE
|
@@ -119,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
128
|
requirements: []
|
120
129
|
|
121
130
|
rubyforge_project: exact4r
|
122
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.2.0
|
123
132
|
signing_key:
|
124
133
|
specification_version: 2
|
125
134
|
summary: E-xact Web Services Client Library.
|
@@ -1,250 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: EWS::Transaction::Transporter</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">EWS::Transaction::Transporter</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../../files/lib/ews/transaction/transporter_rb.html">
|
59
|
-
lib/ews/transaction/transporter.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
A <a href="Transporter.html">Transporter</a> is responsible for
|
84
|
-
communicating with the E-xact Web Service in whichever dialect is chosen by
|
85
|
-
the user. The available options are:
|
86
|
-
</p>
|
87
|
-
<pre>
|
88
|
-
:json REST with JSON payload
|
89
|
-
:rest REST with XML payload
|
90
|
-
:soap SOAP
|
91
|
-
</pre>
|
92
|
-
<p>
|
93
|
-
The <a href="Transporter.html">Transporter</a> will connect to the service,
|
94
|
-
using SSL if required, and will encode Reqests to send to the service, and
|
95
|
-
decode Responses received from the service.
|
96
|
-
</p>
|
97
|
-
<p>
|
98
|
-
Once configured to connect to a particular service, it can be used
|
99
|
-
repeatedly to send as many transactions as required.
|
100
|
-
</p>
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
<div id="method-list">
|
108
|
-
<h3 class="section-bar">Methods</h3>
|
109
|
-
|
110
|
-
<div class="name-list">
|
111
|
-
<a href="#M000001">new</a>
|
112
|
-
<a href="#M000002">submit</a>
|
113
|
-
</div>
|
114
|
-
</div>
|
115
|
-
|
116
|
-
</div>
|
117
|
-
|
118
|
-
|
119
|
-
<!-- if includes -->
|
120
|
-
|
121
|
-
<div id="section">
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
<!-- if method_list -->
|
131
|
-
<div id="methods">
|
132
|
-
<h3 class="section-bar">Public Class methods</h3>
|
133
|
-
|
134
|
-
<div id="method-M000001" class="method-detail">
|
135
|
-
<a name="M000001"></a>
|
136
|
-
|
137
|
-
<div class="method-heading">
|
138
|
-
<a href="#M000001" class="method-signature">
|
139
|
-
<span class="method-name">new</span><span class="method-args">(url = "http://api.dev.e-xact.com/", options = {})</span>
|
140
|
-
</a>
|
141
|
-
</div>
|
142
|
-
|
143
|
-
<div class="method-description">
|
144
|
-
<p>
|
145
|
-
Initialize a <a href="Transporter.html">Transporter</a>.
|
146
|
-
</p>
|
147
|
-
<p>
|
148
|
-
You can specify the URL you would like the <a
|
149
|
-
href="Transporter.html">Transporter</a> to connect to, although it defaults
|
150
|
-
to <a href="https://api.e-xact.com">api.e-xact.com</a>, the location of our
|
151
|
-
web service.
|
152
|
-
</p>
|
153
|
-
<p>
|
154
|
-
You can also specify a hash of options as follows:
|
155
|
-
</p>
|
156
|
-
<pre>
|
157
|
-
:server_cert the path to the server's certificate
|
158
|
-
:issuer_cert the path to the certificate of the issuer of the server certificate
|
159
|
-
:transport_type the default transport_type for this transporter
|
160
|
-
</pre>
|
161
|
-
<p>
|
162
|
-
The default certificates are those required to connect to <a
|
163
|
-
href="https://api.e-xact.com">api.e-xact.com</a> and the default
|
164
|
-
<tt>transport_type</tt> is <tt>:rest</tt>. The default
|
165
|
-
<tt>transport_type</tt> can be overridden on a per-transaction basis, if
|
166
|
-
you choose to do so, by specifying it as a parameter to the <tt>send</tt>
|
167
|
-
method.
|
168
|
-
</p>
|
169
|
-
<p><a class="source-toggle" href="#"
|
170
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
171
|
-
<div class="method-source-code" id="M000001-source">
|
172
|
-
<pre>
|
173
|
-
<span class="ruby-comment cmt"># File lib/ews/transaction/transporter.rb, line 34</span>
|
174
|
-
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">url</span> = <span class="ruby-value str">"http://api.dev.e-xact.com/"</span>, <span class="ruby-identifier">options</span> = {})
|
175
|
-
35: <span class="ruby-ivar">@url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>)
|
176
|
-
36: <span class="ruby-identifier">base</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword kw">__FILE__</span>)
|
177
|
-
37: <span class="ruby-ivar">@server_cert</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:server_cert</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">base</span><span class="ruby-operator">+</span><span class="ruby-value str">"/../../../certs/exact.cer"</span>
|
178
|
-
38: <span class="ruby-ivar">@issuer_cert</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:issuer_cert</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">base</span><span class="ruby-operator">+</span><span class="ruby-value str">"/../../../certs/equifax_ca.cer"</span>
|
179
|
-
39: <span class="ruby-ivar">@transport_type</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:transport_type</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:rest</span>
|
180
|
-
40: <span class="ruby-keyword kw">end</span>
|
181
|
-
</pre>
|
182
|
-
</div>
|
183
|
-
</div>
|
184
|
-
</div>
|
185
|
-
|
186
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
187
|
-
|
188
|
-
<div id="method-M000002" class="method-detail">
|
189
|
-
<a name="M000002"></a>
|
190
|
-
|
191
|
-
<div class="method-heading">
|
192
|
-
<a href="#M000002" class="method-signature">
|
193
|
-
<span class="method-name">submit</span><span class="method-args">(request, transport_type = nil)</span>
|
194
|
-
</a>
|
195
|
-
</div>
|
196
|
-
|
197
|
-
<div class="method-description">
|
198
|
-
<p>
|
199
|
-
Send a transaction request to the server
|
200
|
-
</p>
|
201
|
-
<table>
|
202
|
-
<tr><td valign="top"><tt>request</tt>:</td><td>the <a href="Request.html">Request</a> object to encode for transmission to
|
203
|
-
the server
|
204
|
-
|
205
|
-
</td></tr>
|
206
|
-
<tr><td valign="top"><tt>transport_type</tt>:</td><td>(optional) the transport type to use for this transaction only. If it not
|
207
|
-
specified, the default transport type for this <a
|
208
|
-
href="Transporter.html">Transporter</a> will be used
|
209
|
-
|
210
|
-
</td></tr>
|
211
|
-
</table>
|
212
|
-
<p><a class="source-toggle" href="#"
|
213
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
214
|
-
<div class="method-source-code" id="M000002-source">
|
215
|
-
<pre>
|
216
|
-
<span class="ruby-comment cmt"># File lib/ews/transaction/transporter.rb, line 46</span>
|
217
|
-
46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">submit</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">transport_type</span> = <span class="ruby-keyword kw">nil</span>)
|
218
|
-
47: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Request not supplied"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">nil?</span>
|
219
|
-
48: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">valid?</span>
|
220
|
-
49:
|
221
|
-
50: <span class="ruby-identifier">transport_type</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@transport_type</span>
|
222
|
-
51:
|
223
|
-
52: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Transport type #{transport_type} is not supported"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@@transport_types</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">transport_type</span>
|
224
|
-
53:
|
225
|
-
54: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">request</span>.<span class="ruby-identifier">is_find_transaction?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">transport_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:soap</span>
|
226
|
-
55: <span class="ruby-identifier">content</span> = <span class="ruby-identifier">post</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">transport_type</span>)
|
227
|
-
56: <span class="ruby-keyword kw">else</span>
|
228
|
-
57: <span class="ruby-identifier">content</span> = <span class="ruby-identifier">get</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">transport_type</span>)
|
229
|
-
58: <span class="ruby-keyword kw">end</span>
|
230
|
-
59:
|
231
|
-
60: <span class="ruby-constant">EWS</span><span class="ruby-operator">::</span><span class="ruby-constant">Transaction</span><span class="ruby-operator">::</span><span class="ruby-constant">Mapping</span>.<span class="ruby-identifier">send</span> <span class="ruby-node">"#{transport_type}_to_response"</span>, <span class="ruby-identifier">content</span>
|
232
|
-
61: <span class="ruby-keyword kw">end</span>
|
233
|
-
</pre>
|
234
|
-
</div>
|
235
|
-
</div>
|
236
|
-
</div>
|
237
|
-
|
238
|
-
|
239
|
-
</div>
|
240
|
-
|
241
|
-
|
242
|
-
</div>
|
243
|
-
|
244
|
-
|
245
|
-
<div id="validator-badges">
|
246
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
247
|
-
</div>
|
248
|
-
|
249
|
-
</body>
|
250
|
-
</html>
|