Class: ActiveFulfillment::ShipwireService

Inherits:
Service
  • Object
show all
Defined in:
lib/active_fulfillment/services/shipwire.rb

Constant Summary collapse

SERVICE_URLS =
{ :fulfillment  => 'https://api.shipwire.com/exec/FulfillmentServices.php',
  :inventory    => 'https://api.shipwire.com/exec/InventoryServices.php',
  :tracking     => 'https://api.shipwire.com/exec/TrackingServices.php'
}.freeze
SCHEMA_URLS =
{ :fulfillment => 'http://www.shipwire.com/exec/download/OrderList.dtd',
  :inventory   => 'http://www.shipwire.com/exec/download/InventoryUpdate.dtd',
  :tracking    => 'http://www.shipwire.com/exec/download/TrackingUpdate.dtd'
}.freeze
POST_VARS =
{ :fulfillment => 'OrderListXML',
  :inventory   => 'InventoryUpdateXML',
  :tracking    => 'TrackingUpdateXML'
}.freeze
WAREHOUSES =
{ 'CHI' => 'Chicago',
  'LAX' => 'Los Angeles',
  'REN' => 'Reno',
  'VAN' => 'Vancouver',
  'TOR' => 'Toronto',
  'UK'  => 'United Kingdom'
}.freeze
SHIPPING_METHODS =
{
  '1 Day Service' => '1D',
  '2 Day Service' => '2D',
  'Ground Service' => 'GD',
  'Freight Service' => 'FT',
  'International' => 'INTL'
}.freeze
INVALID_LOGIN =
/(Error with Valid Username\/EmailAddress and Password Required)|(Could not verify Username\/EmailAddress and Password combination)/

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

#fetch_tracking_numbers, #test?

Constructor Details

#initialize(options = {}) ⇒ ShipwireService

Pass in the login and password for the shipwire account. Optionally pass in the :test => true to force test mode



48
49
50
51
52
# File 'lib/active_fulfillment/services/shipwire.rb', line 48

def initialize(options = {})
  requires!(options, :login, :password)

  super
end

Class Method Details

.shipping_methodsObject

The first is the label, and the last is the code



42
43
44
# File 'lib/active_fulfillment/services/shipwire.rb', line 42

def self.shipping_methods
  SHIPPING_METHODS
end

Instance Method Details

#fetch_stock_levels(options = {}) ⇒ Object



58
59
60
# File 'lib/active_fulfillment/services/shipwire.rb', line 58

def fetch_stock_levels(options = {})
  commit :inventory, build_inventory_request(options)
end

#fetch_tracking_data(order_ids, options = {}) ⇒ Object



62
63
64
# File 'lib/active_fulfillment/services/shipwire.rb', line 62

def fetch_tracking_data(order_ids, options = {})
  commit :tracking, build_tracking_request(order_ids)
end

#fulfill(order_id, shipping_address, line_items, options = {}) ⇒ Object



54
55
56
# File 'lib/active_fulfillment/services/shipwire.rb', line 54

def fulfill(order_id, shipping_address, line_items, options = {})
  commit :fulfillment, build_fulfillment_request(order_id, shipping_address, line_items, options)
end

#include_empty_stock?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/active_fulfillment/services/shipwire.rb', line 79

def include_empty_stock?
  @options[:include_empty_stock]
end

#include_pending_stock?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/active_fulfillment/services/shipwire.rb', line 75

def include_pending_stock?
  @options[:include_pending_stock]
end

#test_mode?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/active_fulfillment/services/shipwire.rb', line 71

def test_mode?
  true
end

#valid_credentials?Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/active_fulfillment/services/shipwire.rb', line 66

def valid_credentials?
  response = fetch_tracking_numbers([])
  response.message !~ INVALID_LOGIN
end