Skip to content

Commit

Permalink
Merge pull request #158 from tpitale/allow-hash-shorthand
Browse files Browse the repository at this point in the history
Allow either shorthand for hashes
  • Loading branch information
tpitale authored Nov 1, 2023
2 parents 1efeffd + e42cf8b commit 4502746
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ inherit_from: .rubocop_todo.yml
Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19_no_mixed_keys
EnforcedShorthandSyntax: either
28 changes: 16 additions & 12 deletions lib/mail_room/delivery/postback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
config_basic_auth(connection)
end

connection.post do |request|
Expand All @@ -111,6 +100,21 @@ def config_request_jwt_auth(request)

request.headers[@delivery_options.jwt.header] = @delivery_options.jwt.token
end

def config_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

0 comments on commit 4502746

Please sign in to comment.