Commit b4f4f4c928d39687ed544655c67be3157939ba67
1 parent
744c1e81
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
adding contact email
Showing
2 changed files
with
29 additions
and
0 deletions
Show diff stats
lib/noosfero/api/api.rb
... | ... | @@ -0,0 +1,28 @@ |
1 | +module Noosfero | |
2 | + module API | |
3 | + module V1 | |
4 | + class Contacts < Grape::API | |
5 | + | |
6 | + resource :communities do | |
7 | + | |
8 | + resource ':id/contact' do | |
9 | + #contaxt => {:name => 'some name', :email => 'test@mail.com', :subject => 'some title', :message => 'some message'} | |
10 | + desc "Send a contact message" | |
11 | + post do | |
12 | + profile = environment.communities.find(params[:id]) | |
13 | + forbidden! unless profile.present? | |
14 | + contact = Contact.new params[:contact].merge(dest: profile) | |
15 | + if contact.deliver | |
16 | + {:success => true} | |
17 | + else | |
18 | + {:success => false} | |
19 | + end | |
20 | + end | |
21 | + | |
22 | + end | |
23 | + end | |
24 | + | |
25 | + end | |
26 | + end | |
27 | + end | |
28 | +end | ... | ... |