chutki 0.0.1 → 0.1.1
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 +17 -1
- data/lib/chutki.rb +14 -10
- data/lib/chutki/version.rb +1 -1
- data/test/test_init.rb +4 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
chutki = Chutki.new(username,password,
|
21
|
+
chutki = Chutki.new({username: username, password: password, sender_id: sender_id})
|
22
22
|
result = chutki.send_sms(phone_number,message)
|
23
23
|
if result.success?
|
24
24
|
...
|
@@ -27,6 +27,22 @@ Or install it yourself as:
|
|
27
27
|
end
|
28
28
|
# See documentation for all result codes
|
29
29
|
|
30
|
+
## For using this as an ActionMailer delivery method
|
31
|
+
|
32
|
+
in your config/initializers/chutki.rb
|
33
|
+
|
34
|
+
ActionMailer::Base.add_delivery_method :chutki, Chutki, {
|
35
|
+
username: "username",
|
36
|
+
password: "password",
|
37
|
+
sender_id: "sender_id"
|
38
|
+
}
|
39
|
+
|
40
|
+
in your app/mailer/yourmailer.rb
|
41
|
+
|
42
|
+
def welcome_sms(user)
|
43
|
+
mail :to => user.phone, :delivery_method => :chutki
|
44
|
+
end
|
45
|
+
|
30
46
|
## Contributing
|
31
47
|
|
32
48
|
1. Fork it
|
data/lib/chutki.rb
CHANGED
@@ -5,20 +5,28 @@ class Chutki
|
|
5
5
|
include HTTParty
|
6
6
|
base_uri "http://prosms.easy2approach.com"
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
@username = options[:username]
|
11
|
+
@password = options[:password]
|
12
|
+
@sender_id = options[:sender_id]
|
12
13
|
end
|
13
14
|
|
14
15
|
def send_sms(message,to,opts = {})
|
15
16
|
opts ||= {}
|
16
17
|
opts[:mobiles] = to
|
17
18
|
opts[:message] = message
|
18
|
-
opts[:senderid] = @sender_id
|
19
19
|
makesend("/sendhttp.php",opts)
|
20
20
|
end
|
21
21
|
|
22
|
+
def deliver(mail)
|
23
|
+
send_sms(mail.body,mail.to[0])
|
24
|
+
end
|
25
|
+
|
26
|
+
def deliver!(mail)
|
27
|
+
deliver(mail)
|
28
|
+
end
|
29
|
+
|
22
30
|
def check_dnd_balance
|
23
31
|
balance("dnd")
|
24
32
|
end
|
@@ -50,11 +58,7 @@ class Chutki
|
|
50
58
|
private
|
51
59
|
|
52
60
|
def makesend(endpoint,opts = {})
|
53
|
-
self.class.post(endpoint,opts.merge(options))
|
54
|
-
end
|
55
|
-
|
56
|
-
def options
|
57
|
-
{:user => @username, :password => @password}
|
61
|
+
self.class.post(endpoint,opts.merge(@options))
|
58
62
|
end
|
59
63
|
|
60
64
|
end
|
data/lib/chutki/version.rb
CHANGED
data/test/test_init.rb
CHANGED
@@ -6,7 +6,7 @@ class InitTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
should "require username and password and senderid" do
|
8
8
|
lambda { Chutki.new }.should raise_error(ArgumentError)
|
9
|
-
Chutki.new("username","password","senderid")
|
9
|
+
Chutki.new({username: "username", password: "password", sender_id: "senderid"})
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -17,9 +17,9 @@ class InitTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "Sending SMS" do
|
20
|
-
@chutki = Chutki.new("username","password","senderid")
|
21
|
-
Chutki.expects(:post).with("/sendhttp.php"
|
22
|
-
@chutki.send_sms("message","phonenumber")
|
20
|
+
@chutki = Chutki.new({username: "username", password: "password", sender_id: "senderid"})
|
21
|
+
Chutki.expects(:post).with("/sendhttp.php", :mobiles => "phonenumber", :message => "message", :username => "username", :password => "password", :sender_id => "senderid")
|
22
|
+
@chutki.send_sms("message","phonenumber",{})
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chutki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
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-07-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|