messagebird / ruby-rest-api

MessageBird's REST API for Ruby
BSD 2-Clause "Simplified" License
37 stars 46 forks source link

bug in the http_client.rb code in 4.0.0 build_request method - modified request is not returned if params not empty and submit method allowed #85

Open qvrb opened 1 year ago

qvrb commented 1 year ago

in the following code the request object is not modified or returned in the case where the SUBMIT_METHODS & params not empty in http_client.c

 62     def build_request(method, uri, params = {})
 63       # Construct the HTTP request.
 64       raise MethodNotAllowedException unless ALLOWED_METHODS.include?(method)
 65
 66       request = Class.const_get("Net::HTTP::#{method.to_s.capitalize}").new(uri.request_uri)
 67
 68       request['Accept']        = 'application/json'
 69       request['Authorization'] = "AccessKey #{@access_key}"
 70       request['User-Agent']    = "MessageBird/ApiClient/#{Version::STRING} Ruby/#{RUBY_VERSION}"
 71       if SUBMIT_METHODS.include?(method) && !params.empty?
 72         prepare_request(request, params)
 73       end
 74       request
 75     end

The code on line 72 should read request = prepare_request(request, params)