cirandas.net

ref: master

app/api/v1/contacts.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Api
  module V1
    class Contacts < Grape::API

      resource :communities do

        resource ':id/contact' do
          #contact => {:name => 'some name', :email => 'test@mail.com', :subject => 'some title', :message => 'some message'}
          desc "Send a contact message"
          post do
            profile = environment.communities.find(params[:id])
            forbidden! unless profile.present?
            contact = Contact.new params[:contact].merge(dest: profile)
            if contact.deliver
              {:success => true}
            else
              {:success => false}
            end
          end

        end
      end

    end
  end
end