Class: Paubox::MailToMessage

Inherits:
Object
  • Object
show all
Includes:
FormatHelper
Defined in:
lib/paubox/mail_to_message.rb

Overview

The MailToMessage class takes a Ruby Mail object and attempts to parse it into a Hash formatted for the JSON payload of HTTP api request.

Constant Summary

Constants included from FormatHelper

FormatHelper::BASE64_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#base64_encode_if_needed, #base64_encoded?, #convert_keys_to_json_version, #ruby_to_json_key, #squish, #string_or_array_to_array

Constructor Details

#initialize(mail, args = {}) ⇒ MailToMessage

Returns a new instance of MailToMessage.



11
12
13
14
15
# File 'lib/paubox/mail_to_message.rb', line 11

def initialize(mail, args = {})
  @mail = mail
  @allow_non_tls = args.fetch(:allow_non_tls, false)
  @force_secure_notification = args.fetch(:force_secure_notification, nil)
end

Instance Attribute Details

#mailObject (readonly)

Returns the value of attribute mail.



8
9
10
# File 'lib/paubox/mail_to_message.rb', line 8

def mail
  @mail
end

Instance Method Details

#send_message_payloadObject



17
18
19
# File 'lib/paubox/mail_to_message.rb', line 17

def send_message_payload
  { data: { message: convert_keys_to_json_version(build_parts) } }.to_json
end