denys-potapov / emailwizard-ruby

Ruby integration for emailwizard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EmailWizard

Ruby integration for EmailWizard.io

Installation

Add this line to your application's Gemfile:

gem 'email_wizard'

And then execute:

$ bundle

Or install it yourself as:

$ gem install email_wizard

Usage

Config client

    client = EmailWizard::Client.new
    client.config = EmailWizard::Config.new(
      api_key: 1,
      provider: :sendgrid,
      provider_credentials: {
        api_key: 2
      },
      from: 'no-reply@example.org'
    )

You can set default project id instead of passing it on each call:

    client.current_project_id = 1

Fetch template

See https://docs.emailwizard.io/fetching_emails_api.html for details:

    template = client.fetch_template(template_name: 'hello', payload: {name: 'John Doe'})

    # in case of status code > 299, Emailwizard::DeliveryFailure is thrown
    template.html  # ==> "<html> ...."
    template.text  # ==> "Mail text"

Send template

See https://docs.emailwizard.io/sending_emails_api.html for details:

    message = client.send_template(template_name: 'hello', subject: 'Hello!',
                     recipients: ['user@example.com'], payload: {name: 'John Doe'})

    # in case of status code > 299, Emailwizard::DeliveryFailure is thrown
    message.id  # message id 
    message.messages  # ==> messages - array with messages.
                      # Messages can be string or json objects, depending on service used.

Development

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/emailwizard/emailwizard-ruby.

License

The gem is available as open source under the terms of the MIT License.

About

Ruby integration for emailwizard

License:MIT License


Languages

Language:Ruby 98.8%Language:Shell 1.2%