Class: Epics::ParseEbics
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Epics::ParseEbics
- Defined in:
- lib/epics/middleware/parse_ebics.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, options = {}) ⇒ ParseEbics
constructor
A new instance of ParseEbics.
Constructor Details
#initialize(app = nil, options = {}) ⇒ ParseEbics
Returns a new instance of ParseEbics.
3 4 5 6 |
# File 'lib/epics/middleware/parse_ebics.rb', line 3 def initialize(app = nil, = {}) super(app) @client = [:client] end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/epics/middleware/parse_ebics.rb', line 8 def call(env) @app.call(env).on_complete do |env| env[:body] = ::Epics::Response.new(@client, env[:body]) raise Epics::Error::TechnicalError.new(env[:body].technical_code) if env[:body].technical_error? raise Epics::Error::BusinessError.new(env[:body].business_code) if env[:body].business_error? end end |