Project

mensario

0.0
No commit activity in last 3 years
No release in over 3 years
This gem allow us to send, check status and destroy sms using the Mensario service api
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10.2
~> 1.6.0
~> 0.8.7
~> 1.6.8
~> 2.6.0

Runtime

~> 1.0.15
~> 0.7.1
 Project Readme

Mensario: a wrapper around Mensario API

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

  • Send sms to mobile phone (allowing instant messages and programmed messages)
  • Check the status of sent messages
  • Cancel a programmed message

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:

  • :config -> Path to alternative config file
  • :profile -> Profile to load. Profile by default is :default

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:

  • :sender -> Name of who send de message
  • :text -> Content of message
  • :code -> Country code of mobile
  • :phone -> Telephone number to send de message
  • :date -> Ruby Time object with the send date
  • :timezone -> Timezone of the send

All options are required except :date and :timezone:

  • If :date is undefined the message is sent inmediately.
  • If :timezone is undefined Mensario will use GMT+0

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:

  • MensarioApiException. For errors sent by the api. Has the property status that contains the error code returned by Mensario.
  • MensarioHttpException. If a problem occurs with the HTTP request.

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.