Created
April 10, 2019 11:51
-
-
Save sanjay-btc/71fe5fc0c7ec71c3ca9818479a8965ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationMailbox < ActionMailbox::Base | |
routing ->(inbound_email) { with_sku?(inbound_email) } => :price_finder | |
def self.with_sku?(inbound_email) | |
inbound_email.mail.subject.include?('SKU') || inbound_email.mail.body.include?('SKU') | |
end | |
end | |
class PriceFinderMailbox < ApplicationMailbox | |
def process | |
# Extract product_id and quantities | |
# Call API to get the price of the product | |
# total price = quantities * price | |
# Draft email and send this price to sender via email. | |
Quotation.with_price(mail.to.first).deliver_now | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment