Google-Ads-GoogleAds-Client
view release on metacpan or search on metacpan
examples/advanced_operations/use_cross_account_bidding_strategy.pl view on Meta::CPAN
# Create a GAQL query that will retrieve all cross-account bidding
# strategies.
my $query = "SELECT
bidding_strategy.id,
bidding_strategy.name,
bidding_strategy.type,
bidding_strategy.currency_code
FROM bidding_strategy";
# Issue a streaming search request, then iterate through and print the
# results.
my $search_stream_handler =
Google::Ads::GoogleAds::Utils::SearchStreamHandler->new({
service => $api_client->GoogleAdsService(),
request =>
Google::Ads::GoogleAds::V20::Services::GoogleAdsService::SearchGoogleAdsStreamRequest
->new({
customerId => $manager_customer_id,
query => $query
})});
examples/advanced_operations/use_cross_account_bidding_strategy.pl view on Meta::CPAN
accessible_bidding_strategy.owner_descriptive_name
FROM accessible_bidding_strategy";
# Uncomment the following WHERE clause addition to the query to filter results
# to *only* cross-account bidding strategies shared with the current customer
# by a manager (and not also include the current customer's portfolio bidding
# strategies).
# $query .=
# " WHERE accessible_bidding_strategy.owner_customer_id != $customer_id";
# Issue a streaming search request, then iterate through and print the
# results.
my $search_stream_handler =
Google::Ads::GoogleAds::Utils::SearchStreamHandler->new({
service => $api_client->GoogleAdsService(),
request =>
Google::Ads::GoogleAds::V20::Services::GoogleAdsService::SearchGoogleAdsStreamRequest
->new({
customerId => $customer_id,
query => $query
})});
examples/misc/set_custom_client_timeouts.pl view on Meta::CPAN
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This example illustrates the use of custom client timeouts and retry delays
# in the context of server streaming and unary calls.
use strict;
use warnings;
use utf8;
use FindBin qw($Bin);
use lib "$Bin/../../lib";
use Google::Ads::GoogleAds::Client;
use Google::Ads::GoogleAds::Utils::GoogleAdsHelper;
use Google::Ads::GoogleAds::Utils::SearchStreamHandler;
examples/misc/set_custom_client_timeouts.pl view on Meta::CPAN
#
# Parameters passed on the command line will override any parameters set in
# code.
#
# Running the example with -h will print the command line usage.
my $customer_id = "INSERT_CUSTOMER_ID_HERE";
sub set_custom_client_timeouts {
my ($api_client, $customer_id) = @_;
make_server_streaming_call($api_client, $customer_id);
make_unary_call($api_client, $customer_id);
return 1;
}
# Makes a server streaming call using a custom client timeout.
sub make_server_streaming_call {
my ($api_client, $customer_id) = @_;
# Any server streaming call has a default timeout setting, which can be found
# in the module of Google::Ads::GoogleAds::Constants.
#
# A new value can be provided to override the default timeout setting in the
# API client.
$api_client->set_http_timeout(CLIENT_TIMEOUT_SECONDS);
# Create a search Google Ads stream request that will retrieve all campaign IDs.
my $search_stream_request =
Google::Ads::GoogleAds::V20::Services::GoogleAdsService::SearchGoogleAdsStreamRequest
->new({
examples/misc/set_custom_client_timeouts.pl view on Meta::CPAN
service => $google_ads_service,
request => $search_stream_request
});
# Iterate over all rows in all messages and collect the campaign IDs.
$search_stream_handler->process_contents(
sub {
my $google_ads_row = shift;
$output .= ' ' . $google_ads_row->{campaign}{id};
});
print "The server streaming call completed before the timeout.\n";
};
if ($@) {
my $response_message = $api_client->get_last_response()->message;
# The LWP::UserAgent module returns a "read timeout" message in the HTTP
# response for request timeout.
if ($response_message =~ m/${\HTTP_TIMEOUT_MESSAGE}/) {
print "The server streaming call did not complete before the timeout.\n";
} else {
# Bubble up if the exception is not about timeout.
die $$response_message;
}
}
print "All campaign IDs retrieved : " . ($output ? $output : "None") . "\n";
}
# Makes an unary call using a custom client timeout.
examples/misc/set_custom_client_timeouts.pl view on Meta::CPAN
=pod
=head1 NAME
set_custom_client_timeouts
=head1 DESCRIPTION
This example illustrates the use of custom client timeouts and retry delays
in the context of server streaming and unary calls.
=head1 SYNOPSIS
set_custom_client_timeouts.pl [options]
-help Show the help message.
-customer_id The Google Ads customer ID.
=cut
lib/Google/Ads/GoogleAds/BaseService.pm view on Meta::CPAN
be used to expand the {+resourceName} or any other expression in the request path
and encoded into JSON string for a HTTP POST request.
=item *
I<response_type>: The class name of the expected response. An instance of this class
will be returned if the request succeeds.
=item *
I<content_callback>: The optional streaming content callback method.
=back
=head3 Returns
An instance of the class defined by the C<response_type> parameter, or a
L<Google::Ads::GoogleAds::GoogleAdsException> object if an error has occurred at
the server side by default. However if the C<die_on_faults> flag is set to true
in L<Google::Ads::GoogleAds::Client>, the service will issue a die() with error
message on API errors.
( run in 0.706 second using v1.01-cache-2.11-cpan-4d50c553e7e )