swiftmessages

package module
v0.0.0-...-2c5d16a Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 5 Imported by: 0

README

Coverage Status GoDoc

go-swift-messages

Parses SWIFT financial messages with different message types (MT101, MT103, MT104, MT202, MT509, MT900, MT910, MT940, MT942, MT950).

About MT103

MT103 is a SWIFT payment message type/format used for cash transfer specifically for cross border/international wire transfer.

Documentation

Overview

Package swiftmessages implements a parser for SWIFT financial messages

Index

Constants

This section is empty.

Variables

View Source
var ErrSwiftBlockInvalid = errors.New("swift block is invalid")

ErrSwiftBlockInvalid is raised when an invalid SWIFT financial message received.

View Source
var ErrUnexpectedType = errors.New("unexpected type")

ErrUnexpectedType is raised when an invalid value in a SWIFT block received.

Functions

func Encode

func Encode(swiftBlock ...SwiftBlockRule) (message string, err error)

Encode encodes swiftBlock into a SWIFT message or returns an error.

func MustEncode

func MustEncode(swiftBlock ...SwiftBlockRule) string

MustEncode returns message if err is nil and panics otherwise.

Types

type Lexer

type Lexer struct {
	*bufio.Reader
	// contains filtered or unexported fields
}

Lexer represents a lexical scanner.

func NewLexer

func NewLexer(r io.Reader) *Lexer

NewLexer returns a new instance of Lexer.

func (*Lexer) Scan

func (l *Lexer) Scan() (tok Token, lit string)

Scan returns the next token and literal value.

type Parser

type Parser struct {
	*Lexer
}

Parser represents a parser.

func NewParser

func NewParser(l *Lexer) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Parse

func (p *Parser) Parse() (message SwiftMessage, err error)

Parse parses SWIFT message.

type SwiftBlock

type SwiftBlock struct {
	ID    string
	Value interface{}
}

SwiftBlock represents a SWIFT block.

type SwiftBlockRule

type SwiftBlockRule struct {
	SwiftBlock
	ShortMode bool
}

SwiftBlockRule represents a SWIFT block settings.

type SwiftMessage

type SwiftMessage struct {
	Blocks []SwiftBlock
}

SwiftMessage represents a collection of SWIFT financial blocks.

type Token

type Token int

Token represents a lexical token.

const (
	// Tokens, literals and keywords
	TokenIllegal Token = iota
	TokenEOF
	TokenLBrace
	TokenRBrace
	TokenString
	TokenID
	TokenColon
	TokenLinebreak
	TokenLinebreakColon

	// Characters
	CharacterColon     = ':'
	CharacterLBrace    = '{'
	CharacterRBrace    = '}'
	CharacterLinebreak = '\n'
)

Jump to

Keyboard shortcuts

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