A Elastic Email HTTP API Ruby wrapper
Add this line to your application's Gemfile:
gem 'elasticemail', git: "git://github.com/klebervirgilio/elasticemail.git"
And then execute:
$ bundle
# Add an account
Elasticemail::Accounts.add do |account|
account.email = '[email protected]'
account.password = 'p4550rD!'
account.confirm_password = 'p4550rD!'
account.marketing_type!
end
# Delete an account
Elasticemail::Accounts.delete do |delete_account|
delete_account.notify = false
delete_account.public_account_id = 'account.publicaccountid'
end
# Load an account
Elasticemail::Accounts.find('account.apikey')
# Load update http notification url
Elasticemail::Accounts.update_http_notification_url do |notification|
notification.api_key = api_key
notification.clicked = true
notification.opened = true
notification.sent = true
notification.url = "http://example.com"
end
# Add a contact
Elasticemail::Contacts.add do |contact|
contact.email = '[email protected]'
contact.requires_activation = false
contact.public_account_id = 'account.publicaccountid'
end
# Delete a contact
Elasticemail::Contacts.delete do |contact|
contact.api_key = 'account.apikey'
contact.emails = '[email protected]'
end
# Load a contact
Elasticemail::Contacts.find do |contact|
contact.api_key = 'account.api_key'
contact.email = '[email protected]'
end
# Add an attachment
Elasticemail::Attachments.upload do |attachment|
attachment.attachment_path = csv_file
attachment.attachment_content_type = 'text/csv'
end
# Get an attachment
Elasticemail::Attachments.get(file_name, attachment_id, api_key)
# Remove an attachment
Elasticemail::Attachments.remove(file_name)
# Send email
Elasticemail::Emails.deliver do |email|
email.charset = 'utf-8'
email.post_back = 'http://requestb.in/...'
email.reply_to_email = 'reply to name'
email.channel = 'aka tag'
email.reply_to = '[email protected]'
email.from_name = 'from name'
email.from = '[email protected]'
email.to = '[email protected],[email protected]'
email.msg_to = '[email protected],[email protected]'
email.msg_cc = '[email protected],[email protected]'
email.subject = 'Subject'
email.body_html = '<h1>hi</h1><a href="http://www.google.com">link...</a>'
email.body_text = 'hi'
end
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/klebervirgilio/elasticemail. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.