Google Ads Ad Manager V1 Client - Class CreativeWrapperServiceClient (0.14.1)

Reference documentation and code samples for the Google Ads Ad Manager V1 Client class CreativeWrapperServiceClient.

Service Description: Provides methods for handling CreativeWrapper objects.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Ads \ AdManager \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array|Google\ApiCore\Options\ClientOptions

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials Google\Auth\FetchAuthTokenInterface|Google\ApiCore\CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Ads\AdManager\V1\CreativeWrapperServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new CreativeWrapperServiceClient(['credentials' => $creds]); https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|Google\ApiCore\Transport\TransportInterface

The transport used for executing network requests. At the moment, supports only rest. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

↳ logger false|Psr\Log\LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

batchActivateCreativeWrappers

Batch activates CreativeWrapper objects.

The async variant is CreativeWrapperServiceClient::batchActivateCreativeWrappersAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchActivateCreativeWrappersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\BatchActivateCreativeWrappersResponse
Example
use Google\Ads\AdManager\V1\BatchActivateCreativeWrappersRequest;
use Google\Ads\AdManager\V1\BatchActivateCreativeWrappersResponse;
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `CreativeWrapper` objects to activate.
 *                                      Format: `networks/{network_code}/creativeWrappers/{creative_wrapper_id}`
 *                                      Please see {@see CreativeWrapperServiceClient::creativeWrapperName()} for help formatting this field.
 */
function batch_activate_creative_wrappers_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchActivateCreativeWrappersRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchActivateCreativeWrappersResponse $response */
        $response = $creativeWrapperServiceClient->batchActivateCreativeWrappers($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = CreativeWrapperServiceClient::creativeWrapperName(
        '[NETWORK_CODE]',
        '[CREATIVE_WRAPPER]'
    );

    batch_activate_creative_wrappers_sample($formattedParent, $formattedNamesElement);
}

batchCreateCreativeWrappers

Creates CreativeWrapper objects.

The async variant is CreativeWrapperServiceClient::batchCreateCreativeWrappersAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchCreateCreativeWrappersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\BatchCreateCreativeWrappersResponse
Example
use Google\Ads\AdManager\V1\BatchCreateCreativeWrappersRequest;
use Google\Ads\AdManager\V1\BatchCreateCreativeWrappersResponse;
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\Ads\AdManager\V1\CreateCreativeWrapperRequest;
use Google\Ads\AdManager\V1\CreativeWrapper;
use Google\Ads\AdManager\V1\CreativeWrapperTypeEnum\CreativeWrapperType;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                            The parent resource where `CreativeWrappers` will be created.
 *                                                           Format: `networks/{network_code}`
 *                                                           The parent field in the CreateCreativeWrapperRequest must match this
 *                                                           field. Please see
 *                                                           {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsParent                    The parent resource where this `CreativeWrapper` will be created.
 *                                                           Format: `networks/{network_code}`
 *                                                           Please see {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsCreativeWrapperLabel      Immutable. The resource name of the
 *                                                           [Label][google.ads.admanager.v1.Label].
 *                                                           Format:`networks/{network_code}/label/{label_id}`
 *                                                           Please see {@see CreativeWrapperServiceClient::labelName()} for help formatting this field.
 * @param int    $requestsCreativeWrapperCreativeWrapperType The `creative_wrapper_type`. If the `creative_wrapper_type` is
 *                                                           [CreativeWrapperType.VIDEO_TRACKING_URL][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.VIDEO_TRACKING_URL],
 *                                                           the `video_tracking_urls` field must be set. If the `creative_wrapper_type`
 *                                                           is
 *                                                           [CreativeWrapperType.HTML][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.HTML],
 *                                                           either the header or footer field must be set.
 */
function batch_create_creative_wrappers_sample(
    string $formattedParent,
    string $formattedRequestsParent,
    string $formattedRequestsCreativeWrapperLabel,
    int $requestsCreativeWrapperCreativeWrapperType
): void {
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $requestsCreativeWrapper = (new CreativeWrapper())
        ->setLabel($formattedRequestsCreativeWrapperLabel)
        ->setCreativeWrapperType($requestsCreativeWrapperCreativeWrapperType);
    $createCreativeWrapperRequest = (new CreateCreativeWrapperRequest())
        ->setParent($formattedRequestsParent)
        ->setCreativeWrapper($requestsCreativeWrapper);
    $requests = [$createCreativeWrapperRequest,];
    $request = (new BatchCreateCreativeWrappersRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchCreateCreativeWrappersResponse $response */
        $response = $creativeWrapperServiceClient->batchCreateCreativeWrappers($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsCreativeWrapperLabel = CreativeWrapperServiceClient::labelName(
        '[NETWORK_CODE]',
        '[LABEL]'
    );
    $requestsCreativeWrapperCreativeWrapperType = CreativeWrapperType::CREATIVE_WRAPPER_TYPE_UNSPECIFIED;

    batch_create_creative_wrappers_sample(
        $formattedParent,
        $formattedRequestsParent,
        $formattedRequestsCreativeWrapperLabel,
        $requestsCreativeWrapperCreativeWrapperType
    );
}

batchDeactivateCreativeWrappers

Deactivates a list of CreativeWrapper objects.

The async variant is CreativeWrapperServiceClient::batchDeactivateCreativeWrappersAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchDeactivateCreativeWrappersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\BatchDeactivateCreativeWrappersResponse
Example
use Google\Ads\AdManager\V1\BatchDeactivateCreativeWrappersRequest;
use Google\Ads\AdManager\V1\BatchDeactivateCreativeWrappersResponse;
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `CreativeWrapper` objects to
 *                                      deactivate. Format:
 *                                      `networks/{network_code}/creativeWrappers/{creative_wrapper_id}`
 *                                      Please see {@see CreativeWrapperServiceClient::creativeWrapperName()} for help formatting this field.
 */
function batch_deactivate_creative_wrappers_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchDeactivateCreativeWrappersRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchDeactivateCreativeWrappersResponse $response */
        $response = $creativeWrapperServiceClient->batchDeactivateCreativeWrappers($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = CreativeWrapperServiceClient::creativeWrapperName(
        '[NETWORK_CODE]',
        '[CREATIVE_WRAPPER]'
    );

    batch_deactivate_creative_wrappers_sample($formattedParent, $formattedNamesElement);
}

batchUpdateCreativeWrappers

Batch updates CreativeWrapper objects.

The async variant is CreativeWrapperServiceClient::batchUpdateCreativeWrappersAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchUpdateCreativeWrappersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\BatchUpdateCreativeWrappersResponse
Example
use Google\Ads\AdManager\V1\BatchUpdateCreativeWrappersRequest;
use Google\Ads\AdManager\V1\BatchUpdateCreativeWrappersResponse;
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\Ads\AdManager\V1\CreativeWrapper;
use Google\Ads\AdManager\V1\CreativeWrapperTypeEnum\CreativeWrapperType;
use Google\Ads\AdManager\V1\UpdateCreativeWrapperRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                            The parent resource where `CreativeWrappers` will be updated.
 *                                                           Format: `networks/{network_code}`
 *                                                           The parent field in the UpdateCreativeWrapperRequest must match this
 *                                                           field. Please see
 *                                                           {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsCreativeWrapperLabel      Immutable. The resource name of the
 *                                                           [Label][google.ads.admanager.v1.Label].
 *                                                           Format:`networks/{network_code}/label/{label_id}`
 *                                                           Please see {@see CreativeWrapperServiceClient::labelName()} for help formatting this field.
 * @param int    $requestsCreativeWrapperCreativeWrapperType The `creative_wrapper_type`. If the `creative_wrapper_type` is
 *                                                           [CreativeWrapperType.VIDEO_TRACKING_URL][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.VIDEO_TRACKING_URL],
 *                                                           the `video_tracking_urls` field must be set. If the `creative_wrapper_type`
 *                                                           is
 *                                                           [CreativeWrapperType.HTML][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.HTML],
 *                                                           either the header or footer field must be set.
 */
function batch_update_creative_wrappers_sample(
    string $formattedParent,
    string $formattedRequestsCreativeWrapperLabel,
    int $requestsCreativeWrapperCreativeWrapperType
): void {
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $requestsCreativeWrapper = (new CreativeWrapper())
        ->setLabel($formattedRequestsCreativeWrapperLabel)
        ->setCreativeWrapperType($requestsCreativeWrapperCreativeWrapperType);
    $updateCreativeWrapperRequest = (new UpdateCreativeWrapperRequest())
        ->setCreativeWrapper($requestsCreativeWrapper);
    $requests = [$updateCreativeWrapperRequest,];
    $request = (new BatchUpdateCreativeWrappersRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchUpdateCreativeWrappersResponse $response */
        $response = $creativeWrapperServiceClient->batchUpdateCreativeWrappers($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsCreativeWrapperLabel = CreativeWrapperServiceClient::labelName(
        '[NETWORK_CODE]',
        '[LABEL]'
    );
    $requestsCreativeWrapperCreativeWrapperType = CreativeWrapperType::CREATIVE_WRAPPER_TYPE_UNSPECIFIED;

    batch_update_creative_wrappers_sample(
        $formattedParent,
        $formattedRequestsCreativeWrapperLabel,
        $requestsCreativeWrapperCreativeWrapperType
    );
}

createCreativeWrapper

Creates a CreativeWrapper object.

The async variant is CreativeWrapperServiceClient::createCreativeWrapperAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\CreateCreativeWrapperRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\CreativeWrapper
Example
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\Ads\AdManager\V1\CreateCreativeWrapperRequest;
use Google\Ads\AdManager\V1\CreativeWrapper;
use Google\Ads\AdManager\V1\CreativeWrapperTypeEnum\CreativeWrapperType;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                    The parent resource where this `CreativeWrapper` will be created.
 *                                                   Format: `networks/{network_code}`
 *                                                   Please see {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 * @param string $formattedCreativeWrapperLabel      Immutable. The resource name of the
 *                                                   [Label][google.ads.admanager.v1.Label].
 *                                                   Format:`networks/{network_code}/label/{label_id}`
 *                                                   Please see {@see CreativeWrapperServiceClient::labelName()} for help formatting this field.
 * @param int    $creativeWrapperCreativeWrapperType The `creative_wrapper_type`. If the `creative_wrapper_type` is
 *                                                   [CreativeWrapperType.VIDEO_TRACKING_URL][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.VIDEO_TRACKING_URL],
 *                                                   the `video_tracking_urls` field must be set. If the `creative_wrapper_type`
 *                                                   is
 *                                                   [CreativeWrapperType.HTML][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.HTML],
 *                                                   either the header or footer field must be set.
 */
function create_creative_wrapper_sample(
    string $formattedParent,
    string $formattedCreativeWrapperLabel,
    int $creativeWrapperCreativeWrapperType
): void {
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $creativeWrapper = (new CreativeWrapper())
        ->setLabel($formattedCreativeWrapperLabel)
        ->setCreativeWrapperType($creativeWrapperCreativeWrapperType);
    $request = (new CreateCreativeWrapperRequest())
        ->setParent($formattedParent)
        ->setCreativeWrapper($creativeWrapper);

    // Call the API and handle any network failures.
    try {
        /** @var CreativeWrapper $response */
        $response = $creativeWrapperServiceClient->createCreativeWrapper($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');
    $formattedCreativeWrapperLabel = CreativeWrapperServiceClient::labelName(
        '[NETWORK_CODE]',
        '[LABEL]'
    );
    $creativeWrapperCreativeWrapperType = CreativeWrapperType::CREATIVE_WRAPPER_TYPE_UNSPECIFIED;

    create_creative_wrapper_sample(
        $formattedParent,
        $formattedCreativeWrapperLabel,
        $creativeWrapperCreativeWrapperType
    );
}

getCreativeWrapper

Retrieves a CreativeWrapper object.

The async variant is CreativeWrapperServiceClient::getCreativeWrapperAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\GetCreativeWrapperRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\CreativeWrapper
Example
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\Ads\AdManager\V1\CreativeWrapper;
use Google\Ads\AdManager\V1\GetCreativeWrapperRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The resource name of the CreativeWrapper.
 *                              Format: `networks/{network_code}/creativeWrappers/{creative_wrapper_id}`
 *                              Please see {@see CreativeWrapperServiceClient::creativeWrapperName()} for help formatting this field.
 */
function get_creative_wrapper_sample(string $formattedName): void
{
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $request = (new GetCreativeWrapperRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var CreativeWrapper $response */
        $response = $creativeWrapperServiceClient->getCreativeWrapper($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = CreativeWrapperServiceClient::creativeWrapperName(
        '[NETWORK_CODE]',
        '[CREATIVE_WRAPPER]'
    );

    get_creative_wrapper_sample($formattedName);
}

listCreativeWrappers

Lists CreativeWrapper objects.

The async variant is CreativeWrapperServiceClient::listCreativeWrappersAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\ListCreativeWrappersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\Ads\AdManager\V1\ListCreativeWrappersRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;

/**
 * @param string $formattedParent The parent, which owns this collection of CreativeWrappers.
 *                                Format: `networks/{network_code}`
 *                                Please see {@see CreativeWrapperServiceClient::networkName()} for help formatting this field.
 */
function list_creative_wrappers_sample(string $formattedParent): void
{
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $request = (new ListCreativeWrappersRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $creativeWrapperServiceClient->listCreativeWrappers($request);

        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = CreativeWrapperServiceClient::networkName('[NETWORK_CODE]');

    list_creative_wrappers_sample($formattedParent);
}

updateCreativeWrapper

Updates a CreativeWrapper object.

The async variant is CreativeWrapperServiceClient::updateCreativeWrapperAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\UpdateCreativeWrapperRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\AdManager\V1\CreativeWrapper
Example
use Google\Ads\AdManager\V1\Client\CreativeWrapperServiceClient;
use Google\Ads\AdManager\V1\CreativeWrapper;
use Google\Ads\AdManager\V1\CreativeWrapperTypeEnum\CreativeWrapperType;
use Google\Ads\AdManager\V1\UpdateCreativeWrapperRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedCreativeWrapperLabel      Immutable. The resource name of the
 *                                                   [Label][google.ads.admanager.v1.Label].
 *                                                   Format:`networks/{network_code}/label/{label_id}`
 *                                                   Please see {@see CreativeWrapperServiceClient::labelName()} for help formatting this field.
 * @param int    $creativeWrapperCreativeWrapperType The `creative_wrapper_type`. If the `creative_wrapper_type` is
 *                                                   [CreativeWrapperType.VIDEO_TRACKING_URL][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.VIDEO_TRACKING_URL],
 *                                                   the `video_tracking_urls` field must be set. If the `creative_wrapper_type`
 *                                                   is
 *                                                   [CreativeWrapperType.HTML][google.ads.admanager.v1.CreativeWrapperTypeEnum.CreativeWrapperType.HTML],
 *                                                   either the header or footer field must be set.
 */
function update_creative_wrapper_sample(
    string $formattedCreativeWrapperLabel,
    int $creativeWrapperCreativeWrapperType
): void {
    // Create a client.
    $creativeWrapperServiceClient = new CreativeWrapperServiceClient();

    // Prepare the request message.
    $creativeWrapper = (new CreativeWrapper())
        ->setLabel($formattedCreativeWrapperLabel)
        ->setCreativeWrapperType($creativeWrapperCreativeWrapperType);
    $request = (new UpdateCreativeWrapperRequest())
        ->setCreativeWrapper($creativeWrapper);

    // Call the API and handle any network failures.
    try {
        /** @var CreativeWrapper $response */
        $response = $creativeWrapperServiceClient->updateCreativeWrapper($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedCreativeWrapperLabel = CreativeWrapperServiceClient::labelName(
        '[NETWORK_CODE]',
        '[LABEL]'
    );
    $creativeWrapperCreativeWrapperType = CreativeWrapperType::CREATIVE_WRAPPER_TYPE_UNSPECIFIED;

    update_creative_wrapper_sample($formattedCreativeWrapperLabel, $creativeWrapperCreativeWrapperType);
}

batchActivateCreativeWrappersAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchActivateCreativeWrappersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchActivateCreativeWrappersResponse>

batchCreateCreativeWrappersAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchCreateCreativeWrappersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchCreateCreativeWrappersResponse>

batchDeactivateCreativeWrappersAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchDeactivateCreativeWrappersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchDeactivateCreativeWrappersResponse>

batchUpdateCreativeWrappersAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchUpdateCreativeWrappersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchUpdateCreativeWrappersResponse>

createCreativeWrapperAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\CreateCreativeWrapperRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\CreativeWrapper>

getCreativeWrapperAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\GetCreativeWrapperRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\CreativeWrapper>

listCreativeWrappersAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\ListCreativeWrappersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updateCreativeWrapperAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\UpdateCreativeWrapperRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\CreativeWrapper>

static::creativeName

Formats a string containing the fully-qualified path to represent a creative resource.

Parameters
Name Description
networkCode string
creative string
Returns
Type Description
string The formatted creative resource.

static::creativeWrapperName

Formats a string containing the fully-qualified path to represent a creative_wrapper resource.

Parameters
Name Description
networkCode string
creativeWrapper string
Returns
Type Description
string The formatted creative_wrapper resource.

static::labelName

Formats a string containing the fully-qualified path to represent a label resource.

Parameters
Name Description
networkCode string
label string
Returns
Type Description
string The formatted label resource.

static::networkName

Formats a string containing the fully-qualified path to represent a network resource.

Parameter
Name Description
networkCode string
Returns
Type Description
string The formatted network resource.

static::thirdPartyCompanyName

Formats a string containing the fully-qualified path to represent a third_party_company resource.

Parameters
Name Description
networkCode string
thirdPartyCompany string
Returns
Type Description
string The formatted third_party_company resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • creative: networks/{network_code}/creatives/{creative}
  • creativeWrapper: networks/{network_code}/creativeWrappers/{creative_wrapper}
  • label: networks/{network_code}/labels/{label}
  • network: networks/{network_code}
  • thirdPartyCompany: networks/{network_code}/thirdPartyCompanies/{third_party_company}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template ?string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.