Skip to content

Commit

Permalink
add special features as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed Dec 6, 2023
1 parent 8c7ca69 commit df8d222
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/GDPR/IAB/TCFv2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ The purpose of this package is to parse Transparency & Consent String (TC String
use GDPR::IAB::TCFv2;
use GDPR::IAB::TCFv2::Constants::Purpose qw<:all>;
use GDPR::IAB::TCFv2::Constants::SpecialFeature qw<:all>;
my $consent = GDPR::IAB::TCFv2->Parse(
'CLcVDxRMWfGmWAVAHCENAXCkAKDAADnAABRgA5mdfCKZuYJez-NQm0TBMYA4oCAAGQYIAAAAAAEAIAEgAA.argAC0gAAAAAAAAAAAA'
Expand Down Expand Up @@ -373,6 +374,10 @@ The purpose of this package is to parse Transparency & Consent String (TC String
say "find consent for vendor id 284 (Weborama)" if $consent->vendor_consent(284);
# Geolocation exported by GDPR::IAB::TCFv2::Constants::SpecialFeature
say "user is opt in for special feature 'Geolocation (id 1)'"
if $consent->is_special_feature_opt_in(Geolocation);
=head1 ACRONYMS
L<GDPR|https://gdpr-info.eu/>: General Data Protection Regulation
Expand Down
54 changes: 54 additions & 0 deletions lib/GDPR/IAB/TCFv2/Constants/SpecialFeature.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package GDPR::IAB::TCFv2::Constants::SpecialFeature;
use strict;
use warnings;

require Exporter;
use base qw<Exporter>;

use constant {
Geolocation => 1,
DeviceScan => 2,
};

our @EXPORT_OK = qw<
Geolocation
DeviceScan
>;

our %EXPORT_TAGS = ( all => \@EXPORT_OK );

1;

__END__
=head1 NAME
GDPR::IAB::TCFv2::Constants::SpecialFeature - TCF v2.2 special features
=head1 SYNOPSIS
use strict;
use warnings;
use GDPR::IAB::TCFv2::Constants::SpecialFeature qw<:all>;
use feature 'say';
say "Geolocation id is ". Geolocation;
# Output:
# Geolocation id is 1
=head1 CONSTANTS
=head2 Geolocation
Special feature id 1: Use precise geolocation data
With your acceptance, your precise location (within a radius of less than 500 metres) may be used in support of the purposes explained in this notice.
=head2 DeviceScan
Special feature id 2: Actively scan device characteristics for identification
With your acceptance, certain characteristics specific to your device might be requested and used to distinguish it from other devices (such as the installed fonts or plugins, the resolution of your screen) in support of the purposes explained in this notice.
"description":
6 changes: 5 additions & 1 deletion t/00-load.t
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
use strict;
use warnings;
use Test::More tests => 11;
use Test::More tests => 15;

BEGIN {
use_ok('GDPR::IAB::TCFv2::Constants::Purpose');
use_ok('GDPR::IAB::TCFv2::Constants::SpecialFeature');
use_ok('GDPR::IAB::TCFv2::BitUtils');
use_ok('GDPR::IAB::TCFv2::BitField');
use_ok('GDPR::IAB::TCFv2::RangeSection');
use_ok('GDPR::IAB::TCFv2::RangeConsent');
use_ok('GDPR::IAB::TCFv2');
}

require_ok('GDPR::IAB::TCFv2::Constants::Purpose');
require_ok('GDPR::IAB::TCFv2::Constants::SpecialFeature');
require_ok 'GDPR::IAB::TCFv2::BitUtils';
require_ok 'GDPR::IAB::TCFv2::BitField';
require_ok 'GDPR::IAB::TCFv2::RangeSection';
Expand Down

0 comments on commit df8d222

Please sign in to comment.