/
address.go
70 lines (63 loc) · 1.58 KB
/
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
package cart
type (
// Address defines a cart address
Address struct {
Vat string
Firstname string
Lastname string
MiddleName string
Title string
Salutation string
Street string
StreetNr string
AdditionalAddressLines []string
Company string
City string
PostCode string
State string
RegionCode string
Country string
CountryCode string
TelephoneCountryCode string
TelephoneAreaCode string
TelephoneNumber string
// Deprecated: parts of number should be distinguished, please use TelephoneCountryCode, TelephoneAreaCode and TelephoneNumber
Telephone string
Email string
}
)
// FullName return Firstname Lastname
func (a Address) FullName() string {
return a.Firstname + " " + a.Lastname
}
// IsEmpty checks all fields of the address if they are empty
func (a *Address) IsEmpty() bool {
if a == nil {
return true
}
for _, additionalLine := range a.AdditionalAddressLines {
if additionalLine != "" {
return false
}
}
if a.Vat != "" ||
a.Firstname != "" ||
a.Lastname != "" ||
a.MiddleName != "" ||
a.Title != "" ||
a.Salutation != "" ||
a.Street != "" ||
a.StreetNr != "" ||
a.Company != "" ||
a.City != "" ||
a.PostCode != "" ||
a.State != "" ||
a.RegionCode != "" ||
a.Country != "" ||
a.CountryCode != "" ||
a.Telephone != "" ||
a.Email != "" {
return false
}
return true
}