ozeki-sms 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ozeki_sms.rb +83 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2978950cd33d5b5b5bc234d601cd63e5252bc17b
|
|
4
|
+
data.tar.gz: baebff9ebdc4f77afd5cf594c2e62d72fef1e247
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 593bd489b5421224eabfec1673113cbee9279ca20e1d74537c7612af2e89d55a6de19743347cce1c2643f439416c7ee5fd0244b08f031900467f32b92e6ea001
|
|
7
|
+
data.tar.gz: d332a0a4a2230221b2eb94aefd35bee9b205a085430f22928a41b0327c244d8794904d671dba1feeb4a3d14c8cf1f56fb79c4ad746e8f2414797597d8ab18962
|
data/lib/ozeki_sms.rb
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Simple way to send sms through Ozeki Phone System XE or Ozeki NG SMS Gateway.
|
|
2
|
+
|
|
3
|
+
class SMS
|
|
4
|
+
|
|
5
|
+
require 'uri'
|
|
6
|
+
require 'net/http'
|
|
7
|
+
|
|
8
|
+
# Class method to send an SMS message through Ozeki NG SMS Gateway
|
|
9
|
+
def self.ng_send_sms ng_ip_address, username, password, to, message, port=9501, from=nil
|
|
10
|
+
to = URI::encode(to)
|
|
11
|
+
message = URI::encode(message)
|
|
12
|
+
from ||= ""
|
|
13
|
+
uri = URI "http://#{ng_ip_address}:#{port}/api?action=sendmessage&username=#{username}&password=#{password}&originator=#{from}&recipient=#{to}&messagetype=SMS:TEXT&messagedata=#{message}"
|
|
14
|
+
Response.create Net::HTTP.get uri
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Class method to send an SMS message through Ozeki Phone System XE
|
|
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
|
|
19
|
+
to = URI::encode(to)
|
|
20
|
+
message = URI::encode(message)
|
|
21
|
+
|
|
22
|
+
from ||= ""
|
|
23
|
+
from = URI::encode(from)
|
|
24
|
+
delivery_report_url ||= ""
|
|
25
|
+
delivery_report_url = URI::encode(delivery_report_url)
|
|
26
|
+
http_api_service_port ||= 7780
|
|
27
|
+
|
|
28
|
+
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
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
def self.execute_query query, username, password
|
|
33
|
+
if (username != nil) && (password != nil)
|
|
34
|
+
query += "&username=#{username}&password=#{password}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
uri = URI query
|
|
38
|
+
Response.create Net::HTTP.get uri
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class Response
|
|
43
|
+
|
|
44
|
+
# code: Get the status code of the returned response
|
|
45
|
+
# message: Get the status message of the returned response
|
|
46
|
+
attr_accessor :code, :message
|
|
47
|
+
|
|
48
|
+
# User friendly string format
|
|
49
|
+
def to_s
|
|
50
|
+
message + " (" + code + ")"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
def initialize code=nil, message=nil
|
|
55
|
+
@code = code || ""
|
|
56
|
+
@message = message || ""
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
def self.create response
|
|
61
|
+
lines = response.split(/[\r\n]+/)
|
|
62
|
+
|
|
63
|
+
resp = Response.new
|
|
64
|
+
|
|
65
|
+
lines.each do |line|
|
|
66
|
+
if (((start_index = line.index('<Code>')) != nil) && (end_index = line.index('</Code>')) != nil)
|
|
67
|
+
resp.code = line[start_index + 6, end_index - start_index - 6]
|
|
68
|
+
elsif (((start_index = line.index('<statuscode>')) != nil) && (end_index = line.index('</statuscode>')) != nil)
|
|
69
|
+
resp.code = line[start_index + 12, end_index - start_index - 12]
|
|
70
|
+
elsif (((start_index = line.index('<Message>')) != nil) && (end_index = line.index('</Message>')) != nil)
|
|
71
|
+
resp.message = line[start_index + 9, end_index - start_index - 9]
|
|
72
|
+
elsif (((start_index = line.index('<statusmessage>')) != nil) && (end_index = line.index('</statusmessage>')) != nil)
|
|
73
|
+
resp.message = line[start_index + 15, end_index - start_index - 15]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if (resp.code != "") && (resp.message != "")
|
|
78
|
+
return resp
|
|
79
|
+
else
|
|
80
|
+
return response
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ozeki-sms
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 3.7.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Robert Simon
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Simple way to send sms through Ozeki Phone System XE or Ozeki NG SMS
|
|
14
|
+
Gateway.
|
|
15
|
+
email: simon.robert@ozekiphone.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/ozeki_sms.rb
|
|
21
|
+
homepage: http://www.ozekiphone.com/index.php?owpn=825
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.0.2
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Ozeki SMS sender
|
|
45
|
+
test_files: []
|