Files
iabtcfv2/tcdata.go
2020-04-06 14:30:24 +02:00

58 lines
1.6 KiB
Go

package iabtcfv2
import "strings"
type TCData struct {
CoreString *CoreString
DisclosedVendors *DisclosedVendors
AllowedVendors *AllowedVendors
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 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.AllowedVendors != nil {
segments = append(segments, t.AllowedVendors.Encode())
}
if t.PublisherTC != nil {
segments = append(segments, t.PublisherTC.Encode())
}
return strings.Join(segments, ".")
}