Google-Ads-GoogleAds-Client

 view release on metacpan or  search on metacpan

examples/account_management/get_change_details.pl  view on Meta::CPAN

# This method returns the old resource and new resource based on the change
# resource type of a change event.
sub _get_changed_resources_for_resource_type {
  my $change_event  = shift;
  my $resource_type = $change_event->{changeResourceType};
  if ($resource_type eq AD) {
    return $change_event->{oldResource}{ad}, $change_event->{newResource}{ad};
  } elsif ($resource_type eq AD_GROUP) {
    return $change_event->{oldResource}{adGroup},
      $change_event->{newResource}{adGroup};
  } elsif ($resource_type eq AD_GROUP_AD) {
    return $change_event->{oldResource}{adGroupAd},
      $change_event->{newResource}{adGroupAd};
  } elsif ($resource_type eq AD_GROUP_ASSET) {
    return $change_event->{oldResource}{adGroupAsset},
      $change_event->{newResource}{adGroupAsset};
  } elsif ($resource_type eq AD_GROUP_CRITERION) {
    return $change_event->{oldResource}{adGroupCriterion},
      $change_event->{newResource}{adGroupCriterion};
  } elsif ($resource_type eq AD_GROUP_BID_MODIFIER) {
    return $change_event->{oldResource}{adGroupBidModifier},
      $change_event->{newResource}{adGroupBidModifier};
  } elsif ($resource_type eq ASSET) {
    return $change_event->{oldResource}{asset},
      $change_event->{newResource}{asset};
  } elsif ($resource_type eq ASSET_SET) {
    return $change_event->{oldResource}{assetSet},
      $change_event->{newResource}{assetSet};
  } elsif ($resource_type eq ASSET_SET_ASSET) {
    return $change_event->{oldResource}{assetSetAsset},
      $change_event->{newResource}{assetSetAsset};
  } elsif ($resource_type eq CAMPAIGN) {
    return $change_event->{oldResource}{campaign},
      $change_event->{newResource}{campaign};
  } elsif ($resource_type eq CAMPAIGN_ASSET) {
    return $change_event->{oldResource}{campaignAsset},
      $change_event->{newResource}{campaignAsset};
  } elsif ($resource_type eq CAMPAIGN_ASSET_SET) {
    return $change_event->{oldResource}{campaignAssetSet},
      $change_event->{newResource}{campaignAssetSet};
  } elsif ($resource_type eq CAMPAIGN_BUDGET) {
    return $change_event->{oldResource}{campaignBudget},
      $change_event->{newResource}{campaignBudget};
  } elsif ($resource_type eq CAMPAIGN_CRITERION) {
    return $change_event->{oldResource}{campaignCriterion},
      $change_event->{newResource}{campaignCriterion};
  } elsif ($resource_type eq CUSTOMER_ASSET) {
    return $change_event->{oldResource}{customerAsset},
      $change_event->{newResource}{customerAsset};
  } else {
    print "Unknown change_resource_type $resource_type.\n";
  }
}
# [END get_change_details]

# 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);

# 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.
get_change_details($api_client, $customer_id =~ s/-//gr);

=pod

=head1 NAME

get_change_details

=head1 DESCRIPTION

This example gets specific details about the most recent changes in your
account, including which field changed and the old and new values.

=head1 SYNOPSIS

get_change_details.pl [options]

    -help                       Show the help message.
    -customer_id                The Google Ads customer ID.

=cut



( run in 0.688 second using v1.01-cache-2.11-cpan-5a3173703d6 )