Class: Response::DecodeTradevan

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/response/decode_tradevan.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, key) ⇒ DecodeTradevan

Returns a new instance of DecodeTradevan.



10
11
12
13
# File 'lib/faraday/response/decode_tradevan.rb', line 10

def initialize(app, key)
  super(app)
  @key = key
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/faraday/response/decode_tradevan.rb', line 15

def call(env)
  @app.call(env).on_complete do |env|
    if env[:body] && env[:body]['Success'] != 'E'
      env[:body]['Message'] = decrypt(@key, env[:body]['Message'])
    end
  end
end