Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Stealth 3.0 MAV-155 #6

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.0
bundler-cache: true
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.0
bundler-cache: true
- name: Publish gem
env:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

gem 'stealth', '>= 2.0.0.beta6'
gem 'stealth', git: 'https://github.com/hellostealth/stealth.git', branch: '3.0-mountable'

gemspec
293 changes: 223 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,99 +1,252 @@
GIT
remote: https://github.com/hellostealth/stealth.git
revision: 1dcdc7d3fe8bf5851d10840ff9d8546f26248f95
branch: 3.0-mountable
specs:
stealth (3.0.0.alpha1)
rails (>= 7.1.3.4)
redis (~> 5.0)
sidekiq (~> 7.0)
spectre_ai (~> 1.2.0)

PATH
remote: .
specs:
stealth-bandwidth (1.1.0)
stealth-bandwidth (2.0.0)
http (~> 4.1)
oj (~> 3.11)
stealth (>= 2.0.0.beta6)
stealth (>= 3.0.0.alpha1)

GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
actioncable (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.2.2.1)
actionpack (= 7.2.2.1)
activejob (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
mail (>= 2.8.0)
actionmailer (7.2.2.1)
actionpack (= 7.2.2.1)
actionview (= 7.2.2.1)
activejob (= 7.2.2.1)
activesupport (= 7.2.2.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.2.1)
actionview (= 7.2.2.1)
activesupport (= 7.2.2.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (7.2.2.1)
actionpack (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.2.1)
activesupport (= 7.2.2.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.3.6)
activemodel (7.2.2.1)
activesupport (= 7.2.2.1)
activerecord (7.2.2.1)
activemodel (= 7.2.2.1)
activesupport (= 7.2.2.1)
timeout (>= 0.4.0)
activestorage (7.2.2.1)
actionpack (= 7.2.2.1)
activejob (= 7.2.2.1)
activerecord (= 7.2.2.1)
activesupport (= 7.2.2.1)
marcel (~> 1.0)
activesupport (7.2.2.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
concurrent-ruby (1.1.10)
connection_pool (2.3.0)
diff-lcs (1.5.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ffi (1.15.5)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
builder (3.3.0)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
crass (1.0.6)
date (3.4.1)
diff-lcs (1.5.1)
domain_name (0.6.20240107)
drb (2.2.1)
erubi (1.13.1)
ffi (1.17.1)
ffi-compiler (1.3.2)
ffi (>= 1.15.5)
rake
globalid (1.2.1)
activesupport (>= 6.1)
http (4.4.1)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
http-parser (~> 1.2.0)
http-cookie (1.0.5)
http-cookie (1.0.8)
domain_name (~> 0.5)
http-form_data (2.3.0)
http-parser (1.2.3)
ffi-compiler (>= 1.0, < 2.0)
i18n (1.12.0)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
minitest (5.16.3)
multi_json (1.15.0)
mustermann (2.0.2)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.8)
oj (3.13.23)
public_suffix (5.0.0)
puma (5.6.5)
nio4r (~> 2.0)
rack (2.2.4)
rack-protection (2.2.2)
rack
io-console (0.8.0)
irb (1.15.1)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
logger (1.6.5)
loofah (2.24.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.4)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.4)
net-imap (0.5.5)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oj (3.16.9)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
ostruct (0.6.1)
pp (0.6.2)
prettyprint
prettyprint (0.2.0)
psych (5.2.3)
date
stringio
public_suffix (6.0.1)
racc (1.8.1)
rack (2.2.10)
rack-session (1.0.2)
rack (< 3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rake (13.0.6)
redis (4.8.0)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rackup (1.0.1)
rack (< 3)
webrick
rails (7.2.2.1)
actioncable (= 7.2.2.1)
actionmailbox (= 7.2.2.1)
actionmailer (= 7.2.2.1)
actionpack (= 7.2.2.1)
actiontext (= 7.2.2.1)
actionview (= 7.2.2.1)
activejob (= 7.2.2.1)
activemodel (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
bundler (>= 1.15.0)
railties (= 7.2.2.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (13.2.1)
rdoc (6.12.0)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.23.2)
connection_pool
reline (0.6.0)
io-console (~> 0.5)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.3)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rspec_junit_formatter (0.5.1)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
ruby2_keywords (0.0.5)
sidekiq (6.5.6)
connection_pool (>= 2.2.5)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sinatra (2.2.2)
mustermann (~> 2.0)
rack (~> 2.2)
rack-protection (= 2.2.2)
tilt (~> 2.0)
stealth (2.0.0.beta6)
activesupport (~> 6.0)
multi_json (~> 1.12)
puma (>= 4.2, < 6.0)
sidekiq (~> 6.0)
sinatra (~> 2.0)
thor (~> 1.0)
thor (1.2.1)
tilt (2.0.11)
tzinfo (2.0.5)
securerandom (0.4.1)
sidekiq (7.3.8)
base64
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
spectre_ai (1.2.0)
stringio (3.1.2)
thor (1.3.2)
timeout (0.4.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
zeitwerk (2.6.0)
useragent (0.16.11)
webrick (1.9.1)
websocket-driver (0.7.7)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.18)

PLATFORMS
ruby
Expand All @@ -102,8 +255,8 @@ DEPENDENCIES
rack-test (~> 1.1)
rspec (~> 3.6)
rspec_junit_formatter (~> 0.3)
stealth (>= 2.0.0.beta6)
stealth!
stealth-bandwidth!

BUNDLED WITH
2.2.32
2.6.3
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
2.0.0
17 changes: 8 additions & 9 deletions lib/stealth/services/bandwidth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require 'http'

require 'stealth/services/bandwidth/message_handler'
require 'stealth/services/bandwidth/reply_handler'
require 'stealth/services/bandwidth/setup'
require 'stealth/services/bandwidth/event_handler'
require 'stealth/services/bandwidth/reply_handler'

module Stealth
module Services
Expand All @@ -13,23 +13,22 @@ class Client < Stealth::Services::BaseClient

attr_reader :http_client, :reply, :endpoint

def initialize(reply:)
def initialize(reply:, **args)
@reply = reply
account_id = Stealth.config.bandwidth.account_id
username = Stealth.config.bandwidth.api_username
password = Stealth.config.bandwidth.api_password
application_id = Stealth.config.bandwidth.application_id
account_id = Stealth.config.dig('bandwidth', 'account_id')
username = Stealth.config.dig('bandwidth', 'api_username')
password = Stealth.config.dig('bandwidth', 'api_password')

@endpoint = "https://messaging.bandwidth.com/api/v2/users/#{account_id}/messages"
@http_client = HTTP
.timeout(connect: 15, read: 30)
.basic_auth(user: username, pass: password)
.headers('Content-Type' => 'application/json')
.headers('Content-Type' => 'application/json; charset=utf-8')
end

def transmit
# Don't transmit anything for delays
return true if reply.blank?

json_reply = Oj.dump(reply, mode: :compat)
response = http_client.post(endpoint, body: json_reply)

Expand Down
Loading