shipping 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -135,6 +135,12 @@
135
135
  </div>
136
136
 
137
137
  <div class="method-description">
138
+ <p>
139
+ For current implementation docs, see <a
140
+ href="http://www.ec.ups.com/ecommerce/techdocs/pdf/RatesandServiceHTML.pdf">www.ec.ups.com/ecommerce/techdocs/pdf/RatesandServiceHTML.pdf</a>
141
+ For upcoming XML implementation docs, see <a
142
+ href="http://www.ups.com/gec/techdocs/pdf/dtk_RateXML_V1.zip">www.ups.com/gec/techdocs/pdf/dtk_RateXML_V1.zip</a>
143
+ </p>
138
144
  </div>
139
145
  </div>
140
146
 
@@ -149,6 +155,11 @@
149
155
  </div>
150
156
 
151
157
  <div class="method-description">
158
+ <p>
159
+ See <a
160
+ href="http://www.ups.com/gec/techdocs/pdf/dtk_AddrValidateXML_V1.zip">www.ups.com/gec/techdocs/pdf/dtk_AddrValidateXML_V1.zip</a>
161
+ for API info
162
+ </p>
152
163
  </div>
153
164
  </div>
154
165
 
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line 27</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line 29</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">price</span>
15
15
  <span class="ruby-ivar">@required</span> = [<span class="ruby-identifier">:zip</span>, <span class="ruby-identifier">:country</span>, <span class="ruby-identifier">:sender_zip</span>, <span class="ruby-identifier">:weight</span>]
16
16
 
@@ -10,39 +10,40 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line 45</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line 49</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid_address?</span>( <span class="ruby-identifier">delta</span> = <span class="ruby-value">1.0</span> )
15
15
  <span class="ruby-ivar">@required</span> = [<span class="ruby-identifier">:ups_account</span>, <span class="ruby-identifier">:ups_user</span>, <span class="ruby-identifier">:ups_password</span>]
16
16
 
17
17
  <span class="ruby-identifier">state</span> = <span class="ruby-constant">STATES</span>.<span class="ruby-identifier">has_value?</span>(<span class="ruby-ivar">@state</span>.<span class="ruby-identifier">downcase</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">STATES</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@state</span>.<span class="ruby-identifier">downcase</span>) <span class="ruby-operator">:</span> <span class="ruby-ivar">@state</span>
18
18
 
19
- <span class="ruby-ivar">@data</span> = <span class="ruby-node">&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;
20
- &lt;AccessRequest&gt;
21
- &lt;AccessLicenseNumber&gt;#{@ups_account}&lt;/AccessLicenseNumber&gt;
22
- &lt;UserId&gt;#{@ups_user}&lt;/UserId&gt;
23
- &lt;Password&gt;#{@ups_password}&lt;/Password&gt;
24
- &lt;/AccessRequest&gt;
25
- &lt;?xml version=\&quot;1.0\&quot;?&gt;
26
- &lt;AddressValidationRequest xml:lang=\&quot;en-US\&quot;&gt;
27
- &lt;Request&gt;
28
- &lt;TransactionReference&gt;
29
- &lt;CustomerContext&gt;#{@city}, #{state} #{@zip}&lt;/CustomerContext&gt;
30
- &lt;XpciVersion&gt;#{API_VERSION}&lt;/XpciVersion&gt;
31
- &lt;/TransactionReference&gt;
32
- &lt;RequestAction&gt;AV&lt;/RequestAction&gt;
33
- &lt;/Request&gt;
34
- &lt;Address&gt;
35
- &lt;City&gt;#{@city}&lt;/City&gt;
36
- &lt;StateProvinceCode&gt;#{state}&lt;/StateProvinceCode&gt;
37
- &lt;PostalCode&gt;#{@zip}&lt;/PostalCode&gt;
38
- &lt;/Address&gt;
39
- &lt;/AddressValidationRequest&gt;&quot;</span>
40
-
19
+ <span class="ruby-ivar">@data</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
20
+ <span class="ruby-identifier">b</span> = <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">:target</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@data</span>
21
+
22
+ <span class="ruby-identifier">b</span>.<span class="ruby-identifier">instruct!</span>
23
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">AccessRequest</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
24
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">AccessLicenseNumber</span> <span class="ruby-ivar">@ups_account</span>
25
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">UserId</span> <span class="ruby-ivar">@ups_user</span>
26
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">Password</span> <span class="ruby-ivar">@ups_password</span>
27
+ }
28
+ <span class="ruby-identifier">b</span>.<span class="ruby-identifier">instruct!</span>
29
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">AddressValidationRequest</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
30
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">Request</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
31
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">RequestAction</span> <span class="ruby-value str">&quot;AV&quot;</span>
32
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">TransactionReference</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
33
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">CustomerContext</span> <span class="ruby-node">&quot;#{@city}, #{state} #{@zip}&quot;</span>
34
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">XpciVersion</span> <span class="ruby-constant">API_VERSION</span>
35
+ }
36
+ }
37
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">Address</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
38
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">City</span> <span class="ruby-ivar">@city</span>
39
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">StateProvinceCode</span> <span class="ruby-identifier">state</span>
40
+ <span class="ruby-identifier">b</span>.<span class="ruby-constant">PostalCode</span> <span class="ruby-ivar">@zip</span>
41
+ }
42
+ }
43
+
41
44
  <span class="ruby-identifier">get_response</span> <span class="ruby-value str">&quot;https://wwwcie.ups.com/ups.app/xml/AV&quot;</span>
42
-
43
- <span class="ruby-identifier">doc</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@response</span>)
44
-
45
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;Response&quot;</span>].<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;ResponseStatusCode&quot;</span>].<span class="ruby-identifier">text</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;1&quot;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;AddressValidationResult&quot;</span>].<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;Quality&quot;</span>].<span class="ruby-identifier">text</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">delta</span>
45
+
46
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-ivar">@response</span>, <span class="ruby-value str">&quot;//AddressValidationResponse/Response/ResponseStatusCode&quot;</span>).<span class="ruby-identifier">text</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;1&quot;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-ivar">@response</span>, <span class="ruby-value str">&quot;//AddressValidationResponse/AddressValidationResult/Quality&quot;</span>).<span class="ruby-identifier">text</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">delta</span>
46
47
  <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
47
48
  <span class="ruby-keyword kw">else</span>
48
49
  <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
@@ -92,6 +92,11 @@
92
92
 
93
93
  </td></tr>
94
94
  </table>
95
+ <p>
96
+ See <a
97
+ href="http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf?link=4">www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf?link=4</a>
98
+ for the full XML-based API
99
+ </p>
95
100
 
96
101
  </div>
97
102
 
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Wed Apr 27 10:27:35 PDT 2005
1
+ Thu Jun 02 02:00:08 PDT 2005
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Apr 27 10:27:08 PDT 2005</td>
59
+ <td>Wed May 04 21:14:50 PDT 2005</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Apr 26 21:05:50 PDT 2005</td>
59
+ <td>Fri May 13 04:18:08 PDT 2005</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Apr 26 21:13:48 PDT 2005</td>
59
+ <td>Thu Jun 02 01:41:40 PDT 2005</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -80,6 +80,11 @@
80
80
 
81
81
  </td></tr>
82
82
  </table>
83
+ <p>
84
+ See <a
85
+ href="http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf?link=4">www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf?link=4</a>
86
+ for the full XML-based API
87
+ </p>
83
88
 
84
89
  </div>
85
90
 
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Apr 26 19:18:32 PDT 2005</td>
59
+ <td>Thu Jun 02 01:33:58 PDT 2005</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Apr 26 19:18:53 PDT 2005</td>
59
+ <td>Fri May 13 01:21:56 PDT 2005</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -87,6 +87,8 @@
87
87
  <h3 class="section-bar">Required files</h3>
88
88
 
89
89
  <div class="name-list">
90
+ rubygems&nbsp;&nbsp;
91
+ builder&nbsp;&nbsp;
90
92
  yaml&nbsp;&nbsp;
91
93
  rexml/document&nbsp;&nbsp;
92
94
  net/http&nbsp;&nbsp;
@@ -21,11 +21,14 @@
21
21
  <h1 class="section-bar">Methods</h1>
22
22
  <div id="index-entries">
23
23
  <a href="classes/Shipping/FedEx.html#M000004">base_price (Shipping::FedEx)</a><br />
24
- <a href="classes/Shipping/Base.html#M000006">fedex (Shipping::Base)</a><br />
25
- <a href="classes/Shipping/Base.html#M000005">new (Shipping::Base)</a><br />
26
- <a href="classes/Shipping/UPS.html#M000001">price (Shipping::UPS)</a><br />
24
+ <a href="classes/Shipping/FedEx.html#M000005">express_service_availability (Shipping::FedEx)</a><br />
25
+ <a href="classes/Shipping/Base.html#M000009">fedex (Shipping::Base)</a><br />
26
+ <a href="classes/Shipping/FedEx.html#M000007">label (Shipping::FedEx)</a><br />
27
+ <a href="classes/Shipping/Base.html#M000008">new (Shipping::Base)</a><br />
27
28
  <a href="classes/Shipping/FedEx.html#M000003">price (Shipping::FedEx)</a><br />
28
- <a href="classes/Shipping/Base.html#M000007">ups (Shipping::Base)</a><br />
29
+ <a href="classes/Shipping/UPS.html#M000001">price (Shipping::UPS)</a><br />
30
+ <a href="classes/Shipping/FedEx.html#M000006">register (Shipping::FedEx)</a><br />
31
+ <a href="classes/Shipping/Base.html#M000010">ups (Shipping::Base)</a><br />
29
32
  <a href="classes/Shipping/UPS.html#M000002">valid_address? (Shipping::UPS)</a><br />
30
33
  </div>
31
34
  </div>
data/lib/shipping/base.rb CHANGED
@@ -3,20 +3,22 @@
3
3
  # License:: LGPL
4
4
 
5
5
  module Shipping
6
- class ShippingError < StandardError; end
6
+ class ShippingError < StandardError; end
7
7
 
8
8
  class Base
9
- attr_reader :data, :response, :required
9
+ attr_reader :data, :response, :plain_response, :required
10
10
 
11
11
  attr_writer :ups_account, :ups_user, :ups_password
12
12
  attr_writer :fedex_account, :fedex_meter, :fedex_url
13
13
 
14
- attr_accessor :city, :state, :zip, :country
15
- attr_accessor :sender_city, :sender_state, :sender_zip, :sender_country
14
+ attr_accessor :name, :phone, :email, :address, :city, :state, :zip, :country
15
+ attr_accessor :sender_name, :sender_phone, :sender_email, :sender_address, :sender_city, :sender_state, :sender_zip, :sender_country
16
16
 
17
- attr_accessor :weight, :weight_units, :insured_value, :declared_value, :transaction_type
17
+ attr_accessor :weight, :weight_units, :insured_value, :declared_value, :transaction_type, :description
18
18
  attr_accessor :package_total, :packaging_type, :service_type
19
19
 
20
+ attr_accessor :ship_date, :dropoff_type, :pay_type, :currency_code
21
+
20
22
  def initialize(options = {})
21
23
  prefs = File.expand_path(options[:prefs] || "~/.shipping.yml")
22
24
  YAML.load(File.open(prefs)).each {|pref, value| eval("@#{pref} = #{value.inspect}")} if File.exists?(prefs)
@@ -26,7 +28,7 @@ module Shipping
26
28
  # include all provided data
27
29
  options.each do |method, value|
28
30
  instance_variable_set("@#{method}", value)
29
- end
31
+ end
30
32
  end
31
33
 
32
34
  # Initializes an instance of Shipping::FedEx with the same instance variables as the base object
@@ -55,7 +57,11 @@ module Shipping
55
57
  http.use_ssl = true
56
58
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
57
59
  end
58
- @response = http.post(uri.path, @data).body
60
+ @response_plain = http.post(uri.path, @data).body
61
+ @response = @response_plain.include?('<?xml') ? REXML::Document.new(@response_plain) : @response_plain
62
+
63
+ @response.instance_variable_set "@response_plain", @response_plain
64
+ def @response.plain; @response_plain; end
59
65
  end
60
66
 
61
67
  # Make sure that the required fields are not empty