Class: Coolsms::RestApi::FaradayErrorHandler

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/coolsms/rest_api/faraday_error_handler.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object

Override this to modify the environment after the response has finished. Calls the parse method if defined



6
7
8
9
# File 'lib/coolsms/rest_api/faraday_error_handler.rb', line 6

def on_complete(env)
  # env.body = parse(env.body) if respond_to?(:parse) && env.parse_body?
  raise Coolsms::RestApi::InvalidResultCode, {response: env} if env.body['result_code'] != '00'
end