exact4r 0.5.2 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,168 @@
|
|
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>Module: EWS::Transaction::Validator</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>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">EWS::Transaction::Validator</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/ews/transaction/validator_rb.html">
|
59
|
+
lib/ews/transaction/validator.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
</div>
|
78
|
+
|
79
|
+
<div id="method-list">
|
80
|
+
<h3 class="section-bar">Methods</h3>
|
81
|
+
|
82
|
+
<div class="name-list">
|
83
|
+
<a href="#M000001">valid?</a>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
<!-- if includes -->
|
91
|
+
|
92
|
+
<div id="section">
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<!-- if method_list -->
|
102
|
+
<div id="methods">
|
103
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
104
|
+
|
105
|
+
<div id="method-M000001" class="method-detail">
|
106
|
+
<a name="M000001"></a>
|
107
|
+
|
108
|
+
<div class="method-heading">
|
109
|
+
<a href="#M000001" class="method-signature">
|
110
|
+
<span class="method-name">valid?</span><span class="method-args">()</span>
|
111
|
+
</a>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<div class="method-description">
|
115
|
+
<p><a class="source-toggle" href="#"
|
116
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
117
|
+
<div class="method-source-code" id="M000001-source">
|
118
|
+
<pre>
|
119
|
+
<span class="ruby-comment cmt"># File lib/ews/transaction/validator.rb, line 30</span>
|
120
|
+
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid?</span>
|
121
|
+
31: <span class="ruby-ivar">@errors</span> = {}
|
122
|
+
32:
|
123
|
+
33: <span class="ruby-identifier">validate_lengths</span>
|
124
|
+
34:
|
125
|
+
35: <span class="ruby-identifier">validate_mandatory_fields</span>
|
126
|
+
36:
|
127
|
+
37: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:transaction_type</span>, <span class="ruby-value str">"transaction_type must be supplied"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">transaction_type</span>.<span class="ruby-identifier">blank?</span>
|
128
|
+
38:
|
129
|
+
39: <span class="ruby-comment cmt"># need to authenticate</span>
|
130
|
+
40: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:gateway_id</span>, <span class="ruby-value str">"gateway_id must be supplied"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gateway_id</span>.<span class="ruby-identifier">blank?</span>
|
131
|
+
41: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:password</span>, <span class="ruby-value str">"password must be supplied"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>.<span class="ruby-identifier">blank?</span>
|
132
|
+
42:
|
133
|
+
43: <span class="ruby-comment cmt"># ensure we've been given valid amounts</span>
|
134
|
+
44: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:amount</span>, <span class="ruby-value str">"invalid amount supplied"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_amount?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">amount</span>)
|
135
|
+
45: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:surcharge_amount</span>, <span class="ruby-value str">"invalid surcharge_amount supplied"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_amount?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">surcharge_amount</span>)
|
136
|
+
46: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:tax1_amount</span>, <span class="ruby-value str">"invalid tax1_amount supplied"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_amount?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">tax1_amount</span>)
|
137
|
+
47: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:tax2_amount</span>, <span class="ruby-value str">"invalid tax2_amount supplied"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_amount?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">tax2_amount</span>)
|
138
|
+
48:
|
139
|
+
49: <span class="ruby-comment cmt"># ensure our amounts are within range</span>
|
140
|
+
50: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:amount</span>, <span class="ruby-value str">"amount must be between 0.00 and 99999.99"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">amount_too_big?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">amount</span>)
|
141
|
+
51: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:surcharge_amount</span>, <span class="ruby-value str">"amount must be between 0.00 and 99999.99"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">amount_too_big?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">surcharge_amount</span>)
|
142
|
+
52: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:tax1_amount</span>, <span class="ruby-value str">"amount must be between 0.00 and 99999.99"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">amount_too_big?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">tax1_amount</span>)
|
143
|
+
53: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:tax2_amount</span>, <span class="ruby-value str">"amount must be between 0.00 and 99999.99"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">amount_too_big?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">tax2_amount</span>)
|
144
|
+
54:
|
145
|
+
55: <span class="ruby-comment cmt"># ensure our credit card information is valid</span>
|
146
|
+
56: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:cc_number</span>, <span class="ruby-value str">"invalid cc_number supplied"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_card_number?</span>
|
147
|
+
57: <span class="ruby-identifier">append_error</span>(<span class="ruby-identifier">:cc_expiry</span>, <span class="ruby-value str">"invalid cc_expiry supplied"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_expiry_date?</span>
|
148
|
+
58:
|
149
|
+
59: <span class="ruby-ivar">@errors</span>.<span class="ruby-identifier">empty?</span>
|
150
|
+
60: <span class="ruby-keyword kw">end</span>
|
151
|
+
</pre>
|
152
|
+
</div>
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
|
160
|
+
</div>
|
161
|
+
|
162
|
+
|
163
|
+
<div id="validator-badges">
|
164
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
</body>
|
168
|
+
</html>
|
@@ -0,0 +1,271 @@
|
|
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::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::Transporter</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/ews/transporter_rb.html">
|
59
|
+
lib/ews/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 (default)
|
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="#M000017">new</a>
|
112
|
+
<a href="#M000018">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-M000017" class="method-detail">
|
135
|
+
<a name="M000017"></a>
|
136
|
+
|
137
|
+
<div class="method-heading">
|
138
|
+
<a href="#M000017" class="method-signature">
|
139
|
+
<span class="method-name">new</span><span class="method-args">(url = "https://api.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
|
+
transaction processing 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 transport_type for this transporter (defaults to :rest)
|
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><a
|
167
|
+
href="Transporter.html#M000018">submit</a></tt> method.
|
168
|
+
</p>
|
169
|
+
<p><a class="source-toggle" href="#"
|
170
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
171
|
+
<div class="method-source-code" id="M000017-source">
|
172
|
+
<pre>
|
173
|
+
<span class="ruby-comment cmt"># File lib/ews/transporter.rb, line 32</span>
|
174
|
+
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">url</span> = <span class="ruby-value str">"https://api.e-xact.com/"</span>, <span class="ruby-identifier">options</span> = {})
|
175
|
+
33: <span class="ruby-ivar">@url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\/$/</span>,<span class="ruby-value str">''</span>))
|
176
|
+
34: <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
|
+
35: <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
|
+
36: <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
|
+
37: <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">:json</span>
|
180
|
+
38: <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-M000018" class="method-detail">
|
189
|
+
<a name="M000018"></a>
|
190
|
+
|
191
|
+
<div class="method-heading">
|
192
|
+
<a href="#M000018" class="method-signature">
|
193
|
+
<span class="method-name">submit</span><span class="method-args">(transaction, transport_type = nil)</span>
|
194
|
+
</a>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
<div class="method-description">
|
198
|
+
<p>
|
199
|
+
Submit a transaction request to the server
|
200
|
+
</p>
|
201
|
+
<table>
|
202
|
+
<tr><td valign="top"><tt>transaction</tt>:</td><td>the Request object to encode for transmission to the server
|
203
|
+
|
204
|
+
</td></tr>
|
205
|
+
<tr><td valign="top"><tt>transport_type</tt>:</td><td>(optional) the transport type to use for this transaction only. If it is
|
206
|
+
not specified, the <a href="Transporter.html">Transporter</a>‘s
|
207
|
+
transport type will be used
|
208
|
+
|
209
|
+
</td></tr>
|
210
|
+
</table>
|
211
|
+
<p><a class="source-toggle" href="#"
|
212
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
213
|
+
<div class="method-source-code" id="M000018-source">
|
214
|
+
<pre>
|
215
|
+
<span class="ruby-comment cmt"># File lib/ews/transporter.rb, line 44</span>
|
216
|
+
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">submit</span>(<span class="ruby-identifier">transaction</span>, <span class="ruby-identifier">transport_type</span> = <span class="ruby-keyword kw">nil</span>)
|
217
|
+
45: <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">transaction</span>.<span class="ruby-identifier">nil?</span>
|
218
|
+
46: <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">transaction</span>.<span class="ruby-identifier">valid?</span>
|
219
|
+
47:
|
220
|
+
48: <span class="ruby-identifier">transport_type</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@transport_type</span>
|
221
|
+
49:
|
222
|
+
50: <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>
|
223
|
+
51:
|
224
|
+
52: <span class="ruby-identifier">transport_details</span> = <span class="ruby-ivar">@@transport_types</span>[<span class="ruby-identifier">transport_type</span>]
|
225
|
+
53:
|
226
|
+
54: <span class="ruby-identifier">request</span> = <span class="ruby-identifier">build_http_request</span>(<span class="ruby-identifier">transaction</span>, <span class="ruby-identifier">transport_type</span>, <span class="ruby-identifier">transport_details</span>[<span class="ruby-identifier">:suffix</span>])
|
227
|
+
55: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">basic_auth</span>(<span class="ruby-identifier">transaction</span>.<span class="ruby-identifier">gateway_id</span>, <span class="ruby-identifier">transaction</span>.<span class="ruby-identifier">password</span>)
|
228
|
+
56: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">add_field</span> <span class="ruby-value str">"Accept"</span>, <span class="ruby-identifier">transport_details</span>[<span class="ruby-identifier">:content_type</span>]
|
229
|
+
57: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">add_field</span> <span class="ruby-value str">"User-Agent"</span>, <span class="ruby-value str">"Ruby"</span>
|
230
|
+
58: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">add_field</span> <span class="ruby-value str">"Content-type"</span>, <span class="ruby-node">"#{transport_details[:content_type]}; charset=UTF-8"</span>
|
231
|
+
59:
|
232
|
+
60: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">get_connection</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">request</span>)
|
233
|
+
61:
|
234
|
+
62: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">response</span>
|
235
|
+
63: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPSuccess</span> <span class="ruby-keyword kw">then</span> <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">response</span>.<span class="ruby-identifier">body</span>
|
236
|
+
64: <span class="ruby-keyword kw">else</span>
|
237
|
+
65: <span class="ruby-identifier">r</span> = <span class="ruby-operator">::</span><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">Response</span>.<span class="ruby-identifier">new</span>
|
238
|
+
66: <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">transport_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:soap</span>)
|
239
|
+
67: <span class="ruby-comment cmt"># we may have a SOAP Fault</span>
|
240
|
+
68: <span class="ruby-identifier">r</span> = <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">response</span>.<span class="ruby-identifier">body</span>
|
241
|
+
69: <span class="ruby-keyword kw">end</span>
|
242
|
+
70:
|
243
|
+
71: <span class="ruby-comment cmt"># SOAP Fault may already have populated the error_number etc.</span>
|
244
|
+
72: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">error_number</span>
|
245
|
+
73: <span class="ruby-comment cmt"># populate the error number and description</span>
|
246
|
+
74: <span class="ruby-identifier">r</span>.<span class="ruby-identifier">error_number</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">to_i</span>
|
247
|
+
75: <span class="ruby-identifier">r</span>.<span class="ruby-identifier">error_description</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">message</span>
|
248
|
+
76: <span class="ruby-keyword kw">end</span>
|
249
|
+
77:
|
250
|
+
78: <span class="ruby-identifier">r</span>
|
251
|
+
79: <span class="ruby-keyword kw">end</span>
|
252
|
+
80:
|
253
|
+
81: <span class="ruby-keyword kw">end</span>
|
254
|
+
</pre>
|
255
|
+
</div>
|
256
|
+
</div>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
|
260
|
+
</div>
|
261
|
+
|
262
|
+
|
263
|
+
</div>
|
264
|
+
|
265
|
+
|
266
|
+
<div id="validator-badges">
|
267
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
268
|
+
</div>
|
269
|
+
|
270
|
+
</body>
|
271
|
+
</html>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Thu, 14 Aug 2008 11:12:34 +1000
|
data/doc/files/CHANGELOG.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Aug 14 11:12:08 +1000 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -69,9 +69,22 @@
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
71
|
<div id="description">
|
72
|
-
<h2>v0.
|
72
|
+
<h2>v0.6</h2>
|
73
|
+
<pre>
|
74
|
+
Added client-side request validation
|
75
|
+
</pre>
|
76
|
+
<h2>v0.5.3</h2>
|
77
|
+
<pre>
|
78
|
+
Added fake response messages for testing purposes
|
79
|
+
Moved EWS::Transaction::Transporter to EWS::Transporter
|
80
|
+
Fixed typos
|
81
|
+
</pre>
|
82
|
+
<h2>v0.5.2</h2>
|
73
83
|
<pre>
|
74
84
|
Updated Transporter to play nicely with mod_security
|
85
|
+
Stripped trailing '/'s from URLs
|
86
|
+
Transporter ow re-uses connection
|
87
|
+
Updated RDoc with test login details
|
75
88
|
</pre>
|
76
89
|
<h2>v0.5.1</h2>
|
77
90
|
<pre>
|