mirror of
https://github.com/cubixle/iabtcfv2.git
synced 2026-04-30 12:38:44 +01:00
Encode and decode TCString
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package iabtcf
|
||||
|
||||
import "strings"
|
||||
|
||||
type TCData struct {
|
||||
CoreString *CoreString
|
||||
DisclosedVendors *DisclosedVendors
|
||||
AllowedVendors *AllowedVendors
|
||||
PublisherTC *PublisherTC
|
||||
}
|
||||
|
||||
func (t *TCData) IsPurposeAllowed(id int) bool {
|
||||
return t.CoreString.IsPurposeAllowed(id)
|
||||
}
|
||||
|
||||
func (t *TCData) IsPurposeLIAllowed(id int) bool {
|
||||
return t.CoreString.IsPurposeLIAllowed(id)
|
||||
}
|
||||
|
||||
func (t *TCData) IsVendorAllowed(id int) bool {
|
||||
return t.CoreString.IsVendorAllowed(id)
|
||||
}
|
||||
|
||||
func (t *TCData) IsVendorLIAllowed(id int) bool {
|
||||
return t.CoreString.IsVendorLIAllowed(id)
|
||||
}
|
||||
|
||||
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, ".")
|
||||
}
|
||||
Reference in New Issue
Block a user