gocardless-pro-ruby
gocardless-pro-ruby copied to clipboard
Inconsistent response from API
Submitted on behalf of merchant:
I just ran into an unexpected issue with the GoCardlessPro Ruby gem.
The issue is a Ruby exception because of some empty variable, details below.
I just ran into an unexpected response-body for calling sub-url: /scenario_simulators/:identity/actions/run
in the GoCardlessPro::Services::ScenarioSimulatorsService.run
method. This call is made by using example: https://developer.gocardless.com/api-reference/#scenario-simulators-simulate-a-scenario
Class Resource::ScenarioSimulator
is instantiated on line lib/gocardless_pro/services/scenario_simulator_service.rb:152
with an empty un-enveloped body response, which throws an NoMethodError
with message: 'undefined method [] for nil:NilClass'
The issue can be resolved by implementing the following:
-
lib/gocardless_pro/services/scenario_simulator_service.rb:150
** Replacereturn if response.body.nil?
withreturn if response.body.nil? || response.body.empty?