gocardless-pro-ruby icon indicating copy to clipboard operation
gocardless-pro-ruby copied to clipboard

Inconsistent response from API

Open cmclarnon88 opened this issue 3 years ago • 0 comments

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 ** Replace return if response.body.nil? with return if response.body.nil? || response.body.empty?

cmclarnon88 avatar Jan 10 '22 10:01 cmclarnon88