class ContactController < ApplicationController
  
  layout "public"
  
  def new
    @lang = LangSite.first
  end

  def create
    @lang = LangSite.first
    @params = params
    DemandeMail.prise(@params).deliver
    DemandeMail.remerciement(@params).deliver
    
    
    api_url = "http://#{UAL_API_HOST}/admin/contacts/api"


    @c = Curl::Easy.new(api_url) do |curl|      
      curl.verbose = true
    end


    @c.http_post(
    Curl::PostField.content(:name, @params[:name]),
    Curl::PostField.content(:address, @params[:address]),
    Curl::PostField.content(:address2, @params[:address2]),
    Curl::PostField.content(:cp, @params[:cp]),
    Curl::PostField.content(:city, @params[:city]),
    Curl::PostField.content(:tel, @params[:tel]),
    Curl::PostField.content(:mail, @params[:mail]),
    Curl::PostField.content(:place, @params[:place]),
    Curl::PostField.content(:type, @params[:type].to_s),
    Curl::PostField.content(:owner, @params[:owner].to_s),
    Curl::PostField.content(:message, @params[:message])
    
    )

    @debug = @c.body_str
    
    
    
  end
end
