-
Notifications
You must be signed in to change notification settings - Fork 40
/
constants.go
719 lines (633 loc) · 20.8 KB
/
constants.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
package integrationaccountagreements
import (
"encoding/json"
"fmt"
"strings"
)
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
type AgreementType string
const (
AgreementTypeASTwo AgreementType = "AS2"
AgreementTypeEdifact AgreementType = "Edifact"
AgreementTypeNotSpecified AgreementType = "NotSpecified"
AgreementTypeXOneTwo AgreementType = "X12"
)
func PossibleValuesForAgreementType() []string {
return []string{
string(AgreementTypeASTwo),
string(AgreementTypeEdifact),
string(AgreementTypeNotSpecified),
string(AgreementTypeXOneTwo),
}
}
func (s *AgreementType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseAgreementType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseAgreementType(input string) (*AgreementType, error) {
vals := map[string]AgreementType{
"as2": AgreementTypeASTwo,
"edifact": AgreementTypeEdifact,
"notspecified": AgreementTypeNotSpecified,
"x12": AgreementTypeXOneTwo,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := AgreementType(input)
return &out, nil
}
type EdifactCharacterSet string
const (
EdifactCharacterSetKECA EdifactCharacterSet = "KECA"
EdifactCharacterSetNotSpecified EdifactCharacterSet = "NotSpecified"
EdifactCharacterSetUNOA EdifactCharacterSet = "UNOA"
EdifactCharacterSetUNOB EdifactCharacterSet = "UNOB"
EdifactCharacterSetUNOC EdifactCharacterSet = "UNOC"
EdifactCharacterSetUNOD EdifactCharacterSet = "UNOD"
EdifactCharacterSetUNOE EdifactCharacterSet = "UNOE"
EdifactCharacterSetUNOF EdifactCharacterSet = "UNOF"
EdifactCharacterSetUNOG EdifactCharacterSet = "UNOG"
EdifactCharacterSetUNOH EdifactCharacterSet = "UNOH"
EdifactCharacterSetUNOI EdifactCharacterSet = "UNOI"
EdifactCharacterSetUNOJ EdifactCharacterSet = "UNOJ"
EdifactCharacterSetUNOK EdifactCharacterSet = "UNOK"
EdifactCharacterSetUNOX EdifactCharacterSet = "UNOX"
EdifactCharacterSetUNOY EdifactCharacterSet = "UNOY"
)
func PossibleValuesForEdifactCharacterSet() []string {
return []string{
string(EdifactCharacterSetKECA),
string(EdifactCharacterSetNotSpecified),
string(EdifactCharacterSetUNOA),
string(EdifactCharacterSetUNOB),
string(EdifactCharacterSetUNOC),
string(EdifactCharacterSetUNOD),
string(EdifactCharacterSetUNOE),
string(EdifactCharacterSetUNOF),
string(EdifactCharacterSetUNOG),
string(EdifactCharacterSetUNOH),
string(EdifactCharacterSetUNOI),
string(EdifactCharacterSetUNOJ),
string(EdifactCharacterSetUNOK),
string(EdifactCharacterSetUNOX),
string(EdifactCharacterSetUNOY),
}
}
func (s *EdifactCharacterSet) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseEdifactCharacterSet(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseEdifactCharacterSet(input string) (*EdifactCharacterSet, error) {
vals := map[string]EdifactCharacterSet{
"keca": EdifactCharacterSetKECA,
"notspecified": EdifactCharacterSetNotSpecified,
"unoa": EdifactCharacterSetUNOA,
"unob": EdifactCharacterSetUNOB,
"unoc": EdifactCharacterSetUNOC,
"unod": EdifactCharacterSetUNOD,
"unoe": EdifactCharacterSetUNOE,
"unof": EdifactCharacterSetUNOF,
"unog": EdifactCharacterSetUNOG,
"unoh": EdifactCharacterSetUNOH,
"unoi": EdifactCharacterSetUNOI,
"unoj": EdifactCharacterSetUNOJ,
"unok": EdifactCharacterSetUNOK,
"unox": EdifactCharacterSetUNOX,
"unoy": EdifactCharacterSetUNOY,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := EdifactCharacterSet(input)
return &out, nil
}
type EdifactDecimalIndicator string
const (
EdifactDecimalIndicatorComma EdifactDecimalIndicator = "Comma"
EdifactDecimalIndicatorDecimal EdifactDecimalIndicator = "Decimal"
EdifactDecimalIndicatorNotSpecified EdifactDecimalIndicator = "NotSpecified"
)
func PossibleValuesForEdifactDecimalIndicator() []string {
return []string{
string(EdifactDecimalIndicatorComma),
string(EdifactDecimalIndicatorDecimal),
string(EdifactDecimalIndicatorNotSpecified),
}
}
func (s *EdifactDecimalIndicator) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseEdifactDecimalIndicator(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseEdifactDecimalIndicator(input string) (*EdifactDecimalIndicator, error) {
vals := map[string]EdifactDecimalIndicator{
"comma": EdifactDecimalIndicatorComma,
"decimal": EdifactDecimalIndicatorDecimal,
"notspecified": EdifactDecimalIndicatorNotSpecified,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := EdifactDecimalIndicator(input)
return &out, nil
}
type EncryptionAlgorithm string
const (
EncryptionAlgorithmAESOneNineTwo EncryptionAlgorithm = "AES192"
EncryptionAlgorithmAESOneTwoEight EncryptionAlgorithm = "AES128"
EncryptionAlgorithmAESTwoFiveSix EncryptionAlgorithm = "AES256"
EncryptionAlgorithmDESThree EncryptionAlgorithm = "DES3"
EncryptionAlgorithmNone EncryptionAlgorithm = "None"
EncryptionAlgorithmNotSpecified EncryptionAlgorithm = "NotSpecified"
EncryptionAlgorithmRCTwo EncryptionAlgorithm = "RC2"
)
func PossibleValuesForEncryptionAlgorithm() []string {
return []string{
string(EncryptionAlgorithmAESOneNineTwo),
string(EncryptionAlgorithmAESOneTwoEight),
string(EncryptionAlgorithmAESTwoFiveSix),
string(EncryptionAlgorithmDESThree),
string(EncryptionAlgorithmNone),
string(EncryptionAlgorithmNotSpecified),
string(EncryptionAlgorithmRCTwo),
}
}
func (s *EncryptionAlgorithm) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseEncryptionAlgorithm(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseEncryptionAlgorithm(input string) (*EncryptionAlgorithm, error) {
vals := map[string]EncryptionAlgorithm{
"aes192": EncryptionAlgorithmAESOneNineTwo,
"aes128": EncryptionAlgorithmAESOneTwoEight,
"aes256": EncryptionAlgorithmAESTwoFiveSix,
"des3": EncryptionAlgorithmDESThree,
"none": EncryptionAlgorithmNone,
"notspecified": EncryptionAlgorithmNotSpecified,
"rc2": EncryptionAlgorithmRCTwo,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := EncryptionAlgorithm(input)
return &out, nil
}
type HashingAlgorithm string
const (
HashingAlgorithmMDFive HashingAlgorithm = "MD5"
HashingAlgorithmNone HashingAlgorithm = "None"
HashingAlgorithmNotSpecified HashingAlgorithm = "NotSpecified"
HashingAlgorithmSHAOne HashingAlgorithm = "SHA1"
HashingAlgorithmSHATwoFiveOneTwo HashingAlgorithm = "SHA2512"
HashingAlgorithmSHATwoThreeEightFour HashingAlgorithm = "SHA2384"
HashingAlgorithmSHATwoTwoFiveSix HashingAlgorithm = "SHA2256"
)
func PossibleValuesForHashingAlgorithm() []string {
return []string{
string(HashingAlgorithmMDFive),
string(HashingAlgorithmNone),
string(HashingAlgorithmNotSpecified),
string(HashingAlgorithmSHAOne),
string(HashingAlgorithmSHATwoFiveOneTwo),
string(HashingAlgorithmSHATwoThreeEightFour),
string(HashingAlgorithmSHATwoTwoFiveSix),
}
}
func (s *HashingAlgorithm) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseHashingAlgorithm(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseHashingAlgorithm(input string) (*HashingAlgorithm, error) {
vals := map[string]HashingAlgorithm{
"md5": HashingAlgorithmMDFive,
"none": HashingAlgorithmNone,
"notspecified": HashingAlgorithmNotSpecified,
"sha1": HashingAlgorithmSHAOne,
"sha2512": HashingAlgorithmSHATwoFiveOneTwo,
"sha2384": HashingAlgorithmSHATwoThreeEightFour,
"sha2256": HashingAlgorithmSHATwoTwoFiveSix,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := HashingAlgorithm(input)
return &out, nil
}
type KeyType string
const (
KeyTypeNotSpecified KeyType = "NotSpecified"
KeyTypePrimary KeyType = "Primary"
KeyTypeSecondary KeyType = "Secondary"
)
func PossibleValuesForKeyType() []string {
return []string{
string(KeyTypeNotSpecified),
string(KeyTypePrimary),
string(KeyTypeSecondary),
}
}
func (s *KeyType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseKeyType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseKeyType(input string) (*KeyType, error) {
vals := map[string]KeyType{
"notspecified": KeyTypeNotSpecified,
"primary": KeyTypePrimary,
"secondary": KeyTypeSecondary,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := KeyType(input)
return &out, nil
}
type MessageFilterType string
const (
MessageFilterTypeExclude MessageFilterType = "Exclude"
MessageFilterTypeInclude MessageFilterType = "Include"
MessageFilterTypeNotSpecified MessageFilterType = "NotSpecified"
)
func PossibleValuesForMessageFilterType() []string {
return []string{
string(MessageFilterTypeExclude),
string(MessageFilterTypeInclude),
string(MessageFilterTypeNotSpecified),
}
}
func (s *MessageFilterType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseMessageFilterType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseMessageFilterType(input string) (*MessageFilterType, error) {
vals := map[string]MessageFilterType{
"exclude": MessageFilterTypeExclude,
"include": MessageFilterTypeInclude,
"notspecified": MessageFilterTypeNotSpecified,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := MessageFilterType(input)
return &out, nil
}
type SegmentTerminatorSuffix string
const (
SegmentTerminatorSuffixCR SegmentTerminatorSuffix = "CR"
SegmentTerminatorSuffixCRLF SegmentTerminatorSuffix = "CRLF"
SegmentTerminatorSuffixLF SegmentTerminatorSuffix = "LF"
SegmentTerminatorSuffixNone SegmentTerminatorSuffix = "None"
SegmentTerminatorSuffixNotSpecified SegmentTerminatorSuffix = "NotSpecified"
)
func PossibleValuesForSegmentTerminatorSuffix() []string {
return []string{
string(SegmentTerminatorSuffixCR),
string(SegmentTerminatorSuffixCRLF),
string(SegmentTerminatorSuffixLF),
string(SegmentTerminatorSuffixNone),
string(SegmentTerminatorSuffixNotSpecified),
}
}
func (s *SegmentTerminatorSuffix) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseSegmentTerminatorSuffix(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseSegmentTerminatorSuffix(input string) (*SegmentTerminatorSuffix, error) {
vals := map[string]SegmentTerminatorSuffix{
"cr": SegmentTerminatorSuffixCR,
"crlf": SegmentTerminatorSuffixCRLF,
"lf": SegmentTerminatorSuffixLF,
"none": SegmentTerminatorSuffixNone,
"notspecified": SegmentTerminatorSuffixNotSpecified,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := SegmentTerminatorSuffix(input)
return &out, nil
}
type SigningAlgorithm string
const (
SigningAlgorithmDefault SigningAlgorithm = "Default"
SigningAlgorithmNotSpecified SigningAlgorithm = "NotSpecified"
SigningAlgorithmSHAOne SigningAlgorithm = "SHA1"
SigningAlgorithmSHATwoFiveOneTwo SigningAlgorithm = "SHA2512"
SigningAlgorithmSHATwoThreeEightFour SigningAlgorithm = "SHA2384"
SigningAlgorithmSHATwoTwoFiveSix SigningAlgorithm = "SHA2256"
)
func PossibleValuesForSigningAlgorithm() []string {
return []string{
string(SigningAlgorithmDefault),
string(SigningAlgorithmNotSpecified),
string(SigningAlgorithmSHAOne),
string(SigningAlgorithmSHATwoFiveOneTwo),
string(SigningAlgorithmSHATwoThreeEightFour),
string(SigningAlgorithmSHATwoTwoFiveSix),
}
}
func (s *SigningAlgorithm) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseSigningAlgorithm(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseSigningAlgorithm(input string) (*SigningAlgorithm, error) {
vals := map[string]SigningAlgorithm{
"default": SigningAlgorithmDefault,
"notspecified": SigningAlgorithmNotSpecified,
"sha1": SigningAlgorithmSHAOne,
"sha2512": SigningAlgorithmSHATwoFiveOneTwo,
"sha2384": SigningAlgorithmSHATwoThreeEightFour,
"sha2256": SigningAlgorithmSHATwoTwoFiveSix,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := SigningAlgorithm(input)
return &out, nil
}
type TrailingSeparatorPolicy string
const (
TrailingSeparatorPolicyMandatory TrailingSeparatorPolicy = "Mandatory"
TrailingSeparatorPolicyNotAllowed TrailingSeparatorPolicy = "NotAllowed"
TrailingSeparatorPolicyNotSpecified TrailingSeparatorPolicy = "NotSpecified"
TrailingSeparatorPolicyOptional TrailingSeparatorPolicy = "Optional"
)
func PossibleValuesForTrailingSeparatorPolicy() []string {
return []string{
string(TrailingSeparatorPolicyMandatory),
string(TrailingSeparatorPolicyNotAllowed),
string(TrailingSeparatorPolicyNotSpecified),
string(TrailingSeparatorPolicyOptional),
}
}
func (s *TrailingSeparatorPolicy) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseTrailingSeparatorPolicy(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseTrailingSeparatorPolicy(input string) (*TrailingSeparatorPolicy, error) {
vals := map[string]TrailingSeparatorPolicy{
"mandatory": TrailingSeparatorPolicyMandatory,
"notallowed": TrailingSeparatorPolicyNotAllowed,
"notspecified": TrailingSeparatorPolicyNotSpecified,
"optional": TrailingSeparatorPolicyOptional,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := TrailingSeparatorPolicy(input)
return &out, nil
}
type UsageIndicator string
const (
UsageIndicatorInformation UsageIndicator = "Information"
UsageIndicatorNotSpecified UsageIndicator = "NotSpecified"
UsageIndicatorProduction UsageIndicator = "Production"
UsageIndicatorTest UsageIndicator = "Test"
)
func PossibleValuesForUsageIndicator() []string {
return []string{
string(UsageIndicatorInformation),
string(UsageIndicatorNotSpecified),
string(UsageIndicatorProduction),
string(UsageIndicatorTest),
}
}
func (s *UsageIndicator) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseUsageIndicator(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseUsageIndicator(input string) (*UsageIndicator, error) {
vals := map[string]UsageIndicator{
"information": UsageIndicatorInformation,
"notspecified": UsageIndicatorNotSpecified,
"production": UsageIndicatorProduction,
"test": UsageIndicatorTest,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := UsageIndicator(input)
return &out, nil
}
type X12CharacterSet string
const (
X12CharacterSetBasic X12CharacterSet = "Basic"
X12CharacterSetExtended X12CharacterSet = "Extended"
X12CharacterSetNotSpecified X12CharacterSet = "NotSpecified"
X12CharacterSetUTFEight X12CharacterSet = "UTF8"
)
func PossibleValuesForX12CharacterSet() []string {
return []string{
string(X12CharacterSetBasic),
string(X12CharacterSetExtended),
string(X12CharacterSetNotSpecified),
string(X12CharacterSetUTFEight),
}
}
func (s *X12CharacterSet) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseX12CharacterSet(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseX12CharacterSet(input string) (*X12CharacterSet, error) {
vals := map[string]X12CharacterSet{
"basic": X12CharacterSetBasic,
"extended": X12CharacterSetExtended,
"notspecified": X12CharacterSetNotSpecified,
"utf8": X12CharacterSetUTFEight,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := X12CharacterSet(input)
return &out, nil
}
type X12DateFormat string
const (
X12DateFormatCCYYMMDD X12DateFormat = "CCYYMMDD"
X12DateFormatNotSpecified X12DateFormat = "NotSpecified"
X12DateFormatYYMMDD X12DateFormat = "YYMMDD"
)
func PossibleValuesForX12DateFormat() []string {
return []string{
string(X12DateFormatCCYYMMDD),
string(X12DateFormatNotSpecified),
string(X12DateFormatYYMMDD),
}
}
func (s *X12DateFormat) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseX12DateFormat(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseX12DateFormat(input string) (*X12DateFormat, error) {
vals := map[string]X12DateFormat{
"ccyymmdd": X12DateFormatCCYYMMDD,
"notspecified": X12DateFormatNotSpecified,
"yymmdd": X12DateFormatYYMMDD,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := X12DateFormat(input)
return &out, nil
}
type X12TimeFormat string
const (
X12TimeFormatHHMM X12TimeFormat = "HHMM"
X12TimeFormatHHMMSS X12TimeFormat = "HHMMSS"
X12TimeFormatHHMMSSd X12TimeFormat = "HHMMSSd"
X12TimeFormatHHMMSSdd X12TimeFormat = "HHMMSSdd"
X12TimeFormatNotSpecified X12TimeFormat = "NotSpecified"
)
func PossibleValuesForX12TimeFormat() []string {
return []string{
string(X12TimeFormatHHMM),
string(X12TimeFormatHHMMSS),
string(X12TimeFormatHHMMSSd),
string(X12TimeFormatHHMMSSdd),
string(X12TimeFormatNotSpecified),
}
}
func (s *X12TimeFormat) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseX12TimeFormat(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseX12TimeFormat(input string) (*X12TimeFormat, error) {
vals := map[string]X12TimeFormat{
"hhmm": X12TimeFormatHHMM,
"hhmmss": X12TimeFormatHHMMSS,
"hhmmssd": X12TimeFormatHHMMSSd,
"hhmmssdd": X12TimeFormatHHMMSSdd,
"notspecified": X12TimeFormatNotSpecified,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := X12TimeFormat(input)
return &out, nil
}