Skip to content

Instantly share code, notes, and snippets.

@anbublacky
Last active December 30, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anbublacky/7794179 to your computer and use it in GitHub Desktop.
Save anbublacky/7794179 to your computer and use it in GitHub Desktop.
style code
task :import_car_style => [:environment] do
client = Savon.new('https://services.chromedata.com/AutomotiveConfigCompareService/AutomotiveConfigCompareService3?WSDL')
service = "AutomotiveConfigCompareService3"
port = "AutomotiveConfigCompareService3Port"
getstyle = "getStyles"
style = client.operation(service, port, getstyle)
order_availability = ["Fleet", "Retail"]
order_availability.each do |availability|
ModelDefinition.all.each do |f|
style.body = {:StylesRequest=>{:accountInfo=>{:accountNumber=>"xxx", :accountSecret=>"xxx", :locale=>{:country$
response = style.call
error = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n \"http$
if !(response.raw == error)
hash_body = response.body
puts hash_body
if hash_body[:style_array_element]
hash_style = hash_body[:style_array_element][:style]
puts hash_style
if hash_style
if hash_style.first
puts "*******************************************First**************************"
hash_style.each do |f|
puts f
if f.first
puts f[:division_id]
puts f[:division_name]
puts f[:subdivision_id]
puts f[:model_id]
puts f[:model_name]
puts f[:style_id]
puts f[:stock_photo_url]
puts f[:style_id]
puts f[:stock_photo_url]
if f[:division_name] == "Aston martin" || f[:division_name] == "Bentley" || f[:division_name] == "Ferrari" || f[:d$
else
puts "*************Creating car make***************"
# carmake = Carmake.where(:makename => f[:division_name].to_s, :makeid => f[:division_id]).first_or_create
end
end
end
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment