shippinglogic 1.2.3

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.
Files changed (74) hide show
  1. data/.document +5 -0
  2. data/CHANGELOG.rdoc +55 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +175 -0
  5. data/Rakefile +37 -0
  6. data/VERSION.yml +5 -0
  7. data/init.rb +1 -0
  8. data/lib/shippinglogic.rb +3 -0
  9. data/lib/shippinglogic/attributes.rb +121 -0
  10. data/lib/shippinglogic/error.rb +22 -0
  11. data/lib/shippinglogic/fedex.rb +84 -0
  12. data/lib/shippinglogic/fedex/cancel.rb +47 -0
  13. data/lib/shippinglogic/fedex/enumerations.rb +348 -0
  14. data/lib/shippinglogic/fedex/error.rb +47 -0
  15. data/lib/shippinglogic/fedex/rate.rb +229 -0
  16. data/lib/shippinglogic/fedex/request.rb +134 -0
  17. data/lib/shippinglogic/fedex/response.rb +72 -0
  18. data/lib/shippinglogic/fedex/service.rb +11 -0
  19. data/lib/shippinglogic/fedex/ship.rb +238 -0
  20. data/lib/shippinglogic/fedex/signature.rb +68 -0
  21. data/lib/shippinglogic/fedex/track.rb +124 -0
  22. data/lib/shippinglogic/proxy.rb +23 -0
  23. data/lib/shippinglogic/service.rb +42 -0
  24. data/lib/shippinglogic/ups.rb +83 -0
  25. data/lib/shippinglogic/ups/cancel.rb +52 -0
  26. data/lib/shippinglogic/ups/enumerations.rb +56 -0
  27. data/lib/shippinglogic/ups/error.rb +42 -0
  28. data/lib/shippinglogic/ups/label.rb +50 -0
  29. data/lib/shippinglogic/ups/rate.rb +228 -0
  30. data/lib/shippinglogic/ups/request.rb +49 -0
  31. data/lib/shippinglogic/ups/response.rb +58 -0
  32. data/lib/shippinglogic/ups/service.rb +11 -0
  33. data/lib/shippinglogic/ups/ship_accept.rb +53 -0
  34. data/lib/shippinglogic/ups/ship_confirm.rb +170 -0
  35. data/lib/shippinglogic/ups/track.rb +118 -0
  36. data/lib/shippinglogic/validation.rb +32 -0
  37. data/shippinglogic.gemspec +120 -0
  38. data/spec/attributes_spec.rb +67 -0
  39. data/spec/config/fedex_credentials.example.yml +4 -0
  40. data/spec/config/ups_credentials.example.yml +3 -0
  41. data/spec/error_spec.rb +43 -0
  42. data/spec/fedex/cancel_spec.rb +10 -0
  43. data/spec/fedex/error_spec.rb +26 -0
  44. data/spec/fedex/rate_spec.rb +87 -0
  45. data/spec/fedex/request_spec.rb +15 -0
  46. data/spec/fedex/responses/blank.xml +0 -0
  47. data/spec/fedex/responses/cancel_not_found.xml +7 -0
  48. data/spec/fedex/responses/failed_authentication.xml +7 -0
  49. data/spec/fedex/responses/malformed.xml +8 -0
  50. data/spec/fedex/responses/rate_defaults.xml +7 -0
  51. data/spec/fedex/responses/rate_insurance.xml +9 -0
  52. data/spec/fedex/responses/rate_no_services.xml +7 -0
  53. data/spec/fedex/responses/rate_non_custom_packaging.xml +7 -0
  54. data/spec/fedex/responses/ship_defaults.xml +7 -0
  55. data/spec/fedex/responses/ship_with_no_signature.xml +7 -0
  56. data/spec/fedex/responses/signature_defaults.xml +7 -0
  57. data/spec/fedex/responses/track_defaults.xml +7 -0
  58. data/spec/fedex/responses/unexpected.xml +1 -0
  59. data/spec/fedex/service_spec.rb +19 -0
  60. data/spec/fedex/ship_spec.rb +37 -0
  61. data/spec/fedex/signature_spec.rb +11 -0
  62. data/spec/fedex/spec_helper.rb +84 -0
  63. data/spec/fedex/track_spec.rb +37 -0
  64. data/spec/fedex_spec.rb +16 -0
  65. data/spec/lib/interceptor.rb +17 -0
  66. data/spec/proxy_spec.rb +42 -0
  67. data/spec/service_spec.rb +23 -0
  68. data/spec/spec_helper.rb +12 -0
  69. data/spec/ups/responses/blank.xml +0 -0
  70. data/spec/ups/responses/track_defaults.xml +2 -0
  71. data/spec/ups/spec_helper.rb +43 -0
  72. data/spec/ups_spec.rb +16 -0
  73. data/spec/validation_spec.rb +49 -0
  74. metadata +163 -0
@@ -0,0 +1,84 @@
1
+ require "shippinglogic/fedex/enumerations"
2
+ require "shippinglogic/fedex/service"
3
+ require "shippinglogic/fedex/cancel"
4
+ require "shippinglogic/fedex/rate"
5
+ require "shippinglogic/fedex/ship"
6
+ require "shippinglogic/fedex/signature"
7
+ require "shippinglogic/fedex/track"
8
+
9
+ module Shippinglogic
10
+ class FedEx
11
+ # A hash representing default the options. If you are using this in a Rails app the best place
12
+ # to modify or change these options is either in an initializer or your specific environment file. Keep
13
+ # in mind that these options can be modified on the instance level when creating an object. See #initialize
14
+ # for more details.
15
+ #
16
+ # === Options
17
+ #
18
+ # * <tt>:test</tt> - this basically tells us which url to use. If set to true we will use the FedEx test URL, if false we
19
+ # will use the production URL. If you are using this in a rails app, unless you are in your production environment, this
20
+ # will default to true automatically.
21
+ # * <tt>:test_url</tt> - the test URL for FedEx's webservices. (default: https://gatewaybeta.fedex.com:443/xml)
22
+ # * <tt>:production_url</tt> - the production URL for FedEx's webservices. (default: https://gateway.fedex.com:443/xml)
23
+ def self.options
24
+ @options ||= {
25
+ :test => !!(defined?(Rails) && !Rails.env.production?),
26
+ :production_url => "https://gateway.fedex.com:443/xml",
27
+ :test_url => "https://gatewaybeta.fedex.com:443/xml"
28
+ }
29
+ end
30
+
31
+ attr_accessor :key, :password, :account, :meter, :options
32
+
33
+ # Before you can use the FedEx web services you need to provide 4 credentials:
34
+ #
35
+ # 1. Your fedex web service key
36
+ # 2. Your fedex password
37
+ # 3. Your fedex account number
38
+ # 4. Your fedex meter number
39
+ #
40
+ # You can easily get these things by logging into your fedex account and going to:
41
+ #
42
+ # https://www.fedex.com/wpor/wpor/editConsult.do
43
+ #
44
+ # If for some reason this link no longer works because FedEx changed it, just go to the
45
+ # developer resources area and then navigate to the FedEx web services for shipping area. Once
46
+ # there you should see a link to apply for a develop test key.
47
+ #
48
+ # The last parameter allows you to modify the class options on an instance level. It accepts the
49
+ # same options that the class level method #options accepts. If you don't want to change any of
50
+ # them, don't supply this parameter.
51
+ def initialize(key, password, account, meter, options = {})
52
+ self.key = key
53
+ self.password = password
54
+ self.account = account
55
+ self.meter = meter
56
+ self.options = self.class.options.merge(options)
57
+ end
58
+
59
+ # A convenience method for accessing the endpoint URL for the FedEx API.
60
+ def url
61
+ options[:test] ? options[:test_url] : options[:production_url]
62
+ end
63
+
64
+ def cancel(attributes = {})
65
+ @cancel ||= Cancel.new(self, attributes)
66
+ end
67
+
68
+ def rate(attributes = {})
69
+ @rate ||= Rate.new(self, attributes)
70
+ end
71
+
72
+ def ship(attributes = {})
73
+ @ship ||= Ship.new(self, attributes)
74
+ end
75
+
76
+ def signature(attributes = {})
77
+ @signature ||= Signature.new(self, attributes)
78
+ end
79
+
80
+ def track(attributes = {})
81
+ @track ||= Track.new(self, attributes)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,47 @@
1
+ module Shippinglogic
2
+ class FedEx
3
+ # An interface to the shipment canceling service provided by FedEx. Allows you to cancel a shipment
4
+ #
5
+ # == Accessor methods / options
6
+ #
7
+ # * <tt>tracking_number</tt> - the tracking number
8
+ # * <tt>deletion_control</tt> - one of Enumerations::DELETION_CONTROL (default: DELETE_ALL_PACKAGES)
9
+ #
10
+ # === Simple Example
11
+ #
12
+ # fedex = Shippinglogic::FedEx.new(key, password, account, meter)
13
+ # cancel = fedex.cancel(:tracking_number => "my number")
14
+ # cancel.perform
15
+ # # => true
16
+ class Cancel < Service
17
+ VERSION = {:major => 6, :intermediate => 0, :minor => 0}
18
+
19
+ attribute :tracking_number, :string
20
+ attribute :deletion_control, :string, :default => "DELETE_ALL_PACKAGES"
21
+
22
+ # Our services are set up as a proxy. We need to access the underlying object, to trigger the request
23
+ # to fedex. So calling this method is a way to do that since there really is no underlying object
24
+ def perform
25
+ target && true
26
+ end
27
+
28
+ private
29
+ # The parent class Service requires that we define this method. This is our kicker. This method is only
30
+ # called when we need to deal with information from FedEx. Notice the caching into the @target variable.
31
+ def target
32
+ @target ||= request(build_request)
33
+ end
34
+
35
+ # Just building some XML to send off to FedEx. FedEx require this particualr format.
36
+ def build_request
37
+ b = builder
38
+ xml = b.DeleteShipmentRequest(:xmlns => "http://fedex.com/ws/ship/v#{VERSION[:major]}") do
39
+ build_authentication(b)
40
+ build_version(b, "ship", VERSION[:major], VERSION[:intermediate], VERSION[:minor])
41
+ b.TrackingNumber tracking_number
42
+ b.DeletionControl deletion_control
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,348 @@
1
+ module Shippinglogic
2
+ class FedEx
3
+ # This module contains the various enumerations that FedEx uses for its various options. When describing
4
+ # service options sometimes the docs will specify that the option must be an item in one of these arrays.
5
+ # You can also use these to build drop down options.
6
+ #
7
+ # Lastly, if you want to make these user friendly use a string inflector (humanize or titlize).
8
+ module Enumerations
9
+ # label options
10
+ LABEL_FORMATS = ["COMMON2D", "ERROR", "LABEL_DATA_ONLY", "MAILROOM", "NO_LABEL"]
11
+ LABEL_FILE_TYPES = ["DIB", "DPL", "EPL2", "GIF", "PDF", "PNG", "ZPLII"]
12
+ LABEL_STOCK_TYPES = [
13
+ "PAPER_4X6", "PAPER_4X8", "PAPER_4X9", "PAPER_7X4.75", "PAPER_8.5X11_BOTTOM_HALF_LABEL", "PAPER_8.5X11_TOP_HALF_LABEL",
14
+ "PAPER_LETTER", "STOCK_4X6", "STOCK_4X6.75_LEADING_DOC_TAB", "STOCK_4X6.75_TRAILING_DOC_TAB", "STOCK_4X8",
15
+ "STOCK_4X9_LEADING_DOC_TAB", "STOCK_4X9_TRAILING_DOC_TAB"
16
+ ]
17
+ LABEL_MASK_OPTIONS = [
18
+ "CUSTOMS_VALUE", "DIMENSIONS", "DUTIES_AND_TAXES_PAYOR_ACCOUNT_NUMBER", "FREIGHT_PAYOR_ACCOUNT_NUMBER",
19
+ "PACKAGE_SEQUENCE_AND_COUNT", "SHIPPER_ACCOUNT_NUMBER", "SUPPLEMENTAL_LABEL_DOC_TAB", "TERMS_AND_CONDITIONS",
20
+ "TOTAL_WEIGHT", "TRANSPORTATION_CHARGES_PAYOR_ACCOUNT_NUMBER"
21
+ ]
22
+
23
+ # service options
24
+ REGULAR_SERVICE_TYPES = [
25
+ "GROUND_HOME_DELIVERY", "FEDEX_GROUND", "FEDEX_EXPRESS_SAVER", "FEDEX_2_DAY", "STANDARD_OVERNIGHT",
26
+ "PRIORITY_OVERNIGHT", "FIRST_OVERNIGHT"
27
+ ]
28
+ REGULAR_SATURDAY_SERVICE_TYPES = ["FEDEX_2_DAY_SATURDAY_DELIVERY", "PRIORITY_OVERNIGHT_SATURDAY_DELIVERY"]
29
+ FREIGHT_SERVICE_TYPES = ["FEDEX_3_DAY_FREIGHT", "FEDEX_2_DAY_FREIGHT", "FEDEX_1_DAY_FREIGHT"]
30
+ FREIGHT_SATURDAY_SERVICE_TYPES = [
31
+ "FEDEX_3_DAY_FREIGHT_SATURDAY_DELIVERY", "FEDEX_2_DAY_FREIGHT_SATURDAY_DELIVERY",
32
+ "FEDEX_1_DAY_FREIGHT_SATURDAY_DELIVERY"
33
+ ]
34
+ INTERNATIONAL_SERVICE_TYPES = ["INTERNATIONAL_GROUND", "INTERNATIONAL_ECONOMY", "INTERNATIONAL_PRIORITY", "INTERNATIONAL_FIRST"]
35
+ INTERNATIONAL_SATURDAY_TYPES = ["INTERNATIONAL_PRIORITY_SATURDAY_DELIVERY"]
36
+ INTERNATIONA_FREIGHT_SERVICE_TYPES = ["INTERNATIONAL_ECONOMY_FREIGHT", "INTERNATIONAL_PRIORITY_FREIGHT"]
37
+ SERVICE_TYPES = REGULAR_SERVICE_TYPES + REGULAR_SATURDAY_SERVICE_TYPES + FREIGHT_SERVICE_TYPES + FREIGHT_SATURDAY_SERVICE_TYPES +
38
+ INTERNATIONAL_SERVICE_TYPES + INTERNATIONAL_SATURDAY_TYPES + INTERNATIONA_FREIGHT_SERVICE_TYPES
39
+
40
+ # delivery options
41
+ SIGNATURE_OPTION_TYPES = ["ADULT", "DIRECT", "INDIRECT", "NO_SIGNATURE_REQUIRED", "SERVICE_DEFAULT"]
42
+ SIGNATURE_IMAGE_TYPES = ["LETTER", "FAX"]
43
+ SPECIAL_SERVICES = [
44
+ "APPOINTMENT_DELIVERY", "DANGEROUS_GOODS", "DRY_ICE", "NON_STANDARD_CONTAINER", "PRIORITY_ALERT", "SIGNATURE_OPTION",
45
+ "FEDEX_FREIGHT", "FEDEX_NATIONAL_FREIGHT", "INSIDE_PICKUP", "INSIDE_DELIVERY", "EXHIBITION", "EXTREME_LENGTH", "FLATBED_TRAILER",
46
+ "FREIGHT_GUARANTEE", "LIFTGATE_DELIVERY", "LIFTGATE_PICKUP", "LIMITED_ACCESS_DELIVERY", "LIMITED_ACCESS_PICKUP", "PRE_DELIVERY_NOTIFICATION",
47
+ "PROTECTION_FROM_FREEZING", "REGIONAL_MALL_DELIVERY", "REGIONAL_MALL_PICKUP"
48
+ ]
49
+
50
+ # misc options
51
+ DELETION_CONTROL = ["DELETE_ALL_PACKAGES", "DELETE_ONE_PACKAGE", "LEGACY"]
52
+ EMAIL_TYPES = ["HTML", "TEXT", "WIRELESS"]
53
+ PAYMENT_TYPES = ["SENDER", "CASH", "CREDIT_CARD"]
54
+ REFERENCE_TYPES = [
55
+ "BILL_OF_LADING", "CUSTOMER_REFERENCE", "DEPARTMENT_NUMBER", "INVOICE_NUMER", "P_O_NUMBER",
56
+ "SHIPMENT_INTEGRITY", "STORE_NUMBER"
57
+ ]
58
+ PACKAGE_TYPES = ["FEDEX_ENVELOPE", "FEDEX_PAK", "FEDEX_BOX", "FEDEX_TUBE", "FEDEX_10KG_BOX", "FEDEX_25KG_BOX", "YOUR_PACKAGING"]
59
+ DROP_OFF_TYPES = ["REGULAR_PICKUP", "REQUEST_COURIER", "DROP_BOX", "BUSINESS_SERVICE_CENTER", "STATION"]
60
+ RATE_REQUEST_TYPES = ["ACCOUNT", "LIST", "MULTIWEIGHT"]
61
+
62
+ FEDEX_COUNTRY_CODES = {
63
+ "Albania" => "AL",
64
+ "Algeria" => "DZ",
65
+ "American Samoa" => "AS",
66
+ "Andorra" => "AD",
67
+ "Angola" => "AO",
68
+ "Anguilla" => "AI",
69
+ "Antigua" => "AG",
70
+ "Argentina" => "AR",
71
+ "Armenia" => "AM",
72
+ "Aruba" => "AW",
73
+ "Australia" => "AU",
74
+ "Austria" => "AT",
75
+ "Azerbaijan" => "AZ",
76
+ "Bahamas" => "BS",
77
+ "Bahrain" => "BH",
78
+ "Bangladesh" => "BD",
79
+ "Barbados" => "BB",
80
+ "Belarus" => "BY",
81
+ "Belgium " => "BE",
82
+ "Belize" => "BZ",
83
+ "Benin" => "BJ",
84
+ "Bermuda" => "BM",
85
+ "Bhutan" => "BT",
86
+ "Bolivia" => "BO",
87
+ "Botswana " => "BW",
88
+ "Brazil" => "BR",
89
+ "British Virgin Is." => "VG",
90
+ "Brunei" => "BN",
91
+ "Bulgaria" => "BG",
92
+ "Burkino Faso" => "BF",
93
+ "Burma" => "MM",
94
+ "Burundi" => "BI",
95
+ "Cambodia" => "KH",
96
+ "Cameroon" => "CM",
97
+ "Canada" => "CA",
98
+ "Cape Verde" => "CV",
99
+ "Cayman Islands" => "KY",
100
+ "Central African" => "CF",
101
+ "Chad" => "TD",
102
+ "Chile" => "CL",
103
+ "China" => "CN",
104
+ "Colombia" => "CO",
105
+ "Congo" => "CG",
106
+ "Congo, The Republic of" => "CD",
107
+ "Cook Islands" => "CK",
108
+ "Costa Rica" => "CR",
109
+ "Cote D'Ivoire" => "CI",
110
+ "Croatia" => "HR",
111
+ "Cyprus" => "CY",
112
+ "Czech Republic" => "CZ",
113
+ "Denmark" => "DK",
114
+ "Djibouti" => "DJ",
115
+ "Dominica" => "DM",
116
+ "Dominican Republic" => "DO",
117
+ "Ecuador" => "EC",
118
+ "Egypt" => "EG",
119
+ "El Salvador" => "SV",
120
+ "Equatorial Guinea" => "GQ",
121
+ "Eritrea" => "ER",
122
+ "Estonia" => "EE",
123
+ "Ethiopia" => "ET",
124
+ "Faeroe Islands" => "FO",
125
+ "Fiji" => "FJ",
126
+ "Finland" => "FI",
127
+ "France" => "FR",
128
+ "French Guiana" => "GF",
129
+ "French Polynesia" => "PF",
130
+ "Gabon" => "GA",
131
+ "Gambia" => "GM",
132
+ "Georgia, Republic of" => "GE",
133
+ "Germany" => "DE",
134
+ "Ghana" => "GH",
135
+ "Gibraltar" => "GI",
136
+ "Greece" => "GI",
137
+ "Greenland" => "GL",
138
+ "Grenada" => "GD",
139
+ "Guadeloupe" => "GP",
140
+ "Guam" => "GU",
141
+ "Guatemala" => "GT",
142
+ "Guinea" => "GN",
143
+ "Guinea-Bissau" => "GW",
144
+ "Guyana" => "GY",
145
+ "Haiti" => "HT",
146
+ "Honduras" => "HN",
147
+ "Hong Kong" => "HK",
148
+ "Hungary" => "HU",
149
+ "Iceland" => "IS",
150
+ "India" => "IN",
151
+ "Indonesia" => "ID",
152
+ "Ireland" => "IE",
153
+ "Israel" => "IL",
154
+ "Italy" => "IT",
155
+ "Ivory Coast" => "CI",
156
+ "Jamaica" => "JM",
157
+ "Japan" => "JP",
158
+ "Jordan" => "JO",
159
+ "Kazakhstan" => "KZ",
160
+ "Kenya" => "KE",
161
+ "Kuwait" => "KW",
162
+ "Kyrgyzstan" => "KG",
163
+ "Latvia" => "LV",
164
+ "Lebanon" => "LB",
165
+ "Lesotho" => "LS",
166
+ "Liechtenstein" => "LI",
167
+ "Lithuania" => "LT",
168
+ "Luxembourg" => "LU",
169
+ "Macau" => "MO",
170
+ "Macedonia" => "MK",
171
+ "Madagascar" => "MG",
172
+ "Malawi" => "MW",
173
+ "Malaysia" => "MY",
174
+ "Maldives" => "MV",
175
+ "Mali" => "ML",
176
+ "Malta" => "MT",
177
+ "Marshall Islands" => "MH",
178
+ "Martinique" => "MQ",
179
+ "Mauritania" => "MR",
180
+ "Mauritius" => "MU",
181
+ "Mexico" => "MX",
182
+ "Micronesia" => "FM",
183
+ "Moldova" => "MD",
184
+ "Monaco" => "MC",
185
+ "Mongolia" => "MN",
186
+ "Montserrat" => "MS",
187
+ "Morocco" => "MA",
188
+ "Mozambique" => "MZ",
189
+ "Myanmar" => "MM",
190
+ "Namibia" => "NA",
191
+ "Nepal" => "NP",
192
+ "Netherlands" => "NL",
193
+ "Netherlands Antilles" => "AN",
194
+ "New Caledonia" => "NC",
195
+ "New Zealand" => "NZ",
196
+ "Nicaragua" => "NI",
197
+ "Niger" => "NE",
198
+ "Nigeria" => "NG",
199
+ "Norway" => "NO",
200
+ "Oman" => "OM",
201
+ "Pakistan" => "PK",
202
+ "Palau" => "PW",
203
+ "Panama" => "PA",
204
+ "Papau New Guinea" => "PG",
205
+ "Paraguay" => "PY",
206
+ "Peru" => "PE",
207
+ "Phillipines" => "PH",
208
+ "Poland" => "PL",
209
+ "Portugal" => "PT",
210
+ "Puerto Rico" => "US",
211
+ "Quatar" => "QA",
212
+ "Reunion Island" => "RE",
213
+ "Romania" => "RO",
214
+ "Russia" => "RU",
215
+ "Rwanda" => "RW",
216
+ "Saipan" => "MP",
217
+ "San Marino" => "SM",
218
+ "Saudi Arabia" => "SA",
219
+ "Senegal" => "SN",
220
+ "Seychelles" => "SC",
221
+ "Sierra Leonne" => "SL",
222
+ "Singapore" => "SG",
223
+ "Slovak Republic" => "SK",
224
+ "Slovenia" => "SI",
225
+ "South Africa" => "ZA",
226
+ "South Korea" => "KR",
227
+ "Spain" => "ES",
228
+ "Sri Lanka" => "LK",
229
+ "St. Kitts & Nevis" => "KN",
230
+ "St. Lucia" => "LC",
231
+ "St. Vincent" => "VC",
232
+ "Suriname" => "SR",
233
+ "Swaziland" => "SZ",
234
+ "Sweden" => "SE",
235
+ "Switzerland" => "CH",
236
+ "Syria" => "SY",
237
+ "Taiwan" => "TW",
238
+ "Tanzania" => "TZ",
239
+ "Thailand" => "TH",
240
+ "Togo" => "TG",
241
+ "Trinidad & Tobago" => "TT",
242
+ "Tunisia" => "TN",
243
+ "Turkey" => "TR",
244
+ "Turkmenistan, Republic Of" => "TM",
245
+ "Turks & Caicos Is." => "TC",
246
+ "U.A.E." => "AE",
247
+ "U.S. Virgin Islands" => "VI",
248
+ "U.S.A." => "US",
249
+ "Uganda" => "UG",
250
+ "Ukraine" => "UA",
251
+ "United Kingdom" => "GB",
252
+ "Uruguay" => "UY",
253
+ "Uzbekistan" => "UZ",
254
+ "Vanatu" => "VU",
255
+ "Vatican City"=> "VA",
256
+ "Venezuela" => "VE",
257
+ "Vietnam" => "VN",
258
+ "Wallis & Futuna Islands" => "WF",
259
+ "Yemen" => "YE",
260
+ "Zambia" => "ZM",
261
+ "Zimbabwe" => "ZW"
262
+ }
263
+
264
+ RAILS_COUNTRY_CODES = {
265
+ "United States" => "US"
266
+ }
267
+
268
+ US_STATE_CODES = {
269
+ "Alabama" => "AL",
270
+ "Alaska" => "AK",
271
+ "America Samoa" => "AS",
272
+ "Arizona" => "AZ",
273
+ "Arkansas" => "AR",
274
+ "California" => "CA",
275
+ "Colorado" => "CO",
276
+ "Connecticut" => "CT",
277
+ "Delaware" => "DE",
278
+ "District of Columbia" => "DC",
279
+ "Florida" => "FL",
280
+ "Georgia" => "GA",
281
+ "Guam" => "GU",
282
+ "Hawaii" => "HI",
283
+ "Idaho" => "ID",
284
+ "Illinois" => "IL",
285
+ "Indiana" => "IN",
286
+ "Iowa" => "IA",
287
+ "Islands1" => "MH",
288
+ "Kansas" => "KS",
289
+ "Kentucky" => "KY",
290
+ "Louisiana" => "LA",
291
+ "Maine" => "ME",
292
+ "Maryland" => "MD",
293
+ "Massachusetts" => "MA",
294
+ "Michigan" => "MI",
295
+ "Micronesia1" => "FM",
296
+ "Minnesota" => "MN",
297
+ "Mississippi" => "MS",
298
+ "Missouri" => "MO",
299
+ "Montana" => "MT",
300
+ "Nebraska" => "NE",
301
+ "Nevada" => "NV",
302
+ "New Hampshire" => "NH",
303
+ "New Jersey" => "NJ",
304
+ "New Mexico" => "NM",
305
+ "New York" => "NY",
306
+ "North Carolina" => "NC",
307
+ "North Dakota" => "ND",
308
+ "Ohio" => "OH",
309
+ "Oklahoma" => "OK",
310
+ "Oregon" => "OR",
311
+ "Palau" => "PW",
312
+ "Pennsylvania" => "PA",
313
+ "Puerto Rico" => "PR",
314
+ "Rhode Island" => "RI",
315
+ "South Carolina" => "SC",
316
+ "South Dakota" => "SD",
317
+ "Tennessee" => "TN",
318
+ "Texas" => "TX",
319
+ "Utah" => "UT",
320
+ "Vermont" => "VT",
321
+ "Virgin Island" => "VI",
322
+ "Virginia" => "VA",
323
+ "Washington" => "WA",
324
+ "West Virginia" => "WV",
325
+ "Wisconsin" => "WI",
326
+ "Wyoming" => "WY",
327
+ }
328
+
329
+ CANADA_STATE_CODES = {
330
+ "Alberta" => "AB",
331
+ "British Columbia" => "BC",
332
+ "Manitoba" => "MB",
333
+ "New Brunswick" => "NB",
334
+ "Newfoundland and Labrador" => "NL",
335
+ "Nova Scotia" => "NS",
336
+ "Northwest Territories" => "NT",
337
+ "Nunavut" => "NU",
338
+ "Ontario" => "ON",
339
+ "Prince Edward Island" => "PE",
340
+ "Quebec" => "QC",
341
+ "Saskatchewan" => "SK",
342
+ "Yukon" => "YT"
343
+ }
344
+
345
+ STATE_CODES = US_STATE_CODES.merge(CANADA_STATE_CODES)
346
+ end
347
+ end
348
+ end