Class: ActiveMerchant::Fulfillment::WebgistixService

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

Constant Summary collapse

TEST_URL =
'https://www.webgistix.com/XML/shippingTest.asp'
LIVE_URL =
'https://www.webgistix.com/XML/API.asp'
SUCCESS_MESSAGE =
'Successfully submitted the order'
FAILURE_MESSAGE =
'Failed to submit the order'
INVALID_LOGIN =
'Access Denied'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

#test?

Methods included from PostsData

included, #ssl_get, #ssl_post

Methods included from RequiresParameters

#requires!

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



50
51
52
53
54
# File 'lib/active_fulfillment/fulfillment/services/webgistix.rb', line 50

def initialize(options = {})
  requires!(options, :login, :password)
  super
  @url = test? ? TEST_URL : LIVE_URL
end

Class Method Details

.shipping_methodsObject

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/active_fulfillment/fulfillment/services/webgistix.rb', line 13

def self.shipping_methods
  [ 
    ["UPS Ground Shipping", "Ground"],
    ["UPS Standard Shipping (Canada 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 & Global Priority Mail", "Priority"],
    ["USPS Priority Mail & Global Priority Mail (flat rate)", "Flat Rate Priority"],
    ["USPS First Class Mail", "First Class"],
    ["USPS Express Mail & Global Express Mail", "Express"],
    ["USPS Flat Rate Global Express Mail", "Global Express Mail Flat Rate"],
    ["USPS Parcel Post", "Parcel"],
    ["USPS First Class International", "First Class International"],
    ["USPS Media Mail", "Media Mail"],
    ["USPS Economy Parcel Post", "Economy Parcel"],
    ["USPS Economy Air Letter Post", "Economy Letter"],
  ].inject(ActiveSupport::OrderedHash.new){|h, (k,v)| h[k] = v; h}
end

Instance Method Details

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



56
57
58
59
# File 'lib/active_fulfillment/fulfillment/services/webgistix.rb', line 56

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

#test_mode?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/active_fulfillment/fulfillment/services/webgistix.rb', line 66

def test_mode?
  true
end

#valid_credentials?Boolean

Returns:

  • (Boolean)


61
62
63
64
# File 'lib/active_fulfillment/fulfillment/services/webgistix.rb', line 61

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