Add RestrictionType type

This commit is contained in:
Thomas LAY
2020-04-08 17:54:35 +02:00
parent ec535f08c5
commit 159f4f576c
2 changed files with 11 additions and 2 deletions

View File

@@ -17,3 +17,12 @@ const (
TcfVersion1 TcfVersion = 1
TcfVersion2 TcfVersion = 2
)
type RestrictionType int
const (
RestrictionTypeNotAllowed RestrictionType = 0
RestrictionTypeRequireConsent RestrictionType = 1
RestrictionTypeRequireLI RestrictionType = 2
RestrictionTypeUndefined RestrictionType = 3
)

View File

@@ -82,7 +82,7 @@ func (r *TCEncoder) readRangeEntries(n uint) []*RangeEntry {
func (r *TCEncoder) writePubRestrictions(entries []*PubRestriction) {
for _, entry := range entries {
r.writeInt(entry.PurposeId, 6)
r.writeInt(entry.RestrictionType, 2)
r.writeInt(int(entry.RestrictionType), 2)
r.writeInt(len(entry.RangeEntries), 12)
r.writeRangeEntries(entry.RangeEntries)
}
@@ -96,7 +96,7 @@ func (r *TCEncoder) readPubRestrictions(n uint) []*PubRestriction {
var numEntries = r.readInt(12)
var rangeEntries = r.readRangeEntries(uint(numEntries))
ret = append(ret, &PubRestriction{PurposeId: purposeId,
RestrictionType: restrictionType,
RestrictionType: RestrictionType(restrictionType),
NumEntries: numEntries,
RangeEntries: rangeEntries,
})