Sha256: 7281fe4f52e6eca6d9842c837ee3a2e3d8e1ce40035627b70c1481a67933ba79

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

module TwilioBase
  module Routers
    module Voice
      class TaskRouter < Base
        def route
          yield_response = yield if block_given?
          (yield_response || voice_response).enqueue(enqueue_params) do |e|
            e.task task_attributes
          end.to_s
        end

        private

        def enqueue_params
          {
            action: protocol.action_url,
            wait_url: protocol.wait_url,
            workflow_sid: workflow_sid
          }
        end

        def task_attributes
          { outbound_contact_uri: protocol.endpoint }
        end

        def workflow_sid
          @workflow_sid ||= TwilioBase::GlobalConfig.first.workflow_sid
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twilio_base-1.11.1101 app/services/twilio_base/routers/voice/task_router.rb
twilio_base-1.11.11 app/services/twilio_base/routers/voice/task_router.rb
twilio_base-1.9.0 app/services/twilio_base/routers/voice/task_router.rb
twilio_base-1.8.0 app/services/twilio_base/routers/voice/task_router.rb