pswincom 0.1.2 → 0.1.3
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/lib/pswincom/api.rb +22 -10
- metadata +4 -4
data/lib/pswincom/api.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
).each do |lib|
|
|
4
4
|
require File.join(File.dirname(__FILE__), lib)
|
|
5
5
|
end
|
|
6
|
+
require 'rexml/document'
|
|
6
7
|
|
|
7
8
|
module PSWinCom
|
|
8
9
|
class API
|
|
@@ -16,21 +17,32 @@ module PSWinCom
|
|
|
16
17
|
self.debug_mode = false;
|
|
17
18
|
|
|
18
19
|
def initialize user, password
|
|
19
|
-
@user, @password = user, password
|
|
20
|
+
@user, @password = user, password
|
|
21
|
+
@request = Request.new :user => @user, :passwd => @password
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
def send_sms to, text, args={}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
def send_sms to = nil, text = nil, args={}
|
|
25
|
+
add_sms(to, text, args) unless (to.nil? || text.nil?)
|
|
26
|
+
|
|
27
|
+
# Check if there are any messages to send
|
|
28
|
+
if REXML::Document.new(@request.xml).
|
|
29
|
+
root.get_elements('MSGLST/MSG').count == 0
|
|
30
|
+
raise ArgumentError, 'There are no SMS to send'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
sender = HttpSender.new
|
|
34
|
+
PSWinCom.debug "Request", @request.xml
|
|
35
|
+
|
|
36
|
+
unless self.class.test_mode
|
|
37
|
+
result = sender.send(@request)
|
|
38
|
+
PSWinCom.debug "Result", result.body
|
|
39
|
+
end
|
|
40
|
+
|
|
28
41
|
return result
|
|
29
42
|
end
|
|
30
43
|
|
|
31
|
-
def
|
|
32
|
-
request
|
|
33
|
-
request.add({:text => text, :receiver => to }.merge(args))
|
|
44
|
+
def add_sms to, text, args = {}
|
|
45
|
+
@request.add({:text => text, :receiver => to }.merge(args))
|
|
34
46
|
end
|
|
35
47
|
end
|
|
36
48
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pswincom
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 29
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 0.1.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.1.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- PSWinCom AS
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-02-
|
|
18
|
+
date: 2011-02-15 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|