fedach

package module
v0.0.0-...-37a921c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2017 License: MIT Imports: 7 Imported by: 0

README

fedACH

Build Status Go Report Card GoDoc

This Go package allows you to Marshal or Unmarshal from/to FedACH Participant RDFIs With Commercial Receipt Volume.

You can rely on this package to have the latest official version of the Fed file.

Installation

go get -u github.com/thylong/fedach

Examples

Get current Fed file version
package main

import (
	"fmt"

	"github.com/thylong/fedach"
)

func main() {
	current := fedach.GetCurrentDirectoryFile()

	fmt.Printf("%#v\n", current)
}
Unmarshal from file
package main

import (
	"fmt"

	"github.com/thylong/fedach"
)

func main() {
    fileContent, err := ioutil.ReadFile("sample/FedACHdir.txt")
	if err != nil {
		panic(err)
	}

	var routingDirectoryFile []fedach.RoutingDirectoryRecord
	if err := fedach.Unmarshal(fileContent, &routingDirectoryFile); err != nil {
		panic(err)
	}

	fmt.Printf("%#v\n", routingDirectoryFile)
}
Marshal to file
Using provided data structure
package main

import (
	"fmt"

	"github.com/thylong/fedach"
)

func main() {
	routingDirectoryFile := []fedach.RoutingDirectoryRecord{
		{
			"011000015",
			"O",
			"011000015",
			"0",
			"122415",
			"000000000",
			"FEDERAL RESERVE BANK                ",
			"1000 PEACHTREE ST N.E.              ",
			"ATLANTA             ",
			"GA",
			"30309",
			"4470",
			"877",
			"372",
			"2457",
			"1",
			"1",
			"     ",
		},
	}
	encoded, err := fedach.Marshal(routingDirectoryFile)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s\n", encoded)
}
Using slice
package main

import (
	"fmt"

	"github.com/thylong/fedach"
)

func main() {
	routingDirectoryFile := [][]string{
		{
			"011000015",
			"O",
			"011000015",
			"0",
			"122415",
			"000000000",
			"FEDERAL RESERVE BANK                ",
			"1000 PEACHTREE ST N.E.              ",
			"ATLANTA             ",
			"GA",
			"30309",
			"4470",
			"877",
			"372",
			"2457",
			"1",
			"1",
			"     ",
		},
	}
	encoded, err := fedach.Marshal(routingDirectoryFile)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s\n", encoded)
}

Notes

Please make sure you read the frbservices agreement: https://www.frbservices.org/EPaymentsDirectory/agreement.html

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) (bs []byte, err error)

Marshal returns the Fed file encoding of v.

Example
package main

import (
	"fmt"

	"github.com/thylong/fedach"
)

func main() {
	routingDirectoryFile := []fedach.RoutingDirectoryRecord{
		{
			"011000015",
			"O",
			"011000015",
			"0",
			"122415",
			"000000000",
			"FEDERAL RESERVE BANK                ",
			"1000 PEACHTREE ST N.E.              ",
			"ATLANTA             ",
			"GA",
			"30309",
			"4470",
			"877",
			"372",
			"2457",
			"1",
			"1",
			"     ",
		},
	}
	encoded, err := fedach.Marshal(routingDirectoryFile)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s\n", encoded)
}
Output:

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses the Fed-format-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.

Types

type Records

type Records []byte

Records is an array of records from a Fed file.

type RoutingDirectoryRecord

type RoutingDirectoryRecord struct {
	RoutingNumber         string `length:"9"  pos:"1-9"`
	OfficeCode            string `length:"1"  pos:"10"`
	ServicingFRBNumber    string `length:"9"  pos:"11-19"`
	RecordTypeCode        string `length:"1"  pos:"20"`
	ChangeDate            string `length:"6"  pos:"21-26"`
	NewRoutingNumber      string `length:"9"  pos:"27-35"`
	CustomerName          string `length:"36" pos:"36-71"`
	Address               string `length:"36" pos:"72-107"`
	City                  string `length:"20" pos:"108-127"`
	StateCode             string `length:"2"  pos:"128-129"`
	Zipcode               string `length:"5"  pos:"130-134"`
	ZipcodeExtension      string `length:"4"  pos:"135-138"`
	TelephoneAreaCode     string `length:"3"  pos:"139-141"`
	TelephonePrefixNumber string `length:"3"  pos:"142-144"`
	TelephoneSuffixNumber string `length:"4"  pos:"145-148"`
	InstitutionStatusCode string `length:"1"  pos:"149"`
	DataViewCode          string `length:"1"  pos:"150"`
	Filler                string `length:"5"  pos:"151-155"`
}

RoutingDirectoryRecord is a record of a Routing Directory file.

This file is provided by the Federal Bank Reserve Service and can be found here: https://www.frbservices.org/EPaymentsDirectory/download.html

func GetCurrentDirectoryFile

func GetCurrentDirectoryFile() []RoutingDirectoryRecord

GetCurrentDirectoryFile returns last version of Fed file.

func (*RoutingDirectoryRecord) Bytes

func (r *RoutingDirectoryRecord) Bytes() []byte

Bytes returns RoutingDirectoryRecord bytes representation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL