Class: ActiveShipping::Shipwire

Inherits:
Carrier
  • Object
show all
Defined in:
lib/active_shipping/carriers/shipwire.rb

Constant Summary collapse

URL =
'https://api.shipwire.com/exec/RateServices.php'
SCHEMA_URL =
'http://www.shipwire.com/exec/download/RateRequest.dtd'
WAREHOUSES =
{ 'CHI' => 'Chicago',
  'LAX' => 'Los Angeles',
  'REN' => 'Reno',
  'VAN' => 'Vancouver',
  'TOR' => 'Toronto',
  'UK'  => 'United Kingdom'
}
CARRIERS =
["UPS", "USPS", "FedEx", "Royal Mail", "Parcelforce", "Pharos", "Eurotrux", "Canada Post", "DHL"]
SUCCESS =
"OK"
SUCCESS_MESSAGE =
"Successfully received the shipping rates"
NO_RATES_MESSAGE =
"No shipping rates could be found for the destination address"
REQUIRED_OPTIONS =
[:login, :password].freeze
@@name =
"Shipwire"

Instance Attribute Summary

Attributes inherited from Carrier

#last_request, #test_mode

Instance Method Summary collapse

Methods inherited from Carrier

#available_services, #cancel_shipment, #create_shipment, default_location, #find_tracking_info, #initialize, #maximum_address_field_length, #maximum_weight, #save_request, #timestamp_from_business_day

Constructor Details

This class inherits a constructor from ActiveShipping::Carrier

Instance Method Details

#find_rates(origin, destination, packages, options = {}) ⇒ Object



25
26
27
28
# File 'lib/active_shipping/carriers/shipwire.rb', line 25

def find_rates(origin, destination, packages, options = {})
  requires!(options, :items)
  commit(origin, destination, options)
end

#valid_credentials?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
39
# File 'lib/active_shipping/carriers/shipwire.rb', line 30

def valid_credentials?
  location = self.class.default_location
  find_rates(location, location, Package.new(100, [5, 15, 30]),
             :items => [{ :sku => '', :quantity => 1 }]
  )
rescue ActiveShipping::ResponseError
  true
rescue ActiveUtils::ResponseError => e
  e.response.code != '401'
end