Class: NotificationWorkers::Partner::PackagesReport

Inherits:
ApplicationWorker show all
Includes:
MoneyRails::ActionViewExtension, RollbarSynTokenSetterWorker, Sidekiq::Status::Worker
Defined in:
app/workers/notification_workers/partner/packages_report.rb

Overview

typed: true frozen_string_literal: true

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Attribute Details

#attachmentObject

Returns the value of attribute attachment.



10
11
12
# File 'app/workers/notification_workers/partner/packages_report.rb', line 10

def attachment
  @attachment
end

#emailsObject

Returns the value of attribute emails.



10
11
12
# File 'app/workers/notification_workers/partner/packages_report.rb', line 10

def emails
  @emails
end

#package_typeObject

Returns the value of attribute package_type.



10
11
12
# File 'app/workers/notification_workers/partner/packages_report.rb', line 10

def package_type
  @package_type
end

#pdf_urlObject

Returns the value of attribute pdf_url.



10
11
12
# File 'app/workers/notification_workers/partner/packages_report.rb', line 10

def pdf_url
  @pdf_url
end

#restaurant_idObject

Returns the value of attribute restaurant_id.



10
11
12
# File 'app/workers/notification_workers/partner/packages_report.rb', line 10

def restaurant_id
  @restaurant_id
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'app/workers/notification_workers/partner/packages_report.rb', line 10

def type
  @type
end

Instance Method Details

#perform(args, attachment_id = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/workers/notification_workers/partner/packages_report.rb', line 12

def perform(args, attachment_id = nil)
  assign_attributes(args)
  initialize_status
  find_or_initialize_attachment(attachment_id)

  begin
    I18n.locale = :en

    packages = collect_packages_list

    if pdf?
      generate_pdf_report(packages, args)
    else
      generate_excel_report
    end

    send_report_email
    mark_attachment_as_done
  rescue Aws::SES::Errors::Throttling => e
    handle_email_throttling(e)
  rescue StandardError => e
    handle_standard_error(e)
  end
end