Class: Feed::TransmitEmail
- Inherits:
-
Object
- Object
- Feed::TransmitEmail
- Defined in:
- app/services/feed/transmit_email.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ TransmitEmail
constructor
A new instance of TransmitEmail.
- #process(upload) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TransmitEmail
Returns a new instance of TransmitEmail.
10 11 12 13 14 15 16 17 |
# File 'app/services/feed/transmit_email.rb', line 10 def initialize(={}) @logger = .delete(:logger) @recipient_contact_points = [:recipient_contact_points] @sender_email = [:sender_email] @cc_email = [:cc_email] @extra_emails = [:extra_emails] @options = end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'app/services/feed/transmit_email.rb', line 3 def logger @logger end |
Instance Method Details
#process(upload) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/feed/transmit_email.rb', line 19 def process(upload) result_hsh = {} begin result_hsh[:transmitted] = false #Default result_hsh[:status] = :error # Default communication = CommunicationBuilder.new( emails: @extra_emails.map(&:presence).presence, sender: @sender_email, cc: @cc_email, recipient_contact_points: @recipient_contact_points, template_system_code: 'INVENTORY_FEED', uploads: [upload]).create result_hsh[:transmitted] = true result_hsh[:status] = :ok result_hsh[:upload] = upload result_hsh[:communication] = communication rescue StandardError => exc msg = "Failed to transmit. #{@options.inspect} - #{exc.}" result_hsh[:message] = msg ErrorReporting.error(exc, msg) end Result.new(**result_hsh) end |