class IssuerResponseCodes::Code

Constants

NOT_PROVIDED

Attributes

fraud_notice[R]
id[R]
locale[R]
target[R]

Public Class Methods

new(id:, target: :merchant, locale: :en, fraud_notice: NOT_PROVIDED) click to toggle source
# File lib/issuer_response_codes/code.rb, line 9
def initialize(id:, target: :merchant, locale: :en, fraud_notice: NOT_PROVIDED)
  @id = id
  @target = target
  @locale = locale

  @locale = :en unless AVAILABLE_LOCALES.include?(locale)
  raise IllegalTarget, "No such target: #{target.inspect}" unless AVAILABLE_TARGETS.include?(target)

  if fraud_notice != NOT_PROVIDED
    @fraud_notice = fraud_notice
    return
  end

  @fraud_notice = target == :merchant
end

Public Instance Methods

behaviour() click to toggle source
# File lib/issuer_response_codes/code.rb, line 35
def behaviour
  behaviour_str = LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.behaviour", locale: locale, default: :unknown)
  return behaviour_str unless fraud_notice && fraudulent_code?

  "#{behaviour_str} #{LOCALE_LIBRARY.dig(path: 'issuer_response_codes.fraud_notice')}"
end
description()
Alias for: humanize
fraudulent_code?() click to toggle source
# File lib/issuer_response_codes/code.rb, line 42
def fraudulent_code?
  @fraudulent_code ||= LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.fraudulent_codes", locale: locale)
end
humanize() click to toggle source
# File lib/issuer_response_codes/code.rb, line 25
def humanize
  "#{reason} #{behaviour}"
end
Also aliased as: description
reason() click to toggle source
# File lib/issuer_response_codes/code.rb, line 31
def reason
  LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.targeted.#{target}", locale: locale, default: :unknown)
end