-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from moov-io/intial-reader-and-writer
WIP Intial reader and writer
- Loading branch information
Showing
197 changed files
with
13,051 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2019 The Moov Authors | ||
// Use of this source code is governed by an Apache License | ||
// license that can be found in the LICENSE file. | ||
|
||
package wire | ||
|
||
import "strings" | ||
|
||
// AccountCreditedDrawdown is the account which is credited in a drawdown | ||
type AccountCreditedDrawdown struct { | ||
// tag | ||
tag string | ||
// DrawdownCreditAccountNumber 9 character ABA | ||
DrawdownCreditAccountNumber string `json:"drawdownCreditAccountNumber,omitempty"` | ||
|
||
// validator is composed for data validation | ||
validator | ||
// converters is composed for WIRE to GoLang Converters | ||
converters | ||
} | ||
|
||
// NewAccountCreditedDrawdown returns a new AccountCreditedDrawdown | ||
func NewAccountCreditedDrawdown() *AccountCreditedDrawdown { | ||
creditDD := &AccountCreditedDrawdown{ | ||
tag: TagAccountCreditedDrawdown, | ||
} | ||
return creditDD | ||
} | ||
|
||
// Parse takes the input string and parses the AccountCreditedDrawdown values | ||
// | ||
// Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm | ||
// successful parsing and data validity. | ||
func (creditDD *AccountCreditedDrawdown) Parse(record string) { | ||
creditDD.tag = record[:6] | ||
creditDD.DrawdownCreditAccountNumber = creditDD.parseStringField(record[6:15]) | ||
} | ||
|
||
// String writes AccountCreditedDrawdown | ||
func (creditDD *AccountCreditedDrawdown) String() string { | ||
var buf strings.Builder | ||
// ToDo: Separator | ||
buf.Grow(15) | ||
buf.WriteString(creditDD.tag) | ||
buf.WriteString(creditDD.DrawdownCreditAccountNumberField()) | ||
return buf.String() | ||
} | ||
|
||
// Validate performs WIRE format rule checks on AccountCreditedDrawdown and returns an error if not Validated | ||
// The first error encountered is returned and stops that parsing. | ||
func (creditDD *AccountCreditedDrawdown) Validate() error { | ||
if err := creditDD.fieldInclusion(); err != nil { | ||
return err | ||
} | ||
if err := creditDD.isAlphanumeric(creditDD.DrawdownCreditAccountNumber); err != nil { | ||
return fieldError("DrawdownCreditAccountNumber", err, creditDD.DrawdownCreditAccountNumber) | ||
} | ||
return nil | ||
} | ||
|
||
// fieldInclusion validate mandatory fields. If fields are | ||
// invalid the WIRE will return an error. | ||
func (creditDD *AccountCreditedDrawdown) fieldInclusion() error { | ||
return nil | ||
} | ||
|
||
// DrawdownCreditAccountNumberField gets a string of the DrawdownCreditAccountNumber field | ||
func (creditDD *AccountCreditedDrawdown) DrawdownCreditAccountNumberField() string { | ||
return creditDD.alphaField(creditDD.DrawdownCreditAccountNumber, 9) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package wire | ||
|
||
// mockAccountCreditedDrawdown creates a AccountCreditedDrawdown | ||
func mockAccountCreditedDrawdown() *AccountCreditedDrawdown { | ||
creditDD := NewAccountCreditedDrawdown() | ||
creditDD.DrawdownCreditAccountNumber = "123456789" | ||
return creditDD | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Copyright 2019 The Moov Authors | ||
// Use of this source code is governed by an Apache License | ||
// license that can be found in the LICENSE file. | ||
|
||
package wire | ||
|
||
import "strings" | ||
|
||
// AccountDebitedDrawdown is the account which is debited in a drawdown | ||
type AccountDebitedDrawdown struct { | ||
// tag | ||
tag string | ||
// Identification Code * `D` - Debit | ||
IdentificationCode string `json:"identificationCode"` | ||
// Identifier | ||
Identifier string `json:"identifier"` | ||
// Name | ||
Name string `json:"name"` | ||
Address Address `json:"address,omitempty"` | ||
|
||
// validator is composed for data validation | ||
validator | ||
// converters is composed for WIRE to GoLang Converters | ||
converters | ||
} | ||
|
||
// NewAccountDebitedDrawdown returns a new AccountDebitedDrawdown | ||
func NewAccountDebitedDrawdown() *AccountDebitedDrawdown { | ||
debitDD := &AccountDebitedDrawdown{ | ||
tag: TagAccountDebitedDrawdown, | ||
} | ||
return debitDD | ||
} | ||
|
||
// Parse takes the input string and parses the AccountDebitedDrawdown values | ||
// | ||
// Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm | ||
// successful parsing and data validity. | ||
func (debitDD *AccountDebitedDrawdown) Parse(record string) { | ||
debitDD.tag = record[:6] | ||
debitDD.IdentificationCode = debitDD.parseStringField(record[6:7]) | ||
debitDD.Identifier = debitDD.parseStringField(record[7:41]) | ||
debitDD.Name = debitDD.parseStringField(record[41:76]) | ||
debitDD.Address.AddressLineOne = debitDD.parseStringField(record[76:111]) | ||
debitDD.Address.AddressLineTwo = debitDD.parseStringField(record[111:146]) | ||
debitDD.Address.AddressLineThree = debitDD.parseStringField(record[146:181]) | ||
} | ||
|
||
// String writes AccountDebitedDrawdown | ||
func (debitDD *AccountDebitedDrawdown) String() string { | ||
var buf strings.Builder | ||
// ToDo: Separator | ||
buf.Grow(181) | ||
buf.WriteString(debitDD.tag) | ||
buf.WriteString(debitDD.IdentificationCodeField()) | ||
buf.WriteString(debitDD.IdentifierField()) | ||
buf.WriteString(debitDD.NameField()) | ||
buf.WriteString(debitDD.AddressLineOneField()) | ||
buf.WriteString(debitDD.AddressLineTwoField()) | ||
buf.WriteString(debitDD.AddressLineThreeField()) | ||
return buf.String() | ||
} | ||
|
||
// Validate performs WIRE format rule checks on AccountDebitedDrawdown and returns an error if not Validated | ||
// The first error encountered is returned and stops that parsing. | ||
func (debitDD *AccountDebitedDrawdown) Validate() error { | ||
if err := debitDD.fieldInclusion(); err != nil { | ||
return err | ||
} | ||
if err := debitDD.isIdentificationCode(debitDD.IdentificationCode); err != nil { | ||
return fieldError("IdentificationCode", err, debitDD.IdentificationCode) | ||
} | ||
// Can only be these Identification Codes | ||
switch debitDD.IdentificationCode { | ||
case | ||
"D": | ||
default: | ||
return fieldError("IdentificationCode", ErrIdentificationCode, debitDD.IdentificationCode) | ||
} | ||
if err := debitDD.isAlphanumeric(debitDD.Identifier); err != nil { | ||
return fieldError("Identifier", err, debitDD.Identifier) | ||
} | ||
if err := debitDD.isAlphanumeric(debitDD.Name); err != nil { | ||
return fieldError("Name", err, debitDD.Name) | ||
} | ||
if err := debitDD.isAlphanumeric(debitDD.Address.AddressLineOne); err != nil { | ||
return fieldError("AddressLineOne", err, debitDD.Address.AddressLineOne) | ||
} | ||
if err := debitDD.isAlphanumeric(debitDD.Address.AddressLineTwo); err != nil { | ||
return fieldError("AddressLineTwo", err, debitDD.Address.AddressLineTwo) | ||
} | ||
if err := debitDD.isAlphanumeric(debitDD.Address.AddressLineThree); err != nil { | ||
return fieldError("AddressLineThree", err, debitDD.Address.AddressLineThree) | ||
} | ||
return nil | ||
} | ||
|
||
// fieldInclusion validate mandatory fields. If fields are | ||
// invalid the WIRE will return an error. | ||
func (debitDD *AccountDebitedDrawdown) fieldInclusion() error { | ||
return nil | ||
} | ||
|
||
// IdentificationCodeField gets a string of the IdentificationCode field | ||
func (debitDD *AccountDebitedDrawdown) IdentificationCodeField() string { | ||
return debitDD.alphaField(debitDD.IdentificationCode, 1) | ||
} | ||
|
||
// IdentifierField gets a string of the Identifier field | ||
func (debitDD *AccountDebitedDrawdown) IdentifierField() string { | ||
return debitDD.alphaField(debitDD.Identifier, 34) | ||
} | ||
|
||
// NameField gets a string of the Name field | ||
func (debitDD *AccountDebitedDrawdown) NameField() string { | ||
return debitDD.alphaField(debitDD.Name, 35) | ||
} | ||
|
||
// AddressLineOneField gets a string of AddressLineOne field | ||
func (debitDD *AccountDebitedDrawdown) AddressLineOneField() string { | ||
return debitDD.alphaField(debitDD.Address.AddressLineOne, 35) | ||
} | ||
|
||
// AddressLineTwoField gets a string of AddressLineTwo field | ||
func (debitDD *AccountDebitedDrawdown) AddressLineTwoField() string { | ||
return debitDD.alphaField(debitDD.Address.AddressLineTwo, 35) | ||
} | ||
|
||
// AddressLineThreeField gets a string of AddressLineThree field | ||
func (debitDD *AccountDebitedDrawdown) AddressLineThreeField() string { | ||
return debitDD.alphaField(debitDD.Address.AddressLineThree, 35) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package wire | ||
|
||
// mockAccountDebitedDrawdown creates a AccountDebitedDrawdown | ||
func mockAccountDebitedDrawdown() *AccountDebitedDrawdown { | ||
debitDD := NewAccountDebitedDrawdown() | ||
debitDD.IdentificationCode = "DemandDepositAccountNumber" | ||
debitDD.Identifier = "123456789" | ||
debitDD.Name = "debitDD Name" | ||
debitDD.Address.AddressLineOne = "Address One" | ||
debitDD.Address.AddressLineTwo = "Address Two" | ||
debitDD.Address.AddressLineThree = "Address Three" | ||
return debitDD | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2019 The Moov Authors | ||
// Use of this source code is governed by an Apache License | ||
// license that can be found in the LICENSE file. | ||
|
||
package wire | ||
|
||
import "strings" | ||
|
||
// ActualAmountPaid is the actual amount paid | ||
type ActualAmountPaid struct { | ||
// tag | ||
tag string | ||
// RemittanceAmount is remittance amounts | ||
RemittanceAmount RemittanceAmount `json:"remittanceAmount,omitempty"` | ||
|
||
// validator is composed for data validation | ||
validator | ||
// converters is composed for WIRE to GoLang Converters | ||
converters | ||
} | ||
|
||
// NewActualAmountPaid returns a new ActualAmountPaid | ||
func NewActualAmountPaid() *ActualAmountPaid { | ||
aap := &ActualAmountPaid{ | ||
tag: TagActualAmountPaid, | ||
} | ||
return aap | ||
} | ||
|
||
// Parse takes the input string and parses the ActualAmountPaid values | ||
// | ||
// Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm | ||
// successful parsing and data validity. | ||
func (aap *ActualAmountPaid) Parse(record string) { | ||
aap.tag = record[:6] | ||
aap.RemittanceAmount.CurrencyCode = aap.parseStringField(record[6:9]) | ||
aap.RemittanceAmount.Amount = aap.parseStringField(record[9:28]) | ||
} | ||
|
||
// String writes ActualAmountPaid | ||
func (aap *ActualAmountPaid) String() string { | ||
var buf strings.Builder | ||
// ToDo: Separator | ||
buf.Grow(28) | ||
buf.WriteString(aap.tag) | ||
buf.WriteString(aap.CurrencyCodeField()) | ||
buf.WriteString(aap.AmountField()) | ||
return buf.String() | ||
} | ||
|
||
// Validate performs WIRE format rule checks on ActualAmountPaid and returns an error if not Validated | ||
// The first error encountered is returned and stops that parsing. | ||
func (aap *ActualAmountPaid) Validate() error { | ||
if err := aap.fieldInclusion(); err != nil { | ||
return err | ||
} | ||
if err := aap.isCurrencyCode(aap.RemittanceAmount.CurrencyCode); err != nil { | ||
return fieldError("CurrencyCode", err, aap.RemittanceAmount.CurrencyCode) | ||
} | ||
if err := aap.isAmount(aap.RemittanceAmount.Amount); err != nil { | ||
return fieldError("Amount", err, aap.RemittanceAmount.Amount) | ||
} | ||
return nil | ||
} | ||
|
||
// fieldInclusion validate mandatory fields. If fields are | ||
// invalid the WIRE will return an error. | ||
func (aap *ActualAmountPaid) fieldInclusion() error { | ||
return nil | ||
} | ||
|
||
// CurrencyCodeField gets a string of the CurrencyCode field | ||
func (aap *ActualAmountPaid) CurrencyCodeField() string { | ||
return aap.alphaField(aap.RemittanceAmount.CurrencyCode, 3) | ||
} | ||
|
||
// AmountField gets a string of the Amount field | ||
func (aap *ActualAmountPaid) AmountField() string { | ||
return aap.alphaField(aap.RemittanceAmount.Amount, 19) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package wire | ||
|
||
// ActualAmountPaid creates a ActualAmountPaid | ||
func mockActualAmountPaid() *ActualAmountPaid { | ||
aap := NewActualAmountPaid() | ||
aap.RemittanceAmount.CurrencyCode = "USD" | ||
aap.RemittanceAmount.Amount = "1234.56" | ||
return aap | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2019 The Moov Authors | ||
// Use of this source code is governed by an Apache License | ||
// license that can be found in the LICENSE file. | ||
|
||
package wire | ||
|
||
// AdditionalFIToFI is additional financial institution to financial institution information | ||
type AdditionalFIToFI struct { | ||
// LineOne | ||
LineOne string `json:"lineOne,omitempty"` | ||
// LineTwo | ||
LineTwo string `json:"lineTwo,omitempty"` | ||
// LineThree | ||
LineThree string `json:"lineThree,omitempty"` | ||
// LineFour | ||
LineFour string `json:"lineFour,omitempty"` | ||
// LineFive | ||
LineFive string `json:"lineFive,omitempty"` | ||
// LineSix | ||
LineSix string `json:"lineSix,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2019 The Moov Authors | ||
// Use of this source code is governed by an Apache License | ||
// license that can be found in the LICENSE file. | ||
|
||
package wire | ||
|
||
// ToDo: Consider an array | ||
|
||
// Address is 3 lines of address information | ||
type Address struct { | ||
// AddressLineOne | ||
AddressLineOne string `json:"addressLineOne,omitempty"` | ||
// AddressLineTwo | ||
AddressLineTwo string `json:"addressLineTwo,omitempty"` | ||
// AddressLineThree | ||
AddressLineThree string `json:"addressLineThree,omitempty"` | ||
} |
Oops, something went wrong.