From 2ad493c354e6dffd379594e87a224c258d861210 Mon Sep 17 00:00:00 2001 From: Thomas LAY Date: Mon, 6 Apr 2020 12:25:25 +0200 Subject: [PATCH] Add comment on functions --- segment_allowed_vendors.go | 2 ++ segment_core_string.go | 8 ++++++++ segment_disclosed_vendors.go | 2 ++ segment_publisher_tc.go | 7 +++++++ tcdata.go | 7 +++++++ 5 files changed, 26 insertions(+) diff --git a/segment_allowed_vendors.go b/segment_allowed_vendors.go index 03087a8..68afc3a 100644 --- a/segment_allowed_vendors.go +++ b/segment_allowed_vendors.go @@ -13,6 +13,7 @@ type AllowedVendors struct { RangeEntries []*RangeEntry } +// Returns true if vendor id is allowed for OOB signaling func (a *AllowedVendors) IsVendorAllowed(id int) bool { if a.IsRangeEncoding { for _, entry := range a.RangeEntries { @@ -26,6 +27,7 @@ func (a *AllowedVendors) IsVendorAllowed(id int) bool { return a.AllowedVendors[id] } +// Returns structure as a base64 raw url encoded string func (a *AllowedVendors) Encode() string { bitSize := 20 diff --git a/segment_core_string.go b/segment_core_string.go index 99dd969..036e2bb 100644 --- a/segment_core_string.go +++ b/segment_core_string.go @@ -48,18 +48,23 @@ type RangeEntry struct { EndVendorID int } +// Returns true if user has given consent to special feature id func (c *CoreString) IsSpecialFeatureAllowed(id int) bool { return c.SpecialFeatureOptIns[id] } +// Returns true if user has given consent to purpose id func (c *CoreString) IsPurposeAllowed(id int) bool { return c.PurposesConsent[id] } +// Returns true if legitimate interest is established for purpose id +// and user didn't exercise their right to object func (c *CoreString) IsPurposeLIAllowed(id int) bool { return c.PurposesLITransparency[id] } +// Returns true if user has given consent to vendor id processing their personal data func (c *CoreString) IsVendorAllowed(id int) bool { if c.IsRangeEncoding { for _, entry := range c.RangeEntries { @@ -73,6 +78,8 @@ func (c *CoreString) IsVendorAllowed(id int) bool { return c.VendorsConsent[id] } +// Returns true if transparency for vendor id's legitimate interest is established +// and user didn't exercise their right to object func (c *CoreString) IsVendorLIAllowed(id int) bool { if c.IsRangeEncodingLI { for _, entry := range c.RangeEntriesLI { @@ -86,6 +93,7 @@ func (c *CoreString) IsVendorLIAllowed(id int) bool { return c.VendorsLITransparency[id] } +// Returns structure as a base64 raw url encoded string func (c *CoreString) Encode() string { bitSize := 230 diff --git a/segment_disclosed_vendors.go b/segment_disclosed_vendors.go index 223cb4f..b95ae76 100644 --- a/segment_disclosed_vendors.go +++ b/segment_disclosed_vendors.go @@ -13,6 +13,7 @@ type DisclosedVendors struct { RangeEntries []*RangeEntry } +// Returns true if vendor id is disclosed for validating OOB signaling func (d *DisclosedVendors) IsVendorDisclosed(id int) bool { if d.IsRangeEncoding { for _, entry := range d.RangeEntries { @@ -26,6 +27,7 @@ func (d *DisclosedVendors) IsVendorDisclosed(id int) bool { return d.DisclosedVendors[id] } +// Returns structure as a base64 raw url encoded string func (d *DisclosedVendors) Encode() string { bitSize := 20 diff --git a/segment_publisher_tc.go b/segment_publisher_tc.go index ea2bbe8..8a454f3 100644 --- a/segment_publisher_tc.go +++ b/segment_publisher_tc.go @@ -11,22 +11,29 @@ type PublisherTC struct { CustomPurposesLITransparency map[int]bool } +// Returns true if user has given consent to standard purpose id func (p *PublisherTC) IsPurposeAllowed(id int) bool { return p.PubPurposesConsent[id] } +// Returns true if legitimate interest is established for standard purpose id +// and user didn't exercise their right to object func (p *PublisherTC) IsPurposeLIAllowed(id int) bool { return p.PubPurposesLITransparency[id] } +// Returns true if user has given consent to custom purpose id func (p *PublisherTC) IsCustomPurposeAllowed(id int) bool { return p.CustomPurposesConsent[id] } +// Returns true if legitimate interest is established for custom purpose id +// and user didn't exercise their right to object func (p *PublisherTC) IsCustomPurposeLIAllowed(id int) bool { return p.CustomPurposesLITransparency[id] } +// Returns structure as a base64 raw url encoded string func (p *PublisherTC) Encode() string { bitSize := 57 + (p.NumCustomPurposes * 2) diff --git a/tcdata.go b/tcdata.go index 9b07e0e..5c25b08 100644 --- a/tcdata.go +++ b/tcdata.go @@ -16,22 +16,29 @@ type TCData struct { PublisherTC *PublisherTC } +// 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