smshelper 0.2.10 → 0.3.0

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/README.rdoc CHANGED
@@ -11,16 +11,22 @@ A small utility library to do SMS-MT
11
11
  * www.esendex.com
12
12
  * www.mediaburst.co.uk
13
13
  * www.nexmo.com
14
+ * www.vianett.com
15
+ * www.traitel.com.au
16
+ * www.my-cool-sms.com
17
+ * www.aql.com
14
18
  == Features
15
19
 
16
- * unicode support
20
+ * NEW HLR lookup support via my-cool-sms
21
+ * unicode support - all operators
17
22
  * send message
18
23
  * check balance
19
- * check sent message status
24
+ * check sent message status - select operators only
20
25
  == Installation
21
26
 
22
27
  gem install smshelper
23
28
  == Usage
29
+
24
30
  require 'smshelper'
25
31
  config = Smshelper::Config.new(
26
32
  :webtext => {:uname => '', :passwd => ''},
@@ -47,8 +53,9 @@ gem install smshelper
47
53
  == TODO:
48
54
 
49
55
  * create tests
50
- * refactor
51
- * add support for www.totext.net, www.my-cool-sms.com, sms.vianett.com, www.world-text.com, www.mpulse.eu, www.clicksms.co.uk, www.tellustalk.com, www.aql.com, www.tm4b.com, www.txtnation.com, www.smsextrapro.com, www.truesenses.com, www.traitel.com.au
56
+ * refactor / rewrite class factories as modules
57
+ * handle sms of any size - operator specific settings
58
+ * add support for www.totext.net, www.world-text.com, www.mpulse.eu, www.clicksms.co.uk, www.tellustalk.com, www.tm4b.com, www.txtnation.com, www.smsextrapro.com, www.truesenses.com, www.routomessaging.net
52
59
  == Contributing to smshelper
53
60
 
54
61
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.10
1
+ 0.3.0
@@ -10,7 +10,33 @@ module Smshelper
10
10
  end
11
11
 
12
12
  def send_message(message)
13
- (post 'sms_gw.php')
13
+ uuid = (Digest::CRC32.hexdigest @uuid.generate).unpack('U*').collect {|x| sprintf '%02X', x}.join
14
+
15
+ message.utf_8 ? (q = {:allow_unicode => '1'}) : (q = {})
16
+ options = {
17
+ :destination => message.recipient,
18
+ :originator => message.sender,
19
+ :message => message.text}
20
+ options = options.merge(@extra_options) unless @extra_options.nil?
21
+ # raise ArgumentError, ":dlr_url is required to track messages" unless options.include?(:dlr_url)
22
+ (options[:dlr_url] = options[:dlr_url] + "?status=%code&destination=%dest&message_id=#{uuid}") if options.include?(:dlr_url)
23
+ resp = (post 'sms_gw.php', :extra_query => options.merge(q))
24
+ process_response_code(resp.to_s) ? (@sent_message_ids << uuid; uuid) : (raise ErrorDuringSend, resp)
25
+ end
26
+
27
+ def get_balance
28
+ {'Credits' => (post 'postmsg.php', :extra_query => {:cmd => :credit}).split('=').last}
29
+ end
30
+
31
+ def get_status
32
+ raise NotImplementedError, "Aql does not implement status check"
33
+ end
34
+
35
+ def process_response_code(code)
36
+ (code =~ /SMS successfuly queued/) ? true : false
37
+ end
38
+
39
+ def massage_dlr_url(url)
14
40
  end
15
41
  end
16
42
  end
@@ -1,7 +1,7 @@
1
1
  module Smshelper
2
2
  module Api
3
3
  class Mycoolsms < Base
4
- base_uri 'https://www.my-cool-sms.com/api-socket.php '
4
+ base_uri 'https://www.my-cool-sms.com/'
5
5
 
6
6
  def initialize(*args)
7
7
  config = args.shift
@@ -10,15 +10,26 @@ module Smshelper
10
10
  end
11
11
 
12
12
  def send_message(message)
13
- (post)
13
+ options = {
14
+ :number => message.recipient,
15
+ :message => message.text,
16
+ :senderid => message.sender,
17
+ :function => 'sendSms'}
18
+ options = options.merge(@extra_options) unless @extra_options.nil?
19
+ resp = JSON.parse(post 'api-socket.php', :extra_query => options)
20
+ process_response_code(resp) ? (@sent_message_ids << resp['smsid']; resp['smsid']) : (raise ErrorDuringSend, resp)
14
21
  end
15
22
 
16
23
  def get_balance
17
- (post '', :extra_query => {:function => :getbalance})
24
+ {'EUR' => JSON.parse(post 'api-socket.php', :extra_query => {:function => 'getBalance'})['balance']}
18
25
  end
19
26
 
20
27
  def hlr_lookup(number)
28
+ JSON.parse(post 'api-socket.php', :extra_query => {:function => 'doHlrLookup', :number => number})
29
+ end
21
30
 
31
+ def process_response_code(code)
32
+ code['success']
22
33
  end
23
34
  end
24
35
  end
@@ -172,6 +172,8 @@ module Smshelper
172
172
  '15' => 'Invalid sender address',
173
173
  '16' => 'Invalid TTL'}
174
174
 
175
+ AQL = {}
176
+
175
177
  def webtext(code)
176
178
  WEBTEXT[code]
177
179
  end
@@ -3,7 +3,6 @@ module Smshelper
3
3
  class Traitel < Base
4
4
  base_uri 'http://api.traitel.com'
5
5
  # headers 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language' => 'en-us,en;q=0.5', 'Accept-Encoding' => 'gzip, deflate', 'DNT' => '1', 'Connection' => 'keep-alive'
6
-
7
6
  def initialize(*args)
8
7
  config = args.shift
9
8
  add_query_options! :user => config.traitel[:uname], :pass => config.traitel[:passwd] # "\"#{config.traitel[:passwd]}\""
@@ -25,7 +24,7 @@ module Smshelper
25
24
  :concatenate => true
26
25
  }
27
26
  options = options.merge(@extra_options) unless @extra_options.nil?
28
- resp = (get 'smsgateway.pl', :extra_query => options.merge(q)) #; resp.split(',')[2]
27
+ resp = (get 'smsgateway.pl', :extra_query => options.merge(q))
29
28
  process_response_code(resp) ? (@sent_message_ids << resp.split(',')[2]; resp.split(',')[2]) : (raise ErrorDuringSend "Could not deliver")
30
29
  end
31
30
 
@@ -16,7 +16,7 @@ module Smshelper
16
16
  :destinationaddr => message.recipient,
17
17
  :message => message.text,
18
18
  :sourceaddr => message.sender,
19
- :refno => '1',
19
+ # :refno => '1',
20
20
  :msgid => uuid}
21
21
  options = options.merge(@extra_options) unless @extra_options.nil?
22
22
  resp = (post 'MT.ashx', :extra_query => options)
data/lib/smshelper/api.rb CHANGED
@@ -1,19 +1,26 @@
1
- require 'smshelper/api/base'
2
- require 'smshelper/api/response_codes'
3
1
  # require 'smshelper/api/smswarehouse'
4
2
  # require 'smshelper/api/routomessaging'
5
- require 'smshelper/api/webtext'
6
- require 'smshelper/api/bulksms'
7
- require 'smshelper/api/clickatell'
8
- require 'smshelper/api/textmagic'
9
- require 'smshelper/api/smstrade'
10
- require 'smshelper/api/esendex'
11
- require 'smshelper/api/mediaburst'
12
- require 'smshelper/api/nexmo'
13
- require 'smshelper/api/traitel'
14
3
 
15
- # require 'smshelper/api/totext'
16
- require 'smshelper/api/vianett'
17
- require 'smshelper/api/aql'
18
- require 'smshelper/api/txtnation'
19
- require 'smshelper/api/mycoolsms'
4
+ module Smshelper
5
+ module Api
6
+ path = (File.dirname File.expand_path(__FILE__))
7
+
8
+ autoload :Base, "#{path}/api/base"
9
+ autoload :ResponseCodes, "#{path}/api/response_codes"
10
+ autoload :Webtext, "#{path}/api/webtext"
11
+ autoload :Bulksms, "#{path}/api/bulksms"
12
+ autoload :Clickatell, "#{path}/api/clickatell"
13
+ autoload :Textmagic, "#{path}/api/textmagic"
14
+ autoload :Smstrade, "#{path}/api/smstrade"
15
+ autoload :Esendex, "#{path}/api/esendex"
16
+ autoload :Mediaburst, "#{path}/api/mediaburst"
17
+ autoload :Nexmo, "#{path}/api/nexmo"
18
+ autoload :Traitel, "#{path}/api/traitel"
19
+
20
+ autoload :Aql, "#{path}/api/aql"
21
+ autoload :Vianett, "#{path}/api/vianett"
22
+ autoload :Txtnation, "#{path}/api/txtnation"
23
+ autoload :Totext, "#{path}/api/totext"
24
+ autoload :Mycoolsms, "#{path}/api/mycoolsms"
25
+ end
26
+ end
data/lib/smshelper.rb CHANGED
@@ -2,18 +2,20 @@ require 'uuid'
2
2
  require 'digest/crc32'
3
3
  require 'savon'
4
4
  require 'textmagic'
5
- require 'mediaburst'
5
+ require 'json'
6
6
  require 'api_smith'
7
7
 
8
- require 'smshelper/api'
9
- require 'smshelper/languagetools'
10
- require 'smshelper/message'
11
- require 'smshelper/config'
12
-
13
8
  module Smshelper
14
9
  class NotImplementedError < ArgumentError
15
10
  end
16
11
 
17
12
  class ErrorDuringSend < ArgumentError
18
13
  end
14
+
15
+ path = (File.dirname File.expand_path(__FILE__))
16
+
17
+ autoload :Api, "#{path}/smshelper/api"
18
+ autoload :Languagetools, "#{path}/smshelper/languagetools"
19
+ autoload :Message, "#{path}/smshelper/message"
20
+ autoload :Config, "#{path}/smshelper/config"
19
21
  end
data/smshelper.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "smshelper"
8
- s.version = "0.2.10"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Voip Scout"]
12
- s.date = "2012-05-06"
12
+ s.date = "2012-05-19"
13
13
  s.description = "works with esendex, textmagic, smstrade, bulksms, routomessaging, smswarehouse, mediaburst, clickatell, webtext"
14
14
  s.email = "voipscout@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smshelper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-06 00:00:00.000000000 Z
12
+ date: 2012-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: api_smith
@@ -260,7 +260,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
260
  version: '0'
261
261
  segments:
262
262
  - 0
263
- hash: -51675857748285695
263
+ hash: -2282137222022673328
264
264
  required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  none: false
266
266
  requirements: