Class: NG

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

Overview

Simple way to make and receive telephone calls through a VoIP PBX, such as Ozeki Phone System XE.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ng_ip_address, username, password, port = 9501) ⇒ NG

Creates a new NG object.



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

def initialize ng_ip_address, username, password, port=9501
  @ng_ip_address = ng_ip_address
  @username = username
  @password = password
  @port = port
end

Class Method Details

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

Class method to send an SMS message.



22
23
24
25
26
27
28
# File 'lib/voip.rb', line 22

def self.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

Instance Method Details

#send_sms(to, message, from = nil) ⇒ Object

Instance method to send an SMS message.



17
18
19
# File 'lib/voip.rb', line 17

def send_sms to, message, from=nil
  NG.send_sms @ng_ip_address, @username, @password, to, message, @port, from
end