| 1 |
package segment |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/mitch000001/go-hbci/domain" |
| 5 |
"github.com/mitch000001/go-hbci/element" |
| 6 |
) |
| 7 |
|
| 8 |
const CommonBankParameterID string = "HIBPA" |
| 9 |
|
| 10 |
type CommonBankParameter interface { |
| 11 |
BankSegment |
| 12 |
BankParameterData() domain.BankParameterData |
| 13 |
} |
| 14 |
|
| 15 |
//go:generate go run ../cmd/unmarshaler/unmarshaler_generator.go -segment CommonBankParameterSegment -segment_interface commonBankParameterSegment -segment_versions="CommonBankParameterV2:2,CommonBankParameterV3:3" |
| 16 |
|
| 17 |
type CommonBankParameterSegment struct { |
| 18 |
commonBankParameterSegment |
| 19 |
} |
| 20 |
|
| 21 |
type commonBankParameterSegment interface { |
| 22 |
BankSegment |
| 23 |
BankParameterData() domain.BankParameterData |
| 24 |
} |
| 25 |
|
| 26 |
type CommonBankParameterV2 struct { |
| 27 |
Segment |
| 28 |
BPDVersion *element.NumberDataElement |
| 29 |
BankID *element.BankIdentificationDataElement |
| 30 |
BankName *element.AlphaNumericDataElement |
| 31 |
BusinessTransactionCount *element.NumberDataElement |
| 32 |
SupportedLanguages *element.SupportedLanguagesDataElement |
| 33 |
SupportedHBCIVersions *element.SupportedHBCIVersionsDataElement |
| 34 |
MaxMessageSize *element.NumberDataElement |
| 35 |
} |
| 36 |
|
| 37 |
func (c *CommonBankParameterV2) Version() int { return 2 } |
| 38 |
func (c *CommonBankParameterV2) ID() string { return CommonBankParameterID } |
| 39 |
func (c *CommonBankParameterV2) referencedId() string { return ProcessingPreparationID } |
| 40 |
func (c *CommonBankParameterV2) sender() string { return senderBank } |
| 41 |
|
| 42 |
func (c *CommonBankParameterV2) elements() []element.DataElement { |
| 43 |
return []element.DataElement{ |
| 44 |
c.BPDVersion, |
| 45 |
c.BankID, |
| 46 |
c.BankName, |
| 47 |
c.BusinessTransactionCount, |
| 48 |
c.SupportedLanguages, |
| 49 |
c.SupportedHBCIVersions, |
| 50 |
c.MaxMessageSize, |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
func (c *CommonBankParameterV2) BankParameterData() domain.BankParameterData { |
| 55 |
bpd := domain.BankParameterData{ |
| 56 |
Version: c.BPDVersion.Val(), |
| 57 |
BankID: c.BankID.Val(), |
| 58 |
BankName: c.BankName.Val(), |
| 59 |
MaxTransactionsPerMessage: c.BusinessTransactionCount.Val(), |
| 60 |
} |
| 61 |
if c.MaxMessageSize != nil { |
| 62 |
bpd.MaxMessageSize = c.MaxMessageSize.Val() |
| 63 |
} |
| 64 |
return bpd |
| 65 |
} |
| 66 |
|
| 67 |
type CommonBankParameterV3 struct { |
| 68 |
Segment |
| 69 |
BPDVersion *element.NumberDataElement |
| 70 |
BankID *element.BankIdentificationDataElement |
| 71 |
BankName *element.AlphaNumericDataElement |
| 72 |
BusinessTransactionCount *element.NumberDataElement |
| 73 |
SupportedLanguages *element.SupportedLanguagesDataElement |
| 74 |
SupportedHBCIVersions *element.SupportedHBCIVersionsDataElement |
| 75 |
MaxMessageSize *element.NumberDataElement |
| 76 |
MinTimeoutValue *element.NumberDataElement |
| 77 |
MaxTimeoutValue *element.NumberDataElement |
| 78 |
} |
| 79 |
|
| 80 |
func (c *CommonBankParameterV3) Version() int { return 3 } |
| 81 |
func (c *CommonBankParameterV3) ID() string { return "HIBPA" } |
| 82 |
func (c *CommonBankParameterV3) referencedId() string { return ProcessingPreparationID } |
| 83 |
func (c *CommonBankParameterV3) sender() string { return senderBank } |
| 84 |
|
| 85 |
func (c *CommonBankParameterV3) elements() []element.DataElement { |
| 86 |
return []element.DataElement{ |
| 87 |
c.BPDVersion, |
| 88 |
c.BankID, |
| 89 |
c.BankName, |
| 90 |
c.BusinessTransactionCount, |
| 91 |
c.SupportedLanguages, |
| 92 |
c.SupportedHBCIVersions, |
| 93 |
c.MaxMessageSize, |
| 94 |
c.MinTimeoutValue, |
| 95 |
c.MaxTimeoutValue, |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
func (c *CommonBankParameterV3) BankParameterData() domain.BankParameterData { |
| 100 |
bpd := domain.BankParameterData{ |
| 101 |
Version: c.BPDVersion.Val(), |
| 102 |
BankID: c.BankID.Val(), |
| 103 |
BankName: c.BankName.Val(), |
| 104 |
MaxTransactionsPerMessage: c.BusinessTransactionCount.Val(), |
| 105 |
} |
| 106 |
if c.MaxMessageSize != nil { |
| 107 |
bpd.MaxMessageSize = c.MaxMessageSize.Val() |
| 108 |
} |
| 109 |
if c.MinTimeoutValue != nil { |
| 110 |
bpd.MinTimeout = c.MinTimeoutValue.Val() |
| 111 |
} |
| 112 |
if c.MaxTimeoutValue != nil { |
| 113 |
bpd.MaxTimeout = c.MaxTimeoutValue.Val() |
| 114 |
} |
| 115 |
return bpd |
| 116 |
} |