Class: AchClient::ReturnCode

Inherits:
Object
  • Object
show all
Defined in:
lib/ach_client/objects/return_code.rb

Overview

Represents an Ach Return code. Consult NACHA documentation for a full list See config/return_codes.yml for our list.

Constant Summary collapse

CORRECTION_START_CHARACTER =

The first character in a correction code

'C'
INTERNAL_START_CHARACTER =

The first character in an internal return code

'X'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, description:, reason: nil) ⇒ ReturnCode

Constructs a Ach return code

Parameters:

  • code (String)

    the 3 char code identifier (ie ‘R01’)

  • description (String)

    full explanation of the return

  • reason (String) (defaults to: nil)

    shorter explanation of the return



20
21
22
23
24
# File 'lib/ach_client/objects/return_code.rb', line 20

def initialize(code:, description:, reason: nil)
  @code = code
  @description = description
  @reason = reason
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



12
13
14
# File 'lib/ach_client/objects/return_code.rb', line 12

def code
  @code
end

#descriptionObject

Returns the value of attribute description.



12
13
14
# File 'lib/ach_client/objects/return_code.rb', line 12

def description
  @description
end

#reasonObject

Returns the value of attribute reason.



12
13
14
# File 'lib/ach_client/objects/return_code.rb', line 12

def reason
  @reason
end

Instance Method Details

#correction?Boolean

Returns Whether or not this return is a correction/notice of change.

Returns:

  • (Boolean)

    Whether or not this return is a correction/notice of change



27
28
29
# File 'lib/ach_client/objects/return_code.rb', line 27

def correction?
  @code.start_with?(CORRECTION_START_CHARACTER)
end

#internal?Boolean

An “internal” return means that the ACH provider knew that the ACH

would fail and didn't bother to send it to their upstream provider

Returns:

  • (Boolean)

    Whether or not the return is internal



34
35
36
# File 'lib/ach_client/objects/return_code.rb', line 34

def internal?
  @code.start_with?(INTERNAL_START_CHARACTER)
end