# 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