movile_sms 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/movile_sms/sms.rb +15 -2
- data/lib/movile_sms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d424ce4e29e7b818da4f0e14cfda93db5440d4a
|
4
|
+
data.tar.gz: f382473f308d0148730f7877431bc7e642ccdfcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eb2395522b34e7ba0a925755fac3c211fdf615a55a6259691efd0d2ed52057b65dffc375c84cd2cbb66da0b5254071e1e824adc641a5deff0570ae100b069c3
|
7
|
+
data.tar.gz: 3ef9a1edb44ebd718bc6d1ea264b2fdde0149f3f6b9cf683de60913b02ba171f856e5beae8a76be3517377fd7de6e29fb75d27b92abc7bd996a5aa7590e5991b
|
data/lib/movile_sms/sms.rb
CHANGED
@@ -10,8 +10,21 @@ class Sms
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def send_message(number, text)
|
13
|
-
|
14
|
-
|
13
|
+
if valid_number?(number) and text_size(text)
|
14
|
+
body = { "destination" => number.to_s, "messageText" => text.to_s }.to_json
|
15
|
+
response = self.class.post(BASE_API_URL, headers: @options, body: body )
|
16
|
+
else
|
17
|
+
raise "Check if the imputed number #{number} is valid or if the text has a maximum of 162 characters
|
18
|
+
"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def valid_number?(number)
|
23
|
+
true if Float(number) rescue false
|
24
|
+
end
|
25
|
+
|
26
|
+
def text_size(text)
|
27
|
+
text.size <= 162
|
15
28
|
end
|
16
29
|
|
17
30
|
end
|
data/lib/movile_sms/version.rb
CHANGED