Class: Exigo
- Inherits:
-
Object
- Object
- Exigo
- Defined in:
- lib/exigo.rb
Instance Attribute Summary collapse
-
#company ⇒ Object
Returns the value of attribute company.
-
#namespacer ⇒ Object
Returns the value of attribute namespacer.
-
#password ⇒ Object
Returns the value of attribute password.
-
#transaction_details ⇒ Object
Returns the value of attribute transaction_details.
-
#username ⇒ Object
Returns the value of attribute username.
-
#wsdl ⇒ Object
Returns the value of attribute wsdl.
Instance Method Summary collapse
-
#initialize(username, password, company) ⇒ Exigo
constructor
A new instance of Exigo.
- #method_missing(name, *args, &block) ⇒ Object
-
#new_order(shipping_info, order_properties, distributor_id, create_customer = true, test = false) ⇒ Object
Not yet complete.
Constructor Details
#initialize(username, password, company) ⇒ Exigo
Returns a new instance of Exigo.
6 7 8 9 10 11 12 |
# File 'lib/exigo.rb', line 6 def initialize(username,password,company) @username = username @password = password @company = company @wsdl = "http://api.exigo.com/3.0/ExigoApi.asmx?WSDL" @namespacer = "http://api.exigo.com/" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
14 15 16 17 18 |
# File 'lib/exigo.rb', line 14 def method_missing(name, *args, &block) payload = args[0].each_with_object({}) { |(k,v), h| h["api:#{k}"] = v } make_request(name,payload) end |
Instance Attribute Details
#company ⇒ Object
Returns the value of attribute company.
4 5 6 |
# File 'lib/exigo.rb', line 4 def company @company end |
#namespacer ⇒ Object
Returns the value of attribute namespacer.
4 5 6 |
# File 'lib/exigo.rb', line 4 def namespacer @namespacer end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/exigo.rb', line 4 def password @password end |
#transaction_details ⇒ Object
Returns the value of attribute transaction_details.
4 5 6 |
# File 'lib/exigo.rb', line 4 def transaction_details @transaction_details end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/exigo.rb', line 4 def username @username end |
#wsdl ⇒ Object
Returns the value of attribute wsdl.
4 5 6 |
# File 'lib/exigo.rb', line 4 def wsdl @wsdl end |
Instance Method Details
#new_order(shipping_info, order_properties, distributor_id, create_customer = true, test = false) ⇒ Object
Not yet complete
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 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/exigo.rb', line 21 def new_order(shipping_info,order_properties,distributor_id,create_customer=true, test=false) ship_to = {"api:FirstName" => shipping_info["api:FirstName"], "api:LastName" => shipping_info["api:LastName"], "api:Email" => shipping_info["api:Email"], "api:Phone" => shipping_info["api:Phone"], "api:Address1" => shipping_info["api:MainAddress1"], "api:City" => shipping_info["api:MainCity"], "api:State" => shipping_info["api:MainState"], "api:Zip" => shipping_info["api:MainZip"], "api:Country" => shipping_info["api:MainCountry"], } ret = { :success => true } order_id = nil begin if create_customer cc_res = make_request("create_customer", shipping_info) ret[:new_customer_id] = cc_res[:customer_id] order_info = ship_to.merge(order_properties) order_res = make_request("create_order",order_info) ret[:order_id] = order_res[:order_id] end rescue Exception=>e ret[:success] = false ret[:error] = e.to_s if ret[:order_id] #TODO: cancel order if there is an error after its created end end ret end |