aql_sms_api 0.1.0 → 0.2.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.md CHANGED
@@ -6,9 +6,11 @@ A ruby wrapper for the AQL SMS API. I am building this for use in a specific pro
6
6
 
7
7
  #### Authentication
8
8
 
9
- # @params username, password [, originator]
9
+ # @params hash default_params
10
+ # must include :username and :password but can also contain
11
+ # other default params such as :originator
10
12
  #
11
- AQL::SMS.authenticate "username", "password"
13
+ AQL::SMS.authenticate :username => "username", :password => "password"
12
14
 
13
15
  #### Check credit
14
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aql_sms_api}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Russell"]
12
- s.date = %q{2010-05-28}
12
+ s.date = %q{2010-05-29}
13
13
  s.description = %q{A ruby wrapper for the AQL SMS API.}
14
14
  s.email = %q{aaron@gc4.co.uk}
15
15
  s.extra_rdoc_files = [
@@ -7,20 +7,18 @@ module AQL
7
7
  include HTTParty
8
8
  base_uri "https://gw.aql.com/sms/"
9
9
 
10
- def self.authenticate(user = nil, pass = nil, orig = nil)
11
- @auth = {:username => user, :password => pass, :originator => orig}
10
+ def self.authenticate(opts)
11
+ default_params opts
12
12
  end
13
-
14
- authenticate
15
13
 
16
14
  def self.check_credit
17
- res = get "/postmsg.php", :query => @auth.merge(:cmd => "credit")
15
+ res = get "/postmsg.php", :query => {:cmd => "credit"}
18
16
  valid?(res) ? (res == "AQSMS-AUTHERROR" ? false : res.match(/\=(\d+)/)[1]).to_i : res
19
17
  end
20
18
 
21
19
  def self.send_message(dests = [], msg = "", opts = {})
22
20
  numbers = dests.collect{|n| format_number(n)}.join(",")
23
- res = get "/sms_gw.php", :query => @auth.merge(:destination => numbers, :message => msg).merge(opts)
21
+ res = get "/sms_gw.php", :query => opts.merge(:destination => numbers, :message => msg)
24
22
  valid?(res) ? SMSResponse.new(res) : res
25
23
  end
26
24
 
@@ -49,6 +47,25 @@ module AQL
49
47
 
50
48
  end
51
49
 
50
+ class SMSDeliveryReport
51
+
52
+ attr_reader :code, :message, :destination
53
+
54
+ def initialize(params)
55
+ @code = params[:reportcode].to_s
56
+ @destination = params[:destinationnumber].to_s
57
+ @message = case @code
58
+ when "1" then "Delivered to Handset"
59
+ when "2" then "Rejected from Handset"
60
+ when "4" then "Buffered in transit (phone probably off / out of reception)"
61
+ when "8" then "Accepted by SMSC"
62
+ when "16" then "Rejected by SMSC"
63
+ else "Unknown response code"
64
+ end
65
+ end
66
+
67
+ end
68
+
52
69
  module NumberFormat
53
70
 
54
71
  def self.uk(number)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Russell
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-28 00:00:00 +01:00
17
+ date: 2010-05-29 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency