gupshup 0.2.0 → 0.2.2
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/gupshup.rb +15 -19
- metadata +2 -2
data/lib/gupshup.rb
CHANGED
@@ -7,23 +7,19 @@ require 'cgi'
|
|
7
7
|
require 'httpclient'
|
8
8
|
|
9
9
|
class NilClass
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
10
|
+
def blank?
|
11
|
+
true
|
12
|
+
end unless nil.respond_to? :blank?
|
15
13
|
end
|
16
14
|
|
17
15
|
class String
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
16
|
+
def blank?
|
17
|
+
self !~ /\S/
|
18
|
+
end unless "".respond_to? :blank?
|
23
19
|
end
|
24
20
|
|
25
21
|
module Gupshup
|
26
|
-
VERSION = '0.2.
|
22
|
+
VERSION = '0.2.1'
|
27
23
|
class Enterprise
|
28
24
|
def initialize(opts)
|
29
25
|
@api_url = opts[:api_url] || 'http://enterprise.smsgupshup.com/GatewayAPI/rest'
|
@@ -65,11 +61,11 @@ module Gupshup
|
|
65
61
|
number = opts[:send_to]
|
66
62
|
msg_type = opts[:msg_type] || 'TEXT'
|
67
63
|
|
68
|
-
return
|
69
|
-
return
|
70
|
-
#return
|
71
|
-
return
|
72
|
-
return
|
64
|
+
return false, 'Phone Number is too short' if number.to_s.length < 12
|
65
|
+
return false, 'Phone Number is too long' if number.to_s.length > 12
|
66
|
+
#return false, 'Phone Number should start with "91"' if number.to_s.start_with? "91"
|
67
|
+
return false, 'Phone Number should be numerical value' unless number.to_i.to_s == number.to_s
|
68
|
+
return false, 'Message should be less than 725 characters long' if msg.to_s.length > 724
|
73
69
|
call_api opts.merge({ :method => 'sendMessage' })
|
74
70
|
end
|
75
71
|
|
@@ -102,9 +98,9 @@ module Gupshup
|
|
102
98
|
end
|
103
99
|
|
104
100
|
def group_post(opts)
|
105
|
-
return
|
106
|
-
return
|
107
|
-
return
|
101
|
+
return false,"Invalid group name" if opts[:group_name].blank?
|
102
|
+
return false,"Invalid message" if opts[:msg].blank?
|
103
|
+
return false,"Invalid message type" if opts[:msg_type].blank?
|
108
104
|
call_api opts.merge({:method => 'post_group'})
|
109
105
|
end
|
110
106
|
end
|