Class: Msg91::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/msg91/message.rb

Class Method Summary collapse

Class Method Details

.send_text(sender_id, route, country, recepients, text) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/msg91/message.rb', line 3

def self.send_text(sender_id, route, country, recepients, text)
  auth_key = Msg91.configuration.auth_key
  url = URI('http://api.msg91.com/')
  http = Net::HTTP.new(url.host, url.port)
  path = '/api/v2/sendsms'
  headers = { 'authkey' => auth_key, 'Content-Type' => 'application/json' }
  body_json = build_json(sender_id, route, text, recepients, country)
  response = http.post(path, body_json, headers)
  JSON.parse(response.read_body)
end