Class: ActiveMerchant::Shipping::Shipwire

Inherits:
Carrier show all
Defined in:
lib/active_shipping/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

#initialize, #maximum_weight

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Methods included from RequiresParameters

#requires!

Constructor Details

This class inherits a constructor from ActiveMerchant::Shipping::Carrier

Instance Method Details

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



29
30
31
32
# File 'lib/active_shipping/shipping/carriers/shipwire.rb', line 29

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

#valid_credentials?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
# File 'lib/active_shipping/shipping/carriers/shipwire.rb', line 34

def valid_credentials?
  location = self.class.default_location
  find_rates(location, location, Package.new(100, [5,15,30]),
    :items => [ { :sku => '', :quantity => 1 } ]
  )
rescue ActiveMerchant::Shipping::ResponseError => e
  e.message != "Could not verify e-mail/password combination"
end