REST API wrapper interacting with Emailvision
Latest commit ce163ac Nov 10, 2013 @basgys [Release] 2.2
Failed to load latest commit information.
lib [Release] 2.2 Nov 10, 2013
spec Refactor API #2 Nov 10, 2013
.irbrc Add irb script Oct 9, 2013
CHANGELOG.markdown [Release] 2.2 Nov 10, 2013
Gemfile Add yardoc Oct 12, 2013
Guardfile [Spec] Add some specs Oct 9, 2013
LICENSE Add license (MIT) #2 Nov 10, 2013
README.markdown Add license (MIT) #2 Nov 10, 2013
Rakefile [Travis] Fix Oct 9, 2013
emailvision.gemspec Add license (MIT) #2 Nov 10, 2013


Emailvision ruby/rails library

Build Status Code Climate Coverage Status Dependency Status

Emailvision is a REST API wrapper interacting with Emailvision. It :

  • Has a very comfortable syntax
  • Will support method addition on Emailvision API (dynamic call)
  • Has a clear documentation
  • Is well integrated with Rails, but can be used alone though
  • Is actively developed


If you use one of these versions 2.1.15 - 2.1.19 please update to 2.1.20 immediately. These versions are broken.


ruby 1.9.3 ruby 2.0


Without bundler

$ gem install emailvision

With bundler

Past this line to your Gemfile

gem 'emailvision'

Run bundler

$ bundle


Settable parameters

  • server_name
  • login
  • password
  • key
  • endpoint
  • token
  • debug (true/false)

#1 (Rails configuration file)

If you use Rails, you can set your config in the config/emailvision.yml file

Generate the config file:

rails generate emailvision:install

#2a (on loading)

It can also be set when you initialize your object:

emv = :login => "my_login", :password => "password", :key => "key", :endpoint => "endpoint"

#2b (on loading)

Or if you wanna get fancy, you can use this syntax:

emv = do |o|
    o.login = "my_login"
    o.password = "password"
    o.key = "key"
    o.endpoint = "endpoint"

#3 (afterward)

Of course these parameters can be changed after initialization:

emv.endpoint = "endpoint"


  • Parameters set in the config/emailvision.yml will be automaticaly added to your object. But if you want to override some of them, you just have to set them again at initialization or later.
  • Beware that if you change your endpoint, you will have to recall the open_connection method.


Endpoints available :

  • apiccmd (segment, campaign, message, ...)
  • apitransactional (transactional message)
  • apimember (member list)
# Set an endpoint
emv = :endpoint => "apitransactional"


emv.open_connection # Login to the given endpoint
emv.close_connection # Logout from the given endpoint
emv.connected? # Check connection status

Method calling syntax

emv.get.campaign.last(:limit => 5).call


  • emv instance of Emailvision::Api
  • get is the HTTP verb to use
  • campaign.last is the method name
  • (:limit => 5) is the parameter
  • call is the keyword to perform the API call


  • You cannot change the following order : http verbe / method name / call
  • You can set your API call and perform it later (lazy loading), so you won't have to add your business logic in the view


Data can be sent through URI, Query parameters and body. Here is an example of each :


Method to call : member/getMemberByEmail/{token}/{email}

emv.get.member.get_member_by_email(:uri => [""]).call

Query parameters

Method to call : member/getMemberById/

emv.get.member.get_member_by_id(:id => 10).call


Method to call : member/updateMember/

body = {
        {:key=>"FIRSTNAME", :value=>"Bastien"},
        {:key=>"LASTNAME", :value=>"Gysler"}
} => body).call


You can also combine these ways to send data

id => 10, :uri => [""], :body => {:foo => "bar"}


Debug mode show request sent/received in the console

It's also possible to monitor the traffic by using a proxy like this :

Emailvision::Api.http_proxy 'localhost', 8888

Then all requests will be redirected through the given proxy


  • Improves exception system
  • Improves logger (log file, ..)
  • Write some example in wiki pages


Please see LICENSE for licensing details.


Bastien Gysler :: :: @basgys