Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 37 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ client.get_stock_status(params_for_stock_status)
c.login = "customer_login" #configured in 3PL Central -> Customer -> Customer Users
c.password = "customer_password" # same as login
c.default_facility_id = 1 #this might be removed in a later version, and we'll just look for the "Facility ID" on the order or item level.
c.user_login_id = 4 #We had to contact our account manager with 3PL Central to get this information.
# c.user_login_id = 4 #We had to contact our account manager with 3PL Central to get this information.
c.customer_id = 1

# three_pl_id is for reading, three_pl_key is for writing
c.three_pl_id = "three_pl_id"

# Pass configuration values to Savon
# See values in Savon documentation
c.savon_config = {
log: false
}
end

```
Expand All @@ -59,35 +69,43 @@ client.get_stock_status(params_for_stock_status)

ThreePLCentral::Order.create({
trans_info: {
reference_num: "100001",
reference_num: "100001", # required
expected_date: "2014-11-12",
earliest_ship_date: "2014-11-12",
ship_cancel_date: "2014-11-12"},
ship_to: {
name: "Test Test",
company_name: "Test Co.",
company_name: "Test Co.", # required
address:{
address1: "Toronto",
address1: "Toronto", # required
address2:"Ste. 2",
city:"1234 Fake St.",
state:"ON",
zip:"M4B 1B3",
country:"Canada"},
city:"1234 Fake St.", # required
state:"ON", # required
zip:"M4B 1B3", # required
country:"Canada" # required
},
phone_number1: "999-999-9999",
email_address1: "test@test.com",
shipping_instructions: {
carrier: "FedEx",
mode: "Ground",
shipping_notes: "I need it ASAP!"}
},
shipping_instructions: {
carrier: "FedEx", # required
mode: "Ground", # required
billing_code: "Prepaid" # required
shipping_notes: "I need it ASAP!"},
notes: "More notes!",
order_line_items: [
{
sku:"90RND-010101",
qty:"10",
fulfillment_sale_price:9.99,
fulfillment_discount_percentage:10,
fulfillment_discount_amount:0.99}
order_line_items: [ # required at least one
# NOTE: This is an array of hashes, each hash only contain one key:
# `order_line_item`
{ order_line_item:
{
SKU:"90RND-010101", # It must be all uppercase, required
qty:"10", # required
fulfillment_sale_price:9.99,
fulfillment_discount_percentage:10,
fulfillment_discount_amount:0.99
}
# ... more objects(items) here
}
],
fulfillment_info:{
fulfill_inv_shipping_and_handling:9.12,
Expand Down
5 changes: 3 additions & 2 deletions lib/3pl_central/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def create_creds
"ThreePLKey" => ThreePLCentral.configuration.three_pl_key,
login: ThreePLCentral.configuration.login,
password: ThreePLCentral.configuration.password,
facility_id: facility_id || ThreePLCentral.configuration.default_facility_id
Facility_ID: facility_id || ThreePLCentral.configuration.default_facility_id,
Customer_ID: ThreePLCentral.configuration.customer_id
}}
end

Expand All @@ -21,6 +22,6 @@ def self.read_creds
def self.parser
@parser ||= Nori.new(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym })
end

end
end
5 changes: 4 additions & 1 deletion lib/3pl_central/client.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module ThreePLCentral
class Client
# TODO remove duplication, specifying config values in one place
def initialize(params)
ThreePLCentral.configure do |c|
c.three_pl_key = params[:three_pl_key]
c.login = params[:login]
c.password = params[:password]
c.three_pl_id = params[:three_pl_id]
c.customer_id = params[:customer_id]
c.savon_config = params[:savon_config]
end
end

Expand All @@ -30,4 +33,4 @@ def run_method(class_name, method_name, *args)
full_class.constantize.send(method_name.to_sym, *args)
end
end
end
end
19 changes: 16 additions & 3 deletions lib/3pl_central/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ class << self
end

def self.client
@client ||= Savon.client(wsdl:WSDL_URL, ssl_version: :TLSv1, ssl_verify_mode: :none, log_level: :debug, log: true, pretty_print_xml: true, no_message_tag:true, convert_request_keys_to: :camelcase)
@client ||= Savon.client(savon_config)
end

def self.savon_config
@savon_config ||= {wsdl:WSDL_URL,
ssl_version: :TLSv1, ssl_verify_mode: :none,
log_level: :debug, log: true, pretty_print_xml: true,
no_message_tag:true, convert_request_keys_to: :camelcase}
.with_indifferent_access
.merge(configuration.savon_config)
end

def self.configure
Expand All @@ -16,14 +25,18 @@ def self.configure
end

class Configuration
attr_accessor :three_pl_key, :login, :password, :default_facility_id, :three_pl_id
# TODO remove duplication, specifying config values in one place
attr_accessor :three_pl_key, :login, :password, :default_facility_id,
:three_pl_id, :customer_id, :savon_config

def initialize
@three_pl_key = ''
@login = ''
@password = ''
@default_facility_id = ''
@three_pl_id = ''
@three_pl_id = ''
@customer_id = ''
@savon_config = {}
end
end
end
4 changes: 3 additions & 1 deletion lib/3pl_central/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def find(params)
xml_hash["limitCount"] = 10
xml_hash["focr"] = params
response = ThreePLCentral::Services.find_orders(xml_hash)
parser.parse(response.body[:find_orders])["orders"]["order"].arrayify
parser.parse(response.body[:find_orders])
.with_indifferent_access["orders"]["order"]
.arrayify
end

def create(params)
Expand Down