ruby_sipgate 0.2.3
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/.gitignore +2 -0
- data/README.md +22 -0
- data/lib/ruby_sipgate.rb +5 -0
- data/lib/ruby_sipgate/config.rb +22 -0
- data/lib/ruby_sipgate/sms.rb +45 -0
- data/ruby_sipgate.gemspec +14 -0
- metadata +50 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: cee0dbb7032e1712414dfc2325bdc788b5bd7700
|
|
4
|
+
data.tar.gz: 102b1f54f934adec212811f4438384a39777c64f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1ea85ca6ec52a3ce87f6310010c9d6a012496eeba5862286a32648d96d3bfdb258b7874d6ac2b02425ca8e2a15ef94431243919cd6e2506a89f9f35862131766
|
|
7
|
+
data.tar.gz: d61cd18a5f53d094665bd10e6250c05ed465d8512d33a2630c89c541de0fcddc2ee0e871f818a2a6d6bc37a72722ae4a64f937346c48635f657b764669685da9
|
data/.gitignore
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
ruby-sipgate
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Ruby Gem for sending sms via sipgate api
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Usage
|
|
8
|
+
======
|
|
9
|
+
|
|
10
|
+
require 'rubysgate'
|
|
11
|
+
|
|
12
|
+
Rubysgate::Config.set :password, "your_password"
|
|
13
|
+
|
|
14
|
+
Rubysgate::Config.set :username, "your_username"
|
|
15
|
+
|
|
16
|
+
Rubysgate::Sms.deliver "015598765432", "Lorem Ipsum"
|
|
17
|
+
|
|
18
|
+
Config Parameters
|
|
19
|
+
==================
|
|
20
|
+
* :password = ""
|
|
21
|
+
* :username = ""
|
|
22
|
+
* :debug = false
|
data/lib/ruby_sipgate.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module RubySipgate
|
|
2
|
+
class Config
|
|
3
|
+
@@params={username:"",password:"",debug:false,verbose:false}
|
|
4
|
+
|
|
5
|
+
def self.get *key
|
|
6
|
+
if key.empty?
|
|
7
|
+
return @@params
|
|
8
|
+
elsif key.size == 1
|
|
9
|
+
return @@params[key.first]
|
|
10
|
+
end
|
|
11
|
+
return nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.set hash
|
|
15
|
+
@@params = hash
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.set key,value
|
|
19
|
+
@@params[key]=value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# credits for base construct to Thomas Witt
|
|
2
|
+
# https://gist.github.com/thomaswitt/4006850
|
|
3
|
+
|
|
4
|
+
module RubySipgate
|
|
5
|
+
class Sms
|
|
6
|
+
def self.hi
|
|
7
|
+
puts "Hi #{RubySipgate::Config.get :username}, your pass is '#{RubySipgate::Config.get :password}'!"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.deliver(phonenumber, text)
|
|
11
|
+
user = RubySipgate::Config.get :username
|
|
12
|
+
url = "https://#{user}:#{RubySipgate::Config.get :password}@samurai.sipgate.net/RPC2"
|
|
13
|
+
client = XMLRPC::Client.new2(url)
|
|
14
|
+
client.call('samurai.ClientIdentify', {'ClientName' => 'Ruby-Client'} )
|
|
15
|
+
number = strip_phonenumber(phonenumber)
|
|
16
|
+
args = {
|
|
17
|
+
'RemoteUri' => "sip:#{number}@sipgate.net",
|
|
18
|
+
'TOS' => 'text',
|
|
19
|
+
'Content' => text[0,159]
|
|
20
|
+
}
|
|
21
|
+
if RubySipgate::Config.get :debug
|
|
22
|
+
puts "*** I would have sent the following to #{phonenumber}:"
|
|
23
|
+
puts args.inspect
|
|
24
|
+
else
|
|
25
|
+
if r = client.call('samurai.SessionInitiate', args)
|
|
26
|
+
if RubySipgate::Config.get :verbose
|
|
27
|
+
puts "*** SMS sent to #{number} (#{r.inspect})"
|
|
28
|
+
puts "*** SMS text: #{text}"
|
|
29
|
+
end
|
|
30
|
+
return r
|
|
31
|
+
else
|
|
32
|
+
raise "sms send failed: #{r.inspect}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
def self.strip_phonenumber(number)
|
|
39
|
+
number.gsub!(/\D/, '')
|
|
40
|
+
number.gsub!(/^01/, '491')
|
|
41
|
+
number.gsub!(/^00491/, '491')
|
|
42
|
+
number
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = 'ruby_sipgate'
|
|
5
|
+
s.version = '0.2.3'
|
|
6
|
+
s.date = Date.today.to_s
|
|
7
|
+
s.summary = "sms via sipgate api"
|
|
8
|
+
s.description = "Sending sms via sipgate api"
|
|
9
|
+
s.authors = ["Sebastian Neumann"]
|
|
10
|
+
s.email = 'github@tempo-tm.de'
|
|
11
|
+
s.files = `git ls-files`.split("\n")
|
|
12
|
+
s.homepage = 'https://github.com/tempo/ruby_sipgate'
|
|
13
|
+
s.license = 'MIT'
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruby_sipgate
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sebastian Neumann
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Sending sms via sipgate api
|
|
14
|
+
email: github@tempo-tm.de
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- ".gitignore"
|
|
20
|
+
- README.md
|
|
21
|
+
- lib/ruby_sipgate.rb
|
|
22
|
+
- lib/ruby_sipgate/config.rb
|
|
23
|
+
- lib/ruby_sipgate/sms.rb
|
|
24
|
+
- ruby_sipgate.gemspec
|
|
25
|
+
homepage: https://github.com/tempo/ruby_sipgate
|
|
26
|
+
licenses:
|
|
27
|
+
- MIT
|
|
28
|
+
metadata: {}
|
|
29
|
+
post_install_message:
|
|
30
|
+
rdoc_options: []
|
|
31
|
+
require_paths:
|
|
32
|
+
- lib
|
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
requirements: []
|
|
44
|
+
rubyforge_project:
|
|
45
|
+
rubygems_version: 2.2.1
|
|
46
|
+
signing_key:
|
|
47
|
+
specification_version: 4
|
|
48
|
+
summary: sms via sipgate api
|
|
49
|
+
test_files: []
|
|
50
|
+
has_rdoc:
|