active_shipping 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -71,9 +71,8 @@ module ActiveMerchant
71
71
  end
72
72
 
73
73
  info "--> %d %s (%d %.4fs)" % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
74
- response = handle_response(result)
75
- debug response
76
- response
74
+ debug result.body
75
+ result
77
76
  rescue EOFError => e
78
77
  raise ConnectionError, "The remote server dropped the connection"
79
78
  rescue Errno::ECONNRESET => e
@@ -147,15 +146,6 @@ module ActiveMerchant
147
146
  end
148
147
  end
149
148
 
150
- def handle_response(response)
151
- case response.code.to_i
152
- when 200...300
153
- response.body
154
- else
155
- raise ResponseError.new(response)
156
- end
157
- end
158
-
159
149
  def debug(message, tag = nil)
160
150
  log(:debug, message, tag)
161
151
  end
@@ -169,4 +159,4 @@ module ActiveMerchant
169
159
  logger.send(level, message) if logger
170
160
  end
171
161
  end
172
- end
162
+ end
@@ -46,7 +46,16 @@ module ActiveMerchant #:nodoc:
46
46
  end
47
47
 
48
48
  def code(format)
49
- @codes.select{|c| c.format == format}
49
+ @codes.detect{|c| c.format == format}
50
+ end
51
+
52
+ def ==(other)
53
+ (@name == other.name)
54
+ end
55
+ alias eql? ==
56
+
57
+ def hash
58
+ @name.hash
50
59
  end
51
60
 
52
61
  def to_s
@@ -67,7 +76,6 @@ module ActiveMerchant #:nodoc:
67
76
  { :alpha2 => 'AW', :name => 'Aruba', :alpha3 => 'ABW', :numeric => '533' },
68
77
  { :alpha2 => 'AU', :name => 'Australia', :alpha3 => 'AUS', :numeric => '036' },
69
78
  { :alpha2 => 'AT', :name => 'Austria', :alpha3 => 'AUT', :numeric => '040' },
70
- { :alpha2 => 'AX', :name => 'Åland Islands', :alpha3 => 'ALA', :numeric => '248' },
71
79
  { :alpha2 => 'AZ', :name => 'Azerbaijan', :alpha3 => 'AZE', :numeric => '031' },
72
80
  { :alpha2 => 'BS', :name => 'Bahamas', :alpha3 => 'BHS', :numeric => '044' },
73
81
  { :alpha2 => 'BH', :name => 'Bahrain', :alpha3 => 'BHR', :numeric => '048' },
@@ -84,8 +92,8 @@ module ActiveMerchant #:nodoc:
84
92
  { :alpha2 => 'BW', :name => 'Botswana', :alpha3 => 'BWA', :numeric => '072' },
85
93
  { :alpha2 => 'BV', :name => 'Bouvet Island', :alpha3 => 'BVD', :numeric => '074' },
86
94
  { :alpha2 => 'BR', :name => 'Brazil', :alpha3 => 'BRA', :numeric => '076' },
87
- { :alpha2 => 'BN', :name => 'Brunei Darussalam', :alpha3 => 'BRN', :numeric => '096' },
88
95
  { :alpha2 => 'IO', :name => 'British Indian Ocean Territory', :alpha3 => 'IOT', :numeric => '086' },
96
+ { :alpha2 => 'BN', :name => 'Brunei Darussalam', :alpha3 => 'BRN', :numeric => '096' },
89
97
  { :alpha2 => 'BG', :name => 'Bulgaria', :alpha3 => 'BGR', :numeric => '100' },
90
98
  { :alpha2 => 'BF', :name => 'Burkina Faso', :alpha3 => 'BFA', :numeric => '854' },
91
99
  { :alpha2 => 'BI', :name => 'Burundi', :alpha3 => 'BDI', :numeric => '108' },
@@ -142,15 +150,15 @@ module ActiveMerchant #:nodoc:
142
150
  { :alpha2 => 'GP', :name => 'Guadeloupe', :alpha3 => 'GLP', :numeric => '312' },
143
151
  { :alpha2 => 'GU', :name => 'Guam', :alpha3 => 'GUM', :numeric => '316' },
144
152
  { :alpha2 => 'GT', :name => 'Guatemala', :alpha3 => 'GTM', :numeric => '320' },
153
+ { :alpha2 => 'GG', :name => 'Guernsey', :alpha3 => 'GGY', :numeric => '831' },
145
154
  { :alpha2 => 'GN', :name => 'Guinea', :alpha3 => 'GIN', :numeric => '324' },
146
155
  { :alpha2 => 'GW', :name => 'Guinea-Bissau', :alpha3 => 'GNB', :numeric => '624' },
147
156
  { :alpha2 => 'GY', :name => 'Guyana', :alpha3 => 'GUY', :numeric => '328' },
148
- { :alpha2 => 'GG', :name => 'Guernsey', :alpha3 => 'GGY', :numeric => '831' },
149
157
  { :alpha2 => 'HT', :name => 'Haiti', :alpha3 => 'HTI', :numeric => '332' },
158
+ { :alpha2 => 'HM', :name => 'Heard Island And Mcdonald Islands', :alpha3 => 'HMD', :numeric => '334' },
150
159
  { :alpha2 => 'VA', :name => 'Holy See (Vatican City State)', :alpha3 => 'VAT', :numeric => '336' },
151
160
  { :alpha2 => 'HN', :name => 'Honduras', :alpha3 => 'HND', :numeric => '340' },
152
161
  { :alpha2 => 'HK', :name => 'Hong Kong', :alpha3 => 'HKG', :numeric => '344' },
153
- { :alpha2 => 'HM', :name => 'Heard Island And Mcdonald Islands', :alpha3 => 'HMD', :numeric => '334' },
154
162
  { :alpha2 => 'HU', :name => 'Hungary', :alpha3 => 'HUN', :numeric => '348' },
155
163
  { :alpha2 => 'IS', :name => 'Iceland', :alpha3 => 'ISL', :numeric => '352' },
156
164
  { :alpha2 => 'IN', :name => 'India', :alpha3 => 'IND', :numeric => '356' },
@@ -298,7 +306,8 @@ module ActiveMerchant #:nodoc:
298
306
  { :alpha2 => 'EH', :name => 'Western Sahara', :alpha3 => 'ESH', :numeric => '732' },
299
307
  { :alpha2 => 'YE', :name => 'Yemen', :alpha3 => 'YEM', :numeric => '887' },
300
308
  { :alpha2 => 'ZM', :name => 'Zambia', :alpha3 => 'ZMB', :numeric => '894' },
301
- { :alpha2 => 'ZW', :name => 'Zimbabwe', :alpha3 => 'ZWE', :numeric => '716' }
309
+ { :alpha2 => 'ZW', :name => 'Zimbabwe', :alpha3 => 'ZWE', :numeric => '716' },
310
+ { :alpha2 => 'AX', :name => 'Åland Islands', :alpha3 => 'ALA', :numeric => '248' }
302
311
  ]
303
312
 
304
313
  def self.find(name)
@@ -25,9 +25,12 @@ module ActiveMerchant #:nodoc:
25
25
  def ssl_post(endpoint, data, headers = {})
26
26
  ssl_request(:post, endpoint, data, headers)
27
27
  end
28
-
29
- private
30
- def ssl_request(method, endpoint, data, headers = {})
28
+
29
+ def ssl_request(method, endpoint, data, headers)
30
+ handle_response(raw_ssl_request(method, endpoint, data, headers))
31
+ end
32
+
33
+ def raw_ssl_request(method, endpoint, data, headers = {})
31
34
  connection = Connection.new(endpoint)
32
35
  connection.open_timeout = open_timeout
33
36
  connection.read_timeout = read_timeout
@@ -42,6 +45,17 @@ module ActiveMerchant #:nodoc:
42
45
 
43
46
  connection.request(method, data, headers)
44
47
  end
48
+
49
+ private
50
+
51
+ def handle_response(response)
52
+ case response.code.to_i
53
+ when 200...300
54
+ response.body
55
+ else
56
+ raise ResponseError.new(response)
57
+ end
58
+ end
45
59
 
46
60
  end
47
- end
61
+ end
@@ -242,7 +242,7 @@ module ActiveMerchant
242
242
  # package.options[:mail_type] -- one of [:package, :postcard, :matter_for_the_blind, :envelope].
243
243
  # Defaults to :package.
244
244
  def build_world_rate_request(packages, destination_country)
245
- country = COUNTRY_NAME_CONVERSIONS[destination_country.code(:alpha2).first.value] || destination_country.name
245
+ country = COUNTRY_NAME_CONVERSIONS[destination_country.code(:alpha2).value] || destination_country.name
246
246
  request = XmlNode.new('IntlRateRequest', :USERID => @options[:login]) do |rate_request|
247
247
  packages.each_index do |id|
248
248
  p = packages[id]
@@ -70,7 +70,7 @@ module ActiveMerchant #:nodoc:
70
70
  end
71
71
 
72
72
  def country_code(format = :alpha2)
73
- @country.nil? ? nil : @country.code(format).first.value
73
+ @country.nil? ? nil : @country.code(format).value
74
74
  end
75
75
 
76
76
  def residential?; (@address_type == 'residential') end
@@ -1,3 +1,3 @@
1
1
  module ActiveShipping
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shipping
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 3
10
- version: 0.9.3
9
+ - 4
10
+ version: 0.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - James MacAulay
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-09-21 00:00:00 -04:00
21
+ date: 2010-12-17 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency