Class: Mapper::Imap::SupportEmails

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/bas/mapper/imap/support_emails.rb

Overview

This class implementats the methods of the Mapper::Base module, specifically designed for preparing or shaping support emails data coming from a Fetcher::Base implementation.

Instance Method Summary collapse

Instance Method Details

#map(imap_response) ⇒ Object

Implements the logic for shaping the results from a fetcher response.


Params:

  • Fetcher::Imap::Types::Response imap_response: Array of imap emails data.


return List<Domain::Email> support_emails_list, mapped support emails to be used by a Formatter::Base implementation.



24
25
26
27
28
29
30
31
32
# File 'lib/bas/mapper/imap/support_emails.rb', line 24

def map(imap_response)
  return [] if imap_response.results.empty?

  normalized_email_data = normalize_response(imap_response.results)

  normalized_email_data.map do |email|
    Domain::Email.new(email["subject"], email["sender"], email["date"])
  end
end