Google-Ads-GoogleAds-Client
view release on metacpan or search on metacpan
examples/account_management/verify_advertiser_identity.pl view on Meta::CPAN
# If get_identity_verification returned an empty response, the account is not
# enrolled in mandatory identity verification.
printf "Account $customer_id is not required to perform identity " .
"verification.\n See https://support.google.com/adspolicy/answer/9703665 "
. "for details on how and when an account is required to undergo the "
. "advertiser identity verification program.";
}
return 1;
}
# Retrieves the status of the advertiser identity verification process.
# [START verify_advertiser_identity_1]
sub get_identity_verification {
my ($api_client, $customer_id) = @_;
my $response = $api_client->IdentityVerificationService()->get({
customerId => $customer_id
});
if (!defined $response->{identityVerification}) {
printf "Account %s does not require advertiser identity verification.",
$customer_id;
return;
}
my $identity_verification = $response->{identityVerification}[0];
my $deadline = $identity_verification->{identityVerificationRequirement}
{verificationCompletionDeadlineTime};
my $identity_verification_progress =
$identity_verification->{verificationProgress};
printf "Account %s has a verification completion deadline of %s and status " .
"%s for advertiser identity verification.", $customer_id, $deadline,
$identity_verification_progress->{programStatus};
return $identity_verification;
}
# [END verify_advertiser_identity_1]
# Starts the identity verification process.
# [START verify_advertiser_identity_2]
sub start_identity_verification {
my ($api_client, $customer_id) = @_;
my $request =
Google::Ads::GoogleAds::V24::Services::IdentityVerificationService::StartIdentityVerificationRequest
->new({
customerId => $customer_id,
verificationProgram => ADVERTISER_IDENTITY_VERIFICATION
});
$api_client->AdvertiserIdentityVerificationService()
->start_identity_verification($request);
}
# [END verify_advertiser_identity_2]
# Don't run the example if the file is being included.
if (abs_path($0) ne abs_path(__FILE__)) {
return 1;
}
# Get Google Ads Client, credentials will be read from ~/googleads.properties.
my $api_client = Google::Ads::GoogleAds::Client->new();
# By default examples are set to die on any server returned fault.
$api_client->set_die_on_faults(1);
my $customer_id;
# Parameters passed on the command line will override any parameters set in code.
GetOptions("customer_id=s" => \$customer_id);
# Print the help message if the parameters are not initialized in the code nor
# in the command line.
pod2usage(2) if not check_params($customer_id);
# Call the example.
verify_advertiser_identity($api_client, $customer_id =~ s/-//gr);
=pod
=head1 NAME
verify_advertiser_identity
=head1 DESCRIPTION
This code example retrieves the status of the advertiser identity verification
program and, if required and not already started, starts the verification process.
=head1 SYNOPSIS
verify_advertiser_identity.pl [options]
-help Show the help message.
-customer_id The Google Ads customer ID.
=cut
( run in 1.298 second using v1.01-cache-2.11-cpan-5a3173703d6 )