| 1 |
package segment |
| 2 |
|
| 3 |
import ( |
| 4 |
"strconv" |
| 5 |
|
| 6 |
"github.com/mitch000001/go-hbci/element" |
| 7 |
) |
| 8 |
|
| 9 |
// Possible sync modes |
| 10 |
var ( |
| 11 |
SyncModeAquireClientID = SyncMode{mode: 0} |
| 12 |
SyncModeAquireLastProcessedMessageID = SyncMode{mode: 1} |
| 13 |
SyncModeAquireSignatureID = SyncMode{mode: 2} |
| 14 |
) |
| 15 |
|
| 16 |
type SyncMode struct { |
| 17 |
mode int |
| 18 |
} |
| 19 |
|
| 20 |
func NewSynchronisationSegmentV2(modus SyncMode) *SynchronisationRequestSegment { |
| 21 |
s := &SynchronisationRequestV2{ |
| 22 |
SyncModus: element.NewNumber(modus.mode, 1), |
| 23 |
} |
| 24 |
s.ClientSegment = NewBasicSegment(5, s) |
| 25 |
|
| 26 |
segment := &SynchronisationRequestSegment{ |
| 27 |
ClientSegment: s, |
| 28 |
} |
| 29 |
return segment |
| 30 |
} |
| 31 |
|
| 32 |
type SynchronisationRequestSegment struct { |
| 33 |
ClientSegment |
| 34 |
} |
| 35 |
|
| 36 |
type SynchronisationRequestV2 struct { |
| 37 |
ClientSegment |
| 38 |
// Code | Bedeutung |
| 39 |
// --------------------------------------------------------- |
| 40 |
// 0  | Neue Kundensystem-ID zurückmelden |
| 41 |
// 1 | Letzte verarbeitete Nachrichtennummer zurückmelden   |
| 42 |
// 2  | Signatur-ID zurückmelden |
| 43 |
SyncModus *element.NumberDataElement |
| 44 |
} |
| 45 |
|
| 46 |
func (s *SynchronisationRequestV2) Version() int { return 2 } |
| 47 |
func (s *SynchronisationRequestV2) ID() string { return "HKSYN" } |
| 48 |
func (s *SynchronisationRequestV2) referencedId() string { return "" } |
| 49 |
func (s *SynchronisationRequestV2) sender() string { return senderUser } |
| 50 |
|
| 51 |
func (s *SynchronisationRequestV2) elements() []element.DataElement { |
| 52 |
return []element.DataElement{ |
| 53 |
s.SyncModus, |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
func NewSynchronisationSegmentV3(modus SyncMode) *SynchronisationRequestSegment { |
| 58 |
s := &SynchronisationRequestV3{ |
| 59 |
SyncModus: element.NewCode(strconv.Itoa(modus.mode), 1, []string{"0", "1", "2"}), |
| 60 |
} |
| 61 |
s.ClientSegment = NewBasicSegment(5, s) |
| 62 |
|
| 63 |
segment := &SynchronisationRequestSegment{ |
| 64 |
ClientSegment: s, |
| 65 |
} |
| 66 |
return segment |
| 67 |
} |
| 68 |
|
| 69 |
type SynchronisationRequestV3 struct { |
| 70 |
ClientSegment |
| 71 |
// Code | Bedeutung |
| 72 |
// --------------------------------------------------------- |
| 73 |
// 0  | Neue Kundensystem-ID zurückmelden |
| 74 |
// 1 | Letzte verarbeitete Nachrichtennummer zurückmelden   |
| 75 |
// 2  | Signatur-ID zurückmelden |
| 76 |
SyncModus *element.CodeDataElement |
| 77 |
} |
| 78 |
|
| 79 |
func (s *SynchronisationRequestV3) Version() int { return 3 } |
| 80 |
func (s *SynchronisationRequestV3) ID() string { return "HKSYN" } |
| 81 |
func (s *SynchronisationRequestV3) referencedId() string { return "" } |
| 82 |
func (s *SynchronisationRequestV3) sender() string { return senderUser } |
| 83 |
|
| 84 |
func (s *SynchronisationRequestV3) elements() []element.DataElement { |
| 85 |
return []element.DataElement{ |
| 86 |
s.SyncModus, |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
//go:generate go run ../cmd/unmarshaler/unmarshaler_generator.go -segment SynchronisationResponseSegment -segment_interface SynchronisationResponse -segment_versions="SynchronisationResponseSegmentV3:3,SynchronisationResponseSegmentV4:4" |
| 91 |
|
| 92 |
type SynchronisationResponse interface { |
| 93 |
BankSegment |
| 94 |
ClientSystemID() string |
| 95 |
LastMessageNumber() int |
| 96 |
SignatureID() int |
| 97 |
} |
| 98 |
|
| 99 |
type SynchronisationResponseSegment struct { |
| 100 |
SynchronisationResponse |
| 101 |
} |
| 102 |
|
| 103 |
type SynchronisationResponseSegmentV3 struct { |
| 104 |
Segment |
| 105 |
ClientSystemIDResponse *element.IdentificationDataElement |
| 106 |
MessageNumberResponse *element.NumberDataElement |
| 107 |
SignatureIDResponse *element.NumberDataElement |
| 108 |
} |
| 109 |
|
| 110 |
func (s *SynchronisationResponseSegmentV3) Version() int { return 3 } |
| 111 |
func (s *SynchronisationResponseSegmentV3) ID() string { return "HISYN" } |
| 112 |
func (s *SynchronisationResponseSegmentV3) referencedId() string { return "HKSYN" } |
| 113 |
func (s *SynchronisationResponseSegmentV3) sender() string { return senderBank } |
| 114 |
|
| 115 |
func (s *SynchronisationResponseSegmentV3) elements() []element.DataElement { |
| 116 |
return []element.DataElement{ |
| 117 |
s.ClientSystemIDResponse, |
| 118 |
s.MessageNumberResponse, |
| 119 |
s.SignatureIDResponse, |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
func (s *SynchronisationResponseSegmentV3) ClientSystemID() string { |
| 124 |
return s.ClientSystemIDResponse.Val() |
| 125 |
} |
| 126 |
|
| 127 |
func (s *SynchronisationResponseSegmentV3) LastMessageNumber() int { |
| 128 |
return s.MessageNumberResponse.Val() |
| 129 |
} |
| 130 |
|
| 131 |
func (s *SynchronisationResponseSegmentV3) SignatureID() int { |
| 132 |
return s.SignatureIDResponse.Val() |
| 133 |
} |
| 134 |
|
| 135 |
type SynchronisationResponseSegmentV4 struct { |
| 136 |
Segment |
| 137 |
ClientSystemIDResponse *element.IdentificationDataElement |
| 138 |
MessageNumberResponse *element.NumberDataElement |
| 139 |
SignatureIDResponse *element.NumberDataElement |
| 140 |
} |
| 141 |
|
| 142 |
func (s *SynchronisationResponseSegmentV4) Version() int { return 4 } |
| 143 |
func (s *SynchronisationResponseSegmentV4) ID() string { return "HISYN" } |
| 144 |
func (s *SynchronisationResponseSegmentV4) referencedId() string { return "HKSYN" } |
| 145 |
func (s *SynchronisationResponseSegmentV4) sender() string { return senderBank } |
| 146 |
|
| 147 |
func (s *SynchronisationResponseSegmentV4) elements() []element.DataElement { |
| 148 |
return []element.DataElement{ |
| 149 |
s.ClientSystemIDResponse, |
| 150 |
s.MessageNumberResponse, |
| 151 |
s.SignatureIDResponse, |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
func (s *SynchronisationResponseSegmentV4) ClientSystemID() string { |
| 156 |
return s.ClientSystemIDResponse.Val() |
| 157 |
} |
| 158 |
|
| 159 |
func (s *SynchronisationResponseSegmentV4) LastMessageNumber() int { |
| 160 |
return s.MessageNumberResponse.Val() |
| 161 |
} |
| 162 |
|
| 163 |
func (s *SynchronisationResponseSegmentV4) SignatureID() int { |
| 164 |
return s.SignatureIDResponse.Val() |
| 165 |
} |