Class: AchClient::ReturnCodes

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

Overview

Finding and listing all Ach return codes

Constant Summary collapse

RETURN_CODES_YAML =

The path to the file where the return codes are enumerated

'../../../config/return_codes.yml'

Class Method Summary collapse

Class Method Details

.administrativeObject



28
29
30
# File 'lib/ach_client/objects/return_codes.rb', line 28

def self.administrative
  self.all.select(&:administrative_return?)
end

.allArray<AchClient::ReturnCode>

Returns A list of all return codes.

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ach_client/objects/return_codes.rb', line 11

def self.all
  self._return_codes ||= YAML.load_file(
    File.expand_path(File.join(File.dirname(__FILE__), RETURN_CODES_YAML))
  ).map do |code|
    ReturnCode.new(
      code: code['code'],
      description: code['description'],
      reason: code['reason'],
      risk_and_enforcement_category: code['risk_and_enforcement_category']
    )
  end
end

.find_by(code:) ⇒ Object

Finds the first ReturnCode with the given code, or raises an exception.

Parameters:

  • 3 (String)

    char code identifier for a return code

  • The (AchClient::ReturnCode)

    ReturnCode object with that code



35
36
37
38
39
40
# File 'lib/ach_client/objects/return_codes.rb', line 35

def self.find_by(code:)
  self.all.find do |return_code|
    return_code.code == code
  # For some reason || is bad syntax in this context
  end or raise "Could not find return code #{code}"
end

.unauthorizedObject



24
25
26
# File 'lib/ach_client/objects/return_codes.rb', line 24

def self.unauthorized
  self.all.select(&:unauthorized_return?)
end