From 159f4f576ccc94eac9b85b3f00107496cb7de16c Mon Sep 17 00:00:00 2001 From: Thomas LAY Date: Wed, 8 Apr 2020 17:54:35 +0200 Subject: [PATCH] Add RestrictionType type --- constants.go | 9 +++++++++ tcencoder.go | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/constants.go b/constants.go index a8377d6..758a8bb 100644 --- a/constants.go +++ b/constants.go @@ -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 +) diff --git a/tcencoder.go b/tcencoder.go index 4a0e03f..e602320 100644 --- a/tcencoder.go +++ b/tcencoder.go @@ -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, })