/
fielded_address.go
79 lines (59 loc) · 2.51 KB
/
fielded_address.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
package schema
import (
log "github.com/sirupsen/logrus"
"github.com/qlcchain/go-sonata-server/models"
"github.com/qlcchain/go-sonata-server/util"
)
type FieldedAddress struct {
// City that the address is in
City string `json:"city,omitempty"`
// Country that the address is in
Country string `json:"country,omitempty"`
// geographic sub address
GeographicSubAddress []*GeographicSubAddress `json:"geographicSubAddress" gorm:"foreignkey:ID"`
// Unique identifier of the address
ID string `json:"id,omitempty"`
// "An area of defined or undefined boundaries within a local authority or other legislatively defined area, usually rural or semi-rural in nature." [ANZLIC-STREET], or a suburb "a bounded locality within a city, town or shire principally of urban character " [ANZLICSTREET].
Locality string `json:"locality,omitempty"`
// The four-digit extension on an American postal code, what comes after the hyphen when specified.
PostCodeExtension string `json:"postCodeExtension,omitempty"`
// Descriptor for a postal delivery area, used to speed and simplify the delivery of mail (also known as zipcode)
Postcode string `json:"postcode,omitempty"`
// The State or Province that the address is in
StateOrProvince string `json:"stateOrProvince,omitempty"`
// Name of the street or other street type
StreetName string `json:"streetName,omitempty"`
// Number identifying a specific property on a public street. It may be combined with streetNrLast for ranged addresses
StreetNr string `json:"streetNr,omitempty"`
// Last number in a range of street numbers allocated to a property
StreetNrLast string `json:"streetNrLast,omitempty"`
// Last street number suffix for a ranged address
StreetNrLastSuffix string `json:"streetNrLastSuffix,omitempty"`
// The first street number suffix
StreetNrSuffix string `json:"streetNrSuffix,omitempty"`
// A modifier denoting a relative direction
StreetSuffix string `json:"streetSuffix,omitempty"`
// Alley, avenue, boulevard, brae, crescent, drive, highway, lane, terrace, parade, place, tarn, way, wharf
StreetType string `json:"streetType,omitempty"`
}
func (m *FieldedAddress) To() *models.FieldedAddress {
if m == nil {
return nil
}
to := &models.FieldedAddress{}
if err := util.Convert(m, to); err != nil {
log.Error(err)
}
return to
}
func FromFieldedAddress(f *models.FieldedAddress) *FieldedAddress {
if f == nil {
return nil
}
r := &FieldedAddress{}
if err := util.Convert(f, r); err != nil {
log.Error(err)
}
r.ID = util.NewOrDefault(r.ID)
return r
}