Sha256: 0792544942b05f69a02370865537939a870462b86551ec9e5e038fe2442a0d74

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

module TwilioBase
  module TaskRouter
    class Task < Base
      class << self
        def create(task_attributes:, **options)
          workspace.tasks.create(
            attributes: task_attributes.to_json,
            workflow_sid: workflow_sid,
            **options
          )
        end

        def find(sid)
          workspace.tasks(sid).fetch
        end

        def where(attributes)
          workspace.tasks.list(
            evaluate_task_attributes: evaluable_attributes(attributes)
          )
        end

        private

        def evaluable_attributes(attributes)
          attributes.map { |k, v| "#{k} == '#{v}'" }.join(' AND ')
        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/task_router/task.rb
twilio_base-1.11.11 app/services/twilio_base/task_router/task.rb
twilio_base-1.9.0 app/services/twilio_base/task_router/task.rb
twilio_base-1.8.0 app/services/twilio_base/task_router/task.rb