Skip to content

Commit

Permalink
Merge pull request #2 from googleads/release-stage
Browse files Browse the repository at this point in the history
Added support for v0_2.
  • Loading branch information
fiboknacky authored Jun 15, 2018
2 parents ac8563c + 673e9a2 commit 79f1910
Show file tree
Hide file tree
Showing 65 changed files with 811 additions and 271 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.0

* Added support for V0_2 of Google Ads API, which includes the Percent CPC
bidding strategy.

## 0.1.0

* Initial release with support for V0_1 of Google Ads API.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "googleads/google-ads-php",
"version": "0.1.0",
"author": "Google LLC",
"url": "https://github.com/googleads/google-ads-php",
"description": "Google Ads API client for PHP",
Expand Down
2 changes: 1 addition & 1 deletion examples/AccountManagement/GetAccountInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments(
$options = (new ArgumentParser())->parseCommandArguments(
[
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CAMPAIGN_BUDGET_ID => GetOpt::OPTIONAL_ARGUMENT
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/AddAdGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CAMPAIGN_ID => GetOpt::REQUIRED_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/AddCampaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT
]);

Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/AddExpandedTextAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/AddKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::KEYWORD_TEXT => GetOpt::OPTIONAL_ARGUMENT
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/GetAdGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CAMPAIGN_ID => GetOpt::OPTIONAL_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/GetArtifactMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::ARTIFACT_NAME => GetOpt::REQUIRED_ARGUMENT
]);

Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/GetCampaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT
]);

Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/GetExpandedTextAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::OPTIONAL_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/GetKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::OPTIONAL_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/PauseAd.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_ID => GetOpt::REQUIRED_ARGUMENT
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/RemoveAd.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_ID => GetOpt::REQUIRED_ARGUMENT
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/RemoveAdGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/RemoveCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CAMPAIGN_ID => GetOpt::REQUIRED_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/RemoveKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CRITERION_ID => GetOpt::REQUIRED_ARGUMENT
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/UpdateAdGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CPC_BID_MICRO_AMOUNT => GetOpt::REQUIRED_ARGUMENT
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/UpdateCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CAMPAIGN_ID => GetOpt::REQUIRED_ARGUMENT
]);
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicOperations/UpdateKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CRITERION_ID => GetOpt::REQUIRED_ARGUMENT
Expand Down
33 changes: 25 additions & 8 deletions examples/HotelAds/AddHotelAd.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Google\Ads\GoogleAds\V0\Common\Ad;
use Google\Ads\GoogleAds\V0\Common\HotelAdInfo;
use Google\Ads\GoogleAds\V0\Common\ManualCpc;
use Google\Ads\GoogleAds\V0\Common\PercentCpc;
use Google\Ads\GoogleAds\V0\Enums\AdGroupAdStatusEnum_AdGroupAdStatus;
use Google\Ads\GoogleAds\V0\Enums\AdGroupStatusEnum_AdGroupStatus;
use Google\Ads\GoogleAds\V0\Enums\AdGroupTypeEnum_AdGroupType;
Expand Down Expand Up @@ -66,14 +67,18 @@ class AddHotelAds
// This ID is the same account ID that you use in API requests to the Travel Partner APIs
// (https://developers.google.com/hotels/hotel-ads/api-reference/).
const HOTEL_CENTER_ACCOUNT_ID = 'INSERT_HOTEL_CENTER_ACCOUNT_ID_HERE';
// Specify maximum bid limit that can be set when creating a campaign using the Percent CPC
// bidding strategy.
const CPC_BID_CEILING_MICRO_AMOUNT = 20000000;

public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::HOTEL_CENTER_ACCOUNT_ID => GetOpt::REQUIRED_ARGUMENT
ArgumentNames::HOTEL_CENTER_ACCOUNT_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CPC_BID_CEILING_MICRO_AMOUNT => GetOpt::OPTIONAL_ARGUMENT
]);

// Generate a refreshable OAuth2 credential for authentication.
Expand All @@ -89,7 +94,9 @@ public static function main()
self::runExample(
$googleAdsClient,
$options[ArgumentNames::CUSTOMER_ID] ?: self::CUSTOMER_ID,
$options[ArgumentNames::HOTEL_CENTER_ACCOUNT_ID] ?: self::HOTEL_CENTER_ACCOUNT_ID
$options[ArgumentNames::HOTEL_CENTER_ACCOUNT_ID] ?: self::HOTEL_CENTER_ACCOUNT_ID,
$options[ArgumentNames::CPC_BID_CEILING_MICRO_AMOUNT]
?: self::CPC_BID_CEILING_MICRO_AMOUNT
);
} catch (GoogleAdsException $googleAdsException) {
printf(
Expand Down Expand Up @@ -122,11 +129,13 @@ public static function main()
* @param GoogleAdsClient $googleAdsClient the Google Ads API client
* @param int $customerId the client customer ID without hyphens
* @param int $hotelCenterAccountId the Hotel Center account ID
* @param int $cpcBidCeilingMicroAmount the CPC bid ceiling micro amount
*/
public static function runExample(
GoogleAdsClient $googleAdsClient,
$customerId,
$hotelCenterAccountId
$hotelCenterAccountId,
$cpcBidCeilingMicroAmount
) {
// Creates a budget to be used by the campaign that will be created below.
$budgetResourceName = self::addCampaignBudget($googleAdsClient, $customerId);
Expand All @@ -135,7 +144,8 @@ public static function runExample(
$googleAdsClient,
$customerId,
$budgetResourceName,
$hotelCenterAccountId
$hotelCenterAccountId,
$cpcBidCeilingMicroAmount
);
// Creates a hotel ad group.
$adGroupResourceName =
Expand Down Expand Up @@ -196,14 +206,16 @@ private static function addCampaignBudget(GoogleAdsClient $googleAdsClient, $cus
* @param int $customerId the client customer ID
* @param string $budgetResourceName the resource name of budget for a new campaign
* @param int $hotelCenterAccountId the Hotel Center account ID
* @param int $cpcBidCeilingMicroAmount the CPC bid ceiling micro amount
* @return string the resource name of the newly created campaign
*/
// [START addHotelCampaign]
private static function addHotelCampaign(
GoogleAdsClient $googleAdsClient,
$customerId,
$budgetResourceName,
$hotelCenterAccountId
$hotelCenterAccountId,
$cpcBidCeilingMicroAmount
) {
// Creates a campaign.
$campaign = new Campaign();
Expand All @@ -227,8 +239,13 @@ private static function addHotelCampaign(
// the ads from immediately serving. Set to ENABLED once you've added
// targeting and the ads are ready to serve.
$campaign->setStatus(CampaignStatusEnum_CampaignStatus::PAUSED);
// Sets the bidding strategy. Only Manual CPC can be used for hotel campaigns.
$campaign->setManualCpc(new ManualCpc());
// Sets the bidding strategy to PercentCpc. Only Manual CPC and Percent CPC can be used for
// hotel campaigns.
$percentCpc = new PercentCpc();
$wrappedCpcBidCeilingMicros = new Int64Value();
$wrappedCpcBidCeilingMicros->setValue($cpcBidCeilingMicroAmount);
$percentCpc->setCpcBidCeilingMicros($wrappedCpcBidCeilingMicros);
$campaign->setPercentCpc($percentCpc);

// Sets the budget.
$wrappedBudgetResourceName = new StringValue();
Expand Down
2 changes: 1 addition & 1 deletion examples/HotelAds/AddHotelAdGroupBidModifiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function main()
{
// Either pass the required parameters for this example on the command line, or insert them
// into the constants above.
$options = ArgumentParser::parseCommandArguments([
$options = (new ArgumentParser())->parseCommandArguments([
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::AD_GROUP_ID => GetOpt::REQUIRED_ARGUMENT,
ArgumentNames::CHECK_IN_DAY_CRITERION_ID => GetOpt::OPTIONAL_ARGUMENT
Expand Down
Loading

0 comments on commit 79f1910

Please sign in to comment.