cm-sms 0.1.2 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0f2ddda808c0d11d899468746aa95076b5847be
4
- data.tar.gz: c6c6567a54ffb37ccb70d8b635dd433786273da7
3
+ metadata.gz: 4e9024d044fac2ec296fffc599f6cf000f94548c
4
+ data.tar.gz: 8b548a9a0af55c8ec08a2acd87209e782f08b1e5
5
5
  SHA512:
6
- metadata.gz: 7ed859dd972e7b6991b318f647bf8334197019dd2bd2610e6a07dc553883744691f9185969bf7141dd9a0692a0bcb27c6d701f1c2d7cdb9a86dbf80409da38ea
7
- data.tar.gz: fe02896939a41c166ea28f785aa24ed5925515c09a535d0967a53f86dce9d07fa9ac14658b3288a38ef98333e34b8ba453ed6cc7b706507ba8f7c00ac38960c1
6
+ metadata.gz: ed7594d60bcecd5d12b414c80f5ea8355ab3759e7b849104e0884bbeb065e1a309907d5d3282ce3241cbedc305554211b13d3789e4d7e45ee8723a9757c12d95
7
+ data.tar.gz: 67f32ac8fa737e730c2e491bc46af34a45d33b2536aa6ffed227357677e108d08cc42d28965d88795b3a98d5e9f0698ae7115b6b32d1316c40b5d0474f3ef5d9
Binary file
@@ -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
@@ -7,7 +7,7 @@ module CmSms
7
7
  module VERSION
8
8
  MAJOR = 0
9
9
  MINOR = 1
10
- TINY = 2
10
+ TINY = 4
11
11
  PRE = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -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("THe given to attribute is not a plausible phone number.\nMaybe the country code is missing.") unless receiver_plausible?
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.2
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