From 4387c642b5770d5611bf7b7c6ead080a8cde1481 Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Thu, 23 Jun 2016 09:59:34 -0500 Subject: [PATCH 1/7] Add CustomerID to configuration. Fix FacilityID case. --- lib/3pl_central/base.rb | 5 +++-- lib/3pl_central/client.rb | 3 ++- lib/3pl_central/configuration.rb | 11 ++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/3pl_central/base.rb b/lib/3pl_central/base.rb index 23db7e0..053e1ce 100644 --- a/lib/3pl_central/base.rb +++ b/lib/3pl_central/base.rb @@ -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 @@ -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 diff --git a/lib/3pl_central/client.rb b/lib/3pl_central/client.rb index d909e97..da3705b 100644 --- a/lib/3pl_central/client.rb +++ b/lib/3pl_central/client.rb @@ -6,6 +6,7 @@ def initialize(params) c.login = params[:login] c.password = params[:password] c.three_pl_id = params[:three_pl_id] + c.customer_id = params[:customer_id] end end @@ -30,4 +31,4 @@ def run_method(class_name, method_name, *args) full_class.constantize.send(method_name.to_sym, *args) end end -end \ No newline at end of file +end diff --git a/lib/3pl_central/configuration.rb b/lib/3pl_central/configuration.rb index 03ee26e..b4fadc0 100644 --- a/lib/3pl_central/configuration.rb +++ b/lib/3pl_central/configuration.rb @@ -7,7 +7,10 @@ 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(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) end def self.configure @@ -16,14 +19,16 @@ def self.configure end class Configuration - attr_accessor :three_pl_key, :login, :password, :default_facility_id, :three_pl_id + attr_accessor :three_pl_key, :login, :password, :default_facility_id, + :three_pl_id, :customer_id def initialize @three_pl_key = '' @login = '' @password = '' @default_facility_id = '' - @three_pl_id = '' + @three_pl_id = '' + @customer_id = '' end end end From dba334e428806280c02405cd5bc06d1b0d146e3f Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Thu, 23 Jun 2016 10:11:13 -0500 Subject: [PATCH 2/7] Fix hash structure in README.md. --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bddde30..775edc3 100644 --- a/README.md +++ b/README.md @@ -75,19 +75,21 @@ ThreePLCentral::Order.create({ country:"Canada"}, 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", + mode: "Ground", + shipping_notes: "I need it ASAP!"}, notes: "More notes!", order_line_items: [ - { + # NOTE: This is an array of hashes, each hash only contain one key: + # `order_line_item` + { order_line_item: { sku:"90RND-010101", qty:"10", fulfillment_sale_price:9.99, fulfillment_discount_percentage:10, - fulfillment_discount_amount:0.99} + fulfillment_discount_amount:0.99}} ], fulfillment_info:{ fulfill_inv_shipping_and_handling:9.12, From 49eba8d0d3e4f7894bf89427b8547dc07a64892e Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Thu, 23 Jun 2016 10:14:26 -0500 Subject: [PATCH 3/7] Update configuration README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 775edc3..e2ff487 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,11 @@ 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" end ``` From 19d058e2c3ddc2d265e9d9c88196823f9f7dd9e5 Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Thu, 23 Jun 2016 10:39:42 -0500 Subject: [PATCH 4/7] Note required parameters on README.md. --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e2ff487..61a662d 100644 --- a/README.md +++ b/README.md @@ -63,34 +63,36 @@ 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", + carrier: "FedEx", # required + mode: "Ground", # required + billing_code: "Prepaid" # required shipping_notes: "I need it ASAP!"}, notes: "More notes!", - order_line_items: [ + 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", - qty:"10", + 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}} From ec37d3bcf5d2b98e88b165642114167b0ef444f3 Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Fri, 24 Jun 2016 15:08:22 -0500 Subject: [PATCH 5/7] Allow to configure Savon. To supress log for example. --- README.md | 6 ++++++ lib/3pl_central/client.rb | 2 ++ lib/3pl_central/configuration.rb | 14 +++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61a662d..30b1e68 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,12 @@ client.get_stock_status(params_for_stock_status) # 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 ``` diff --git a/lib/3pl_central/client.rb b/lib/3pl_central/client.rb index da3705b..3bc1023 100644 --- a/lib/3pl_central/client.rb +++ b/lib/3pl_central/client.rb @@ -1,5 +1,6 @@ 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] @@ -7,6 +8,7 @@ def initialize(params) 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 diff --git a/lib/3pl_central/configuration.rb b/lib/3pl_central/configuration.rb index b4fadc0..0893055 100644 --- a/lib/3pl_central/configuration.rb +++ b/lib/3pl_central/configuration.rb @@ -7,10 +7,16 @@ class << self end def self.client - @client ||= Savon.client(wsdl:WSDL_URL, + @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) + no_message_tag:true, convert_request_keys_to: :camelcase} + .with_indifferent_access + .merge(configuration.savon_config) end def self.configure @@ -19,8 +25,9 @@ def self.configure end class Configuration + # TODO remove duplication, specifying config values in one place attr_accessor :three_pl_key, :login, :password, :default_facility_id, - :three_pl_id, :customer_id + :three_pl_id, :customer_id, :savon_config def initialize @three_pl_key = '' @@ -29,6 +36,7 @@ def initialize @default_facility_id = '' @three_pl_id = '' @customer_id = '' + @savon_config = {} end end end From e56957ce51d1103b37f375521e2cb3de1ad02c99 Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Sat, 16 Jul 2016 12:11:28 -0500 Subject: [PATCH 6/7] Find method indifferent access. --- lib/3pl_central/order.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/3pl_central/order.rb b/lib/3pl_central/order.rb index 764f57e..a3fa8ed 100644 --- a/lib/3pl_central/order.rb +++ b/lib/3pl_central/order.rb @@ -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) From 8635afb8cb2c5b02b9e554a1b8b8eee3f829e7a8 Mon Sep 17 00:00:00 2001 From: Juan Pastas Date: Wed, 27 Jul 2016 20:31:47 -0500 Subject: [PATCH 7/7] Items documentation. --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 30b1e68..2baa03e 100644 --- a/README.md +++ b/README.md @@ -96,12 +96,16 @@ ThreePLCentral::Order.create({ 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}} + { 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,