This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathforeignborndocument.go
More file actions
78 lines (67 loc) · 2.52 KB
/
foreignborndocument.go
File metadata and controls
78 lines (67 loc) · 2.52 KB
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
package api
import "encoding/json"
// ForeignBornDocument is a basic input.
type ForeignBornDocument struct {
PayloadDocumentType Payload `json:"DocumentType" sql:"-"`
PayloadOtherExplanation Payload `json:"OtherExplanation" sql:"-"`
PayloadDocumentNumber Payload `json:"DocumentNumber" sql:"-"`
PayloadDocumentExpiration Payload `json:"DocumentExpiration" sql:"-"`
PayloadDocumentExpirationNotApplicable Payload `json:"DocumentExpirationNotApplicable" sql:"-"`
DocumentType *Radio `json:"-"`
OtherExplanation *Textarea `json:"-"`
DocumentNumber *Text `json:"-"`
DocumentExpiration *DateControl `json:"-"`
DocumentExpirationNotApplicable *NotApplicable `json:"-"`
}
// Unmarshal bytes in to the entity properties.
func (entity *ForeignBornDocument) Unmarshal(raw []byte) error {
err := json.Unmarshal(raw, entity)
if err != nil {
return err
}
documentType, err := entity.PayloadDocumentType.Entity()
if err != nil {
return err
}
entity.DocumentType = documentType.(*Radio)
otherExplanation, err := entity.PayloadOtherExplanation.Entity()
if err != nil {
return err
}
entity.OtherExplanation = otherExplanation.(*Textarea)
documentNumber, err := entity.PayloadDocumentNumber.Entity()
if err != nil {
return err
}
entity.DocumentNumber = documentNumber.(*Text)
documentExpiration, err := entity.PayloadDocumentExpiration.Entity()
if err != nil {
return err
}
entity.DocumentExpiration = documentExpiration.(*DateControl)
documentExpirationNotApplicable, err := entity.PayloadDocumentExpirationNotApplicable.Entity()
if err != nil {
return err
}
entity.DocumentExpirationNotApplicable = documentExpirationNotApplicable.(*NotApplicable)
return err
}
// Marshal to payload structure
func (entity *ForeignBornDocument) Marshal() Payload {
if entity.DocumentType != nil {
entity.PayloadDocumentType = entity.DocumentType.Marshal()
}
if entity.OtherExplanation != nil {
entity.PayloadOtherExplanation = entity.OtherExplanation.Marshal()
}
if entity.DocumentNumber != nil {
entity.PayloadDocumentNumber = entity.DocumentNumber.Marshal()
}
if entity.DocumentExpiration != nil {
entity.PayloadDocumentExpiration = entity.DocumentExpiration.Marshal()
}
if entity.DocumentExpirationNotApplicable != nil {
entity.PayloadDocumentExpirationNotApplicable = entity.DocumentExpirationNotApplicable.Marshal()
}
return MarshalPayloadEntity("foreignborndocument", entity)
}