From 8fd16e2b285d987ae6b208dc268d5ae84576cdb8 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 20 Oct 2016 18:26:49 +0200 Subject: [PATCH] api contact --- Gemfile | 4 +++- app/controllers/contact_controller.rb | 29 +++++++++++++++++++++++++++ config/environments/development.rb | 1 + config/environments/production.rb | 4 ++-- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 546d14d..e05bda0 100644 --- a/Gemfile +++ b/Gemfile @@ -70,4 +70,6 @@ gem 'curb' gem 'kaminari-bootstrap' -gem 'fastimage' \ No newline at end of file +gem 'fastimage' + +gem 'curb' \ No newline at end of file diff --git a/app/controllers/contact_controller.rb b/app/controllers/contact_controller.rb index 2078225..e27b28f 100644 --- a/app/controllers/contact_controller.rb +++ b/app/controllers/contact_controller.rb @@ -10,5 +10,34 @@ class ContactController < ApplicationController @lang = LangSite.first @params = params DemandeMail.prise(@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 diff --git a/config/environments/development.rb b/config/environments/development.rb index 05a82e6..ea65e4e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -43,4 +43,5 @@ Rails.application.configure do config.action_mailer.delivery_method = :file config.action_mailer.default_url_options = { :host => HOSTNAME } + UAL_API_HOST = "localhost:3000" end diff --git a/config/environments/production.rb b/config/environments/production.rb index 326e250..c3a272a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -77,8 +77,8 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - HOSTNAME="test.com" - + HOSTNAME="luxlaverie.com" + UAL_API_HOST = "une-autre-laverie.com" #config.action_mailer.delivery_method = :file config.action_mailer.default_url_options = { :host => HOSTNAME }