Module: Sendout

Includes:
HTTParty
Defined in:
lib/sendout.rb,
lib/sendout/version.rb

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.authenticateObject

authentication based on enviroment variables



32
33
34
# File 'lib/sendout.rb', line 32

def self.authenticate
  auth  = {"api_id":ENV["SO_API_ID"], "api_token":ENV["SO_API_TOKEN"]}
end

.check_balanceObject

check account balance



10
11
12
# 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) ⇒ Object

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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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