Sha256: f12566f23e566af5c164272cfce97832cfcd7c8d065096a0f663cd9d74b98049

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literals: true

module Jobshop
  class RFQHandler
    def initialize(message, organization:)
      @from = message.from.first
      @subject = message.subject
      @content = message.text_part.decoded
      @organization = organization
    end

    def process
      new_rfq = @organization.rfqs.create({
        from: @from,
        subject: @subject,
        content: @content
      })

      if new_rfq.persisted?
        # TODO: Send response email to customer
        # TODO: Send rfq to quoting queue.
        return new_rfq
      else
        # TODO: There was some kind of failure which should be logged.
        return false
      end
    end

    # Whether or not to copy the original to a new location after processing.
    def copy_after_processing?
      true
    end

    # Whether or not to delete the original item after processing.
    def delete_after_processing?
      true
    end

    def processed_copy_prefix
      "rfqs/processed"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.163 app/email_handlers/jobshop/rfq_handler.rb