-
Notifications
You must be signed in to change notification settings - Fork 30
/
enum.go
183 lines (157 loc) · 6.28 KB
/
enum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package ivms101
import (
"encoding/json"
"errors"
"strings"
)
//
// Constant Code Helpers
//
// Short form natural person name type codes.
const (
NaturalPersonAlias = NaturalPersonNameTypeCode_NATURAL_PERSON_NAME_TYPE_CODE_ALIA
NaturalPersonBirth = NaturalPersonNameTypeCode_NATURAL_PERSON_NAME_TYPE_CODE_BIRT
NaturalPersonMaiden = NaturalPersonNameTypeCode_NATURAL_PERSON_NAME_TYPE_CODE_MAID
NaturalPersonLegal = NaturalPersonNameTypeCode_NATURAL_PERSON_NAME_TYPE_CODE_LEGL
NaturalPersonMisc = NaturalPersonNameTypeCode_NATURAL_PERSON_NAME_TYPE_CODE_MISC
)
// Short form legal person name type codes.
const (
LegalPersonLegal = LegalPersonNameTypeCode_LEGAL_PERSON_NAME_TYPE_CODE_LEGL
LegalPersonShort = LegalPersonNameTypeCode_LEGAL_PERSON_NAME_TYPE_CODE_SHRT
LegalPersonTrading = LegalPersonNameTypeCode_LEGAL_PERSON_NAME_TYPE_CODE_TRAD
)
// Short form address type codes.
const (
AddressTypeHome = AddressTypeCode_ADDRESS_TYPE_CODE_HOME
AddressTypeBusiness = AddressTypeCode_ADDRESS_TYPE_CODE_BIZZ
AddressTypeGeographic = AddressTypeCode_ADDRESS_TYPE_CODE_GEOG
)
// Short form national identifier type codes.
const (
NationalIdentifierARNU = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_ARNU
NationalIdentifierCCPT = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_CCPT
NationalIdentifierRAID = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_RAID
NationalIdentifierDRLC = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_DRLC
NationalIdentifierFIIN = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_FIIN
NationalIdentifierTXID = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_TXID
NationalIdentifierSOCS = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_SOCS
NationalIdentifierIDCD = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_IDCD
NationalIdentifierLEIX = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_LEIX
NationalIdentifierMISC = NationalIdentifierTypeCode_NATIONAL_IDENTIFIER_TYPE_CODE_MISC
)
//
// NaturalPersonNameTypeCode JSON
//
const naturalPersonTypeCodePrefix = "NATURAL_PERSON_NAME_TYPE_CODE_"
// Must be a value receiver to ensure it is marshaled correctly from it's parent struct
func (n NaturalPersonNameTypeCode) MarshalJSON() ([]byte, error) {
data := strings.TrimPrefix(n.String(), naturalPersonTypeCodePrefix)
return json.Marshal(data)
}
// Must be a pointer receiver so that we can indirect back to the correct variable
func (n *NaturalPersonNameTypeCode) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return errors.New("could not parse NaturalPersonNameTypeCode from value")
}
s = naturalPersonTypeCodePrefix + strings.ToUpper(s)
code, ok := NaturalPersonNameTypeCode_value[s]
if !ok {
return errors.New("invalid NaturalPersonNameTypeCode alias")
}
*n = NaturalPersonNameTypeCode(code)
return nil
}
//
// LegalPersonNameTypeCode JSON
//
const legalPersonNameTypeCodePrefix = "LEGAL_PERSON_NAME_TYPE_CODE_"
// Must be a value receiver to ensure it is marshaled correctly from it's parent struct
func (l LegalPersonNameTypeCode) MarshalJSON() ([]byte, error) {
data := strings.TrimPrefix(l.String(), legalPersonNameTypeCodePrefix)
return json.Marshal(data)
}
// Must be a pointer receiver so that we can indirect back to the correct variable
func (l *LegalPersonNameTypeCode) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return errors.New("could not parse LegalPersonNameTypeCode from value")
}
s = legalPersonNameTypeCodePrefix + strings.ToUpper(s)
code, ok := LegalPersonNameTypeCode_value[s]
if !ok {
return errors.New("invalid LegalPersonNameTypeCode alias")
}
*l = LegalPersonNameTypeCode(code)
return nil
}
//
// AddressTypeCode JSON
//
const addressTypeCodePrefix = "ADDRESS_TYPE_CODE_"
// Must be a value receiver to ensure it is marshaled correctly from it's parent struct
func (a AddressTypeCode) MarshalJSON() ([]byte, error) {
data := strings.TrimPrefix(a.String(), addressTypeCodePrefix)
return json.Marshal(data)
}
// Must be a pointer receiver so that we can indirect back to the correct variable
func (a *AddressTypeCode) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return errors.New("could not parse AddressTypeCode from value")
}
s = addressTypeCodePrefix + strings.ToUpper(s)
code, ok := AddressTypeCode_value[s]
if !ok {
return errors.New("invalid AddressTypeCode alias")
}
*a = AddressTypeCode(code)
return nil
}
//
// NationalIdentifierTypeCode JSON
//
const nationalIdentifierTypeCodePrefix = "NATIONAL_IDENTIFIER_TYPE_CODE_"
// Must be a value receiver to ensure it is marshaled correctly from it's parent struct
func (i NationalIdentifierTypeCode) MarshalJSON() ([]byte, error) {
data := strings.TrimPrefix(i.String(), nationalIdentifierTypeCodePrefix)
return json.Marshal(data)
}
// Must be a pointer receiver so that we can indirect back to the correct variable
func (i *NationalIdentifierTypeCode) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return errors.New("could not parse NationalIdentifierTypeCode from value")
}
s = nationalIdentifierTypeCodePrefix + strings.ToUpper(s)
code, ok := NationalIdentifierTypeCode_value[s]
if !ok {
return errors.New("invalid NationalIdentifierTypeCode alias")
}
*i = NationalIdentifierTypeCode(code)
return nil
}
//
// TransliterationMethodCode JSON
//
const transliterationMethodCodePrefix = "TRANSLITERATION_METHOD_CODE_"
// Must be a value receiver to ensure it is marshaled correctly from it's parent struct
func (t TransliterationMethodCode) MarshalJSON() ([]byte, error) {
data := strings.TrimPrefix(t.String(), transliterationMethodCodePrefix)
return json.Marshal(data)
}
// Must be a pointer receiver so that we can indirect back to the correct variable
func (t *TransliterationMethodCode) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return errors.New("could not parse TransliterationMethodCode from value")
}
s = transliterationMethodCodePrefix + strings.ToUpper(s)
code, ok := TransliterationMethodCode_value[s]
if !ok {
return errors.New("invalid TransliterationMethodCode alias")
}
*t = TransliterationMethodCode(code)
return nil
}