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



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

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','unicode' => '1'}
  body_json = build_json(sender_id,route,text,recepients,country)
  response = http.post(path,body_json,headers)
  parsed_response = JSON.parse(response.read_body)
  return parsed_response
end