sms_broker 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea414f2b1fa82dce9c8c0d1d3e4ecf6fe3ea992c
4
- data.tar.gz: c32329c461796e15dbcc731b41d41663ae2cc144
3
+ metadata.gz: de0fd0c33b437013e02a4ade7f46121eba90e819
4
+ data.tar.gz: 12ae1bb6e541bebb950b316102ad90c226513291
5
5
  SHA512:
6
- metadata.gz: 93756cbd914e72958c4f6b4956582582640627b248d645aab289854a0ea7f8f4aacc08e18779d447584291711ae0a24b7ff600d19ae3e38bb54f1abbd707dcaa
7
- data.tar.gz: 99121ad5099a3505d825b2db0b33f184c3197fc97bacb4e793c509a9d06f7dc3d58269ce876e81f52a0fad50c4da87fd451e8b9c74903bcc6f0053f59770c40d
6
+ metadata.gz: 2b253d6f2cfaabf8d9eeb227bab1ac8038eabeede40091776fb317c1a7423879d4aa74d172e84a625148e89cf8c82bcad0e62ad440925cc05564d50b6e03e8f3
7
+ data.tar.gz: 75c9a6c6e463d2d98b1893a0b9677c536b3cea8869c1859bba3964cc3822a4639a7a2a34e80aa1dfc823e0453749193ac5b98af69f9ff1c60b07408dd24765de
@@ -2,7 +2,7 @@ module SmsBroker
2
2
  module Client
3
3
  module Response
4
4
  class TwilioError < Error
5
- SENDER_ID_NOT_SUPPORTED = '21212'.freeze
5
+ SENDER_ID_NOT_SUPPORTED = %w(21212 21612).freeze
6
6
 
7
7
  def initialize(twilio_response)
8
8
  super :twilio, twilio_response, serialize(twilio_response)
@@ -23,7 +23,7 @@ module SmsBroker
23
23
  response.error_code.to_s => [response.error_message]
24
24
  }
25
25
 
26
- if response.error_code.to_s == SENDER_ID_NOT_SUPPORTED
26
+ if SENDER_ID_NOT_SUPPORTED.include?(response.error_code.to_s)
27
27
  errors['sender_id'] = ['is invalid']
28
28
  end
29
29
 
@@ -35,7 +35,7 @@ module SmsBroker
35
35
  exception.code.to_s => [exception.message]
36
36
  }
37
37
 
38
- if exception.code.to_s == SENDER_ID_NOT_SUPPORTED
38
+ if SENDER_ID_NOT_SUPPORTED.include?(exception.code.to_s)
39
39
  errors['sender_id'] = ['is invalid']
40
40
  end
41
41
 
@@ -1,3 +1,3 @@
1
1
  module SmsBroker
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.0.5'.freeze
3
3
  end
@@ -46,7 +46,7 @@ describe SmsBroker do
46
46
  end
47
47
  end
48
48
 
49
- it 'should return error for invalid sender_id' do
49
+ it 'should return 21212 error for invalid sender_id' do
50
50
  VCR.use_cassette('twilio/create_invalid_phone_error') do
51
51
  response = send_message(text_message, '15005550006')
52
52
 
@@ -59,6 +59,20 @@ describe SmsBroker do
59
59
  include("The 'From' number +15005550001 is not a valid")
60
60
  end
61
61
  end
62
+
63
+ it 'should return 21612 error for invalid sender_id' do
64
+ VCR.use_cassette('twilio/create_invalid_phone_error_21612') do
65
+ response = send_message(text_message, '15005550006')
66
+
67
+ expect(response.service).to eq(:twilio)
68
+ expect(response.success?).to eq(false)
69
+ expect(response.serialized[:errors].keys).to include('21612')
70
+ # if the code is 21612 and message includes the phone_number,
71
+ # it means that it tried with sender_id and failed
72
+ expect(response.serialized[:errors]['21612'][0]).to \
73
+ include("The 'From' number +15005550001 is not a valid")
74
+ end
75
+ end
62
76
  end
63
77
  end
64
78
 
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.twilio.com/2010-04-01/Accounts/account_sid/Messages.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: Body=Hello+World&From=%2B15005550001&To=%2B15005550006
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Charset:
13
+ - utf-8
14
+ User-Agent:
15
+ - twilio-ruby/4.13.0 (ruby/x86_64-darwin16 2.3.0-p0)
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Authorization:
19
+ - Basic YWNjb3VudF9zaWQ6YXV0aF90b2tlbg==
20
+ Content-Type:
21
+ - application/x-www-form-urlencoded
22
+ response:
23
+ status:
24
+ code: 400
25
+ message: BAD REQUEST
26
+ headers:
27
+ Access-Control-Allow-Credentials:
28
+ - 'true'
29
+ Access-Control-Allow-Headers:
30
+ - Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match,
31
+ If-Unmodified-Since
32
+ Access-Control-Allow-Methods:
33
+ - GET, POST, DELETE, OPTIONS
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Expose-Headers:
37
+ - ETag
38
+ Content-Type:
39
+ - application/json; charset=utf-8
40
+ Date:
41
+ - Thu, 03 Aug 2017 16:25:30 GMT
42
+ Twilio-Request-Duration:
43
+ - '0.005'
44
+ Twilio-Request-Id:
45
+ - RQ88fc11c3581341748e3b3a7ec25dd449
46
+ X-Powered-By:
47
+ - AT-5000
48
+ X-Shenanigans:
49
+ - none
50
+ Content-Length:
51
+ - '185'
52
+ Connection:
53
+ - keep-alive
54
+ body:
55
+ encoding: UTF-8
56
+ string: '{"code": 21612, "message": "The ''From'' number +15005550001 is not
57
+ a valid phone number, shortcode, or alphanumeric sender ID.", "more_info":
58
+ "https://www.twilio.com/docs/errors/21212", "status": 400}'
59
+ http_version:
60
+ recorded_at: Thu, 03 Aug 2017 16:25:30 GMT
61
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Streetbees Dev Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nexmo
@@ -154,6 +154,7 @@ files:
154
154
  - spec/spec_helper.rb
155
155
  - spec/support/nexmo_helpers.rb
156
156
  - spec/support/vcr_cassettes/twilio/create_invalid_phone_error.yml
157
+ - spec/support/vcr_cassettes/twilio/create_invalid_phone_error_21612.yml
157
158
  - spec/support/vcr_cassettes/twilio/create_success.yml
158
159
  homepage: https://github.com/streetbees/sms_broker
159
160
  licenses: []
@@ -174,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
175
  version: '0'
175
176
  requirements: []
176
177
  rubyforge_project:
177
- rubygems_version: 2.4.6
178
+ rubygems_version: 2.6.10
178
179
  signing_key:
179
180
  specification_version: 4
180
181
  summary: Sms Broker
@@ -188,4 +189,5 @@ test_files:
188
189
  - spec/spec_helper.rb
189
190
  - spec/support/nexmo_helpers.rb
190
191
  - spec/support/vcr_cassettes/twilio/create_invalid_phone_error.yml
192
+ - spec/support/vcr_cassettes/twilio/create_invalid_phone_error_21612.yml
191
193
  - spec/support/vcr_cassettes/twilio/create_success.yml