outbox-twilio 0.3.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +7 -3
- data/.travis.yml +3 -3
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/lib/outbox-twilio.rb +2 -1
- data/lib/outbox/twilio.rb +2 -0
- data/lib/outbox/twilio/client.rb +14 -2
- data/lib/outbox/twilio/version.rb +3 -1
- data/outbox-twilio.gemspec +5 -5
- data/spec/outbox/twilio/client_spec.rb +22 -1
- data/spec/outbox/twilio_spec.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cbd8daa2d1ffbd08eab90da3f93e4b71d3803f337f812709939838b636a4cb58
|
4
|
+
data.tar.gz: eb131c4481756b84eff1483da5a3199f20a4e03622a66ee0c0a67c6b61b2cfc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b5608e3b43c76c1e07c2d1bc4394c4b7345af4276ed87ab558fc079381c68faff1d9ae0d002e01a4187ec4b8316e987b8016baf89129000e197d691d5b3d783
|
7
|
+
data.tar.gz: 15bf9f943d2a954df373c6df3f2431200b5357d4452b286b4984cb695a334332c6cc3df48b709be01696ee1609117c3a81bda61c8f65684a44cb1a893aae3c7a
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
|
-
-
|
3
|
+
- 'vendor/**/*'
|
4
4
|
DisplayCopNames: true
|
5
5
|
DisplayStyleGuide: true
|
6
6
|
|
@@ -9,8 +9,12 @@ Style/Documentation:
|
|
9
9
|
|
10
10
|
Metrics/BlockLength:
|
11
11
|
Exclude:
|
12
|
-
-
|
12
|
+
- 'spec/**/*'
|
13
13
|
|
14
|
-
|
14
|
+
Naming/FileName:
|
15
|
+
Exclude:
|
16
|
+
- 'lib/outbox-twilio.rb'
|
17
|
+
|
18
|
+
Layout/LineLength:
|
15
19
|
IgnoreCopDirectives: true
|
16
20
|
Max: 100
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/outbox-twilio.rb
CHANGED
data/lib/outbox/twilio.rb
CHANGED
data/lib/outbox/twilio/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'twilio-ruby'
|
2
4
|
|
3
5
|
module Outbox
|
@@ -25,7 +27,7 @@ module Outbox
|
|
25
27
|
@api_client = ::Twilio::REST::Client.new(
|
26
28
|
options[:username] || options[:account_sid],
|
27
29
|
options[:password] || options[:auth_token],
|
28
|
-
options[:account_sid]
|
30
|
+
options[:subaccount_sid] || options[:account_sid]
|
29
31
|
)
|
30
32
|
end
|
31
33
|
|
@@ -39,7 +41,17 @@ module Outbox
|
|
39
41
|
application_sid: sms[:application_sid]
|
40
42
|
}
|
41
43
|
params.delete_if { |_, value| value.nil? }
|
42
|
-
|
44
|
+
account(sms).messages.create(params)
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def account(sms)
|
50
|
+
if sms[:account_sid]
|
51
|
+
@api_client.api.accounts(sms[:account_sid])
|
52
|
+
else
|
53
|
+
@api_client
|
54
|
+
end
|
43
55
|
end
|
44
56
|
end
|
45
57
|
end
|
data/outbox-twilio.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'outbox/twilio/version'
|
6
6
|
|
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_runtime_dependency 'outbox', '~> 0.2'
|
23
|
-
spec.add_runtime_dependency 'twilio-ruby', '~> 5.0
|
24
|
-
spec.add_development_dependency 'bundler', '
|
23
|
+
spec.add_runtime_dependency 'twilio-ruby', '~> 5.0'
|
24
|
+
spec.add_development_dependency 'bundler', '>= 1.6'
|
25
25
|
spec.add_development_dependency 'rake', '~> 12.0.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.5.0'
|
27
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.82.0'
|
28
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Outbox::Twilio::Client do
|
@@ -51,7 +53,7 @@ describe Outbox::Twilio::Client do
|
|
51
53
|
end
|
52
54
|
|
53
55
|
it 'delivers the SMS' do
|
54
|
-
expect(@client.api_client.
|
56
|
+
expect(@client.api_client.messages).to receive(:create).with(
|
55
57
|
to: '+14155551212',
|
56
58
|
from: 'Company Name',
|
57
59
|
body: 'Hello world.',
|
@@ -61,5 +63,24 @@ describe Outbox::Twilio::Client do
|
|
61
63
|
).and_return(double(:message_context))
|
62
64
|
@client.deliver(@sms)
|
63
65
|
end
|
66
|
+
|
67
|
+
context 'with a subaccount' do
|
68
|
+
it 'delivers the SMS from the subaccount' do
|
69
|
+
@sms[:account_sid] = 'subaccount_sid_1'
|
70
|
+
account = double(:account, messages: double(:messages))
|
71
|
+
expect(@client.api_client.api).to(
|
72
|
+
receive(:accounts).with('subaccount_sid_1').and_return(account)
|
73
|
+
)
|
74
|
+
expect(account.messages).to receive(:create).with(
|
75
|
+
to: '+14155551212',
|
76
|
+
from: 'Company Name',
|
77
|
+
body: 'Hello world.',
|
78
|
+
media_url: 'http://www.example.com/hearts.png',
|
79
|
+
status_callback: 'http://www.example.com/callback',
|
80
|
+
application_sid: '1234'
|
81
|
+
).and_return(double(:message_context))
|
82
|
+
@client.deliver(@sms)
|
83
|
+
end
|
84
|
+
end
|
64
85
|
end
|
65
86
|
end
|
data/spec/outbox/twilio_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outbox-twilio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Browne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: outbox
|
@@ -30,26 +30,26 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 5.0
|
33
|
+
version: '5.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 5.0
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.6'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.82.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.82.0
|
97
97
|
description: Twilio API wrapper for Outbox, a generic interface for sending notificatons.
|
98
98
|
email:
|
99
99
|
- pete.browne@localmed.com
|
@@ -136,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
|
140
|
-
rubygems_version: 2.4.5.2
|
139
|
+
rubygems_version: 3.0.1
|
141
140
|
signing_key:
|
142
141
|
specification_version: 4
|
143
142
|
summary: Outbox SMS client for Twilio.
|