func (b *BasicMessage) MarshalHBCI() ([]byte, error) {
	if b.HBCIMessage == nil {
		return nil, fmt.Errorf("HBCIMessage must be set")
	}
	err := b.SetSize()
	if err != nil {
		return nil, err
	}
	if len(b.marshaledContent) == 0 {
		var buffer bytes.Buffer
		headerBytes, err := b.Header.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		buffer.Write(headerBytes)
		if b.SignatureBegin != nil {
			sigBytes, err := b.SignatureBegin.MarshalHBCI()
			if err != nil {
				return nil, err
			}
			buffer.Write(sigBytes)
		}
		for _, segment := range b.HBCIMessage.HBCISegments() {
			if !reflect.ValueOf(segment).IsNil() {
				segBytes, err := segment.MarshalHBCI()
				if err != nil {
					return nil, err
				}
				buffer.Write(segBytes)
			}
		}
		if b.SignatureEnd != nil {
			sigEndBytes, err := b.SignatureEnd.MarshalHBCI()
			if err != nil {
				return nil, err
			}
			buffer.Write(sigEndBytes)
		}
		endBytes, err := b.End.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		buffer.Write(endBytes)
		b.marshaledContent = buffer.Bytes()
	}
	return b.marshaledContent, nil
}
// MarshalHBCI marshals b into HBCI wire format
MarshalHBCI marshals b into HBCI wire format
// MarshalHBCI marshals b into HBCI wire format
func (b *BasicMessage) MarshalHBCI() ([]byte, error) {
	if b.HBCIMessage == nil {
		return nil, fmt.Errorf("HBCIMessage must be set")
	}
	err := b.SetSize()
	if err != nil {
		return nil, err
	}
	if len(b.marshaledContent) == 0 {
		var buffer bytes.Buffer
		headerBytes, err := b.Header.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		buffer.Write(headerBytes)
		if b.SignatureBegin != nil {
			sigBytes, err := b.SignatureBegin.MarshalHBCI()
			if err != nil {
				return nil, err
			}
			buffer.Write(sigBytes)
		}
		for _, segment := range b.HBCIMessage.HBCISegments() {
			if !reflect.ValueOf(segment).IsNil() {
				segBytes, err := segment.MarshalHBCI()
				if err != nil {
					return nil, err
				}
				buffer.Write(segBytes)
			}
		}
		if b.SignatureEnd != nil {
			sigEndBytes, err := b.SignatureEnd.MarshalHBCI()
			if err != nil {
				return nil, err
			}
			buffer.Write(sigEndBytes)
		}
		endBytes, err := b.End.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		buffer.Write(endBytes)
		b.marshaledContent = buffer.Bytes()
	}
	return b.marshaledContent, nil
}
func ( b * BasicMessage ) MarshalHBCI ( ) ( [ ] byte , error ) { if b . HBCIMessage == nil { return nil , fmt . Errorf ( " " ) } err := b . SetSize ( ) if err != nil { return nil , err } if len ( b . marshaledContent ) == 0 { var buffer bytes . Buffer headerBytes , err := b . Header . MarshalHBCI ( ) if err != nil { return nil , err } buffer . Write ( headerBytes ) if b . SignatureBegin != nil { sigBytes , err := b . SignatureBegin . MarshalHBCI ( ) if err != nil { return nil , err } buffer . Write ( sigBytes ) } for _ , segment := range b . HBCIMessage . HBCISegments ( ) { if ! reflect . ValueOf ( segment ) . IsNil ( ) { segBytes , err := segment . MarshalHBCI ( ) if err != nil { return nil , err } buffer . Write ( segBytes ) } } if b . SignatureEnd != nil { sigEndBytes , err := b . SignatureEnd . MarshalHBCI ( ) if err != nil { return nil , err } buffer . Write ( sigEndBytes ) } endBytes , err := b . End . MarshalHBCI ( ) if err != nil { return nil , err } buffer . Write ( endBytes ) b . marshaledContent = buffer . Bytes ( ) } return b . marshaledContent , nil }
MarshalHBCI marshals b into HBCI wire format
MarshalHBCI marshals b into HBCI wire format