Class: BN::Middleware::APIResponse

Inherits:
Base
  • Object
show all
Defined in:
lib/bn/middleware/api_error.rb

Overview

Checks the JSON API response to see if it is an error.

Instance Method Summary collapse

Methods inherited from Base

execute, #initialize

Constructor Details

This class inherits a constructor from BN::Middleware::Base

Instance Method Details

#execute(data) ⇒ Hash

Execute the middleware.

Parameters:

  • data (#to_h)

Returns:

  • (Hash)

Raises:



12
13
14
15
16
17
18
# File 'lib/bn/middleware/api_error.rb', line 12

def execute(data)
  data = data.to_h

  raise BN::Error::Middleware::InvalidAPIRequest, data if error?(data)

  data
end