Class: ActiveFulfillment::WebgistixService

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

Constant Summary collapse

SERVICE_URLS =
{
  :fulfillment => 'https://www.webgistix.com/XML/CreateOrder.asp',
  :inventory   => 'https://www.webgistix.com/XML/GetInventory.asp',
  :tracking    => 'https://www.webgistix.com/XML/GetTracking.asp'
}.freeze
TEST_URLS =
SERVICE_URLS.dup.merge({
  :fulfillment => 'https://www.webgistix.com/XML/CreateOrderTest.asp'
}).freeze
SUCCESS_MESSAGE =
'Successfully submitted the order'.freeze
FAILURE_MESSAGE =
'Failed to submit the order'.freeze
DUPLICATE_MESSAGE =
'This order has already been successfully submitted'.freeze
INVALID_LOGIN =
'Invalid Credentials'.freeze
NOT_SHIPPED =
'Not Shipped'.freeze
TRACKING_COMPANIES =
%w(UPS FedEx USPS).freeze
SHIPPING_PROVIDERS =
{
    'UPS Ground Shipping' => 'Ground',
    'UPS Ground' => 'Ground',
    'UPS Standard Shipping (Canada Only)' => 'Standard',
    'UPS Standard Shipping (CA & MX Only)' => 'Standard',
    'UPS 3-Business Day' => '3-Day Select',
    'UPS 2-Business Day' => '2nd Day Air',
    'UPS 2-Business Day AM' => '2nd Day Air AM',
    'UPS Next Day' => 'Next Day Air',
    'UPS Next Day Saver' => 'Next Day Air Saver',
    'UPS Next Day Early AM' => 'Next Day Air Early AM',
    'UPS Worldwide Express (Next Day)' => 'Worldwide Express',
    'UPS Worldwide Expedited (2nd Day)' => 'Worldwide Expedited',
    'UPS Worldwide Express Saver' => 'Worldwide Express Saver',
    'FedEx Priority Overnight' => 'FedEx Priority Overnight',
    'FedEx Standard Overnight' => 'FedEx Standard Overnight',
    'FedEx First Overnight' => 'FedEx First Overnight',
    'FedEx 2nd Day' => 'FedEx 2nd Day',
    'FedEx Express Saver' => 'FedEx Express Saver',
    'FedEx International Priority' => 'FedEx International Priority',
    'FedEx International Economy' => 'FedEx International Economy',
    'FedEx International First' => 'FedEx International First',
    'FedEx Ground' => 'FedEx Ground',
    'USPS Priority Mail' => 'Priority Mail',
    'USPS Priority Mail International' => 'Priority Mail International',
    'USPS Priority Mail Small Flat Rate Box' => 'Priority Mail Small Flat Rate Box',
    'USPS Priority Mail Medium Flat Rate Box' => 'Priority Mail Medium Flat Rate Box',
    'USPS Priority Mail Large Flat Rate Box' => "Priority Mail Large Flat Rate Box",
    'USPS Priority Mail Flat Rate Envelope' => 'Priority Mail Flat Rate Envelope',
    'USPS First Class Mail' => 'First Class',
    'USPS First Class International' => 'First Class International',
    'USPS Express Mail' => 'Express',
    'USPS Express Mail International' => 'Express Mail International',
    'USPS Parcel Post' => 'Parcel',
    'USPS Media Mail' => 'Media Mail'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

#fetch_tracking_numbers, #test?

Constructor Details

#initialize(options = {}) ⇒ WebgistixService

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



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

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



68
69
70
# File 'lib/active_fulfillment/services/webgistix.rb', line 68

def self.shipping_methods
  SHIPPING_PROVIDERS
end

Instance Method Details

#fetch_stock_levels(options = {}) ⇒ Object



84
85
86
# File 'lib/active_fulfillment/services/webgistix.rb', line 84

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

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



88
89
90
# File 'lib/active_fulfillment/services/webgistix.rb', line 88

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

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



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

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

#test_mode?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/active_fulfillment/services/webgistix.rb', line 97

def test_mode?
  true
end

#valid_credentials?Boolean

Returns:

  • (Boolean)


92
93
94
95
# File 'lib/active_fulfillment/services/webgistix.rb', line 92

def valid_credentials?
  response = fulfill('', {}, [], :shipping_method => '')
  response.message != INVALID_LOGIN
end