Sha256: 92ff52fe7802a794452f3b5f82ff5be3560d5741b6ba9acfcea60ebee000a8ca

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require_dependency "sipgate_io/application_controller"

module SipgateIo
  class EventsController < ApplicationController
    skip_before_action :verify_authenticity_token, raise: false
    before_action :add_response_header

    def create
      (head 500 and return) unless params.key?(:event)

      event = create_event(params)

      (head 500 and return) if event.invalid?


      answer = event.process
      render xml: answer
    end

    private

    def add_response_header
      response.headers["X-API-Client"] = "sipgate_io-#{SipgateIo::VERSION} (source: https://github.com/superbilk/sipgate_io)"
    end

    def create_event(params)
      event_type = params[:event].clone
      event_type[0] = event_type[0].upcase
      "SipgateIo::#{event_type}".constantize.new(params)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sipgate_io-0.3.4 app/controllers/sipgate_io/events_controller.rb
sipgate_io-0.3.3 app/controllers/sipgate_io/events_controller.rb