lib/resend/request.rb in resend-0.15.0 vs lib/resend/request.rb in resend-0.16.0

- old
+ new

@@ -11,19 +11,21 @@ BASE_URL = ENV["RESEND_BASE_URL"] || "https://api.resend.com/" attr_accessor :body, :verb def initialize(path = "", body = {}, verb = "POST") - raise if Resend.api_key.nil? + raise if (api_key = Resend.api_key).nil? + api_key = api_key.call if api_key.is_a?(Proc) + @path = path @body = body @verb = verb @headers = { "Content-Type" => "application/json", "Accept" => "application/json", "User-Agent" => "resend-ruby:#{Resend::VERSION}", - "Authorization" => "Bearer #{Resend.api_key}" + "Authorization" => "Bearer #{api_key}" } end # Performs the HTTP call def perform