Class: Report::MissedCalls::MissedCallsCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
app/services/report/missed_calls/missed_calls_command.rb

Overview

Command pattern to encapsulate parameters necessary to run a presence report

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#result_type_filterObject (readonly)

Filter on the call result type: both, completed, or not_completed.

Validations:

  • Inclusion ({ in: %w[both completed not_completed] })


10
# File 'app/services/report/missed_calls/missed_calls_command.rb', line 10

validates :result_type_filter, inclusion: { in: %w[both completed not_completed] }

Instance Method Details

#executeObject

Run the report with the given filters and store the result.

Returns:

  • (Object)


14
15
16
17
18
# File 'app/services/report/missed_calls/missed_calls_command.rb', line 14

def execute
  return unless valid?

  @result = Report::MissedCalls::MissedCalls.result_report(attributes)
end

#success?Boolean

Whether the command validated and ran successfully.

Returns:

  • (Boolean)


28
29
30
# File 'app/services/report/missed_calls/missed_calls_command.rb', line 28

def success?
  valid? && @result.success?
end

#unfiltered_dataObject

Unfiltered data.

Returns:

  • (Object)


22
23
24
# File 'app/services/report/missed_calls/missed_calls_command.rb', line 22

def unfiltered_data
  Report::MissedCalls::MissedCalls.result_report(attributes.merge(result_type_filter: 'both')).data
end