Class: SMS

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

Overview

Simple way to send sms through Ozeki Phone System XE or Ozeki NG SMS Gateway.

Class Method Summary collapse

Class Method Details

.ng_send_sms(ng_ip_address, username, password, to, message, port = 9501, from = nil) ⇒ Object

Class method to send an SMS message through Ozeki NG SMS Gateway



9
10
11
12
13
14
15
# File 'lib/ozeki_sms.rb', line 9

def self.ng_send_sms ng_ip_address, username, password, to, message, port=9501, from=nil
  to = URI::encode(to)
  message = URI::encode(message)
  from ||= ""
  uri = URI "http://#{ng_ip_address}:#{port}/api?action=sendmessage&username=#{username}&password=#{password}&originator=#{from}&recipient=#{to}&messagetype=SMS:TEXT&messagedata=#{message}"
  Response.create Net::HTTP.get uri
end

.ops_send_sms(ops_ip_address, api_extension, to, message, http_api_service_port = 7780, from = nil, delivery_report_url = nil, username = nil, password = nil) ⇒ Object

Class method to send an SMS message through Ozeki Phone System XE



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ozeki_sms.rb', line 18

def self.ops_send_sms ops_ip_address, api_extension, to, message, http_api_service_port=7780, from=nil, delivery_report_url=nil, username=nil, password=nil
  to = URI::encode(to)
  message = URI::encode(message)
  
  from ||= ""
  from = URI::encode(from)
  delivery_report_url ||= "" 
  delivery_report_url = URI::encode(delivery_report_url)
  http_api_service_port ||= 7780

  SMS.execute_query "http://#{ops_ip_address}:#{http_api_service_port}/?Command=SendSms&ApiExtension=#{api_extension}&Sender=#{from}&Recipient=#{to}&Message=#{message}&DeliveryReportURL=#{delivery_report_url}", username, password
end