signupto 0.0.2
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/LICENSE +20 -0
- data/README +4 -0
- data/Rakefile +35 -0
- data/lib/signupto.rb +9 -0
- data/lib/signupto/account.rb +19 -0
- data/lib/signupto/action/balance.rb +24 -0
- data/lib/signupto/action/base.rb +31 -0
- data/lib/signupto/action/sender.rb +32 -0
- data/lib/signupto/base.rb +30 -0
- data/lib/signupto/message.rb +19 -0
- data/lib/signupto/version.rb +9 -0
- metadata +59 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 YOUR NAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'lib/signupto/version'
|
4
|
+
|
5
|
+
PLUGIN = "signupto"
|
6
|
+
NAME = "signupto"
|
7
|
+
VERSION = Signupto::Version::STRING
|
8
|
+
AUTHOR = "Tim Perrett"
|
9
|
+
EMAIL = "code@timperrett.com"
|
10
|
+
HOMEPAGE = "http://blog.timperrett.com"
|
11
|
+
SUMMARY = "Core connectivity to the signupto SMS gateway service"
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = NAME
|
15
|
+
s.version = VERSION
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = ["README", "LICENSE"]
|
19
|
+
s.summary = SUMMARY
|
20
|
+
s.description = s.summary
|
21
|
+
s.author = AUTHOR
|
22
|
+
s.email = EMAIL
|
23
|
+
s.homepage = HOMEPAGE
|
24
|
+
s.require_path = 'lib'
|
25
|
+
s.autorequire = PLUGIN
|
26
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{lib,spec}/**/*")
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
30
|
+
pkg.gem_spec = spec
|
31
|
+
end
|
32
|
+
|
33
|
+
task :install => [:package] do
|
34
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
|
35
|
+
end
|
data/lib/signupto.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'signupto/account'
|
5
|
+
require 'signupto/message'
|
6
|
+
require 'signupto/action/base'
|
7
|
+
require 'signupto/action/balance'
|
8
|
+
require 'signupto/action/sender'
|
9
|
+
require 'signupto/base'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Signupto
|
2
|
+
class Account
|
3
|
+
|
4
|
+
attr_reader :apihash
|
5
|
+
attr_reader :customer_number
|
6
|
+
|
7
|
+
# Pass in your account details to create an account object.
|
8
|
+
# Your +apihash+ and +cid+ which will both be found on the signup.to
|
9
|
+
# dashboard interface.
|
10
|
+
def initialize(apihash, customer_number)
|
11
|
+
@apihash, @customer_number = apihash, customer_number
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_http
|
15
|
+
URI.encode("cid=#{@customer_number}&hash=#{@apihash}")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Signupto
|
2
|
+
module Action
|
3
|
+
class Balance < Base
|
4
|
+
|
5
|
+
def initialize(account)
|
6
|
+
if account.is_a?(Account)
|
7
|
+
if super(account.apihash, account.customer_number)
|
8
|
+
payload = set_payload()
|
9
|
+
run_action(payload)
|
10
|
+
end
|
11
|
+
else
|
12
|
+
raise "ERROR"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def set_payload
|
19
|
+
@payload = [@account.to_http, 'mode=balance'].join('&')
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Signupto
|
5
|
+
module Action
|
6
|
+
class Base
|
7
|
+
|
8
|
+
# Parent class that all specific actions are derived.
|
9
|
+
def initialize(account_hash, customer_number)
|
10
|
+
@account = Signupto::Account.new(account_hash, customer_number)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
return @result.body
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
# Actually make the call to the api URL. SignUp.to use a
|
20
|
+
# PHP response method, so I make a URI encoded GET to there servers
|
21
|
+
# and await the response; handling it appropriatly.
|
22
|
+
def run_action(payload, page = 'smpp_account')
|
23
|
+
Net::HTTP.start('sms.sign-up.to', 80) do |http|
|
24
|
+
@result = http.get('/'<< page << '.php?' << payload)
|
25
|
+
return @result
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Signupto
|
2
|
+
module Action
|
3
|
+
class Sender < Base
|
4
|
+
|
5
|
+
def initialize(account, message)
|
6
|
+
if message.is_a?(Message) and account.is_a?(Account)
|
7
|
+
if super(account.apihash, account.customer_number)
|
8
|
+
@message = message
|
9
|
+
payload = set_payload()
|
10
|
+
run_action(payload, 'smpp_send')
|
11
|
+
end
|
12
|
+
else
|
13
|
+
raise "You can only supply a Message object"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
# Configure the payload to send on this text message.
|
20
|
+
# to - Recipient mobile number in full international format (no ‘+’ or ‘00’)
|
21
|
+
# message - Message body text
|
22
|
+
# from - SMS sender
|
23
|
+
# cost - Cost (in pence) to the recipient
|
24
|
+
# network - Recipient’s network
|
25
|
+
# smsc - ID of client selected SMS route
|
26
|
+
def set_payload
|
27
|
+
@payload = [@account.to_http, "to=#{@message.to.to_s}", "message=#{@message.body.to_s}", "from=#{@message.from.to_s}"].join('&')
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Signupto
|
2
|
+
class Base
|
3
|
+
|
4
|
+
class << self
|
5
|
+
# retrives your account balance and returns it as a string
|
6
|
+
def balance(options = {})
|
7
|
+
if options.has_key?(:account_hash) and options.has_key?(:customer_number)
|
8
|
+
account = Account.new(options[:account_hash], options[:customer_number])
|
9
|
+
return Action::Balance.new(account).to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Upon a sucsesfull send this will return the message number for tracking purposese
|
14
|
+
# on the signupto systems.
|
15
|
+
def send!(options = {})
|
16
|
+
if options.has_key?(:account_hash) and options.has_key?(:customer_number)
|
17
|
+
account = Account.new(options[:account_hash], options[:customer_number])
|
18
|
+
if options.has_key?(:message) and options.has_key?(:to)
|
19
|
+
message = Message.new(options[:to], options[:message], options[:from])
|
20
|
+
puts message.to
|
21
|
+
return Action::Sender.new(account, message)
|
22
|
+
else
|
23
|
+
raise ArgumentError, "You must supply a message to send and a place to send it"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Signupto
|
2
|
+
class Message
|
3
|
+
|
4
|
+
# Make the elements of the message accesible.
|
5
|
+
# This way you can do @message.from etc to makes debuging the code
|
6
|
+
# a lot simpler (I find at least)
|
7
|
+
attr_reader :to, :from, :body
|
8
|
+
|
9
|
+
# Set the recipient (which must be in international format, with no leading +)
|
10
|
+
# and the from paramater, and the body. The From paramater will take a string up to
|
11
|
+
# 12 characters long, then on the recipients phone it will appear as if it is from
|
12
|
+
# someone in there contacts rather than and unknown number.
|
13
|
+
def initialize(to, body, from = nil)
|
14
|
+
# validate_number(to)
|
15
|
+
@to, @body, @from = to, URI.encode(body), from
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: signupto
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2008-01-04 00:00:00 +00:00
|
8
|
+
summary: Core connectivity to the signupto SMS gateway service
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: code@timperrett.com
|
12
|
+
homepage: http://blog.timperrett.com
|
13
|
+
rubyforge_project:
|
14
|
+
description: Core connectivity to the signupto SMS gateway service
|
15
|
+
autorequire: signupto
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Tim Perrett
|
31
|
+
files:
|
32
|
+
- LICENSE
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- lib/signupto
|
36
|
+
- lib/signupto/account.rb
|
37
|
+
- lib/signupto/action
|
38
|
+
- lib/signupto/action/balance.rb
|
39
|
+
- lib/signupto/action/base.rb
|
40
|
+
- lib/signupto/action/sender.rb
|
41
|
+
- lib/signupto/base.rb
|
42
|
+
- lib/signupto/message.rb
|
43
|
+
- lib/signupto/version.rb
|
44
|
+
- lib/signupto.rb
|
45
|
+
test_files: []
|
46
|
+
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
extra_rdoc_files:
|
50
|
+
- README
|
51
|
+
- LICENSE
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
dependencies: []
|
59
|
+
|