14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/emailbutler/webhooks/mappers/sendgrid.rb', line 14
def call(payload:)
payload['_json'].filter_map { |message|
message.stringify_keys!
message_uuid = message['smtp-id'] || message['sg_message_id']
status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
next if message_uuid.nil? || status.nil?
{
message_uuid: message_uuid,
status: status,
timestamp: message['timestamp'] ? Time.at(message['timestamp'].to_i).utc.to_datetime : nil
}
}
end
|