Skip to content

Inconsistent response from API #95

@cmclarnon88

Description

@cmclarnon88

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions