postalmethods 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,282 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>
5
+ lib/postalmethods.rb - C0 code coverage information
6
+ </title>
7
+ <style type='text/css'>
8
+ body { background-color: rgb(240, 240, 245); }
9
+ </style>
10
+ <style type='text/css'>
11
+ span.cross-ref-title { font-size: 140%; } span.cross-ref a {
12
+ text-decoration: none; } span.cross-ref { background-color:#f3f7fa;
13
+ border: 1px dashed #333; margin: 1em; padding: 0.5em; overflow: hidden; }
14
+ a.crossref-toggle { text-decoration: none; } span.marked0 {
15
+ background-color: rgb(185, 210, 200); display: block; } span.marked1 {
16
+ background-color: rgb(190, 215, 205); display: block; } span.inferred0 {
17
+ background-color: rgb(175, 200, 200); display: block; } span.inferred1 {
18
+ background-color: rgb(180, 205, 205); display: block; } span.uncovered0 {
19
+ background-color: rgb(225, 110, 110); display: block; } span.uncovered1 {
20
+ background-color: rgb(235, 120, 120); display: block; } span.overview {
21
+ border-bottom: 8px solid black; } div.overview { border-bottom: 8px solid
22
+ black; } body { font-family: verdana, arial, helvetica; } div.footer {
23
+ font-size: 68%; margin-top: 1.5em; } h1, h2, h3, h4, h5, h6 {
24
+ margin-bottom: 0.5em; } h5 { margin-top: 0.5em; } .hidden { display: none;
25
+ } div.separator { height: 10px; } /* Commented out for better readability,
26
+ esp. on IE */ /* table tr td, table tr th { font-size: 68%; } td.value
27
+ table tr td { font-size: 11px; } */ table.percent_graph { height: 12px;
28
+ border: #808080 1px solid; empty-cells: show; } table.percent_graph
29
+ td.covered { height: 10px; background: #00f000; } table.percent_graph
30
+ td.uncovered { height: 10px; background: #e00000; } table.percent_graph
31
+ td.NA { height: 10px; background: #eaeaea; } table.report {
32
+ border-collapse: collapse; width: 100%; } table.report td.heading {
33
+ background: #dcecff; border: #d0d0d0 1px solid; font-weight: bold;
34
+ text-align: center; } table.report td.heading:hover { background: #c0ffc0;
35
+ } table.report td.text { border: #d0d0d0 1px solid; } table.report
36
+ td.value, table.report td.lines_total, table.report td.lines_code {
37
+ text-align: right; border: #d0d0d0 1px solid; } table.report tr.light {
38
+ background-color: rgb(240, 240, 245); } table.report tr.dark {
39
+ background-color: rgb(230, 230, 235); }
40
+ </style>
41
+ <script type='text/javascript'>
42
+ // <![CDATA[ function toggleCode( id ) { if ( document.getElementById )
43
+ elem = document.getElementById( id ); else if ( document.all ) elem =
44
+ eval( "document.all." + id ); else return false; elemStyle = elem.style;
45
+ if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else {
46
+ elemStyle.display = "none" } return true; } // Make cross-references
47
+ hidden by default document.writeln( "<style
48
+ type=\"text/css\">span.cross-ref { display: none }</style>" ) // ]]>
49
+ </script>
50
+ <style type='text/css'>
51
+ span.run0 { background-color: rgb(178, 204, 255); display: block; }
52
+ span.run1 { background-color: rgb(178, 206, 255); display: block; }
53
+ span.run2 { background-color: rgb(178, 209, 255); display: block; }
54
+ span.run3 { background-color: rgb(178, 211, 255); display: block; }
55
+ span.run4 { background-color: rgb(178, 214, 255); display: block; }
56
+ span.run5 { background-color: rgb(178, 218, 255); display: block; }
57
+ span.run6 { background-color: rgb(178, 220, 255); display: block; }
58
+ span.run7 { background-color: rgb(178, 223, 255); display: block; }
59
+ span.run8 { background-color: rgb(178, 225, 255); display: block; }
60
+ span.run9 { background-color: rgb(178, 228, 255); display: block; }
61
+ span.run10 { background-color: rgb(178, 232, 255); display: block; }
62
+ span.run11 { background-color: rgb(178, 234, 255); display: block; }
63
+ span.run12 { background-color: rgb(178, 237, 255); display: block; }
64
+ span.run13 { background-color: rgb(178, 239, 255); display: block; }
65
+ span.run14 { background-color: rgb(178, 242, 255); display: block; }
66
+ span.run15 { background-color: rgb(178, 246, 255); display: block; }
67
+ span.run16 { background-color: rgb(178, 248, 255); display: block; }
68
+ span.run17 { background-color: rgb(178, 251, 255); display: block; }
69
+ span.run18 { background-color: rgb(178, 253, 255); display: block; }
70
+ span.run19 { background-color: rgb(178, 255, 253); display: block; }
71
+ span.run20 { background-color: rgb(178, 255, 249); display: block; }
72
+ span.run21 { background-color: rgb(178, 255, 247); display: block; }
73
+ span.run22 { background-color: rgb(178, 255, 244); display: block; }
74
+ span.run23 { background-color: rgb(178, 255, 242); display: block; }
75
+ span.run24 { background-color: rgb(178, 255, 239); display: block; }
76
+ span.run25 { background-color: rgb(178, 255, 235); display: block; }
77
+ span.run26 { background-color: rgb(178, 255, 233); display: block; }
78
+ span.run27 { background-color: rgb(178, 255, 230); display: block; }
79
+ span.run28 { background-color: rgb(178, 255, 228); display: block; }
80
+ span.run29 { background-color: rgb(178, 255, 225); display: block; }
81
+ span.run30 { background-color: rgb(178, 255, 221); display: block; }
82
+ span.run31 { background-color: rgb(178, 255, 219); display: block; }
83
+ span.run32 { background-color: rgb(178, 255, 216); display: block; }
84
+ span.run33 { background-color: rgb(178, 255, 214); display: block; }
85
+ span.run34 { background-color: rgb(178, 255, 211); display: block; }
86
+ span.run35 { background-color: rgb(178, 255, 207); display: block; }
87
+ span.run36 { background-color: rgb(178, 255, 205); display: block; }
88
+ span.run37 { background-color: rgb(178, 255, 202); display: block; }
89
+ span.run38 { background-color: rgb(178, 255, 200); display: block; }
90
+ span.run39 { background-color: rgb(178, 255, 197); display: block; }
91
+ span.run40 { background-color: rgb(178, 255, 193); display: block; }
92
+ span.run41 { background-color: rgb(178, 255, 191); display: block; }
93
+ span.run42 { background-color: rgb(178, 255, 188); display: block; }
94
+ span.run43 { background-color: rgb(178, 255, 186); display: block; }
95
+ span.run44 { background-color: rgb(178, 255, 183); display: block; }
96
+ span.run45 { background-color: rgb(178, 255, 179); display: block; }
97
+ span.run46 { background-color: rgb(179, 255, 178); display: block; }
98
+ span.run47 { background-color: rgb(182, 255, 178); display: block; }
99
+ span.run48 { background-color: rgb(184, 255, 178); display: block; }
100
+ span.run49 { background-color: rgb(187, 255, 178); display: block; }
101
+ span.run50 { background-color: rgb(191, 255, 178); display: block; }
102
+ span.run51 { background-color: rgb(193, 255, 178); display: block; }
103
+ span.run52 { background-color: rgb(196, 255, 178); display: block; }
104
+ span.run53 { background-color: rgb(198, 255, 178); display: block; }
105
+ span.run54 { background-color: rgb(201, 255, 178); display: block; }
106
+ span.run55 { background-color: rgb(205, 255, 178); display: block; }
107
+ span.run56 { background-color: rgb(207, 255, 178); display: block; }
108
+ span.run57 { background-color: rgb(210, 255, 178); display: block; }
109
+ span.run58 { background-color: rgb(212, 255, 178); display: block; }
110
+ span.run59 { background-color: rgb(215, 255, 178); display: block; }
111
+ span.run60 { background-color: rgb(219, 255, 178); display: block; }
112
+ span.run61 { background-color: rgb(221, 255, 178); display: block; }
113
+ span.run62 { background-color: rgb(224, 255, 178); display: block; }
114
+ span.run63 { background-color: rgb(226, 255, 178); display: block; }
115
+ span.run64 { background-color: rgb(229, 255, 178); display: block; }
116
+ span.run65 { background-color: rgb(233, 255, 178); display: block; }
117
+ span.run66 { background-color: rgb(235, 255, 178); display: block; }
118
+ span.run67 { background-color: rgb(238, 255, 178); display: block; }
119
+ span.run68 { background-color: rgb(240, 255, 178); display: block; }
120
+ span.run69 { background-color: rgb(243, 255, 178); display: block; }
121
+ span.run70 { background-color: rgb(247, 255, 178); display: block; }
122
+ span.run71 { background-color: rgb(249, 255, 178); display: block; }
123
+ span.run72 { background-color: rgb(252, 255, 178); display: block; }
124
+ span.run73 { background-color: rgb(255, 255, 178); display: block; }
125
+ span.run74 { background-color: rgb(255, 252, 178); display: block; }
126
+ span.run75 { background-color: rgb(255, 248, 178); display: block; }
127
+ span.run76 { background-color: rgb(255, 246, 178); display: block; }
128
+ span.run77 { background-color: rgb(255, 243, 178); display: block; }
129
+ span.run78 { background-color: rgb(255, 240, 178); display: block; }
130
+ span.run79 { background-color: rgb(255, 238, 178); display: block; }
131
+ span.run80 { background-color: rgb(255, 234, 178); display: block; }
132
+ span.run81 { background-color: rgb(255, 232, 178); display: block; }
133
+ span.run82 { background-color: rgb(255, 229, 178); display: block; }
134
+ span.run83 { background-color: rgb(255, 226, 178); display: block; }
135
+ span.run84 { background-color: rgb(255, 224, 178); display: block; }
136
+ span.run85 { background-color: rgb(255, 220, 178); display: block; }
137
+ span.run86 { background-color: rgb(255, 218, 178); display: block; }
138
+ span.run87 { background-color: rgb(255, 215, 178); display: block; }
139
+ span.run88 { background-color: rgb(255, 212, 178); display: block; }
140
+ span.run89 { background-color: rgb(255, 210, 178); display: block; }
141
+ span.run90 { background-color: rgb(255, 206, 178); display: block; }
142
+ span.run91 { background-color: rgb(255, 204, 178); display: block; }
143
+ span.run92 { background-color: rgb(255, 201, 178); display: block; }
144
+ span.run93 { background-color: rgb(255, 198, 178); display: block; }
145
+ span.run94 { background-color: rgb(255, 196, 178); display: block; }
146
+ span.run95 { background-color: rgb(255, 192, 178); display: block; }
147
+ span.run96 { background-color: rgb(255, 189, 178); display: block; }
148
+ span.run97 { background-color: rgb(255, 187, 178); display: block; }
149
+ span.run98 { background-color: rgb(255, 184, 178); display: block; }
150
+ span.run99 { background-color: rgb(255, 182, 178); display: block; }
151
+ span.run100 { background-color: rgb(255, 178, 178); display: block; }
152
+ </style>
153
+ </head>
154
+ <body>
155
+ <h3>
156
+ C0 code coverage information
157
+ </h3>
158
+ <p>
159
+ Generated on Sun Dec 21 22:36:24 +0000 2008 with
160
+ <a href='http://eigenclass.org/hiki/rcov'>
161
+ rcov 0.8.1.2
162
+ </a>
163
+ </p>
164
+ <hr />
165
+ <pre><span class='marked0'>Code reported as executed by Ruby looks like
166
+ this... </span><span class='marked1'>and this: this line is also marked as
167
+ covered. </span><span class='inferred0'>Lines considered as run by rcov, but
168
+ not reported by Ruby, look like this, </span><span class='inferred1'>and
169
+ this: these lines were inferred by rcov (using simple heuristics).
170
+ </span><span class='uncovered0'>Finally, here&apos;s a line marked as not
171
+ executed. </span></pre>
172
+ <table class='report'> <thead> <tr> <td class='heading'> Name </td> <td
173
+ class='heading'> Total lines </td> <td class='heading'> Lines of code </td>
174
+ <td class='heading'> Total coverage </td> <td class='heading'> Code coverage
175
+ </td> </tr> </thead> <tbody> <tr class='light'> <td> <a
176
+ href='lib-postalmethods_rb.html'> lib/postalmethods.rb </a> </td> <td
177
+ class='lines_total'> <tt> 71 </tt> </td> <td class='lines_code'> <tt> 52
178
+ </tt> </td> <td> <table cellspacing='0' align='right' cellpadding='0'> <tr>
179
+ <td> <tt class='coverage_total'> 97.2% </tt> &nbsp; </td> <td> <table
180
+ class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
181
+ class='covered' width='97' /> <td class='uncovered' width='3' /> </tr>
182
+ </table> </td> </tr> </table> </td> <td> <table cellspacing='0'
183
+ align='right' cellpadding='0'> <tr> <td> <tt class='coverage_code'> 96.2%
184
+ </tt> &nbsp; </td> <td> <table class='percent_graph' cellspacing='0'
185
+ width='100' cellpadding='0'> <tr> <td class='covered' width='96' /> <td
186
+ class='uncovered' width='4' /> </tr> </table> </td> </tr> </table> </td>
187
+ </tr> </tbody> </table><pre><span class="uncovered1"><a name="line1"></a> 1
188
+ $:.unshift(File.dirname(__FILE__)) unless </span><span class="marked0"><a
189
+ name="line2"></a> 2 $:.include?(File.dirname(__FILE__)) ||
190
+ $:.include?(File.expand_path(File.dirname(__FILE__))) </span><span
191
+ class="inferred1"><a name="line3"></a> 3 </span><span class="marked0"><a
192
+ name="line4"></a> 4 module PostalMethods </span><span class="inferred1"><a
193
+ name="line5"></a> 5 </span><span class="marked0"><a name="line6"></a> 6
194
+ class Client </span><span class="inferred1"><a name="line7"></a> 7
195
+ </span><span class="marked0"><a name="line8"></a> 8 require 'rubygems'
196
+ </span><span class="marked1"><a name="line9"></a> 9 gem 'soap4r'
197
+ </span><span class="marked0"><a name="line10"></a>10 require
198
+ 'soap/rpc/driver' </span><span class="marked1"><a name="line11"></a>11
199
+ require 'soap/wsdlDriver' </span><span class="marked0"><a
200
+ name="line12"></a>12 require 'ruby-debug' </span><span class="inferred1"><a
201
+ name="line13"></a>13 </span><span class="marked0"><a name="line14"></a>14
202
+ VERBOSE=nil # soap4r is a noisy bugger </span><span class="inferred1"><a
203
+ name="line15"></a>15 </span><span class="marked0"><a name="line16"></a>16
204
+ require 'postalmethods/exceptions.rb' </span><span class="marked1"><a
205
+ name="line17"></a>17 require 'postalmethods/document_processor.rb'
206
+ </span><span class="marked0"><a name="line18"></a>18 require
207
+ 'postalmethods/send_letter.rb' </span><span class="marked1"><a
208
+ name="line19"></a>19 require 'postalmethods/get_letter_status.rb'
209
+ </span><span class="marked0"><a name="line20"></a>20 require
210
+ 'postalmethods/utility.rb' </span><span class="inferred1"><a
211
+ name="line21"></a>21 </span><span class="inferred0"><a name="line22"></a>22
212
+ # include modules </span><span class="marked1"><a name="line23"></a>23
213
+ include SendLetter </span><span class="marked0"><a name="line24"></a>24
214
+ include DocumentProcessor </span><span class="marked1"><a
215
+ name="line25"></a>25 include GetLetterStatus </span><span class="marked0"><a
216
+ name="line26"></a>26 include UtilityMethods </span><span
217
+ class="inferred1"><a name="line27"></a>27 </span><span class="marked0"><a
218
+ name="line28"></a>28 attr_accessor :api_uri, :username, :password, :to_send,
219
+ :rpc_driver, :prepared, :work_mode, :valid_work_modes </span><span
220
+ class="inferred1"><a name="line29"></a>29 </span><span class="marked0"><a
221
+ name="line30"></a>30 def initialize(opts = {}) </span><span
222
+ class="marked1"><a name="line31"></a>31 if opts[:username].nil? ||
223
+ opts[:password].nil? </span><span class="marked0"><a name="line32"></a>32
224
+ raise PostalMethods::NoCredentialsException </span><span
225
+ class="inferred1"><a name="line33"></a>33 end </span><span
226
+ class="inferred0"><a name="line34"></a>34 </span><span class="marked1"><a
227
+ name="line35"></a>35 self.valid_work_modes = {:default =&gt;
228
+ &quot;Default&quot;, :production =&gt; &quot;Production&quot;, :development
229
+ =&gt; &quot;Development&quot;} </span><span class="inferred0"><a
230
+ name="line36"></a>36 </span><span class="inferred1"><a name="line37"></a>37
231
+ ## declare here so we can override in tests, etc. </span><span
232
+ class="marked0"><a name="line38"></a>38 self.api_uri =
233
+ &quot;https://api.postalmethods.com/PostalWS.asmx?WSDL&quot; </span><span
234
+ class="inferred1"><a name="line39"></a>39 </span><span class="marked0"><a
235
+ name="line40"></a>40 self.username = opts[:username] </span><span
236
+ class="marked1"><a name="line41"></a>41 self.password = opts[:password]
237
+ </span><span class="inferred0"><a name="line42"></a>42 </span><span
238
+ class="marked1"><a name="line43"></a>43 self.work_mode =
239
+ (opts[:work_mode].nil? ? &quot;default&quot; : opts[:work_mode])
240
+ </span><span class="inferred0"><a name="line44"></a>44 end </span><span
241
+ class="inferred1"><a name="line45"></a>45 </span><span class="marked0"><a
242
+ name="line46"></a>46 def prepare! </span><span class="marked1"><a
243
+ name="line47"></a>47 begin </span><span class="marked0"><a
244
+ name="line48"></a>48 self.rpc_driver ||=
245
+ SOAP::WSDLDriverFactory.new(self.api_uri).create_rpc_driver </span><span
246
+ class="inferred1"><a name="line49"></a>49 rescue SocketError, RuntimeError
247
+ </span><span class="marked0"><a name="line50"></a>50 raise
248
+ PostalMethods::NoConnectionError </span><span class="inferred1"><a
249
+ name="line51"></a>51 end </span><span class="marked0"><a
250
+ name="line52"></a>52 self.prepared = true </span><span class="marked1"><a
251
+ name="line53"></a>53 return self </span><span class="inferred0"><a
252
+ name="line54"></a>54 end </span><span class="inferred1"><a
253
+ name="line55"></a>55 </span><span class="marked0"><a name="line56"></a>56
254
+ def work_mode=(in_mode=&quot;default&quot;) </span><span class="marked1"><a
255
+ name="line57"></a>57 mode = in_mode.to_s.downcase.to_sym </span><span
256
+ class="inferred0"><a name="line58"></a>58 </span><span class="marked1"><a
257
+ name="line59"></a>59 if self.valid_work_modes[mode].nil? </span><span
258
+ class="uncovered0"><a name="line60"></a>60 @work_mode = :default
259
+ </span><span class="inferred1"><a name="line61"></a>61 else </span><span
260
+ class="marked0"><a name="line62"></a>62 @work_mode = mode </span><span
261
+ class="inferred1"><a name="line63"></a>63 end </span><span
262
+ class="inferred0"><a name="line64"></a>64 end </span><span
263
+ class="inferred1"><a name="line65"></a>65 </span><span class="marked0"><a
264
+ name="line66"></a>66 def work_mode </span><span class="marked1"><a
265
+ name="line67"></a>67 return self.valid_work_modes[@work_mode] </span><span
266
+ class="inferred0"><a name="line68"></a>68 end </span><span
267
+ class="inferred1"><a name="line69"></a>69 </span><span class="inferred0"><a
268
+ name="line70"></a>70 end </span><span class="inferred1"><a
269
+ name="line71"></a>71 end </span></pre>
270
+ <hr />
271
+ <p> Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'> rcov
272
+ code coverage analysis tool for Ruby </a> version 0.8.1.2. </p>
273
+ <p>
274
+ <a href='http://validator.w3.org/check/referer'>
275
+ <img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88' />
276
+ </a>
277
+ <a href='http://jigsaw.w3.org/css-validator/check/referer'>
278
+ <img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px' />
279
+ </a>
280
+ </p>
281
+ </body>
282
+ </html>
@@ -8,11 +8,11 @@ module PostalMethods
8
8
  ## get status
9
9
  opts = {:Username => self.username, :Password => self.password, :ID => id}
10
10
 
11
- rv = @rpc_driver.getLetterStatus(opts)
11
+ rv = @rpc_driver.getLetterStatusV2(opts)
12
12
 
13
- ws_status = rv.getLetterStatusResult.resultCode.to_i
14
- delivery_status = rv.getLetterStatusResult.status.to_i
15
- last_update = rv.getLetterStatusResult.lastUpdateTime
13
+ ws_status = rv.getLetterStatusV2Result.resultCode.to_i
14
+ delivery_status = rv.getLetterStatusV2Result.status.to_i
15
+ last_update = rv.getLetterStatusV2Result.lastUpdateTime
16
16
 
17
17
  if ws_status == -3000
18
18
  return [delivery_status, last_update]
@@ -35,12 +35,11 @@ module PostalMethods
35
35
  ## get status
36
36
  opts = {:Username => self.username, :Password => self.password, :ID => ids}
37
37
 
38
- rv = @rpc_driver.getLetterStatus_Multiple(opts)
39
-
40
- ws_status = rv.getLetterStatus_MultipleResult.resultCode.to_i
38
+ rv = @rpc_driver.getLetterStatusV2_Multiple(opts)
39
+ ws_status = rv.getLetterStatusV2_MultipleResult.resultCode.to_i
41
40
 
42
41
  if ws_status == -3000
43
- return rv.getLetterStatus_MultipleResult.letterStatuses.letterStatus
42
+ return rv.getLetterStatusV2_MultipleResult.letterStatuses.letterStatusAndDesc
44
43
  elsif API_STATUS_CODES.has_key?(ws_status)
45
44
  instance_eval("raise APIStatusCode#{ws_status.to_s.gsub(/( |\-)/,'')}Exception")
46
45
  end
@@ -53,12 +52,12 @@ module PostalMethods
53
52
  ## get status
54
53
  opts = {:Username => self.username, :Password => self.password, :MinID => minid.to_i, :MaxID => maxid.to_i}
55
54
 
56
- rv = @rpc_driver.getLetterStatus_Range(opts)
55
+ rv = @rpc_driver.getLetterStatusV2_Range(opts)
57
56
 
58
- ws_status = rv.getLetterStatus_RangeResult.resultCode.to_i
57
+ ws_status = rv.getLetterStatusV2_RangeResult.resultCode.to_i
59
58
 
60
59
  if ws_status == -3000
61
- return rv.getLetterStatus_RangeResult.letterStatuses.letterStatus
60
+ return rv.getLetterStatusV2_RangeResult.letterStatuses.letterStatusAndDesc
62
61
  elsif API_STATUS_CODES.has_key?(ws_status)
63
62
  instance_eval("raise APIStatusCode#{ws_status.to_s.gsub(/( |\-)/,'')}Exception")
64
63
  end
@@ -2,14 +2,17 @@ module PostalMethods
2
2
 
3
3
  module SendLetter
4
4
 
5
- def send_letter(doc, description)
5
+ def send_letter(doc, description, work_mode = "")
6
6
  raise PostalMethods::NoPreparationException unless self.prepared
7
7
  ## push a letter over the api
8
+
9
+
10
+
8
11
  self.document = doc
9
- rv = @rpc_driver.sendLetter(:Username => self.username, :Password => self.password, :FileExtension => self.document[:extension],
10
- :FileBinaryData => self.document[:bytes], :MyDescription => description)
12
+ rv = @rpc_driver.sendLetterV2(:Username => self.username, :Password => self.password, :FileExtension => self.document[:extension],
13
+ :FileBinaryData => self.document[:bytes], :MyDescription => description, :WorkMode => self.work_mode)
11
14
 
12
- status_code = rv.sendLetterResult.to_i
15
+ status_code = rv.sendLetterV2Result.to_i
13
16
 
14
17
  if status_code > 0
15
18
  return status_code
@@ -26,13 +29,13 @@ module PostalMethods
26
29
  self.document = doc
27
30
 
28
31
  opts = {:Username => self.username, :Password => self.password, :FileExtension => self.document[:extension],
29
- :FileBinaryData => self.document[:bytes], :MyDescription => description}
32
+ :FileBinaryData => self.document[:bytes], :MyDescription => description, :WorkMode => self.work_mode}
30
33
 
31
34
  opts.merge!(address)
32
35
 
33
36
  ## push a letter over the api
34
- rv = @rpc_driver.sendLetterAndAddress(opts)
35
- status_code = rv.sendLetterAndAddressResult.to_i
37
+ rv = @rpc_driver.sendLetterAndAddressV2(opts)
38
+ status_code = rv.sendLetterAndAddressV2Result.to_i
36
39
 
37
40
  if status_code > 0
38
41
  return status_code
@@ -8,13 +8,14 @@ module PostalMethods
8
8
  raise PostalMethods::NoPreparationException unless self.prepared
9
9
 
10
10
  ## get a letter as pdf over the wire
11
- rv = @rpc_driver.getLetterDetails(:Username => self.username, :Password => self.password, :ID => id)
11
+ rv = @rpc_driver.getLetterDetailsV2(:Username => self.username, :Password => self.password, :ID => id)
12
12
 
13
- status_code = rv.getLetterDetailsResult.resultCode.to_i
14
- letter_data = rv.getLetterDetailsResult
13
+ status_code = rv.getLetterDetailsV2Result.resultCode.to_i
14
+ letter_data = rv.getLetterDetailsV2Result
15
+ work_mode = rv.getLetterDetailsV2Result.workMode.to_s
15
16
 
16
17
  if status_code == -3000 # successfully received the req
17
- return [letter_data, status_code]
18
+ return [letter_data, status_code, work_mode]
18
19
  elsif API_STATUS_CODES.has_key?(status_code)
19
20
  instance_eval("raise APIStatusCode#{status_code.to_s.gsub(/( |\-)/,'')}Exception")
20
21
  end
@@ -1,8 +1,8 @@
1
- module Postalmethods
1
+ module PostalMethods
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 0
5
- TINY = 1
4
+ MINOR = 1
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/postalmethods.rb CHANGED
@@ -4,37 +4,45 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  module PostalMethods
5
5
 
6
6
  class Client
7
-
7
+
8
8
  require 'rubygems'
9
9
  gem 'soap4r'
10
10
  require 'soap/rpc/driver'
11
11
  require 'soap/wsdlDriver'
12
-
12
+ require 'ruby-debug'
13
+
14
+ VERBOSE=nil # soap4r is a noisy bugger
15
+
13
16
  require 'postalmethods/exceptions.rb'
14
17
  require 'postalmethods/document_processor.rb'
15
18
  require 'postalmethods/send_letter.rb'
16
19
  require 'postalmethods/get_letter_status.rb'
17
20
  require 'postalmethods/utility.rb'
18
-
21
+ require 'postalmethods/version.rb'
19
22
 
20
23
  # include modules
24
+ include VERSION
21
25
  include SendLetter
22
26
  include DocumentProcessor
23
27
  include GetLetterStatus
24
28
  include UtilityMethods
25
29
 
26
- attr_accessor :api_uri, :username, :password, :to_send, :rpc_driver, :prepared
30
+ attr_accessor :api_uri, :username, :password, :to_send, :rpc_driver, :prepared, :work_mode, :valid_work_modes
27
31
 
28
32
  def initialize(opts = {})
29
33
  if opts[:username].nil? || opts[:password].nil?
30
34
  raise PostalMethods::NoCredentialsException
31
35
  end
32
36
 
37
+ self.valid_work_modes = {:default => "Default", :production => "Production", :development => "Development"}
38
+
33
39
  ## declare here so we can override in tests, etc.
34
40
  self.api_uri = "https://api.postalmethods.com/PostalWS.asmx?WSDL"
35
41
 
36
42
  self.username = opts[:username]
37
43
  self.password = opts[:password]
44
+
45
+ self.work_mode = (opts[:work_mode].nil? ? "default" : opts[:work_mode])
38
46
  end
39
47
 
40
48
  def prepare!
@@ -47,5 +55,19 @@ module PostalMethods
47
55
  return self
48
56
  end
49
57
 
58
+ def work_mode=(in_mode="default")
59
+ mode = in_mode.to_s.downcase.to_sym
60
+
61
+ if self.valid_work_modes[mode].nil?
62
+ @work_mode = :default
63
+ else
64
+ @work_mode = mode
65
+ end
66
+ end
67
+
68
+ def work_mode
69
+ return self.valid_work_modes[@work_mode]
70
+ end
71
+
50
72
  end
51
73
  end
@@ -0,0 +1,36 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{postalmethods}
3
+ s.version = "1.1.0"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["James Cox"]
7
+ s.date = %q{2008-12-22}
8
+ s.description = %q{API wrapper library for the postal methods api.}
9
+ s.email = ["james@imaj.es"]
10
+ s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "README.txt"]
11
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "coverage/index.html", "coverage/lib-postalmethods-document_processor_rb.html", "coverage/lib-postalmethods-exceptions_rb.html", "coverage/lib-postalmethods-get_letter_status_rb.html", "coverage/lib-postalmethods-send_letter_rb.html", "coverage/lib-postalmethods-utility_rb.html", "coverage/lib-postalmethods_rb.html", "lib/postalmethods.rb", "lib/postalmethods/document_processor.rb", "lib/postalmethods/exceptions.rb", "lib/postalmethods/get_letter_status.rb", "lib/postalmethods/send_letter.rb", "lib/postalmethods/utility.rb", "lib/postalmethods/version.rb", "postalmethods.gemspec", "script/console", "script/destroy", "script/generate", "setup.rb", "spec/doc/WSDL-Output", "spec/doc/default.rb", "spec/doc/defaultMappingRegistry.rb", "spec/doc/sample.pdf", "spec/document_processor_spec.rb", "spec/get_letter_status_spec.rb", "spec/postalmethods_spec.rb", "spec/rcov.opts", "spec/send_letter_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/utility_spec.rb", "tasks/rspec.rake"]
12
+ s.has_rdoc = true
13
+ s.homepage = %q{Info: http://www.postalmethods.com/resources/quickstart}
14
+ s.post_install_message = %q{PostInstall.txt}
15
+ s.rdoc_options = ["--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{postalmethods}
18
+ s.rubygems_version = %q{1.2.0}
19
+ s.summary = %q{API wrapper library for the postal methods api.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
24
+
25
+ if current_version >= 3 then
26
+ s.add_development_dependency(%q<newgem>, [">= 1.2.1"])
27
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
28
+ else
29
+ s.add_dependency(%q<newgem>, [">= 1.2.1"])
30
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<newgem>, [">= 1.2.1"])
34
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
35
+ end
36
+ end