ryu39/sendgrid_actionmailer_adapter

View on GitHub
lib/sendgrid_actionmailer_adapter/converters/send_at.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

require 'sendgrid-ruby'

module SendGridActionMailerAdapter
  module Converters
    class SendAt
      def validate(_mail)
      end

      def convert(mail)
        send_at_str = mail['send_at']&.value
        return if send_at_str.nil? || send_at_str.empty?

        send_at_str.to_i
      end

      def assign_attributes(sendgrid_mail, value)
        sendgrid_mail.send_at = value
      end
    end
  end
end