Module: Sendout

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

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.authenticateObject

authentication based on enviroment variables



28
29
30
# File 'lib/sendout.rb', line 28

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 = [], 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
# File 'lib/sendout.rb', line 15

def self.send_sms(numbers=[], message)
  # fields from API
  data = {"para" => numbers, "sms" => message}

  # 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