outbox-bandwidth 0.3.0 → 0.4.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
2
  SHA256:
3
- metadata.gz: fe84da290b87177f84735ff437f2d5600d8efbfda6c55920db8ea720882061b9
4
- data.tar.gz: bb13853fa6ae2fa479cb5349cf2f909824b16cbdbf161e5d1e023387e7ffe2fb
3
+ metadata.gz: 60b94af8abf93c73a1d8b43a086cd6ff394470230c7e7da25c0d0934fe6f2463
4
+ data.tar.gz: d093735ad46d6758aa39eb9ab79283672cad1a20d7aeaf62f3476c3c9a401a43
5
5
  SHA512:
6
- metadata.gz: '08f16ee11879814ac458d923dee1e94717a8e6402ce94cb15e05fbcae2dfa3891b4506595113d5084b3e642faaad5e715256474934e96a3fa61938af9ea1c894'
7
- data.tar.gz: 8c1387469eaddb1eb2225ef320e5477653e31d6258d392b59d2c136afbd93d92791a1769791121ba0f2c8b49f0e78ec8160b479e9324aa24ea14b77f2fec7b2b
6
+ metadata.gz: eb1d5bc634ac50b29c9347e366c4286b503fa74999765cc6974532f2d9e04054539a4bf10f78ccabd662434f599249fce88b843e90b94312dd6aa8cf8f8e8946
7
+ data.tar.gz: 1eaef2caa45b6f8044bf73c786204dec73bcb2e32e5e89957c6b94837c747296c0c3e2d06e5e18d501b440076d01d2fdb9041bc7754be96bd9e0962b6be9541a
@@ -7,12 +7,8 @@ module Outbox
7
7
  # Uses Bandwidth's official Ruby API client (bandwidth) to deliver
8
8
  # SMS messages.
9
9
  #
10
- # Outbox::Messages::SMS.default_client(
11
- # :bandwidth,
12
- # account_sid: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
13
- # token: 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
14
- # secret: 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
15
- # )
10
+ # https://dev.bandwidth.com/sdks/ruby.html
11
+ #
16
12
  # sms = Outbox::Messages::SMS.new(
17
13
  # to: '+15552224444',
18
14
  # from: '+15551115555',
@@ -25,14 +21,22 @@ module Outbox
25
21
 
26
22
  def initialize(settings = nil)
27
23
  super
28
-
29
24
  options = @settings.dup
30
- @api_client = ::Bandwidth::Client.new(
31
- messaging_basic_auth_user_name: options[:token],
32
- messaging_basic_auth_password: options[:secret]
25
+ bandwidth_client_settings = options.slice(
26
+ :messaging_basic_auth_user_name,
27
+ :messaging_basic_auth_password,
28
+ :voice_basic_auth_user_name,
29
+ :voice_basic_auth_password,
30
+ :two_factor_auth_basic_auth_user_name,
31
+ :two_factor_auth_basic_auth_password,
32
+ :environment,
33
+ :base_url
33
34
  )
34
35
  @account_id = options[:subaccount_id] || options[:account_id]
35
36
  @application_id = options[:application_id]
37
+ @api_client = ::Bandwidth::Client.new(
38
+ bandwidth_client_settings
39
+ )
36
40
  end
37
41
 
38
42
  def deliver(sms)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Outbox
4
4
  module Bandwidth
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
@@ -5,17 +5,37 @@ require 'ostruct'
5
5
 
6
6
  describe Outbox::Bandwidth::Client do
7
7
  describe '.new' do
8
- it 'configures the Bandwidth API client' do
9
- api_client = double(:api_client)
10
- expect(::Bandwidth::Client).to receive(:new).with(
11
- messaging_basic_auth_user_name: 'AC1',
12
- messaging_basic_auth_password: 'abcdef'
13
- ).and_return(api_client)
14
- client = Outbox::Bandwidth::Client.new(
15
- token: 'AC1',
16
- secret: 'abcdef'
17
- )
18
- expect(client.api_client).to be(api_client)
8
+ context 'with a messaging_basic_auth' do
9
+ it 'configures the Bandwidth API client' do
10
+ api_client = double(:api_client)
11
+ expect(::Bandwidth::Client).to receive(:new).with(
12
+ messaging_basic_auth_user_name: 'AC1',
13
+ messaging_basic_auth_password: 'abcdef'
14
+ ).and_return(api_client)
15
+ client = Outbox::Bandwidth::Client.new(
16
+ messaging_basic_auth_user_name: 'AC1',
17
+ messaging_basic_auth_password: 'abcdef'
18
+ )
19
+ expect(client.api_client).to be(api_client)
20
+ end
21
+ end
22
+ context 'with a custom environment and base url' do
23
+ it 'configures the Bandwidth API client' do
24
+ api_client = double(:api_client)
25
+ expect(::Bandwidth::Client).to receive(:new).with(
26
+ messaging_basic_auth_user_name: 'AC1',
27
+ messaging_basic_auth_password: 'abcdef',
28
+ environment: 'custom_env',
29
+ base_url: 'custom.test.com'
30
+ ).and_return(api_client)
31
+ client = Outbox::Bandwidth::Client.new(
32
+ messaging_basic_auth_user_name: 'AC1',
33
+ messaging_basic_auth_password: 'abcdef',
34
+ environment: 'custom_env',
35
+ base_url: 'custom.test.com'
36
+ )
37
+ expect(client.api_client).to be(api_client)
38
+ end
19
39
  end
20
40
  end
21
41
 
@@ -30,8 +50,8 @@ describe Outbox::Bandwidth::Client do
30
50
  messaging_basic_auth_password: 'abcdef'
31
51
  ).and_return(@api_client)
32
52
  @client = Outbox::Bandwidth::Client.new(
33
- token: 'AC1',
34
- secret: 'abcdef',
53
+ messaging_basic_auth_user_name: 'AC1',
54
+ messaging_basic_auth_password: 'abcdef',
35
55
  account_id: 'account_1'
36
56
  )
37
57
  @sms = Outbox::Messages::SMS.new do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outbox-bandwidth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Browne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-22 00:00:00.000000000 Z
12
+ date: 2020-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bandwidth-sdk