class Workarea::Klarna::Gateway::Response
Attributes
raw_response[R]
request[R]
Public Class Methods
new(request, raw_response)
click to toggle source
# File lib/workarea/klarna/gateway/response.rb, line 7 def initialize(request, raw_response) @request = request @raw_response = raw_response end
Public Instance Methods
body()
click to toggle source
# File lib/workarea/klarna/gateway/response.rb, line 12 def body @body ||= if raw_response&.body.present? JSON.parse(raw_response.body) else {} end end
Also aliased as: params
message()
click to toggle source
# File lib/workarea/klarna/gateway/response.rb, line 27 def message if success? I18n.t('workarea.klarna.gateway.response.success', summary: request.summary) else errors = body.fetch('error_messages', []).join('. ') I18n.t('workarea.klarna.gateway.response.failure', summary: errors) end end
success?()
click to toggle source
# File lib/workarea/klarna/gateway/response.rb, line 23 def success? raw_response.present? && raw_response.status.in?([200, 201, 202, 204]) end