Skip to content

Commit d23be41

Browse files
author
Vincent Tsao
committed
Preparing src for release 5.6.0
1 parent 59e499c commit d23be41

File tree

8 files changed

+797
-1
lines changed

8 files changed

+797
-1
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* This example creates a new product base rate. To determine which base rates
4+
* exist, run GetAllBaseRates.php.
5+
*
6+
* Tags: BaseRateService.createBaseRates
7+
*
8+
* PHP version 5
9+
*
10+
* Copyright 2014, Google Inc. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*
24+
* @package GoogleApiAdsDfp
25+
* @subpackage v201411
26+
* @category WebServices
27+
* @copyright 2014, Google Inc. All Rights Reserved.
28+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
29+
* Version 2.0
30+
* @author Vincent Tsao
31+
*/
32+
error_reporting(E_STRICT | E_ALL);
33+
34+
// You can set the include path to src directory or reference
35+
// DfpUser.php directly via require_once.
36+
// $path = '/path/to/dfp_api_php_lib/src';
37+
$path = dirname(__FILE__) . '/../../../../src';
38+
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
39+
40+
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
41+
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
42+
43+
// Set the rate card ID to add the base rate to.
44+
$rateCardId = 'INSERT_RATE_CARD_ID_HERE';
45+
46+
// Set the product to apply this base rate to.
47+
$productId = 'INSERT_PRODUCT_ID_HERE';
48+
49+
try {
50+
// Get DfpUser from credentials in "../auth.ini"
51+
// relative to the DfpUser.php file's directory.
52+
$user = new DfpUser();
53+
54+
// Log SOAP XML request and response.
55+
$user->LogDefaults();
56+
57+
// Get the BaseRateService.
58+
$baseRateService = $user->GetService('BaseRateService', 'v201411');
59+
60+
// Create a base rate for a product.
61+
$productBaseRate = new ProductBaseRate();
62+
63+
// Set the rate card ID that the product base rate belongs to.
64+
$productBaseRate->rateCardId = $rateCardId;
65+
66+
// Set the product the base rate will be applied to.
67+
$productBaseRate->productId = $productId;
68+
69+
// Create a rate worth $2 and set that on the product base rate.
70+
$rate = new Money();
71+
$rate->currencyCode = 'USD';
72+
$rate->microAmount = 2000000;
73+
$productBaseRate->rate = $rate;
74+
75+
// Create the product base rate on the server.
76+
$baseRates = $baseRateService->createBaseRates(array($productBaseRate));
77+
78+
foreach ($baseRates as $createdBaseRate) {
79+
printf("A product base rate with ID %d and rate %.2f %s was created.\n",
80+
$createdBaseRate->id,
81+
$createdBaseRate->rate->microAmount / 1000000,
82+
$createdBaseRate->rate->currencyCode
83+
);
84+
}
85+
} catch (OAuth2Exception $e) {
86+
ExampleUtils::CheckForOAuth2Errors($e);
87+
} catch (ValidationException $e) {
88+
ExampleUtils::CheckForOAuth2Errors($e);
89+
} catch (Exception $e) {
90+
printf("%s\n", $e->getMessage());
91+
}
92+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* This example creates a new product template base rate. To determine which
4+
* base rates exist, run GetAllBaseRates.php.
5+
*
6+
* Tags: BaseRateService.createBaseRates
7+
*
8+
* PHP version 5
9+
*
10+
* Copyright 2014, Google Inc. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*
24+
* @package GoogleApiAdsDfp
25+
* @subpackage v201411
26+
* @category WebServices
27+
* @copyright 2014, Google Inc. All Rights Reserved.
28+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
29+
* Version 2.0
30+
* @author Vincent Tsao
31+
*/
32+
error_reporting(E_STRICT | E_ALL);
33+
34+
// You can set the include path to src directory or reference
35+
// DfpUser.php directly via require_once.
36+
// $path = '/path/to/dfp_api_php_lib/src';
37+
$path = dirname(__FILE__) . '/../../../../src';
38+
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
39+
40+
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
41+
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
42+
43+
// Set the rate card ID to add the base rate to.
44+
$rateCardId = 'INSERT_RATE_CARD_ID_HERE';
45+
46+
// Set the product template to apply this base rate to.
47+
$productTemplateId = 'INSERT_PRODUCT_TEMPLATE_ID_HERE';
48+
49+
try {
50+
// Get DfpUser from credentials in "../auth.ini"
51+
// relative to the DfpUser.php file's directory.
52+
$user = new DfpUser();
53+
54+
// Log SOAP XML request and response.
55+
$user->LogDefaults();
56+
57+
// Get the BaseRateService.
58+
$baseRateService = $user->GetService('BaseRateService', 'v201411');
59+
60+
// Create a base rate for a product template.
61+
$productTemplateBaseRate = new ProductTemplateBaseRate();
62+
63+
// Set the rate card ID that the product template base rate belongs to.
64+
$productTemplateBaseRate->rateCardId = $rateCardId;
65+
66+
// Set the product template the base rate will be applied to.
67+
$productTemplateBaseRate->productTemplateId = $productTemplateId;
68+
69+
// Create a rate worth $2 and set that on the product template base rate.
70+
$rate = new Money();
71+
$rate->currencyCode = 'USD';
72+
$rate->microAmount = 2000000;
73+
$productTemplateBaseRate->rate = $rate;
74+
75+
// Create the product template base rate on the server.
76+
$baseRates =
77+
$baseRateService->createBaseRates(array($productTemplateBaseRate));
78+
79+
foreach ($baseRates as $createdBaseRate) {
80+
printf("A product template base rate with ID %d and rate %.2f %s was "
81+
. "created.\n",
82+
$createdBaseRate->id,
83+
$createdBaseRate->rate->microAmount / 1000000,
84+
$createdBaseRate->rate->currencyCode
85+
);
86+
}
87+
} catch (OAuth2Exception $e) {
88+
ExampleUtils::CheckForOAuth2Errors($e);
89+
} catch (ValidationException $e) {
90+
ExampleUtils::CheckForOAuth2Errors($e);
91+
} catch (Exception $e) {
92+
printf("%s\n", $e->getMessage());
93+
}
94+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/**
3+
* This example creates a new exchange rate. To determine which exchange rates
4+
* exist, run GetAllExchangeRates.php.
5+
*
6+
* Tags: ExchangeRateService.createExchangeRates
7+
*
8+
* PHP version 5
9+
*
10+
* Copyright 2014, Google Inc. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*
24+
* @package GoogleApiAdsDfp
25+
* @subpackage v201411
26+
* @category WebServices
27+
* @copyright 2014, Google Inc. All Rights Reserved.
28+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
29+
* Version 2.0
30+
* @author Vincent Tsao
31+
*/
32+
error_reporting(E_STRICT | E_ALL);
33+
34+
// You can set the include path to src directory or reference
35+
// DfpUser.php directly via require_once.
36+
// $path = '/path/to/dfp_api_php_lib/src';
37+
$path = dirname(__FILE__) . '/../../../../src';
38+
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
39+
40+
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
41+
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
42+
43+
try {
44+
// Get DfpUser from credentials in "../auth.ini"
45+
// relative to the DfpUser.php file's directory.
46+
$user = new DfpUser();
47+
48+
// Log SOAP XML request and response.
49+
$user->LogDefaults();
50+
51+
// Get the ExchangeRateService.
52+
$exchangeRateService = $user->GetService('ExchangeRateService', 'v201411');
53+
54+
// Create an exchange rate.
55+
$exchangeRate = new ExchangeRate();
56+
57+
// Set the currency code.
58+
$exchangeRate->currencyCode = 'AUD';
59+
60+
// Set the direction of the conversion (from the network currency).
61+
$exchangeRate->direction = 'FROM_NETWORK';
62+
63+
// Set the conversion value as 1.5 (this value is multiplied by
64+
// 10,000,000,000)
65+
$exchangeRate->exchangeRate = 15000000000;
66+
67+
// Do not refresh exchange rate from Google data. Update manually only.
68+
$exchangeRate->refreshRate = 'FIXED';
69+
70+
// Create the exchange rate on the server.
71+
$exchangeRates =
72+
$exchangeRateService->createExchangeRates(array($exchangeRate));
73+
74+
foreach ($exchangeRates as $createdExchangeRate) {
75+
printf("An exchange rate with ID %d, currency code '%s', direction '%s', "
76+
. "and exchange rate %.2f was created.\n",
77+
$createdExchangeRate->id,
78+
$createdExchangeRate->currencyCode,
79+
$createdExchangeRate->direction,
80+
$createdExchangeRate->exchangeRate / 10000000000
81+
);
82+
}
83+
} catch (OAuth2Exception $e) {
84+
ExampleUtils::CheckForOAuth2Errors($e);
85+
} catch (ValidationException $e) {
86+
ExampleUtils::CheckForOAuth2Errors($e);
87+
} catch (Exception $e) {
88+
printf("%s\n", $e->getMessage());
89+
}
90+

examples/Dfp/v201411/ExchangeRateService/UpdateExchangeRates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
$updatedExchangeRate->id,
8383
$updatedExchangeRate->currencyCode,
8484
$updatedExchangeRate->direction,
85-
$updatedExchangeRate->exchangeRate
85+
$updatedExchangeRate->exchangeRate / 10000000000
8686
);
8787
}
8888
} catch (OAuth2Exception $e) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/**
3+
* This example creates a new premium rate for a specific rate card. To
4+
* determine which premium rates exist, run GetAllPremiumRates.php.
5+
*
6+
* Tags: PremiumRateService.createPremiumRates
7+
*
8+
* PHP version 5
9+
*
10+
* Copyright 2014, Google Inc. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*
24+
* @package GoogleApiAdsDfp
25+
* @subpackage v201411
26+
* @category WebServices
27+
* @copyright 2014, Google Inc. All Rights Reserved.
28+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
29+
* Version 2.0
30+
* @author Vincent Tsao
31+
*/
32+
error_reporting(E_STRICT | E_ALL);
33+
34+
// You can set the include path to src directory or reference
35+
// DfpUser.php directly via require_once.
36+
// $path = '/path/to/dfp_api_php_lib/src';
37+
$path = dirname(__FILE__) . '/../../../../src';
38+
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
39+
40+
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
41+
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
42+
43+
// Set the ID of the rate card to add premium rates to.
44+
$rateCardId = 'INSERT_RATE_CARD_ID_HERE';
45+
46+
try {
47+
// Get DfpUser from credentials in "../auth.ini"
48+
// relative to the DfpUser.php file's directory.
49+
$user = new DfpUser();
50+
51+
// Log SOAP XML request and response.
52+
$user->LogDefaults();
53+
54+
// Get the PremiumRateService.
55+
$premiumRateService = $user->GetService('PremiumRateService', 'v201411');
56+
57+
$premiumRate = new PremiumRate();
58+
59+
// Create an ad unit premium to apply to the rate card.
60+
$adUnitPremiumFeature = new AdUnitPremiumFeature();
61+
62+
// Create a CPM based premium rate value with adjustments in micro amounts.
63+
// This will adjust a CPM priced proposal line item that has inventory
64+
// targeting specified by 2 units of the currency associated with the rate
65+
// card (this comes from absolute value adjustment).
66+
$cpmPremiumRateValue = new PremiumRateValue();
67+
$cpmPremiumRateValue->premiumFeature = $adUnitPremiumFeature;
68+
$cpmPremiumRateValue->rateType = 'CPM';
69+
$cpmPremiumRateValue->adjustmentSize = 2000000;
70+
$cpmPremiumRateValue->adjustmentType = 'ABSOLUTE_VALUE';
71+
72+
// Create a CPC based premium rate value with adjustments in milli amounts.
73+
// This will adjust a CPC priced proposal line item that has inventory
74+
// targeting specified by 10% of the cost associated with the rate card (this
75+
// comes from a percentage adjustment).
76+
$cpcPremiumRateValue = new PremiumRateValue();
77+
$cpcPremiumRateValue->premiumFeature = $adUnitPremiumFeature;
78+
$cpcPremiumRateValue->rateType = 'CPC';
79+
$cpcPremiumRateValue->adjustmentSize = 10000;
80+
$cpcPremiumRateValue->adjustmentType = 'PERCENTAGE';
81+
82+
// Associate premium rate with the rate card and set premium information. This
83+
// premium will apply for proposal line items targeting 'any' ad unit for both
84+
// CPM and CPC rate types.
85+
$premiumRate->rateCardId = $rateCardId;
86+
$premiumRate->pricingMethod = 'ANY_VALUE';
87+
$premiumRate->premiumFeature = $adUnitPremiumFeature;
88+
$premiumRate->premiumRateValues =
89+
array($cpmPremiumRateValue, $cpcPremiumRateValue);
90+
91+
// Create the premium rate on the server.
92+
$premiumRates = $premiumRateService->createPremiumRates(array($premiumRate));
93+
94+
foreach ($premiumRates as $createdPremiumRate) {
95+
printf("A premium rate with ID %d, of type '%s', assigned to rate card "
96+
. "with ID %d was created.\n",
97+
$createdPremiumRate->id,
98+
$createdPremiumRate->premiumFeature->PremiumFeatureType,
99+
$createdPremiumRate->rateCardId
100+
);
101+
}
102+
} catch (OAuth2Exception $e) {
103+
ExampleUtils::CheckForOAuth2Errors($e);
104+
} catch (ValidationException $e) {
105+
ExampleUtils::CheckForOAuth2Errors($e);
106+
} catch (Exception $e) {
107+
printf("%s\n", $e->getMessage());
108+
}
109+

0 commit comments

Comments
 (0)