Class: Incoming::Strategies::SendGrid
- Inherits:
-
Object
- Object
- Incoming::Strategies::SendGrid
- Includes:
- Incoming::Strategy
- Defined in:
- lib/incoming/strategies/sendgrid.rb
Instance Attribute Summary
Attributes included from Incoming::Strategy
Instance Method Summary collapse
-
#initialize(request) ⇒ SendGrid
constructor
A new instance of SendGrid.
Methods included from Incoming::Strategy
#authenticate, included, #receive
Constructor Details
#initialize(request) ⇒ SendGrid
Returns a new instance of SendGrid.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/incoming/strategies/sendgrid.rb', line 8 def initialize(request) params = request.params.dup # TODO: Properly handle encodings encodings = JSON.parse(params['charsets']) = 1.upto(params['attachments'].to_i).map do |num| (params["attachment#{num}"]) end @message = Mail.new do header params['headers'] if encodings['text'].blank? body params['text'] else body params['text'].force_encoding(encodings['text']).encode('UTF-8') end html_part do content_type 'text/html; charset=UTF-8' if encodings['html'].blank? body params['html'] else body params['html'].force_encoding(encodings['html']).encode('UTF-8') end end if params['html'] .each do || add_file() end end end |