validate_response_hash

in ee/app/services/remote_development/service_response_factory.rb [40:75]


    def validate_response_hash(response_hash)
      raise "response_hash must not be nil" if response_hash.nil?

      
      
      hash = { status: nil, payload: nil, message: nil, reason: nil }.merge(response_hash)

      
      hash => {
        status: Symbol => status,
        payload: (Hash | NilClass) => payload,
        message: (String | NilClass) => message,
        reason: (Symbol | NilClass)=> reason,
      }

      raise "Invalid 'status:' value for response: #{status}" unless [:success, :error].include?(status)

      
      
      if status == :success
        raise "'reason:' cannot specified if 'status:' is :success" if reason

        raise "'message:' cannot specified if 'status:' is :success" if message

        raise "'payload:' must specified if 'status:' is :success" if payload.nil?
      else
        raise "'reason:' must be specified if 'status:' is :error" if reason.nil?

        raise "'message:' must be specified if 'status:' is :error" if message.nil?

        raise "'payload:' cannot be specified if 'status:' is :error" if payload
      end

      nil
    end