Sha256: d0d5896825ffa6ce68d23d98ead752d70da5b4cf326b5d76483d05c8bb67ec5b
Contents?: true
Size: 1.85 KB
Versions: 4
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true module TwilioBase module Fake module TaskRouter class Task Task = Struct.new( :sid, :workflow_sid, :task_channel, :attributes, :age, :priority, :task_queue_friendly_name, :timeout ) do def assignment_status JSON.parse(attributes)['assignment_status'] end def delete TwilioBase::Fake::TaskRouter::Task.tasks -= [self] end def task_channel_unique_name task_channel&.name end def update(params = {}) self.attributes = params.to_json end def update(params) attributes = JSON.parse(params[:attributes] || '{}') self.attributes = attributes.merge(params.except(:attributes)) .to_json end end cattr_accessor :sid, :tasks self.tasks = [] def initialize(sid = nil) self.sid = sid || FactoryBot.generate(:task_sid) end def create(attributes) task = Task.new( sid, attributes[:workflow_sid], attributes[:task_channel], task_attributes(attributes), attributes[:age], attributes[:priority], attributes[:task_queue_friendly_name], attributes[:timeout] ) self.class.tasks << task task end def task_attributes(attributes) if attributes[:attributes].present? attributes[:attributes] else { assignment_status: 'reserved' }.to_json end end def list(_attributes = {}) tasks end def fetch tasks.detect { |task| task.sid == sid } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems