cellular 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +1 -1
- data/README.md +1 -1
- data/cellular.gemspec +6 -2
- data/lib/cellular.rb +16 -0
- data/lib/cellular/backends.rb +5 -0
- data/lib/cellular/backends/sendega.rb +73 -0
- data/lib/cellular/configuration.rb +7 -0
- data/lib/cellular/models/sms.rb +43 -0
- data/lib/cellular/version.rb +1 -1
- metadata +42 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6797a5f2c6ccf1a9f71167bad98a54eeed77d729
|
4
|
+
data.tar.gz: 03dd1fcc61fd35ab0bfebee9a40b181fe731dff5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14a1c8bf8e47f83eaa088cecf5efc867b60b76c5578b7b8236ed3897821018b85dc8b726bb969556bd72648e44aab42ce12324954f0c5a260a96475eae8b192b
|
7
|
+
data.tar.gz: 1554bbe7f7d214a02aa49c0de8d3c58c6155bc0738e9d79ab1d2ce088b4ae75873d51a3b992775e6cf877af96386e86f118efea8240e0022ba44d027f18ca119
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
data/cellular.gemspec
CHANGED
@@ -8,8 +8,8 @@ require 'cellular/version'
|
|
8
8
|
Gem::Specification.new do |gem|
|
9
9
|
gem.name = 'cellular'
|
10
10
|
gem.version = Cellular::VERSION
|
11
|
-
gem.authors = ['Tim Kurvers']
|
12
|
-
gem.email = ['
|
11
|
+
gem.authors = ['Sindre Moen', 'Tim Kurvers']
|
12
|
+
gem.email = ['johannes@hyper.no']
|
13
13
|
gem.description = %q{Sending and receiving SMSs through pluggable backends}
|
14
14
|
gem.summary = %q{Sending and receiving SMSs through pluggable backends}
|
15
15
|
gem.homepage = ''
|
@@ -18,4 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
20
|
gem.require_paths = ['lib']
|
21
|
+
|
22
|
+
gem.add_dependency 'savon'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'pry'
|
21
25
|
end
|
data/lib/cellular.rb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
require 'cellular/version'
|
2
|
+
require 'cellular/configuration'
|
3
|
+
require 'cellular/models/sms'
|
4
|
+
require 'cellular/backends'
|
2
5
|
|
3
6
|
module Cellular
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :config
|
10
|
+
|
11
|
+
def configure
|
12
|
+
yield config
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
@config ||= Configuration.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
4
20
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
module Cellular
|
4
|
+
module Backends
|
5
|
+
class Sendega
|
6
|
+
|
7
|
+
GATEWAY_URL = 'https://smsc.sendega.com/Content.asmx?WSDL'
|
8
|
+
|
9
|
+
def self.deliver(options = {})
|
10
|
+
# Send an SMS and return its initial delivery status code.
|
11
|
+
#
|
12
|
+
# Delivery status codes:
|
13
|
+
# 0 -- Message is received and is being processed.
|
14
|
+
# 1001 -- Not validated
|
15
|
+
# 1003 -- Wrong format: pid/dcs
|
16
|
+
# 1004 -- Erroneous typeid
|
17
|
+
# 1020 -- Fromalpha too long
|
18
|
+
# 1021 -- Fromnumber too long
|
19
|
+
# 1022 -- Erroneous recipient, integer overflow
|
20
|
+
# 1023 -- No message content submitted
|
21
|
+
# 1024 -- Premium sms must have abbreviated number as sender
|
22
|
+
# 1025 -- The message sender is not allowed
|
23
|
+
# 1026 -- Balance to low
|
24
|
+
# 1027 -- Message too long
|
25
|
+
# 1028 -- Alphanumeric sender is not valid
|
26
|
+
# 1099 -- Internal error
|
27
|
+
# 9001 -- Username and password does not match
|
28
|
+
# 9002 -- Account is closed
|
29
|
+
# 9004 -- Http not enabled
|
30
|
+
# 9005 -- Smpp not enabled
|
31
|
+
# 9006 -- Ip not allowed
|
32
|
+
# 9007 -- Demo account empty
|
33
|
+
#
|
34
|
+
# See Gate API Documentation:
|
35
|
+
# http://www.sendega.no/downloads/Sendega%20API%20documentation%20v2.0.pdf
|
36
|
+
|
37
|
+
client = Savon.client wsdl: GATEWAY_URL
|
38
|
+
|
39
|
+
result = client.call(:send, message: {
|
40
|
+
username: Cellular.config.username,
|
41
|
+
password: Cellular.config.password,
|
42
|
+
sender: options[:sender],
|
43
|
+
destination: options[:recipient],
|
44
|
+
pricegroup: options[:price] || 0, # default price to 0
|
45
|
+
contentTypeID: 1,
|
46
|
+
contentHeader: "",
|
47
|
+
content: options[:message],
|
48
|
+
dlrUrl: Cellular.config.delivery_url,
|
49
|
+
ageLimit: 0,
|
50
|
+
extID: "",
|
51
|
+
sendDate: "",
|
52
|
+
refID: "",
|
53
|
+
priority: 0,
|
54
|
+
gwID: 0,
|
55
|
+
pid: 0,
|
56
|
+
dcs: 0
|
57
|
+
}
|
58
|
+
)
|
59
|
+
|
60
|
+
if result.success?
|
61
|
+
[ result.body[:error_number], 'Message is received and is being processed.' ]
|
62
|
+
else
|
63
|
+
[ result.body[:error_number], result.body[:error_message] ]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.receive(data)
|
68
|
+
raise NotImplementedError
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Cellular
|
2
|
+
class SMS
|
3
|
+
|
4
|
+
attr_accessor :recipient, :sender, :message, :price, :country
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@backend = Cellular.config.backend
|
8
|
+
|
9
|
+
@recipient = options[:recipient]
|
10
|
+
@sender = options[:sender]
|
11
|
+
@message = options[:message]
|
12
|
+
@price = options[:price]
|
13
|
+
@country = options[:country]
|
14
|
+
|
15
|
+
@delivered = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def deliver
|
19
|
+
@delivery_status, @delivery_message = @backend.deliver(
|
20
|
+
recipient: @recipient,
|
21
|
+
sender: @sender,
|
22
|
+
price: @price,
|
23
|
+
country: @country,
|
24
|
+
message: @message
|
25
|
+
)
|
26
|
+
|
27
|
+
@delivered = true
|
28
|
+
end
|
29
|
+
|
30
|
+
def save(options)
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
|
34
|
+
def receive(options)
|
35
|
+
raise NotImplementedError
|
36
|
+
end
|
37
|
+
|
38
|
+
def delivered?
|
39
|
+
@delivered
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/cellular/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cellular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
7
|
+
- Sindre Moen
|
8
8
|
- Tim Kurvers
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: pry
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
14
42
|
description: Sending and receiving SMSs through pluggable backends
|
15
43
|
email:
|
16
|
-
-
|
44
|
+
- johannes@hyper.no
|
17
45
|
executables: []
|
18
46
|
extensions: []
|
19
47
|
extra_rdoc_files: []
|
@@ -25,29 +53,32 @@ files:
|
|
25
53
|
- Rakefile
|
26
54
|
- cellular.gemspec
|
27
55
|
- lib/cellular.rb
|
56
|
+
- lib/cellular/backends.rb
|
57
|
+
- lib/cellular/backends/sendega.rb
|
58
|
+
- lib/cellular/configuration.rb
|
59
|
+
- lib/cellular/models/sms.rb
|
28
60
|
- lib/cellular/version.rb
|
29
61
|
homepage: ''
|
30
62
|
licenses: []
|
63
|
+
metadata: {}
|
31
64
|
post_install_message:
|
32
65
|
rdoc_options: []
|
33
66
|
require_paths:
|
34
67
|
- lib
|
35
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
69
|
requirements:
|
38
|
-
- -
|
70
|
+
- - '>='
|
39
71
|
- !ruby/object:Gem::Version
|
40
72
|
version: '0'
|
41
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
74
|
requirements:
|
44
|
-
- -
|
75
|
+
- - '>='
|
45
76
|
- !ruby/object:Gem::Version
|
46
77
|
version: '0'
|
47
78
|
requirements: []
|
48
79
|
rubyforge_project:
|
49
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.2.1
|
50
81
|
signing_key:
|
51
|
-
specification_version:
|
82
|
+
specification_version: 4
|
52
83
|
summary: Sending and receiving SMSs through pluggable backends
|
53
84
|
test_files: []
|