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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c4467b6e7223984477b6df87915491435f7dc86a
4
- data.tar.gz: 1d8b92b6b7d9ace5bae4615117e64c02bd7b57c7
2
+ SHA256:
3
+ metadata.gz: cbd8daa2d1ffbd08eab90da3f93e4b71d3803f337f812709939838b636a4cb58
4
+ data.tar.gz: eb131c4481756b84eff1483da5a3199f20a4e03622a66ee0c0a67c6b61b2cfc7
5
5
  SHA512:
6
- metadata.gz: 1c577e568b0d8e85fdddd445bf5fc21d67a0f89e1c74fe3e62028cba034f00478a5005f776f7342dde63c0a50c5b13020a9ac510fa15900465c1524b4b8b2e96
7
- data.tar.gz: 1cc18a20f03c626ec57391d064e1c9d6b562035d5c41a320940d72870508fbd36d7cf7c40069513b91c91b9866dc75e921ff2d9391c4914d441d0d86e89b8810
6
+ metadata.gz: 3b5608e3b43c76c1e07c2d1bc4394c4b7345af4276ed87ab558fc079381c68faff1d9ae0d002e01a4187ec4b8316e987b8016baf89129000e197d691d5b3d783
7
+ data.tar.gz: 15bf9f943d2a954df373c6df3f2431200b5357d4452b286b4984cb695a334332c6cc3df48b709be01696ee1609117c3a81bda61c8f65684a44cb1a893aae3c7a
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - "vendor/**/*"
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
- - "spec/**/*"
12
+ - 'spec/**/*'
13
13
 
14
- Metrics/LineLength:
14
+ Naming/FileName:
15
+ Exclude:
16
+ - 'lib/outbox-twilio.rb'
17
+
18
+ Layout/LineLength:
15
19
  IgnoreCopDirectives: true
16
20
  Max: 100
@@ -2,9 +2,9 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - 2.2.6
6
- - 2.3.3
7
- - 2.4.1
5
+ - 2.5.8
6
+ - 2.6.6
7
+ - 2.7.1
8
8
  script:
9
9
  - bundle exec rubocop
10
10
  - bundle exec rspec
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in outbox-twilio.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -1,2 +1,3 @@
1
- # rubocop:disable Style/FileName
1
+ # frozen_string_literal: true
2
+
2
3
  require 'outbox/twilio'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'outbox'
2
4
 
3
5
  module Outbox
@@ -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
- @api_client.api.account.messages.create(params)
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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Outbox
2
4
  module Twilio
3
- VERSION = '0.3.2'.freeze
5
+ VERSION = '1.0.0'
4
6
  end
5
7
  end
@@ -1,6 +1,6 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
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.0.rc17'
24
- spec.add_development_dependency 'bundler', '~> 1.6'
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.48.1'
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.api.account.messages).to receive(:create).with(
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Outbox::Twilio do
@@ -1,2 +1,4 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'outbox/twilio'
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.3.2
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: 2017-05-02 00:00:00.000000000 Z
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.0.rc17
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.0.rc17
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.48.1
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.48.1
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
- rubyforge_project:
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.