class Messente

Public Class Methods

new(options) click to toggle source
# File lib/messente.rb, line 10
def initialize(options)
  @defaults = options
end

Public Instance Methods

send(options) click to toggle source
# File lib/messente.rb, line 40
def send(options)
  query = @defaults.merge(options)

  response = self.class.get("/send_sms", :query => query)
  items    = response.split(" ")
  error_message = errors[response.to_s]
  if items[0] != "ERROR" && error_message.nil?
    return true
  else
    return { :error => error_message, :code => response }
  end
end
verify_pin(options) click to toggle source
# File lib/messente.rb, line 27
def verify_pin(options)
  query = @defaults.merge(options)

  response = self.class.get("/verify/pin/", :query => query)
  items    = response.split(" ")
  error_message = errors[response]
  if items[0] != "ERROR" && error_message.nil?
    return {}
  else
    return { :error => error_message, :code => response }
  end
end
verify_start(options) click to toggle source
# File lib/messente.rb, line 14
def verify_start(options)
  query = @defaults.merge(options)

  response      = self.class.get("/verify/start/", :query => query)
  items         = response.split(" ")
  error_message = errors[response]
  if items[0] != "ERROR" && error_message.nil?
    return { :id => items[1] }
  else
    return { :error => error_message, :code => response }
  end
end

Private Instance Methods

errors() click to toggle source
items[1]

end

# File lib/messente.rb, line 70
def errors
  {
    'VERIFIED'   => 'User is logging in from already verified computer, no PIN code verification is required.',
    'ERROR 101'  => 'Access is restricted, wrong credentials. Check the username and password values.',
    'ERROR 102'  => 'Parameters are wrong or missing. Check that all the required parameters are present.',
    'ERROR 103'  => 'Invalid IP address. The IP address you made the request from, is not in the API settings whitelist.',
    'ERROR 111'  => 'Sender parameter "from" is invalid. You have not activated this sender name from Messente.com',
    'ERROR 109'  => 'PIN code field is missing in the template value.',
    'FAILED 209' => 'Server failure, try again after a few seconds or try the api3.messente.com backup server.'
  }
end