cm-sms 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cm-sms-0.1.2.gem +0 -0
- data/lib/cm_sms/configuration.rb +6 -2
- data/lib/cm_sms/gem_version.rb +1 -1
- data/lib/cm_sms/message.rb +11 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e9024d044fac2ec296fffc599f6cf000f94548c
|
4
|
+
data.tar.gz: 8b548a9a0af55c8ec08a2acd87209e782f08b1e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7594d60bcecd5d12b414c80f5ea8355ab3759e7b849104e0884bbeb065e1a309907d5d3282ce3241cbedc305554211b13d3789e4d7e45ee8723a9757c12d95
|
7
|
+
data.tar.gz: 67f32ac8fa737e730c2e491bc46af34a45d33b2536aa6ffed227357677e108d08cc42d28965d88795b3a98d5e9f0698ae7115b6b32d1316c40b5d0474f3ef5d9
|
data/cm-sms-0.1.2.gem
ADDED
Binary file
|
data/lib/cm_sms/configuration.rb
CHANGED
@@ -8,7 +8,7 @@ module CmSms
|
|
8
8
|
PATH = '/gateway.ashx'
|
9
9
|
DCS = 8
|
10
10
|
|
11
|
-
attr_accessor :from, :to, :product_token, :endpoint, :path
|
11
|
+
attr_accessor :from, :to, :product_token, :endpoint, :path, :dcs
|
12
12
|
|
13
13
|
alias :'api_key=' :'product_token='
|
14
14
|
|
@@ -20,8 +20,12 @@ module CmSms
|
|
20
20
|
@path || PATH
|
21
21
|
end
|
22
22
|
|
23
|
+
def dcs
|
24
|
+
@dcs || DCS
|
25
|
+
end
|
26
|
+
|
23
27
|
def defaults
|
24
|
-
@defaults ||= { from: from, to: to }
|
28
|
+
@defaults ||= { from: from, to: to, dcs: dcs }
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/cm_sms/gem_version.rb
CHANGED
data/lib/cm_sms/message.rb
CHANGED
@@ -9,6 +9,7 @@ module CmSms
|
|
9
9
|
class BodyMissing < ArgumentError; end
|
10
10
|
class BodyToLong < ArgumentError; end
|
11
11
|
class ToUnplausible < ArgumentError; end
|
12
|
+
class DCSNotNumeric < ArgumentError; end
|
12
13
|
|
13
14
|
attr_accessor :from, :to, :body, :dcs, :reference
|
14
15
|
|
@@ -22,6 +23,12 @@ module CmSms
|
|
22
23
|
@product_token = CmSms.config.product_token
|
23
24
|
end
|
24
25
|
|
26
|
+
def dcs_numeric?
|
27
|
+
true if dcs.nil? || Float(dcs)
|
28
|
+
rescue
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
25
32
|
def receiver_plausible?
|
26
33
|
receiver_present? && Phony.plausible?(to)
|
27
34
|
end
|
@@ -57,11 +64,12 @@ module CmSms
|
|
57
64
|
end
|
58
65
|
|
59
66
|
def deliver!
|
60
|
-
raise FromMissing.new('The from attribute is missing.') unless sender_present?
|
61
|
-
raise ToMissing.new('The to attribute is missing.') unless receiver_present?
|
67
|
+
raise FromMissing.new('The value for the from attribute is missing.') unless sender_present?
|
68
|
+
raise ToMissing.new('The value for the to attribute is missing.') unless receiver_present?
|
62
69
|
raise BodyMissing.new('The body of the message is missing.') unless body_present?
|
63
70
|
raise BodyToLong.new('The body of the message has a length greater than 160.') unless body_correct_length?
|
64
|
-
raise ToUnplausible.new("
|
71
|
+
raise ToUnplausible.new("The given value for the to attribute is not a plausible phone number.\nMaybe the country code is missing.") unless receiver_plausible?
|
72
|
+
raise DCSNotNumeric.new("The given value for the dcs attribute is not a number.") unless dcs_numeric?
|
65
73
|
|
66
74
|
deliver
|
67
75
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- itschn
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- bin/setup
|
115
115
|
- cm-sms-0.1.0.gem
|
116
116
|
- cm-sms-0.1.1.gem
|
117
|
+
- cm-sms-0.1.2.gem
|
117
118
|
- cm-sms.gemspec
|
118
119
|
- lib/cm-sms.rb
|
119
120
|
- lib/cm_sms.rb
|