smartcall 0.0.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.
- data/.git/COMMIT_EDITMSG +1 -0
- data/.git/HEAD +1 -0
- data/.git/config +9 -0
- data/.git/description +1 -0
- data/.git/hooks/applypatch-msg.sample +15 -0
- data/.git/hooks/commit-msg.sample +24 -0
- data/.git/hooks/post-commit.sample +8 -0
- data/.git/hooks/post-receive.sample +15 -0
- data/.git/hooks/post-update.sample +8 -0
- data/.git/hooks/pre-applypatch.sample +14 -0
- data/.git/hooks/pre-commit.sample +18 -0
- data/.git/hooks/pre-rebase.sample +169 -0
- data/.git/hooks/prepare-commit-msg.sample +36 -0
- data/.git/hooks/update.sample +107 -0
- data/.git/index +0 -0
- data/.git/info/exclude +7 -0
- data/.git/logs/HEAD +2 -0
- data/.git/logs/refs/heads/master +2 -0
- data/.git/logs/refs/remotes/origin/master +2 -0
- data/.git/objects/00/f1013a65955cd471412182a97d5f1fffd3704c +0 -0
- data/.git/objects/02/71eea5123474aedbde8015255a504d94f685bd +0 -0
- data/.git/objects/06/aee68532f3f27a0069ba2d3b83882e9de694c2 +0 -0
- data/.git/objects/0e/645be9c8c9577a7c510f18f02a911625b84f33 +0 -0
- data/.git/objects/1b/6da8fb93b154f0e61fd79bd8937054239efb6a +0 -0
- data/.git/objects/2c/19b6786301350db21213800d5947f3c1c3e970 +0 -0
- data/.git/objects/3b/d7d5c3db3c5505818578db99b2ddf1f08c2cf6 +0 -0
- data/.git/objects/44/b350588a68aefd6f341ada560d97dd02c4cfa6 +0 -0
- data/.git/objects/47/ce4582a7061057570755212b88e3bea4361772 +0 -0
- data/.git/objects/59/e5c948076ec6694f10b5d462a3ceb97f8ab8eb +0 -0
- data/.git/objects/5c/c37cedc951acf642517aa2816227278cd01151 +0 -0
- data/.git/objects/69/362213610bb67096bfc2a42e30412ef27c2f77 +0 -0
- data/.git/objects/69/40d60f0a57a0348157f98262f36c824317eed6 +0 -0
- data/.git/objects/6d/3ef15461c2da28aa4885e6451fbbb17b2d6b94 +2 -0
- data/.git/objects/6f/71532e99159d5eba176702d74769330fc81eb6 +0 -0
- data/.git/objects/72/141584a5836168fe912ebce5b4537bd0eafc09 +1 -0
- data/.git/objects/77/b144ee27d70aae0d0c41943d81c0db04895164 +0 -0
- data/.git/objects/7c/ec2abaf23f2e5bc8666f30624f0e86f528736b +2 -0
- data/.git/objects/7e/87ba0640047dbe24aea1df4a246a62b7fc1def +0 -0
- data/.git/objects/88/b52085d0de43bb32ecbe1ed8aaad31d2c90d42 +0 -0
- data/.git/objects/92/da48d3bc17b4a555c3a36bf460587f9a8e6a1d +1 -0
- data/.git/objects/97/9064357d9ab94a16a799667044e4b4d2ddca51 +0 -0
- data/.git/objects/99/d4bec753e7a5893098c9c27c7ddb189e32fb21 +0 -0
- data/.git/objects/9c/2d3352332af363407ac78c2e2c4ab6a9d52728 +0 -0
- data/.git/objects/9f/f1cdcf1dc45d82a72b69276ab2cc490fe0da08 +0 -0
- data/.git/objects/a4/038466c09a502e2236584dd120b296c6e6e7ff +4 -0
- data/.git/objects/a8/56644c6c2e01d84f39f7fcb51ba636db60b4ff +0 -0
- data/.git/objects/af/c3ea327fa220ee42a5ebecfcc7d218be4ea1d9 +0 -0
- data/.git/objects/b7/4a78a94dd22b27a7fb74e43105fa6f5e064c26 +0 -0
- data/.git/objects/c2/7f6559350f7adb19d43742b55b2f91d07b6550 +0 -0
- data/.git/objects/c5/993b40f4cfd00704d4ca626faee36a30aed8d9 +0 -0
- data/.git/objects/d4/c63cfc1f685add1e56823c11a0314486b7d4b0 +0 -0
- data/.git/objects/d6/1464e3acc27506d452770bf403c7c1421d10de +5 -0
- data/.git/objects/d9/649874f15b9532896e4b95ffdb75dc030e9f77 +1 -0
- data/.git/objects/de/55b52626e60d61116d4e15234bb7a12e4321d3 +0 -0
- data/.git/objects/e2/5ee33ae1b32b3476efbdefccb5674a4b76cee0 +0 -0
- data/.git/objects/e3/d3891ead56297ae33071a8b97f1ef48c716f5b +0 -0
- data/.git/objects/e4/8464df56bf487e96e21ea99487330266dae3c9 +0 -0
- data/.git/objects/e6/5f20ff918715435fa0aa9685e18cc7d8b5eb86 +0 -0
- data/.git/objects/e9/560b6d4b2a5a11fe232679960f82f4d3791448 +0 -0
- data/.git/objects/f8/b030b7589aa1a720de29026879002a1f8d595b +0 -0
- data/.git/objects/fd/7ab688bb41aab7531c5e3dc1330c55ba1297fa +0 -0
- data/.git/refs/heads/master +1 -0
- data/.git/refs/remotes/origin/master +1 -0
- data/History.txt +4 -0
- data/Manifest.txt +88 -0
- data/PostInstall.txt +6 -0
- data/README.rdoc +50 -0
- data/Rakefile +26 -0
- data/bin/smartcall +38 -0
- data/config/website.yml.sample +2 -0
- data/lib/smartcall/soap/default.rb +147 -0
- data/lib/smartcall/soap/default_driver.rb +70 -0
- data/lib/smartcall/soap/smartcall_error.rb +9 -0
- data/lib/smartcall/soap/sms_ws_client.rb +108 -0
- data/lib/smartcall/utility/options.rb +91 -0
- data/lib/smartcall/utility.rb +6 -0
- data/lib/smartcall.rb +30 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +71 -0
- data/test/test_helper.rb +3 -0
- data/test/test_smartcall.rb +11 -0
- data/website/index.html +78 -0
- data/website/index.txt +52 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +159 -0
- data/website/template.html.erb +50 -0
- metadata +155 -0
data/Manifest.txt
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
.git/COMMIT_EDITMSG
|
|
2
|
+
.git/HEAD
|
|
3
|
+
.git/config
|
|
4
|
+
.git/description
|
|
5
|
+
.git/hooks/applypatch-msg.sample
|
|
6
|
+
.git/hooks/commit-msg.sample
|
|
7
|
+
.git/hooks/post-commit.sample
|
|
8
|
+
.git/hooks/post-receive.sample
|
|
9
|
+
.git/hooks/post-update.sample
|
|
10
|
+
.git/hooks/pre-applypatch.sample
|
|
11
|
+
.git/hooks/pre-commit.sample
|
|
12
|
+
.git/hooks/pre-rebase.sample
|
|
13
|
+
.git/hooks/prepare-commit-msg.sample
|
|
14
|
+
.git/hooks/update.sample
|
|
15
|
+
.git/index
|
|
16
|
+
.git/info/exclude
|
|
17
|
+
.git/logs/HEAD
|
|
18
|
+
.git/logs/refs/heads/master
|
|
19
|
+
.git/logs/refs/remotes/origin/master
|
|
20
|
+
.git/objects/00/f1013a65955cd471412182a97d5f1fffd3704c
|
|
21
|
+
.git/objects/02/71eea5123474aedbde8015255a504d94f685bd
|
|
22
|
+
.git/objects/06/aee68532f3f27a0069ba2d3b83882e9de694c2
|
|
23
|
+
.git/objects/0e/645be9c8c9577a7c510f18f02a911625b84f33
|
|
24
|
+
.git/objects/1b/6da8fb93b154f0e61fd79bd8937054239efb6a
|
|
25
|
+
.git/objects/2c/19b6786301350db21213800d5947f3c1c3e970
|
|
26
|
+
.git/objects/3b/d7d5c3db3c5505818578db99b2ddf1f08c2cf6
|
|
27
|
+
.git/objects/44/b350588a68aefd6f341ada560d97dd02c4cfa6
|
|
28
|
+
.git/objects/47/ce4582a7061057570755212b88e3bea4361772
|
|
29
|
+
.git/objects/59/e5c948076ec6694f10b5d462a3ceb97f8ab8eb
|
|
30
|
+
.git/objects/5c/c37cedc951acf642517aa2816227278cd01151
|
|
31
|
+
.git/objects/69/362213610bb67096bfc2a42e30412ef27c2f77
|
|
32
|
+
.git/objects/69/40d60f0a57a0348157f98262f36c824317eed6
|
|
33
|
+
.git/objects/6d/3ef15461c2da28aa4885e6451fbbb17b2d6b94
|
|
34
|
+
.git/objects/6f/71532e99159d5eba176702d74769330fc81eb6
|
|
35
|
+
.git/objects/72/141584a5836168fe912ebce5b4537bd0eafc09
|
|
36
|
+
.git/objects/77/b144ee27d70aae0d0c41943d81c0db04895164
|
|
37
|
+
.git/objects/7c/ec2abaf23f2e5bc8666f30624f0e86f528736b
|
|
38
|
+
.git/objects/7e/87ba0640047dbe24aea1df4a246a62b7fc1def
|
|
39
|
+
.git/objects/88/b52085d0de43bb32ecbe1ed8aaad31d2c90d42
|
|
40
|
+
.git/objects/92/da48d3bc17b4a555c3a36bf460587f9a8e6a1d
|
|
41
|
+
.git/objects/97/9064357d9ab94a16a799667044e4b4d2ddca51
|
|
42
|
+
.git/objects/99/d4bec753e7a5893098c9c27c7ddb189e32fb21
|
|
43
|
+
.git/objects/9c/2d3352332af363407ac78c2e2c4ab6a9d52728
|
|
44
|
+
.git/objects/9f/f1cdcf1dc45d82a72b69276ab2cc490fe0da08
|
|
45
|
+
.git/objects/a4/038466c09a502e2236584dd120b296c6e6e7ff
|
|
46
|
+
.git/objects/a8/56644c6c2e01d84f39f7fcb51ba636db60b4ff
|
|
47
|
+
.git/objects/af/c3ea327fa220ee42a5ebecfcc7d218be4ea1d9
|
|
48
|
+
.git/objects/b7/4a78a94dd22b27a7fb74e43105fa6f5e064c26
|
|
49
|
+
.git/objects/c2/7f6559350f7adb19d43742b55b2f91d07b6550
|
|
50
|
+
.git/objects/c5/993b40f4cfd00704d4ca626faee36a30aed8d9
|
|
51
|
+
.git/objects/d4/c63cfc1f685add1e56823c11a0314486b7d4b0
|
|
52
|
+
.git/objects/d6/1464e3acc27506d452770bf403c7c1421d10de
|
|
53
|
+
.git/objects/d9/649874f15b9532896e4b95ffdb75dc030e9f77
|
|
54
|
+
.git/objects/de/55b52626e60d61116d4e15234bb7a12e4321d3
|
|
55
|
+
.git/objects/e2/5ee33ae1b32b3476efbdefccb5674a4b76cee0
|
|
56
|
+
.git/objects/e3/d3891ead56297ae33071a8b97f1ef48c716f5b
|
|
57
|
+
.git/objects/e4/8464df56bf487e96e21ea99487330266dae3c9
|
|
58
|
+
.git/objects/e6/5f20ff918715435fa0aa9685e18cc7d8b5eb86
|
|
59
|
+
.git/objects/e9/560b6d4b2a5a11fe232679960f82f4d3791448
|
|
60
|
+
.git/objects/f8/b030b7589aa1a720de29026879002a1f8d595b
|
|
61
|
+
.git/objects/fd/7ab688bb41aab7531c5e3dc1330c55ba1297fa
|
|
62
|
+
.git/refs/heads/master
|
|
63
|
+
.git/refs/remotes/origin/master
|
|
64
|
+
History.txt
|
|
65
|
+
Manifest.txt
|
|
66
|
+
PostInstall.txt
|
|
67
|
+
README.rdoc
|
|
68
|
+
Rakefile
|
|
69
|
+
bin/smartcall
|
|
70
|
+
config/website.yml.sample
|
|
71
|
+
lib/smartcall.rb
|
|
72
|
+
lib/smartcall/soap/default.rb
|
|
73
|
+
lib/smartcall/soap/default_driver.rb
|
|
74
|
+
lib/smartcall/soap/smartcall_error.rb
|
|
75
|
+
lib/smartcall/soap/sms_ws_client.rb
|
|
76
|
+
lib/smartcall/utility.rb
|
|
77
|
+
lib/smartcall/utility/options.rb
|
|
78
|
+
script/console
|
|
79
|
+
script/destroy
|
|
80
|
+
script/generate
|
|
81
|
+
script/txt2html
|
|
82
|
+
test/test_helper.rb
|
|
83
|
+
test/test_smartcall.rb
|
|
84
|
+
website/index.html
|
|
85
|
+
website/index.txt
|
|
86
|
+
website/javascripts/rounded_corners_lite.inc.js
|
|
87
|
+
website/stylesheets/screen.css
|
|
88
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
= smartcall sms gem
|
|
2
|
+
|
|
3
|
+
* http://github.com/agilisto/smartcall
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
Gem to provide sms functionality through the Smartcall Technology Solutions web services.
|
|
8
|
+
|
|
9
|
+
== FEATURES/PROBLEMS:
|
|
10
|
+
|
|
11
|
+
* MSISDN in international format not accepted.
|
|
12
|
+
* Only South African delivery
|
|
13
|
+
|
|
14
|
+
== SYNOPSIS:
|
|
15
|
+
require 'smartcall'
|
|
16
|
+
|
|
17
|
+
api = Smartcall::API.new(<USERNAME>, <PASSWORD>, <CAMPAIGN_ID>, <REFERENCE>)
|
|
18
|
+
api.send_message("0825559629", "Hello World")
|
|
19
|
+
|
|
20
|
+
== REQUIREMENTS:
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
== INSTALL:
|
|
24
|
+
|
|
25
|
+
sudo gem install smartcall
|
|
26
|
+
|
|
27
|
+
== LICENSE:
|
|
28
|
+
|
|
29
|
+
(The MIT License)
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2009 Armand du Plessis
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
34
|
+
a copy of this software and associated documentation files (the
|
|
35
|
+
'Software'), to deal in the Software without restriction, including
|
|
36
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
37
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
38
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
39
|
+
the following conditions:
|
|
40
|
+
|
|
41
|
+
The above copyright notice and this permission notice shall be
|
|
42
|
+
included in all copies or substantial portions of the Software.
|
|
43
|
+
|
|
44
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
45
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
46
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
47
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
48
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
49
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
50
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
|
3
|
+
require 'hoe'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require './lib/smartcall'
|
|
6
|
+
|
|
7
|
+
Hoe.plugin :newgem
|
|
8
|
+
Hoe.plugin :website
|
|
9
|
+
# Hoe.plugin :cucumber_features
|
|
10
|
+
|
|
11
|
+
# Generate all the Rake tasks
|
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
|
13
|
+
$hoe = Hoe.spec 'smartcall' do
|
|
14
|
+
self.developer 'FIXME full name', 'FIXME email'
|
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
|
17
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
require 'newgem/tasks'
|
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
|
23
|
+
|
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
|
25
|
+
# remove_task :default
|
|
26
|
+
# task :default => [:spec, :features]
|
data/bin/smartcall
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
local_libs = [
|
|
4
|
+
File.join(File.dirname(__FILE__), *%w[../lib/smartcall]),
|
|
5
|
+
File.join(File.dirname(__FILE__), *%w[../lib/smartcall/utility])
|
|
6
|
+
]
|
|
7
|
+
|
|
8
|
+
if File.exist?(local_libs.first)
|
|
9
|
+
local_libs.each { |lib| require lib }
|
|
10
|
+
else
|
|
11
|
+
require 'rubygems'
|
|
12
|
+
require 'smartcall'
|
|
13
|
+
require 'smartcall/utility'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# parse command line options
|
|
17
|
+
options = Smartcall::Utility::Options.parse(ARGV)
|
|
18
|
+
|
|
19
|
+
# authenticate and load the API
|
|
20
|
+
api = Smartcall::API.new(options.username, options.password, options.campaign_id, options.reference)
|
|
21
|
+
|
|
22
|
+
begin
|
|
23
|
+
puts "Sending '#{options.message}' to #{options.recipient}..."
|
|
24
|
+
additional_opts = {}
|
|
25
|
+
additional_opts[:from] = options.from if options.from
|
|
26
|
+
msg_id = api.send_message(options.recipient, options.message, additional_opts)
|
|
27
|
+
puts "Message sent successfully (Result: #{msg_id})." unless msg_id == false
|
|
28
|
+
puts "Message sending failed. Switch to debug for more info" if msg_id == false
|
|
29
|
+
exit 0
|
|
30
|
+
rescue Smartcall::Soap::SmartcallError => e
|
|
31
|
+
puts "Unexpected error occurred. #{e.message}"
|
|
32
|
+
exit 1
|
|
33
|
+
|
|
34
|
+
rescue Timeout::Error
|
|
35
|
+
puts "The connection the the Smartcall service timed out"
|
|
36
|
+
puts "Please check your network settings and try again."
|
|
37
|
+
exit 1
|
|
38
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
require 'xsd/qname'
|
|
2
|
+
|
|
3
|
+
module Smartcall
|
|
4
|
+
module Soap
|
|
5
|
+
# {http://tempuri.org/}login
|
|
6
|
+
class Login
|
|
7
|
+
@@schema_type = "login"
|
|
8
|
+
@@schema_ns = "http://tempuri.org/"
|
|
9
|
+
@@schema_qualified = "true"
|
|
10
|
+
@@schema_element = [["username", "SOAP::SOAPString"], ["password", "SOAP::SOAPString"]]
|
|
11
|
+
|
|
12
|
+
attr_accessor :username
|
|
13
|
+
attr_accessor :password
|
|
14
|
+
|
|
15
|
+
def initialize(username = nil, password = nil)
|
|
16
|
+
@username = username
|
|
17
|
+
@password = password
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# {http://tempuri.org/}loginResponse
|
|
22
|
+
class LoginResponse
|
|
23
|
+
@@schema_type = "loginResponse"
|
|
24
|
+
@@schema_ns = "http://tempuri.org/"
|
|
25
|
+
@@schema_qualified = "true"
|
|
26
|
+
@@schema_element = [["loginResult", "SOAP::SOAPBoolean"], ["token", "SOAP::SOAPString"]]
|
|
27
|
+
|
|
28
|
+
attr_accessor :loginResult
|
|
29
|
+
attr_accessor :token
|
|
30
|
+
|
|
31
|
+
def initialize(loginResult = nil, token = nil)
|
|
32
|
+
@loginResult = loginResult
|
|
33
|
+
@token = token
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# {http://tempuri.org/}sendSMS
|
|
38
|
+
class SendSMS
|
|
39
|
+
@@schema_type = "sendSMS"
|
|
40
|
+
@@schema_ns = "http://tempuri.org/"
|
|
41
|
+
@@schema_qualified = "true"
|
|
42
|
+
@@schema_element = [["token", "SOAP::SOAPString"], ["recipient", "SOAP::SOAPString"], ["message", "SOAP::SOAPString"], ["reference", "SOAP::SOAPString"], ["campaignid", "SOAP::SOAPInt"]]
|
|
43
|
+
|
|
44
|
+
attr_accessor :token
|
|
45
|
+
attr_accessor :recipient
|
|
46
|
+
attr_accessor :message
|
|
47
|
+
attr_accessor :reference
|
|
48
|
+
attr_accessor :campaignid
|
|
49
|
+
|
|
50
|
+
def initialize(token = nil, recipient = nil, message = nil, reference = nil, campaignid = nil)
|
|
51
|
+
@token = token
|
|
52
|
+
@recipient = recipient
|
|
53
|
+
@message = message
|
|
54
|
+
@reference = reference
|
|
55
|
+
@campaignid = campaignid
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# {http://tempuri.org/}sendSMSResponse
|
|
60
|
+
class SendSMSResponse
|
|
61
|
+
@@schema_type = "sendSMSResponse"
|
|
62
|
+
@@schema_ns = "http://tempuri.org/"
|
|
63
|
+
@@schema_qualified = "true"
|
|
64
|
+
@@schema_element = [["sendSMSResult", "SOAP::SOAPString"]]
|
|
65
|
+
|
|
66
|
+
attr_accessor :sendSMSResult
|
|
67
|
+
|
|
68
|
+
def initialize(sendSMSResult = nil)
|
|
69
|
+
@sendSMSResult = sendSMSResult
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# {http://tempuri.org/}sendWAPLink
|
|
74
|
+
class SendWAPLink
|
|
75
|
+
@@schema_type = "sendWAPLink"
|
|
76
|
+
@@schema_ns = "http://tempuri.org/"
|
|
77
|
+
@@schema_qualified = "true"
|
|
78
|
+
@@schema_element = [["token", "SOAP::SOAPString"], ["recipient", "SOAP::SOAPString"], ["href", "SOAP::SOAPString"], ["text", "SOAP::SOAPString"], ["reference", "SOAP::SOAPString"], ["campaignid", "SOAP::SOAPInt"]]
|
|
79
|
+
|
|
80
|
+
attr_accessor :token
|
|
81
|
+
attr_accessor :recipient
|
|
82
|
+
attr_accessor :href
|
|
83
|
+
attr_accessor :text
|
|
84
|
+
attr_accessor :reference
|
|
85
|
+
attr_accessor :campaignid
|
|
86
|
+
|
|
87
|
+
def initialize(token = nil, recipient = nil, href = nil, text = nil, reference = nil, campaignid = nil)
|
|
88
|
+
@token = token
|
|
89
|
+
@recipient = recipient
|
|
90
|
+
@href = href
|
|
91
|
+
@text = text
|
|
92
|
+
@reference = reference
|
|
93
|
+
@campaignid = campaignid
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# {http://tempuri.org/}sendWAPLinkResponse
|
|
98
|
+
class SendWAPLinkResponse
|
|
99
|
+
@@schema_type = "sendWAPLinkResponse"
|
|
100
|
+
@@schema_ns = "http://tempuri.org/"
|
|
101
|
+
@@schema_qualified = "true"
|
|
102
|
+
@@schema_element = [["sendWAPLinkResult", "SOAP::SOAPString"]]
|
|
103
|
+
|
|
104
|
+
attr_accessor :sendWAPLinkResult
|
|
105
|
+
|
|
106
|
+
def initialize(sendWAPLinkResult = nil)
|
|
107
|
+
@sendWAPLinkResult = sendWAPLinkResult
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# {http://tempuri.org/}sendBinaryString
|
|
112
|
+
class SendBinaryString
|
|
113
|
+
@@schema_type = "sendSMS"
|
|
114
|
+
@@schema_ns = "http://tempuri.org/"
|
|
115
|
+
@@schema_qualified = "true"
|
|
116
|
+
@@schema_element = [["token", "SOAP::SOAPString"], ["recipient", "SOAP::SOAPString"], ["binary", "SOAP::SOAPString"], ["reference", "SOAP::SOAPString"], ["campaignid", "SOAP::SOAPInt"]]
|
|
117
|
+
|
|
118
|
+
attr_accessor :token
|
|
119
|
+
attr_accessor :recipient
|
|
120
|
+
attr_accessor :binary
|
|
121
|
+
attr_accessor :reference
|
|
122
|
+
attr_accessor :campaignid
|
|
123
|
+
|
|
124
|
+
def initialize(token = nil, recipient = nil, binary = nil, reference = nil, campaignid = nil)
|
|
125
|
+
@token = token
|
|
126
|
+
@recipient = recipient
|
|
127
|
+
@binary = binary
|
|
128
|
+
@reference = reference
|
|
129
|
+
@campaignid = campaignid
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# {http://tempuri.org/}sendBinaryStringResponse
|
|
134
|
+
class SendBinaryStringResponse
|
|
135
|
+
@@schema_type = "sendSMSResponse"
|
|
136
|
+
@@schema_ns = "http://tempuri.org/"
|
|
137
|
+
@@schema_qualified = "true"
|
|
138
|
+
@@schema_element = [["sendBinaryStringResult", "SOAP::SOAPString"]]
|
|
139
|
+
|
|
140
|
+
attr_accessor :sendBinaryStringResult
|
|
141
|
+
|
|
142
|
+
def initialize(sendBinaryStringResult = nil)
|
|
143
|
+
@sendBinaryStringResult = sendBinaryStringResult
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'soap/rpc/driver'
|
|
2
|
+
|
|
3
|
+
module Smartcall
|
|
4
|
+
module Soap
|
|
5
|
+
|
|
6
|
+
class SmsWSSoap < ::SOAP::RPC::Driver
|
|
7
|
+
DefaultEndpointUrl = "http://www.smartcalltech.co.za/SmsWS/Service.asmx"
|
|
8
|
+
MappingRegistry = ::SOAP::Mapping::Registry.new
|
|
9
|
+
|
|
10
|
+
Methods = [
|
|
11
|
+
[ "http://tempuri.org/login",
|
|
12
|
+
"login",
|
|
13
|
+
[ ["in", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "login"], true],
|
|
14
|
+
["out", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "loginResponse"], true] ],
|
|
15
|
+
{ :request_style => :document, :request_use => :literal,
|
|
16
|
+
:response_style => :document, :response_use => :literal }
|
|
17
|
+
],
|
|
18
|
+
[ "http://tempuri.org/sendSMS",
|
|
19
|
+
"sendSMS",
|
|
20
|
+
[ ["in", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "sendSMS"], true],
|
|
21
|
+
["out", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "sendSMSResponse"], true] ],
|
|
22
|
+
{ :request_style => :document, :request_use => :literal,
|
|
23
|
+
:response_style => :document, :response_use => :literal }
|
|
24
|
+
],
|
|
25
|
+
[ "http://tempuri.org/sendWAPLink",
|
|
26
|
+
"sendWAPLink",
|
|
27
|
+
[ ["in", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "sendWAPLink"], true],
|
|
28
|
+
["out", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "sendWAPLinkResponse"], true] ],
|
|
29
|
+
{ :request_style => :document, :request_use => :literal,
|
|
30
|
+
:response_style => :document, :response_use => :literal }
|
|
31
|
+
],
|
|
32
|
+
[ "http://tempuri.org/sendBinaryString",
|
|
33
|
+
"sendBinaryString",
|
|
34
|
+
[ ["in", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "sendBinaryString"]],
|
|
35
|
+
["out", "parameters", ["::SOAP::SOAPElement", "http://tempuri.org/", "sendBinaryStringResponse"]] ],
|
|
36
|
+
{ :request_style => :document, :request_use => :literal,
|
|
37
|
+
:response_style => :document, :response_use => :literal,
|
|
38
|
+
:faults => {} }
|
|
39
|
+
],
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
def initialize(endpoint_url = nil)
|
|
43
|
+
endpoint_url ||= DefaultEndpointUrl
|
|
44
|
+
super(endpoint_url, nil)
|
|
45
|
+
self.mapping_registry = MappingRegistry
|
|
46
|
+
init_methods
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def init_methods
|
|
52
|
+
Methods.each do |definitions|
|
|
53
|
+
opt = definitions.last
|
|
54
|
+
if opt[:request_style] == :document
|
|
55
|
+
add_document_operation(*definitions)
|
|
56
|
+
else
|
|
57
|
+
add_rpc_operation(*definitions)
|
|
58
|
+
qname = definitions[0]
|
|
59
|
+
name = definitions[2]
|
|
60
|
+
if qname.name != name and qname.name.capitalize == name.capitalize
|
|
61
|
+
::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
|
|
62
|
+
__send__(name, *arg)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
module Smartcall
|
|
2
|
+
module Soap
|
|
3
|
+
class SmsWSClient
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
def no_authorisation_error
|
|
7
|
+
raise SmartcallError.new("SmsWSErrors: Unable to Login")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def invalid_token_error
|
|
11
|
+
raise SmartcallError.new("SmsWSErrors: Invalid Token")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def invalid_source_address_error
|
|
15
|
+
raise SmartcallError.new("SmsWSErrors: Invalid Source Address")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def invalid_number_error
|
|
19
|
+
raise SmartcallError.new("SmsWSErrors: InvalidNumber")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def not_implemented_error
|
|
23
|
+
raise SmartcallError.new("SmsWSErrors: Not Implemented")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def debug_mode=(value)
|
|
27
|
+
@@debug_mode = value
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
@@debug_mode = false
|
|
32
|
+
|
|
33
|
+
RESPONSE_HANDLER = { 'Success' => true , 'InvalidSourceAddress' => Proc.new { SmsWSClient.invalid_source_address_error } ,
|
|
34
|
+
'InvalidToken' => Proc.new { SmsWSClient.invalid_token_error } , 'Failed' => false ,
|
|
35
|
+
'InvalidNumber' => Proc.new { SmsWSClient.invalid_number_error } }
|
|
36
|
+
|
|
37
|
+
DEFAULT_ENDPOINT = "http://www.smartcalltech.co.za/SmsWS/Service.asmx"
|
|
38
|
+
|
|
39
|
+
def initialize(username, password, campaign_id, reference)
|
|
40
|
+
@retry = true
|
|
41
|
+
@username, @password, @campaign_id, @reference = username, password, campaign_id, reference
|
|
42
|
+
@obj = SmsWSSoap.new(DEFAULT_ENDPOINT)
|
|
43
|
+
@obj.wiredump_dev = STDERR if @@debug_mode
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def send_sms(cell , msg)
|
|
47
|
+
@cell = cell
|
|
48
|
+
@msg = msg
|
|
49
|
+
@token ||= self.login
|
|
50
|
+
if @token
|
|
51
|
+
s = SendSMS.new(@token , cell , msg , @reference , @campaign_id)
|
|
52
|
+
response = @obj.sendSMS(s)
|
|
53
|
+
return process_response(RESPONSE_HANDLER[response.sendSMSResult])
|
|
54
|
+
else
|
|
55
|
+
update_token
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def send_binary_sms(cell, header, part)
|
|
60
|
+
@cell = cell
|
|
61
|
+
@token ||= self.login
|
|
62
|
+
if @token
|
|
63
|
+
s = SendBinaryString.new(@token, cell, header + part, @reference, @campaign_id)
|
|
64
|
+
response = @obj.sendBinaryString(s)
|
|
65
|
+
result = process_response(RESPONSE_HANDLER[response.sendBinaryStringResult])
|
|
66
|
+
return result
|
|
67
|
+
else
|
|
68
|
+
update_token
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def send_wap_link(cell, href, msg)
|
|
73
|
+
@cell = cell
|
|
74
|
+
@msg = msg
|
|
75
|
+
@token ||= self.login
|
|
76
|
+
if @token
|
|
77
|
+
s = SendWAPLink.new(@token , cell , href, msg , @reference , @campaign_id)
|
|
78
|
+
response = @obj.sendWAPLink(s)
|
|
79
|
+
return process_response(RESPONSE_HANDLER[response.sendWAPLinkResult])
|
|
80
|
+
else
|
|
81
|
+
update_token
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
protected
|
|
86
|
+
|
|
87
|
+
def process_response(response_handler)
|
|
88
|
+
response_handler.class == Proc ? response_handler.call : response_handler
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def update_token
|
|
92
|
+
@retry ? @token = self.login : ( raise no_authorisation_error )
|
|
93
|
+
@retry = false
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def retry_sms
|
|
97
|
+
send_sms(@cell , @msg) if @retry
|
|
98
|
+
@retry = false
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def login
|
|
102
|
+
l = Login.new(@username , @password)
|
|
103
|
+
response = @obj.login(l)
|
|
104
|
+
response.loginResult != 'false' ? @token = response.token : false
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
require 'ostruct'
|
|
3
|
+
|
|
4
|
+
module Smartcall
|
|
5
|
+
module Utility
|
|
6
|
+
class Options #:nodoc:
|
|
7
|
+
class << self
|
|
8
|
+
|
|
9
|
+
def parse(args)
|
|
10
|
+
@options = self.default_options
|
|
11
|
+
parser = OptionParser.new do |opts|
|
|
12
|
+
opts.banner = "Usage: smartcall [options] recipient message"
|
|
13
|
+
opts.separator ""
|
|
14
|
+
opts.separator "Specific options:"
|
|
15
|
+
|
|
16
|
+
opts.on('-u', '--username USERNAME',
|
|
17
|
+
"Specify the smartcall username (overrides ~/.smartcall setting)") do |username|
|
|
18
|
+
@options.username = username
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
opts.on('-p', '--password PASSWORD',
|
|
22
|
+
"Specify the smartcall password (overrides ~/.smartcall setting)") do |password|
|
|
23
|
+
@options.password = password
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
opts.on('-c', '--campaign CAMPAIGN_ID',
|
|
27
|
+
"Specify the campaign key (overrides ~/.smartcall setting)") do |key|
|
|
28
|
+
@options.campaign_id = key
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
opts.on('-r', '--reference REFERENCE',
|
|
32
|
+
"Specify the reference (overrides ~/.smartcall setting)") do |reference|
|
|
33
|
+
@options.reference = reference
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
opts.on('-d', '--debug') do
|
|
37
|
+
Smartcall::Soap::SmsWSClient.debug_mode = true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
opts.on_tail('-h', '--help', "Show this message") do
|
|
41
|
+
puts opts
|
|
42
|
+
exit
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
opts.on_tail('-v', '--version') do
|
|
46
|
+
puts "Ruby Smartcall SMS Utility #{Smartcall::VERSION}"
|
|
47
|
+
exit
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
parser.parse!(args)
|
|
52
|
+
@options.recipient = ARGV[-2]
|
|
53
|
+
@options.message = ARGV[-1]
|
|
54
|
+
|
|
55
|
+
if (@options.message.nil? || @options.recipient.nil?) && send_message?
|
|
56
|
+
puts "You must specify a recipient and message!"
|
|
57
|
+
puts parser
|
|
58
|
+
exit
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
return @options
|
|
62
|
+
|
|
63
|
+
rescue OptionParser::MissingArgument => e
|
|
64
|
+
switch_given = e.message.split(':').last.strip
|
|
65
|
+
puts "The #{switch_given} option requires an argument."
|
|
66
|
+
puts parser
|
|
67
|
+
exit
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def default_options
|
|
71
|
+
options = OpenStruct.new
|
|
72
|
+
config_file = File.open(File.join(ENV['HOME'], '.smartcall'))
|
|
73
|
+
config = YAML.load(config_file)
|
|
74
|
+
options.username = config['username']
|
|
75
|
+
options.password = config['password']
|
|
76
|
+
options.campaign_id = config['campaign_id']
|
|
77
|
+
options.reference = config['reference']
|
|
78
|
+
return options
|
|
79
|
+
rescue Errno::ENOENT
|
|
80
|
+
return options
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def send_message?
|
|
84
|
+
(@options.show_status.nil? &&
|
|
85
|
+
@options.show_balance.nil?)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/smartcall.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
|
+
|
|
4
|
+
require 'smartcall/soap/default'
|
|
5
|
+
require 'smartcall/soap/default_driver'
|
|
6
|
+
require 'smartcall/soap/smartcall_error'
|
|
7
|
+
require 'smartcall/soap/sms_ws_client'
|
|
8
|
+
|
|
9
|
+
module Smartcall
|
|
10
|
+
VERSION = '0.0.1'
|
|
11
|
+
|
|
12
|
+
class API
|
|
13
|
+
|
|
14
|
+
def initialize(username, password, campaign_id, reference)
|
|
15
|
+
@client = Smartcall::Soap::SmsWSClient.new(username, password, campaign_id, reference)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def send_message(msisdn, message_body, options = {})
|
|
19
|
+
@client.send_sms(msisdn, message_body)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def send_binary_message(msisdn, header, part, options = {})
|
|
23
|
+
raise NotImplementedError.new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def send_wap_link(msisdn, href, message, options = {})
|
|
27
|
+
raise NotImplementedError.new
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|