module Sendout

Constants

VERSION

Public Class Methods

authenticate() click to toggle source

authentication based on enviroment variables

# File lib/sendout.rb, line 32
def self.authenticate
  auth  = {"api_id":ENV["SO_API_ID"], "api_token":ENV["SO_API_TOKEN"]}
end
check_balance() click to toggle source

check account balance

# File lib/sendout.rb, line 10
def self.check_balance
 post("/saldo", {:body => authenticate.to_json, :headers => {'Content-Type' => 'application/json'}}).parsed_response
end
send_sms(numbers=[], debug={}, message) click to toggle source

send sms: dest is always an array of numbers and the message a string

# File lib/sendout.rb, line 15
def self.send_sms(numbers=[], debug={}, message)
  # fields from API
  if debug == false
    data = {"para" => numbers, "sms" => message}
  else
    data = {"para" => numbers, "sms" => message, "debug" => debug}
  end

  # merge the body content
  content = {}
  content.merge!(authenticate)
  content.merge!(data)

  post("/envia", {:body => content.to_json, :headers => {'Content-Type' => 'application/json'}}).parsed_response
end