gupshup 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/gupshup.rb +15 -19
  2. metadata +2 -2
@@ -7,23 +7,19 @@ require 'cgi'
7
7
  require 'httpclient'
8
8
 
9
9
  class NilClass
10
- unless defined? :blank?
11
- def blank?
12
- true
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
- unless defined? :blank?
19
- def blank?
20
- self.empty?
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.0'
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 (false, 'Phone Number is too short') if number.to_s.length < 12
69
- return (false, 'Phone Number is too long') if number.to_s.length > 12
70
- #return (false, 'Phone Number should start with "91"') if number.to_s.start_with? "91"
71
- return (false, 'Phone Number should be numerical value') unless number.to_i.to_s == number.to_s
72
- return (false, 'Message should be less than 725 characters long') if msg.to_s.length > 724
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 (false,"Invalid group name") if opts[:group_name].blank?
106
- return (false,"Invalid message") if opts[:msg].blank?
107
- return (false,"Invalid message type") if opts[:msg_type].blank?
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nilesh Trivedi