lib/email/delivery/client.rb
# Goal of this method is to serve email by one of the service providers
# In case of a failure return a status code and a failure message.
Goal of this method is to serve email by one of the service providers
In case of a failure return a status code and a failure message.
Goal of this method is to serve email by one of the service providers In case of a failure return a status code and a failure message .
def dispatch
        response = Email::Delivery::SendgridClient.new.dispatch(from, to, cc, bcc, subject, body)
        if [200, 202].include?(response[:status])
          status = 0
          message = 'success'
        else
          response = Email::Delivery::MailgunClient.new.dispatch(from, to, cc, bcc, subject, body)
          if response[:status] == 200
            status = 0
            message = 'success'
          else
            status = 4
            message = "Emails failed in sending. The error message is as followed: #{ response[:message] }"
          end
        end
        {status: status, message: message}
      end
def dispatch response = Email :: Delivery :: SendgridClient . new . dispatch ( from , to , cc , bcc , subject , body ) if [ 200 , 202 ] . include? ( response [ :status ] ) status = 0 message = 'success' else response = Email :: Delivery :: MailgunClient . new . dispatch ( from , to , cc , bcc , subject , body ) if response [ :status ] == 200 status = 0 message = 'success' else status = 4 message = "Emails failed in sending. The error message is as followed: #{ response[:message] }" end end { status : status , message : message } end
Goal of this method is to serve email by one of the service providers
In case of a failure return a status code and a failure message.
Goal of this method is to serve email by one of the service providers In case of a failure return a status code and a failure message .