Class: GmoServices::Payments::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/gmo_services/payments/error.rb

Constant Summary collapse

ERROR_INFO_SEPARATOR =
'|'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_body, locale = :en) ⇒ Error

Returns a new instance of Error.



8
9
10
11
# File 'lib/gmo_services/payments/error.rb', line 8

def initialize(response_body, locale = :en)
  @response_body = response_body
  @locale = locale
end

Instance Attribute Details

#localeObject

Returns the value of attribute locale.



4
5
6
# File 'lib/gmo_services/payments/error.rb', line 4

def locale
  @locale
end

#response_bodyObject

Returns the value of attribute response_body.



4
5
6
# File 'lib/gmo_services/payments/error.rb', line 4

def response_body
  @response_body
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'lib/gmo_services/payments/error.rb', line 13

def call
  error_info_array = response_body['ErrInfo'].split(ERROR_INFO_SEPARATOR)
  error_message_array = error_info_array.map { |error_info| translate(error_info) }
  error_message = error_message_array.join(ERROR_INFO_SEPARATOR)
  response_body['ErrMessage'] = error_message
  response_body
end