summaryrefslogtreecommitdiff
path: root/app/controllers/api/v1/pager_groups_controller.rb
blob: 468a6aa3527e5a71e8fad62a6828540a1f46544a (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Api
  module V1
    class PagerGroupsController < ApplicationController
      respond_to :json

      skip_before_filter :verify_authenticity_token

      def index
        # if params[:ids]
        #   @sip_accounts = SipAccount.where(:id => params[:ids])
        # else
        #   @sip_accounts = SipAccount.all
        # end
        @pager_groups = PagerGroup.all

        respond_with @pager_groups
      end

      def show
        @pager_group = PagerGroup.find(params[:id])

        respond_with @pager_group
      end 

      def new
        if params[:sip_account_id] && SipAccount.find(params[:sip_account_id])
          @pager_group = SipAccount.find(params[:sip_account_id]).pager_groups.new
          @pager_group.callback_url = params[:callback_url]
          @pager_group.pager_group_destination_ids = params[:pager_group_destination_ids]
          if @pager_group.save
            respond_with @pager_group
          end
        end

      end

      # def create
      #   @pager_group = PagerGroup.new(params[:pager_group])
      #   if @pager_group.save
      #     redirect_to @pager_group, :notice => t('pager_groups.controller.successfuly_created')
      #   else
      #     render :new
      #   end
      # end

      def destroy
        @pager_group = PagerGroup.find(params[:id])
        @pager_group.destroy
        respond_with nil
      end      

    end
  end
end