Skip to content

Commit 9c2f1fe

Browse files
feat: [ShoppingMerchantConversions] add conversions API client libraries for v1 (#8490)
* feat: add conversions API client libraries for v1 PiperOrigin-RevId: 790723312 Source-Link: googleapis/googleapis@ef16549 Source-Link: googleapis/googleapis-gen@9207d35 Copy-Tag: eyJwIjoiU2hvcHBpbmdNZXJjaGFudENvbnZlcnNpb25zLy5Pd2xCb3QueWFtbCIsImgiOiI5MjA3ZDM1MGZhMWFmZTYxNDQxZmJkOTFkODhhZjAzYzlmY2MwYjI5In0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 0122ade commit 9c2f1fe

28 files changed

Lines changed: 3660 additions & 0 deletions
5.85 KB
Binary file not shown.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START merchantapi_v1_generated_ConversionSourcesService_CreateConversionSource_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Shopping\Merchant\Conversions\V1\Client\ConversionSourcesServiceClient;
28+
use Google\Shopping\Merchant\Conversions\V1\ConversionSource;
29+
use Google\Shopping\Merchant\Conversions\V1\CreateConversionSourceRequest;
30+
31+
/**
32+
* Creates a new conversion source.
33+
*
34+
* @param string $formattedParent The merchant account that will own the new conversion source.
35+
* Format: `accounts/{account}`
36+
* Please see {@see ConversionSourcesServiceClient::accountName()} for help formatting this field.
37+
*/
38+
function create_conversion_source_sample(string $formattedParent): void
39+
{
40+
// Create a client.
41+
$conversionSourcesServiceClient = new ConversionSourcesServiceClient();
42+
43+
// Prepare the request message.
44+
$conversionSource = new ConversionSource();
45+
$request = (new CreateConversionSourceRequest())
46+
->setParent($formattedParent)
47+
->setConversionSource($conversionSource);
48+
49+
// Call the API and handle any network failures.
50+
try {
51+
/** @var ConversionSource $response */
52+
$response = $conversionSourcesServiceClient->createConversionSource($request);
53+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
54+
} catch (ApiException $ex) {
55+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
56+
}
57+
}
58+
59+
/**
60+
* Helper to execute the sample.
61+
*
62+
* This sample has been automatically generated and should be regarded as a code
63+
* template only. It will require modifications to work:
64+
* - It may require correct/in-range values for request initialization.
65+
* - It may require specifying regional endpoints when creating the service client,
66+
* please see the apiEndpoint client configuration option for more details.
67+
*/
68+
function callSample(): void
69+
{
70+
$formattedParent = ConversionSourcesServiceClient::accountName('[ACCOUNT]');
71+
72+
create_conversion_source_sample($formattedParent);
73+
}
74+
// [END merchantapi_v1_generated_ConversionSourcesService_CreateConversionSource_sync]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START merchantapi_v1_generated_ConversionSourcesService_DeleteConversionSource_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Shopping\Merchant\Conversions\V1\Client\ConversionSourcesServiceClient;
28+
use Google\Shopping\Merchant\Conversions\V1\DeleteConversionSourceRequest;
29+
30+
/**
31+
* Archives an existing conversion source. If the conversion source is a
32+
* Merchant Center Destination, it will be recoverable for 30 days. If the
33+
* conversion source is a Google Analytics Link, it will be deleted
34+
* immediately and can be restored by creating a new one.
35+
*
36+
* @param string $formattedName The name of the conversion source to be deleted.
37+
* Format: `accounts/{account}/conversionSources/{conversion_source}`
38+
* Please see {@see ConversionSourcesServiceClient::conversionSourceName()} for help formatting this field.
39+
*/
40+
function delete_conversion_source_sample(string $formattedName): void
41+
{
42+
// Create a client.
43+
$conversionSourcesServiceClient = new ConversionSourcesServiceClient();
44+
45+
// Prepare the request message.
46+
$request = (new DeleteConversionSourceRequest())
47+
->setName($formattedName);
48+
49+
// Call the API and handle any network failures.
50+
try {
51+
$conversionSourcesServiceClient->deleteConversionSource($request);
52+
printf('Call completed successfully.' . PHP_EOL);
53+
} catch (ApiException $ex) {
54+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
55+
}
56+
}
57+
58+
/**
59+
* Helper to execute the sample.
60+
*
61+
* This sample has been automatically generated and should be regarded as a code
62+
* template only. It will require modifications to work:
63+
* - It may require correct/in-range values for request initialization.
64+
* - It may require specifying regional endpoints when creating the service client,
65+
* please see the apiEndpoint client configuration option for more details.
66+
*/
67+
function callSample(): void
68+
{
69+
$formattedName = ConversionSourcesServiceClient::conversionSourceName(
70+
'[ACCOUNT]',
71+
'[CONVERSION_SOURCE]'
72+
);
73+
74+
delete_conversion_source_sample($formattedName);
75+
}
76+
// [END merchantapi_v1_generated_ConversionSourcesService_DeleteConversionSource_sync]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START merchantapi_v1_generated_ConversionSourcesService_GetConversionSource_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Shopping\Merchant\Conversions\V1\Client\ConversionSourcesServiceClient;
28+
use Google\Shopping\Merchant\Conversions\V1\ConversionSource;
29+
use Google\Shopping\Merchant\Conversions\V1\GetConversionSourceRequest;
30+
31+
/**
32+
* Fetches a conversion source.
33+
*
34+
* @param string $formattedName The name of the conversion source to be fetched.
35+
* Format: `accounts/{account}/conversionSources/{conversion_source}`
36+
* Please see {@see ConversionSourcesServiceClient::conversionSourceName()} for help formatting this field.
37+
*/
38+
function get_conversion_source_sample(string $formattedName): void
39+
{
40+
// Create a client.
41+
$conversionSourcesServiceClient = new ConversionSourcesServiceClient();
42+
43+
// Prepare the request message.
44+
$request = (new GetConversionSourceRequest())
45+
->setName($formattedName);
46+
47+
// Call the API and handle any network failures.
48+
try {
49+
/** @var ConversionSource $response */
50+
$response = $conversionSourcesServiceClient->getConversionSource($request);
51+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
52+
} catch (ApiException $ex) {
53+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
54+
}
55+
}
56+
57+
/**
58+
* Helper to execute the sample.
59+
*
60+
* This sample has been automatically generated and should be regarded as a code
61+
* template only. It will require modifications to work:
62+
* - It may require correct/in-range values for request initialization.
63+
* - It may require specifying regional endpoints when creating the service client,
64+
* please see the apiEndpoint client configuration option for more details.
65+
*/
66+
function callSample(): void
67+
{
68+
$formattedName = ConversionSourcesServiceClient::conversionSourceName(
69+
'[ACCOUNT]',
70+
'[CONVERSION_SOURCE]'
71+
);
72+
73+
get_conversion_source_sample($formattedName);
74+
}
75+
// [END merchantapi_v1_generated_ConversionSourcesService_GetConversionSource_sync]
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START merchantapi_v1_generated_ConversionSourcesService_ListConversionSources_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\PagedListResponse;
28+
use Google\Shopping\Merchant\Conversions\V1\Client\ConversionSourcesServiceClient;
29+
use Google\Shopping\Merchant\Conversions\V1\ConversionSource;
30+
use Google\Shopping\Merchant\Conversions\V1\ListConversionSourcesRequest;
31+
32+
/**
33+
* Retrieves the list of conversion sources the caller has access to.
34+
*
35+
* @param string $formattedParent The merchant account who owns the collection of conversion
36+
* sources. Format: `accounts/{account}`
37+
* Please see {@see ConversionSourcesServiceClient::accountName()} for help formatting this field.
38+
*/
39+
function list_conversion_sources_sample(string $formattedParent): void
40+
{
41+
// Create a client.
42+
$conversionSourcesServiceClient = new ConversionSourcesServiceClient();
43+
44+
// Prepare the request message.
45+
$request = (new ListConversionSourcesRequest())
46+
->setParent($formattedParent);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var PagedListResponse $response */
51+
$response = $conversionSourcesServiceClient->listConversionSources($request);
52+
53+
/** @var ConversionSource $element */
54+
foreach ($response as $element) {
55+
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
56+
}
57+
} catch (ApiException $ex) {
58+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
59+
}
60+
}
61+
62+
/**
63+
* Helper to execute the sample.
64+
*
65+
* This sample has been automatically generated and should be regarded as a code
66+
* template only. It will require modifications to work:
67+
* - It may require correct/in-range values for request initialization.
68+
* - It may require specifying regional endpoints when creating the service client,
69+
* please see the apiEndpoint client configuration option for more details.
70+
*/
71+
function callSample(): void
72+
{
73+
$formattedParent = ConversionSourcesServiceClient::accountName('[ACCOUNT]');
74+
75+
list_conversion_sources_sample($formattedParent);
76+
}
77+
// [END merchantapi_v1_generated_ConversionSourcesService_ListConversionSources_sync]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START merchantapi_v1_generated_ConversionSourcesService_UndeleteConversionSource_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Shopping\Merchant\Conversions\V1\Client\ConversionSourcesServiceClient;
28+
use Google\Shopping\Merchant\Conversions\V1\ConversionSource;
29+
use Google\Shopping\Merchant\Conversions\V1\UndeleteConversionSourceRequest;
30+
31+
/**
32+
* Re-enables an archived conversion source. Only Available for Merchant
33+
* Center Destination conversion sources.
34+
*
35+
* @param string $formattedName The name of the conversion source to be undeleted.
36+
* Format: `accounts/{account}/conversionSources/{conversion_source}`
37+
* Please see {@see ConversionSourcesServiceClient::conversionSourceName()} for help formatting this field.
38+
*/
39+
function undelete_conversion_source_sample(string $formattedName): void
40+
{
41+
// Create a client.
42+
$conversionSourcesServiceClient = new ConversionSourcesServiceClient();
43+
44+
// Prepare the request message.
45+
$request = (new UndeleteConversionSourceRequest())
46+
->setName($formattedName);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var ConversionSource $response */
51+
$response = $conversionSourcesServiceClient->undeleteConversionSource($request);
52+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
53+
} catch (ApiException $ex) {
54+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
55+
}
56+
}
57+
58+
/**
59+
* Helper to execute the sample.
60+
*
61+
* This sample has been automatically generated and should be regarded as a code
62+
* template only. It will require modifications to work:
63+
* - It may require correct/in-range values for request initialization.
64+
* - It may require specifying regional endpoints when creating the service client,
65+
* please see the apiEndpoint client configuration option for more details.
66+
*/
67+
function callSample(): void
68+
{
69+
$formattedName = ConversionSourcesServiceClient::conversionSourceName(
70+
'[ACCOUNT]',
71+
'[CONVERSION_SOURCE]'
72+
);
73+
74+
undelete_conversion_source_sample($formattedName);
75+
}
76+
// [END merchantapi_v1_generated_ConversionSourcesService_UndeleteConversionSource_sync]

0 commit comments

Comments
 (0)