NAME
GDPR::IAB::TCFv2::Publisher - Transparency & Consent String version 2 publisher
Combines the creation of GDPR::IAB::TCFv2::PublisherRestrictions and GDPR::IAB::TCFv2::PublisherTC based on the data available.
SYNOPSIS
my $publisher = GDPR::IAB::TCFv2::Publisher->Parse(
    core_data         => $core_data,
    core_data_size    => $core_data_size,
    publisher_tc_data => $publisher_tc_data, # optional
    options           => { json => ... },
);
say "there is publisher restriction on purpose id 1, type 0 on vendor_id 284"
    if $publisher->check_restriction(1, 0, 284);
CONSTRUCTOR
Constructor Parse receives an hash of 4 parameters:
Key
core_datais the binary core dataKey
core_data_sizeis the original binary core data sizeKey
publisher_tc_datais the binary publisher data. Optional.Key
optionsis the GDPR::IAB::TCFv2 options (includes thejsonfield to modify the "TO_JSON" method output.
METHODS
check_restriction
Return true for a given combination of purpose id, restriction type and vendor_id
my $purpose_id = 1;
my $restriction_type = 0;
my $vendor_id = 284;
$ok = $publisher->check_restriction($purpose_id, $restriction_type, $vendor_id);
restrictions
Return a hashref of purpose => { restriction type => bool } for a given vendor id.
Example, by parsing the consent COwAdDhOwAdDhN4ABAENAPCgAAQAAv___wAAAFP_AAp_4AI6ACACAA we can generate this.
my $restrictions = $publisher->restrictions(32);
# returns { 7 => { 1 => 1 } }
publisher_tc
If the consent string has a Publisher TC section, we will decode this section as an instance of GDPR::IAB::TCFv2::PublisherTC.
Will return undefined if there is no Publisher TC section.
TO_JSON
Returns a hashref with the following format:
{
    consents => ...,
    legitimate_interests => ...,
    custom_purposes => {
        consents => ...,
        legitimate_interests => ...,
    },
    restrictions => {
        '[purpose id]' => {
            # 0 - Not Allowed
            # 1 - Require Consent
            # 2 - Require Legitimate Interest
            '[vendor_id id]' => 1,
        },
    }
}
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_purpose" : {
     "consents" : [],
     "legitimate_interests" : []
  },
  "restrictions" : {
     "7" : {
        "32" : 1
     }
  }
}
However by parsing the consent COwAdDhOwAdDhN4ABAENAPCgAAQAAv___wAAAFP_AAp_4AI6ACACAA without the Publisher TC section will omit all fields except restrictions:
{
  "restrictions" : {
     "7" : {
        "32" : 1
     }
  }
}