From 283a0b609f4d120d66aaf72e3710d96089d0bc31 Mon Sep 17 00:00:00 2001 From: Tony Pitale Date: Tue, 31 Oct 2023 21:59:53 -0500 Subject: [PATCH 1/4] Allow either shorthand for hashes --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 389ed29..26ed846 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,3 +3,4 @@ inherit_from: .rubocop_todo.yml Style/HashSyntax: Enabled: true EnforcedStyle: ruby19_no_mixed_keys + EnforcedShorthandSyntax: either From b8deb4683991cdfaa30cc126736c758889524451 Mon Sep 17 00:00:00 2001 From: Tony Pitale Date: Tue, 31 Oct 2023 22:02:07 -0500 Subject: [PATCH 2/4] Fix trailing whitespace --- lib/mail_room/delivery/postback.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mail_room/delivery/postback.rb b/lib/mail_room/delivery/postback.rb index 9d05e11..9d854f1 100644 --- a/lib/mail_room/delivery/postback.rb +++ b/lib/mail_room/delivery/postback.rb @@ -80,7 +80,7 @@ def deliver(message) ) else connection.request( - :authorization, :basic, + :authorization, :basic, @delivery_options.username, @delivery_options.password ) From c6bfca6362abd4750af2d394ab938948b44c9889 Mon Sep 17 00:00:00 2001 From: Tony Pitale Date: Tue, 31 Oct 2023 22:03:35 -0500 Subject: [PATCH 3/4] Split method for setting basic auth --- lib/mail_room/delivery/postback.rb | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/mail_room/delivery/postback.rb b/lib/mail_room/delivery/postback.rb index 9d854f1..c2de131 100644 --- a/lib/mail_room/delivery/postback.rb +++ b/lib/mail_room/delivery/postback.rb @@ -73,18 +73,7 @@ def deliver(message) if @delivery_options.token_auth? connection.token_auth @delivery_options.token elsif @delivery_options.basic_auth? - if defined?(connection.basic_auth) - connection.basic_auth( - @delivery_options.username, - @delivery_options.password - ) - else - connection.request( - :authorization, :basic, - @delivery_options.username, - @delivery_options.password - ) - end + set_basic_auth(connection) end connection.post do |request| @@ -111,6 +100,21 @@ def config_request_jwt_auth(request) request.headers[@delivery_options.jwt.header] = @delivery_options.jwt.token end + + def set_basic_auth(connection) + if defined?(connection.basic_auth) + connection.basic_auth( + @delivery_options.username, + @delivery_options.password + ) + else + connection.request( + :authorization, :basic, + @delivery_options.username, + @delivery_options.password + ) + end + end end end end From e42cf8b8e14c3f8c5b12aa37b58620c1286c3d71 Mon Sep 17 00:00:00 2001 From: Tony Pitale Date: Tue, 31 Oct 2023 22:06:31 -0500 Subject: [PATCH 4/4] Change method name for rubocop --- lib/mail_room/delivery/postback.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mail_room/delivery/postback.rb b/lib/mail_room/delivery/postback.rb index c2de131..e6f7951 100644 --- a/lib/mail_room/delivery/postback.rb +++ b/lib/mail_room/delivery/postback.rb @@ -73,7 +73,7 @@ def deliver(message) if @delivery_options.token_auth? connection.token_auth @delivery_options.token elsif @delivery_options.basic_auth? - set_basic_auth(connection) + config_basic_auth(connection) end connection.post do |request| @@ -101,7 +101,7 @@ def config_request_jwt_auth(request) request.headers[@delivery_options.jwt.header] = @delivery_options.jwt.token end - def set_basic_auth(connection) + def config_basic_auth(connection) if defined?(connection.basic_auth) connection.basic_auth( @delivery_options.username,