Mensario: a wrapper around Mensario API

This gem allows us to perform the following operations through the mensario API:

Config

There are three ways to set configuration parameters of Mensario:

Separately

Mensario::license =  "PERT123446423"
Mensario::username = "caer3456"

Block of code

Mensario::set_config do |m|
  m.license = "PERT123446423"
  m.username = "caer3456"
  m.password = "frt3gg5"
end

Through a YAML file

By default, Mensario expects a YAML configuration file in config/mensario.yml root path of our application.

The YAML file expects to have the following scheme:

:profilename:
    :license: ABCD1234
    :username: user0
    :password: pass0
:otherprofile:
    :license: ABDC1234
    :username: user1
    :password: pass1

If the config file is located in another location we have available the method Mensario::config in order to use some different configuration. The config options are:

For example, using an alternative config file:

Mensario::config :config => /path/to/file.yml

Another example, using an alternative profile:

Mensario::config :profile => :otherprofile

Sending a message

To send a message, we need some options:

All options are required except :date and :timezone:

If a message is sent correctly the method return its id.

An example may be something like this:

opts = {
  :sender => 'Myself'
  :text => 'My message'
  :code => 34
  :phone => 123456789
  :timezone => 'Europe/Madrid'
}

Mensario::send_message opts

Get the status of message

To check the status of a messege we need to use Mensario::status with id of message that we want to consult. All states of a message are in Mensarios API.

For example:

Mensario::status 12345678

Cancel a programmed message

Only messages whose status is “CMS-PEND” can be cancelled. The method Mensario::destroy cancels them.

For example:

Mensario::destroy 12345678

Check balance remaining

Method Mensario::balance allow us to consult balance

For example:

Mensario::balance

Handle errors

If a request error occurs or the api responds with an error, Mensario throw an exception of type MensarioException. Depending on the type of error, there are several exceptions that inherit from MensarioException:

About

Mensario is a gem developed by NoSoloSoftware.

License

Mensario is Copyright 2011 NoSoloSoftware, it is free software.

Mensario is distributed under GPLv3 license. More details can be found at COPYING file.