class Solo::Customer
Public Class Methods
create!(arguments)
click to toggle source
# File lib/solo/customer.rb, line 39 def self.create!(arguments) raise "Configuration Not Set" if Solo.configuration.nil? endpoint = URI('http://secure.softwarekey.com/solo/webservices/customerserver.asmx/CreateCustomer') auth = {} auth[:authorID] = Solo.configuration.author_id auth[:userID] = Solo.configuration.username auth[:userPassword] = Solo.configuration.password auth[:companyName] = '' auth[:firstName] = '' auth[:lastName] = '' auth[:address1] = '' auth[:address2] = '' auth[:city] = '' auth[:stateProvince] = '' auth[:postalCode] = '' auth[:country] = '' auth[:email] = '' auth[:password] = '' auth[:phone] = '' auth[:fax] = '' auth[:nickname] = '' auth[:offerProduct] = false auth[:offerPartners] = false auth.merge!(arguments) result = Net::HTTP.post_form(endpoint, auth) parser = Nori.new parsed = parser.parse(result.body) if parsed.has_key?("int") return parsed["int"].to_i else return parsed end end
search(arguments)
click to toggle source
# File lib/solo/customer.rb, line 3 def self.search(arguments) raise "Configuration Not Set" if Solo.configuration.nil? endpoint = URI('http://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx/CustomerSearchS') # build xml xml = String.new xml += '<CustomerSearch>' xml += Solo.configuration.to_xml arguments.each { |key, value| xml += "<#{key}>#{value}</#{key}>" } xml += '</CustomerSearch>' result = Net::HTTP.post_form(endpoint, 'xml' => xml) parser = Nori.new parsed = parser.parse(result.body) return parsed["Customers"] end
search_by_id(id)
click to toggle source
# File lib/solo/customer.rb, line 18 def self.search_by_id(id) raise "Configuration Not Set" if Solo.configuration.nil? endpoint = URI('http://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx/GetCustomerDataByAuthorS') if id.blank? puts "ID can not be blank" else # build xml xml = String.new xml += '<GetCustomerDataByAuthor>' xml += Solo.configuration.to_xml xml += "<CustomerID>#{id}</CustomerID>" xml += '</GetCustomerDataByAuthor>' result = Net::HTTP.post_form(endpoint, 'xml' => xml) parser = Nori.new parsed = parser.parse(result.body) #return parsed["CustomerData"] if parsed["CustomerData"].has_key? "ResultCode" #return parsed["CustomerData"]["Customer"] return parsed["CustomerData"] end end