Last active
December 14, 2015 15:39
-
-
Save hueyl77/5109518 to your computer and use it in GitHub Desktop.
This file contains 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 MailgunGateway | |
def send_batch_message(options={}) | |
RestClient.post(messaging_api_end_point, | |
from: default_sender, | |
to: delivery_filter(options[:to]), | |
subject: options[:subject], | |
html: options[:body], | |
:"h:Reply-To" => options[:reply_to], | |
:"recipient-variables" => options[:recipient_variables] | |
) if Rails.env.staging? || Rails.env.production? | |
end | |
end | |
private | |
def default_sender | |
"Tealeaf Academy " | |
end | |
def api_key | |
@api_key ||= ENV['mailgun_api_key'] | |
end | |
def messaging_api_end_point | |
@messaging_api_end_piont ||= | |
"https://api:#{api_key}@api.mailgun.net/v2/messaging.gotealeaf.com/messages" | |
end | |
def delivery_filter(emails) | |
Rails.env.production? ? emails : "kevin@gotealeaf.com, chris@gotealeaf.com" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment