NAME

GDPR::IAB::TCFv2::PublisherTC - TCF v2.3 publisher TC section parser

SYNOPSIS

use GDPR::IAB::TCFv2::PublisherTC;
my $publisher_tc_data = '...';

my $publisher_tc = GDPR::IAB::TCFv2::PublisherTC->Parse(
    data         => $publisher_tc_data,
    data_size    => length($publisher_tc_data) * 8,
    options      => { json => {} },
);

my $num = $publisher_tc->num_custom_purposes;

if ($publisher_tc->is_purpose_consent_allowed(1)) {
    # ...
}

CONSTRUCTOR

Constructor Parse receives a hash of 3 parameters:

  • Key data is the binary data

  • Key data_size is the original binary data size

  • Key options is the GDPR::IAB::TCFv2 options (includes the json field to modify the "TO_JSON" method output.

METHODS

num_custom_purposes

Custom purpose IDs are numbered 1 to NumberCustomPurposes. Custom purposes will be defined by the publisher and displayed to a user in a CMP user interface.

If the publisher does not use any Custom Purposes, this method returns 0.

The user's consent value for each Purpose established on the legal basis of consent, for the publisher.

is_purpose_legitimate_interest_allowed

The Purposes transparency requirements are met for each Purpose established on the legal basis of legitimate interest and the user has not exercised their "Right to Object" to that Purpose.

By default or if the user has exercised their "Right to Object to a Purpose", the corresponding bit for that purpose is set to 0

The consent value for each custom purpose id

is_custom_purpose_legitimate_interest_allowed

The legitimate Interest disclosure establishment value for each custom purpose id

TO_JSON

Returns a hashref describing the publisher's purpose decisions:

{
    consents             => ...,
    legitimate_interests => ...,
    custom_purposes      => {
        consents             => ...,
        legitimate_interests => ...,
    },
}

Publisher restrictions are emitted by "TO_JSON" in GDPR::IAB::TCFv2::PublisherRestrictions; the "TO_JSON" in GDPR::IAB::TCFv2::Publisher wrapper combines the two views into a single hashref.

Example, by parsing the consent COwAdDhOwAdDhN4ABAENAPCgAAQAAv___wAAAFP_AAp_4AI6ACACAA.argAC0gAAAAAAAAAAAA we can generate this compact hashref.

{
  "consents" : [
     2,
     4,
     6,
     8,
     9,
     10
  ],
  "legitimate_interests" : [
     2,
     4,
     5,
     7,
     10
  ],
  "custom_purposes" : {
     "consents" : [],
     "legitimate_interests" : []
  }
}