The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

GDPR::IAB::TCFv2::PublisherRestrictions - Transparency & Consent String version 2 publisher restriction

SYNOPSIS

    my $publisher_restrictions = GDPR::IAB::TCFv2::PublisherRestrictions->Parse(
        data      => substr($self->{data}, OFFSET ),
        data_size => length($self->{data}),
        options => { json => ... },
    );

    say "there is publisher restriction on purpose id 1, type 0 on vendor 284"
        if $publisher_restrictions->check_restriction(1, 0, 284);

CONSTRUCTOR

Constructor Parse receives an 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

check_restriction

Return true for a given combination of purpose id, restriction type and vendor

    my $purpose_id = 1;
    my $restriction_type = 0;
    my $vendor_id = 284;
    my $ok = $object->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 = $object->restrictions(32);
    # returns { 7 => { 1 => 1 } }

TO_JSON

Returns a hashref with the following format:

    {
        '[purpose id]' => {
            # 0 - Not Allowed
            # 1 - Require Consent
            # 2 - Require Legitimate Interest
            '[vendor id]' => 1,
        },
    }

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

    {
        "7" => {
            "32" => 1
        }
    }