Class: Griddler::Sendgrid::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/griddler/sendgrid/adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Adapter

Returns a new instance of Adapter.



4
5
6
# File 'lib/griddler/sendgrid/adapter.rb', line 4

def initialize(params)
  @params = params
end

Class Method Details

.normalize_params(params) ⇒ Object



8
9
10
11
# File 'lib/griddler/sendgrid/adapter.rb', line 8

def self.normalize_params(params)
  adapter = new(params)
  adapter.normalize_params
end

Instance Method Details

#normalize_paramsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/griddler/sendgrid/adapter.rb', line 13

def normalize_params
  params.merge(
    to: recipients(:to).map(&:format),
    cc: recipients(:cc).map(&:format),
    bcc: get_bcc,
    attachments: attachment_files,
    charsets: charsets,
    spam_report: {
      report: params[:spam_report],
      score: params[:spam_score],
    }

  )
end