Sha256: 2369b23089d52bbdf829da97742908147040d4e5b07a9ed09b75fbf5e522c5bc

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

module ActionMailboxAmazonIngress
  module RSpec
    class Email
      def initialize(authentic: true, topic: 'topic:arn:default', mail: default_mail, message_params: {})
        @authentic = authentic
        @topic = topic
        @mail = mail
        @message_params = message_params
      end

      def headers
        { 'content-type' => 'application/json' }
      end

      def url
        '/rails/action_mailbox/amazon/inbound_emails'
      end

      def params
        {
          'Type' => 'Notification',
          'TopicArn' => @topic,
          'Message' => message_json
        }
      end

      def message_json
        {
          'notificationType' => 'Received',
          'content' => @mail.encoded
        }.merge(@message_params).to_json
      end

      def authentic?
        @authentic
      end

      def default_mail
        Mail.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_mailbox_amazon_ingress-0.2.0 lib/action_mailbox_amazon_ingress/rspec/email.rb