/
tcdata.go
82 lines (67 loc) · 2.93 KB
/
tcdata.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
package iabtcfv2
import "strings"
type TCData struct {
CoreString *CoreString
DisclosedVendors *DisclosedVendors
PublisherTC *PublisherTC
}
// Returns true if user has given consent to special feature id
func (t *TCData) IsSpecialFeatureAllowed(id int) bool {
return t.CoreString.IsSpecialFeatureAllowed(id)
}
// Returns true if user has given consent to purpose id
func (t *TCData) IsPurposeAllowed(id int) bool {
return t.CoreString.IsPurposeAllowed(id)
}
// Returns true if legitimate interest is established for purpose id
// and user didn't exercise their right to object
func (t *TCData) IsPurposeLIAllowed(id int) bool {
return t.CoreString.IsPurposeLIAllowed(id)
}
// Returns true if user has given consent to vendor id processing their personal data
func (t *TCData) IsVendorAllowed(id int) bool {
return t.CoreString.IsVendorAllowed(id)
}
// Returns true if transparency for vendor id's legitimate interest is established
// and user didn't exercise their right to object
func (t *TCData) IsVendorLIAllowed(id int) bool {
return t.CoreString.IsVendorLIAllowed(id)
}
// Returns true if user has given consent to vendor id processing all purposes ids
// and publisher hasn't set restrictions for them
func (t *TCData) IsVendorAllowedForPurposes(id int, purposeIds ...int) bool {
return t.CoreString.IsVendorAllowedForPurposes(id, purposeIds...)
}
// Returns true if transparency for vendor id's legitimate interest is established for all purpose ids
// and publisher hasn't set restrictions for them
func (t *TCData) IsVendorAllowedForPurposesLI(id int, purposeIds ...int) bool {
return t.CoreString.IsVendorAllowedForPurposesLI(id, purposeIds...)
}
// Returns true if user has given consent to vendor id processing all purposes ids
// or if transparency for its legitimate interest is established in accordance with publisher restrictions
func (t *TCData) IsVendorAllowedForFlexiblePurposes(id int, purposeIds ...int) bool {
return t.CoreString.IsVendorAllowedForFlexiblePurposes(id, purposeIds...)
}
// Returns true if transparency for vendor id's legitimate interest is established for all purpose ids
// or if user has given consent in accordance with publisher restrictions
func (t *TCData) IsVendorAllowedForFlexiblePurposesLI(id int, purposeIds ...int) bool {
return t.CoreString.IsVendorAllowedForFlexiblePurposesLI(id, purposeIds...)
}
// Returns a list of publisher restrictions applied to purpose id
func (t *TCData) GetPubRestrictionsForPurpose(id int) []*PubRestriction {
return t.CoreString.GetPubRestrictionsForPurpose(id)
}
// Returns structure as a base64 raw url encoded string
func (t *TCData) ToTCString() string {
var segments []string
if t.CoreString != nil {
segments = append(segments, t.CoreString.Encode())
}
if t.DisclosedVendors != nil {
segments = append(segments, t.DisclosedVendors.Encode())
}
if t.PublisherTC != nil {
segments = append(segments, t.PublisherTC.Encode())
}
return strings.Join(segments, ".")
}