Sha256: dee077c4426143d514874baac4009f83a9eebed928ecfd49a7abcf6c2be1738f
Contents?: true
Size: 930 Bytes
Versions: 7
Compression:
Stored size: 930 Bytes
Contents
# frozen_string_literal: true require 'emailbutler/webhooks/mappers/sendgrid' require 'emailbutler/webhooks/mappers/smtp2go' module Emailbutler module Webhooks class Receiver SENDGRID_USER_AGENT = 'SendGrid Event API' SMTP2GO_USER_AGENT = 'Go-http-client/1.1' RECEIVERS_MAPPER = { 'SendGrid Event API' => Emailbutler::Webhooks::Mappers::Sendgrid, 'Go-http-client/1.1' => Emailbutler::Webhooks::Mappers::Smtp2Go }.freeze def self.call(...) new.call(...) end def call(user_agent:, payload:) mapper = RECEIVERS_MAPPER[user_agent] return unless mapper mapper .call(payload: payload) .each { |event| message = Emailbutler.find_message_by(uuid: event.delete(:message_uuid)) next unless message Emailbutler.update_message(message, event) } end end end end
Version data entries
7 entries across 7 versions & 1 rubygems