Class: ChimpactionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ChimpactionsController
- Defined in:
- app/controllers/chimpactions_controller.rb
Instance Method Summary collapse
- #add_webhook ⇒ Object
-
#create ⇒ Object
POST /chimpactions POST /chimpactions.xml.
- #delete_webhook ⇒ Object
-
#destroy ⇒ Object
DELETE /chimpactions/1 DELETE /chimpactions/1.xml.
-
#edit ⇒ Object
GET /chimpactions/1/edit.
- #index ⇒ Object
-
#new ⇒ Object
GET /chimpactions/new GET /chimpactions/new.xml.
- #receive ⇒ Object
-
#update ⇒ Object
PUT /chimpactions/1 PUT /chimpactions/1.xml.
- #webhooks ⇒ Object
Instance Method Details
#add_webhook ⇒ Object
73 74 75 76 77 78 79 |
# File 'app/controllers/chimpactions_controller.rb', line 73 def add_webhook list = Chimpactions.list(params[:id]) if list.set_webhook :url => 'http://www.postbin.org/1iwea1s'#webhook_url flash[:notice] = "Added Webhook!" end redirect_to '/chimpactions/webhooks' end |
#create ⇒ Object
POST /chimpactions POST /chimpactions.xml
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/chimpactions_controller.rb', line 27 def create @chimpaction = Chimpaction.new(params[:chimpaction]) respond_to do |format| if @chimpaction.save format.html { redirect_to(chimpactions_url, :notice => 'Chimpaction was successfully created.') } format.xml { render :xml => @chimpaction, :status => :created, :location => @chimpaction } else format.html { render :action => "new" } format.xml { render :xml => @chimpaction.errors, :status => :unprocessable_entity } end end end |
#delete_webhook ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/controllers/chimpactions_controller.rb', line 81 def delete_webhook list = Chimpactions.list(params[:id]) if list.remove_webhook :url => 'http://www.postbin.org/1iwea1s' #webhook_url flash[:notice] = "Removed Webhook!" end redirect_to '/chimpactions/webhooks' end |
#destroy ⇒ Object
DELETE /chimpactions/1 DELETE /chimpactions/1.xml
59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/chimpactions_controller.rb', line 59 def destroy @chimpaction = Chimpaction.find(params[:id]) @chimpaction.destroy respond_to do |format| format.html { redirect_to(chimpactions_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /chimpactions/1/edit
21 22 23 |
# File 'app/controllers/chimpactions_controller.rb', line 21 def edit @chimpaction = Chimpaction.find(params[:id]) end |
#index ⇒ Object
2 3 4 5 6 7 |
# File 'app/controllers/chimpactions_controller.rb', line 2 def index @all_actions = Chimpactions.actions @registered = Chimpactions.registered_class_name @actions = Chimpaction.all @lists = Chimpactions.available_lists end |
#new ⇒ Object
GET /chimpactions/new GET /chimpactions/new.xml
11 12 13 14 15 16 17 18 |
# File 'app/controllers/chimpactions_controller.rb', line 11 def new @chimpaction = Chimpaction.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @chimpaction } end end |
#receive ⇒ Object
89 90 91 92 93 94 95 |
# File 'app/controllers/chimpactions_controller.rb', line 89 def receive if params['data'] subscriber = Chimpactions.registered_class.find_by_email(params['data']['email']) subscriber.receive_webhook(params) if subscriber.respond_to?(:receive_webhook) end render :nothing => true end |
#update ⇒ Object
PUT /chimpactions/1 PUT /chimpactions/1.xml
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/chimpactions_controller.rb', line 43 def update @chimpaction = Chimpaction.find(params[:id]) respond_to do |format| if @chimpaction.update_attributes(params[:chimpaction]) format.html { redirect_to(chimpactions_url, :notice => 'Chimpaction was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @chimpaction.errors, :status => :unprocessable_entity } end end end |
#webhooks ⇒ Object
69 70 71 |
# File 'app/controllers/chimpactions_controller.rb', line 69 def webhooks @lists = Chimpactions.available_lists end |