Class: Report::SmartServices::SmartServicesCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::SmartServices::SmartServicesCommand
- Defined in:
- app/models/report/smart_services/smart_services_command.rb
Instance Method Summary collapse
- #execute ⇒ Object
- #success? ⇒ Boolean
- #to_smart_services_by_rep_csv ⇒ Object
- #to_smart_services_by_report_grouping_csv ⇒ Object
Instance Method Details
#execute ⇒ Object
10 11 12 13 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 10 def execute return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) end |
#success? ⇒ Boolean
41 42 43 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 41 def success? valid? && @result.success? end |
#to_smart_services_by_rep_csv ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 28 def to_smart_services_by_rep_csv return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) return unless @result.smart_services_data_breakdown_by_rep.present? attributes = @result.smart_services_data_breakdown_by_rep.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.smart_services_data_breakdown_by_rep.each do |r| csv << r end end end |
#to_smart_services_by_report_grouping_csv ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/report/smart_services/smart_services_command.rb', line 15 def to_smart_services_by_report_grouping_csv return unless valid? @result = Report::SmartServices::SmartServices.result(attributes) return unless @result.smart_services_data_breakdown.present? attributes = @result.smart_services_data_breakdown.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.smart_services_data_breakdown.each do |r| csv << r end end end |