From 4430b418ff8cb7d75f83191fcc673b7d3d2cc075 Mon Sep 17 00:00:00 2001 From: Michael Cloonan Date: Fri, 14 Mar 2014 12:03:26 -0400 Subject: [PATCH] New version of AdX plus cleaning up READMEs to .md --- ads_common/{README => README.md} | 0 adwords_api/{README => README.md} | 0 adx_buyer_api/ChangeLog | 5 + adx_buyer_api/{README => README.md} | 213 ++++++++++-------- .../v201302/reporting/get_campaign_stats.rb | 105 --------- .../v201309/reporting/get_campaign_stats.rb | 113 ---------- .../account_management/get_account_changes.rb | 10 +- .../basic_operations/add_ad_group.rb | 10 +- .../basic_operations/add_campaign.rb | 27 ++- .../basic_operations/add_placements.rb | 10 +- .../add_thirdparty_redirect_ad.rb | 21 +- .../basic_operations/delete_ad.rb | 10 +- .../basic_operations/delete_ad_group.rb | 10 +- .../basic_operations/delete_campaign.rb | 10 +- .../basic_operations/delete_placement.rb | 10 +- .../basic_operations/get_ad_groups.rb | 10 +- .../basic_operations/get_campaigns.rb | 10 +- .../basic_operations/get_placements.rb | 10 +- .../get_thirdparty_redirect_ads.rb | 10 +- .../basic_operations/pause_ad.rb | 10 +- .../basic_operations/update_ad_group.rb | 10 +- .../basic_operations/update_campaign.rb | 10 +- .../basic_operations/update_placement.rb | 10 +- .../add_placements_in_bulk.rb | 10 +- .../get_all_disapproved_ads.rb | 10 +- .../handle_captcha_challenge.rb | 2 +- .../error_handling/handle_partial_failures.rb | 10 +- .../handle_policy_violation_error.rb | 10 +- .../handle_two_factor_authorization_error.rb | 2 +- .../misc/get_all_images_and_videos.rb | 10 +- .../misc/setup_oauth2.rb} | 43 ++-- .../{v201302 => v201402}/misc/upload_image.rb | 10 +- .../misc/use_oauth2_jwt.rb | 2 +- .../optimization/get_placement_ideas.rb | 10 +- .../remarketing/add_audience.rb | 14 +- .../remarketing/add_conversion_tracker.rb | 10 +- .../reporting/download_criteria_report.rb | 10 +- .../reporting/get_report_fields.rb | 10 +- .../add_campaign_targeting_criteria.rb | 10 +- .../get_campaign_targeting_criteria.rb | 10 +- .../get_targetable_languages_and_carriers.rb | 10 +- .../targeting/lookup_location.rb | 10 +- adx_buyer_api/google-adx-buyer-api.gemspec | 2 +- dfp_api/{README => README.md} | 0 44 files changed, 451 insertions(+), 388 deletions(-) rename ads_common/{README => README.md} (100%) rename adwords_api/{README => README.md} (100%) rename adx_buyer_api/{README => README.md} (51%) delete mode 100755 adx_buyer_api/examples/v201302/reporting/get_campaign_stats.rb delete mode 100755 adx_buyer_api/examples/v201309/reporting/get_campaign_stats.rb rename adx_buyer_api/examples/{v201302 => v201402}/account_management/get_account_changes.rb (91%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/add_ad_group.rb (86%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/add_campaign.rb (78%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/add_placements.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/add_thirdparty_redirect_ad.rb (83%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/delete_ad.rb (84%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/delete_ad_group.rb (83%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/delete_campaign.rb (83%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/delete_placement.rb (86%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/get_ad_groups.rb (84%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/get_campaigns.rb (84%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/get_placements.rb (86%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/get_thirdparty_redirect_ads.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/pause_ad.rb (84%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/update_ad_group.rb (83%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/update_campaign.rb (84%) rename adx_buyer_api/examples/{v201302 => v201402}/basic_operations/update_placement.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/campaign_management/add_placements_in_bulk.rb (91%) rename adx_buyer_api/examples/{v201302 => v201402}/campaign_management/get_all_disapproved_ads.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/error_handling/handle_captcha_challenge.rb (99%) rename adx_buyer_api/examples/{v201302 => v201402}/error_handling/handle_partial_failures.rb (89%) rename adx_buyer_api/examples/{v201302 => v201402}/error_handling/handle_policy_violation_error.rb (91%) rename adx_buyer_api/examples/{v201302 => v201402}/error_handling/handle_two_factor_authorization_error.rb (99%) rename adx_buyer_api/examples/{v201302 => v201402}/misc/get_all_images_and_videos.rb (87%) rename adx_buyer_api/examples/{v201302/misc/use_oauth2.rb => v201402/misc/setup_oauth2.rb} (74%) rename adx_buyer_api/examples/{v201302 => v201402}/misc/upload_image.rb (86%) rename adx_buyer_api/examples/{v201302 => v201402}/misc/use_oauth2_jwt.rb (99%) rename adx_buyer_api/examples/{v201302 => v201402}/optimization/get_placement_ideas.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/remarketing/add_audience.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/remarketing/add_conversion_tracker.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/reporting/download_criteria_report.rb (85%) rename adx_buyer_api/examples/{v201302 => v201402}/reporting/get_report_fields.rb (83%) rename adx_buyer_api/examples/{v201302 => v201402}/targeting/add_campaign_targeting_criteria.rb (88%) rename adx_buyer_api/examples/{v201302 => v201402}/targeting/get_campaign_targeting_criteria.rb (87%) rename adx_buyer_api/examples/{v201302 => v201402}/targeting/get_targetable_languages_and_carriers.rb (85%) rename adx_buyer_api/examples/{v201302 => v201402}/targeting/lookup_location.rb (88%) rename dfp_api/{README => README.md} (100%) diff --git a/ads_common/README b/ads_common/README.md similarity index 100% rename from ads_common/README rename to ads_common/README.md diff --git a/adwords_api/README b/adwords_api/README.md similarity index 100% rename from adwords_api/README rename to adwords_api/README.md diff --git a/adx_buyer_api/ChangeLog b/adx_buyer_api/ChangeLog index 8f8e0b1fc..ea10bac11 100644 --- a/adx_buyer_api/ChangeLog +++ b/adx_buyer_api/ChangeLog @@ -1,3 +1,8 @@ +0.4.9: + - Now require google-adwords-api-0.11.1 or later. + - Added examples for v201402. + - Removed examples for sunset API versions. + 0.4.8: - Now require google-adwords-api-0.11.0 or later. - Added examples for v201309. diff --git a/adx_buyer_api/README b/adx_buyer_api/README.md similarity index 51% rename from adx_buyer_api/README rename to adx_buyer_api/README.md index 0a0a51216..ef6bd5ad1 100644 --- a/adx_buyer_api/README +++ b/adx_buyer_api/README.md @@ -1,4 +1,4 @@ -= Google AdWords and DoubleClick Ad Exchange Buyer Client Library +# Google AdWords and DoubleClick Ad Exchange Buyer Client Library Welcome to the next generation Google-developed Ruby client library for the AdWords and DoubleClick Ad Exchange Buyer API! @@ -8,126 +8,139 @@ a simplified programming interface that lets you handle everything in native Ruby collections. -= Docs for Users +# Docs for Users -== 1 - Installation: +## 1 - Installation: -google-adwords-api and google-adx-buyer-api are ruby gems. - See http://docs.rubygems.org/read/book/1 +`google-adwords-api` and `google-adx-buyer-api` are ruby gems. See: + +> [http://docs.rubygems.org/read/book/1]() Install them using the gem install command: - $ gem install --remote google-adwords-api - $ gem install --remote google-adx-buyer-api -Please note the google-adx-buyer-api gem contains only DoubleClick Ad Exchange + $ gem install --remote google-adwords-api + $ gem install --remote google-adx-buyer-api + +Please note the `google-adx-buyer-api` gem contains only DoubleClick Ad Exchange Buyer client library examples. You need the AdWords library in order to use it which is installed automatically as a dependency. The following gem libraries are required: - - savon; - - google-ads-common. + - savon + - google-ads-common -== 2 - Using the client library: + +## 2 - Using the client library: Include the library with 'require': - require 'adwords_api' + + require 'adwords_api' Then create an API instance: - adwords = AdwordsApi::Api.new + + adwords = AdwordsApi::Api.new The created API object will grant you access to all the services for all of the currently supported vesions of the APIs. It uses a config file in: - ENV['HOME']/adwords_api.yml to read all of your configurations by default. + + ENV['HOME']/adwords_api.yml to read all of your configurations by default. There is an example configuration file shipped with these libraries. You can also pass API a manually constructed config hash like: - adwords = AdwordsApi::Api.new({ - :authentication => { - :method => 'OAuth2', - :oauth2_client_id: 'INSERT_OAUTH2_CLIENT_ID_HERE' - :oauth2_client_secret: 'INSERT_OAUTH2_CLIENT_SECRET_HERE' - :developer_token => 'DEVELOPER_TOKEN', - :client_customer_id => '012-345-6789', - :user_agent => 'Ruby Sample' - }, - :service => { - :environment => 'PRODUCTION' - } - }) - -To obtain OAuth2 client credentials, follow instructions on the wiki: - - http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2 + + adwords = AdwordsApi::Api.new({ + :authentication => { + :method => 'OAuth2', + :oauth2_client_id: 'INSERT_OAUTH2_CLIENT_ID_HERE' + :oauth2_client_secret: 'INSERT_OAUTH2_CLIENT_SECRET_HERE' + :developer_token => 'DEVELOPER_TOKEN', + :client_customer_id => '012-345-6789', + :user_agent => 'Ruby Sample' + }, + :service => { + :environment => 'PRODUCTION' + } + }) + +To obtain OAuth2 client credentials, follow instructions +[on the wiki](https://github.com/googleads/google-api-ads-ruby/wiki/OAuth2). Once the library instance is create, specify which service you're looking to use, and which version: - campaign_srv = adwords.service(:CampaignService, :v201306) -and you should now be able to just use the API methods in the object you were + campaign_srv = adwords.service(:CampaignService, :v201306) + +You should now be able to just use the API methods in the object you were returned: - # Get 'Id', 'Name' and 'Status' fields of all campaigns. - campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']}) + + # Get 'Id', 'Name' and 'Status' fields of all campaigns. + campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']}) See the code in the examples directory for working examples you can build from. *Note*: if your setup requires you to send connections through a proxy server, please set the appropriate options in the config file or config hash. E.g.: - config[:connection] = { - :proxy => 'http://user:password@proxy_hostname:8080' - } + + config[:connection] = { + :proxy => 'http://user:password@proxy_hostname:8080' + } *Note*: if you are using Ruby 1.8 you may need to include RubyGems to be able to require other gems code. There are several ways to do it, the easiest one is to pass '-rubygems' parameter to the ruby interpreter: - $ ruby -rubygems my_program_that_uses_gems -you can also set this up in the environment: - $ export RUBYOPT="rubygems" + $ ruby -rubygems my_program_that_uses_gems + +You can also set this up in the environment: + + $ export RUBYOPT="rubygems" + +Or add it to the bash configuration file: -or add it to the bash configuration file: - $ echo 'export RUBYOPT="rubygems"' >> ~/.bashrc + $ echo 'export RUBYOPT="rubygems"' >> ~/.bashrc -=== 2.1 - Ruby names for a Ruby library: +### 2.1 - Ruby names for a Ruby library: In order to make things more Ruby-like for our Ruby developers, we've renamed API objects and methods to more closely match Ruby conventions. This means using snake_case for methods and parameters, and UpperCamelCase for class names. -For example, the 'startDate' field of the Campaign object is named 'start_date' -in the client library. The 'get' method, returns a CampaignPage object which has -an 'entries' and a 'total_num_entries' field. So, to access the return +For example, the `startDate` field of the Campaign object is named `start_date` +in the client library. The `get` method, returns a CampaignPage object which has +an `entries` and a `total_num_entries` field. So, to access the return values, you would do this: - response = campaign_srv.get(selector) - num_entries = response[:total_num_entries] + response = campaign_srv.get(selector) + num_entries = response[:total_num_entries] Essentially, all you have to do is follow Ruby conventions, and the library will do the rest. All of the examples are written following this standard. -=== 2.2 - Using the Test Account: +### 2.2 - Using the Test Account: For testing purposes, obtain a Test Account in the production environment. Any -request against a Test Account inccurs no API units charge. See this guide for -more details: +request against a Test Account inccurs no API units charge. See +[this guide](https://developers.google.com/adwords/api/docs/test-accounts) for +more details. - https://developers.google.com/adwords/api/docs/test-accounts +To use the library against a Test Account, set the `client_customer_id property` +in the configuration file to its client customer ID. -To use the library against a Test Account, set client_customer_id property in -the configuration file to its client customer ID. - -=== 2.3 - Logging: +### 2.3 - Logging: It is often useful to see a trace of the raw SOAP XML being sent and received. The quickest way of achieving this when debugging your application is by setting the library.log_level configuration variable to 'DEBUG': - config[:library] = { - :log_level => 'DEBUG' - } + + config[:library] = { + :log_level => 'DEBUG' + } + or via configuration file (see example). This will output the SOAP XML to stderr, which will usually show up in your @@ -135,89 +148,92 @@ terminal window. There's also an option of logging requests and XML to a file. In order to enable this, you should create a standard Logger object and pass it to the library: - require 'logger' - logger = Logger.new('path/to/log_filename') - logger.level = Logger::DEBUG - adwords = AdwordsApi::Api.new - adwords.logger = logger + + require 'logger' + logger = Logger.new('path/to/log_filename') + logger.level = Logger::DEBUG + adwords = AdwordsApi::Api.new + adwords.logger = logger Request details and units spend are logged at the INFO log level, while raw HTTP headers and XML dumps are logged at the DEBUG log level. For more details on using Logger refer to the Ruby Logger documentation. -=== 2.4 - Calculating operations usage +### 2.4 - Calculating operations usage Each AdWords API operation performed consumes a certain number of operations as -described in the rate sheet: - - https://developers.google.com/adwords/api/docs/ratesheet +described in the +[rate sheet](https://developers.google.com/adwords/api/docs/ratesheet). The amount of operations consumed is returned in the header part of the SOAP response. This information can be obtained by passing a user block during the method call: - response = campaign_srv.get(selector) do |header| - puts "Operations consumed: %d" % header[:operations] - end + response = campaign_srv.get(selector) do |header| + puts "Operations consumed: %d" % header[:operations] + end You can also retrieve the response body as the second block parameter: - campaign_srv.get(selector) {|header, body| ... } -=== 2.5 - GZip compression + campaign_srv.get(selector) {|header, body| ... } + +### 2.5 - GZip compression The library offers a transparent compression option which can be enabled in the configuration file or by the following setting: - config[:connection] = { - :enable_gzip => true - } + config[:connection] = { + :enable_gzip => true + } Enabling this option will set the headers required to request the server to respond in gzipped format. All requests are sent uncompressed regardless. -= Docs for Developers +# Docs for Developers -== Rake targets +## Rake targets + + $ rake generate - $ rake generate to regenerate the stubs if needed - $ gem build google-adwords-api.gemspec - $ gem build google-adx-buyer-api.gemspec + $ gem build google-adwords-api.gemspec + $ gem build google-adx-buyer-api.gemspec + to build the gems - $ rake test -to run unit tests on the library + $ rake test +to run unit tests on the library -== Where do I submit bug reports and feature requests? -Bug reports and feature requests can be posted on the library page: +## Where do I submit bug reports and feature requests? - http://code.google.com/p/google-api-ads-ruby/issues +Bug reports and feature requests can be posted on the +[library page](https://github.com/googleads/google-api-ads-ruby/issues). Questions can be asked on forum - http://groups.google.com/group/adwords-api +> [http://groups.google.com/group/adwords-api]() Make sure to subscribe to our Google Plus page for API change announcements and other news: - https://plus.google.com/+GoogleAdsDevelopers +> [https://plus.google.com/+GoogleAdsDevelopers]() -= Copyright/License Info +# Copyright/License Info -== Licence +## Licence -Copyright 2010-2013, Google Inc. All Rights Reserved. +Copyright 2010-2014, Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +> [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, @@ -225,11 +241,14 @@ 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. -== Authors +## Authors Authors: - api.sgomes (Sérgio Gomes) - api.dklimkin@gmail.com (Danial Klimkin) + + - api.sgomes (Sérgio Gomes) + - api.dklimkin@gmail.com (Danial Klimkin) + - api.mcloonan@gmail.com (Michael Cloonan) Maintainer: - api.dklimkin@gmail.com (Danial Klimkin) + + - api.mcloonan@gmail.com (Michael Cloonan) diff --git a/adx_buyer_api/examples/v201302/reporting/get_campaign_stats.rb b/adx_buyer_api/examples/v201302/reporting/get_campaign_stats.rb deleted file mode 100755 index 50770beba..000000000 --- a/adx_buyer_api/examples/v201302/reporting/get_campaign_stats.rb +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env ruby -# Encoding: utf-8 -# -# Author:: api.dklimkin@gmail.com (Danial Klimkin) -# -# Copyright:: Copyright 2012, Google Inc. All Rights Reserved. -# -# License:: Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# 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 gets various statistics for campaigns that received at least one -# impression during the last week. To get campaigns, run get_campaigns.rb. -# -# Tags: CampaignService.get - -require 'adwords_api' -require 'date' - -def get_campaign_stats() - # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml - # when called without parameters. - adwords = AdwordsApi::Api.new - - # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in - # the configuration file or provide your own logger: - # adwords.logger = Logger.new('adwords_xml.log') - - campaign_srv = adwords.service(:CampaignService, API_VERSION) - - # Prepare start and end date for the last week. - start_date = DateTime.parse((Date.today - 7).to_s).strftime("%Y%m%d") - end_date = DateTime.parse((Date.today - 1).to_s).strftime("%Y%m%d") - - # Get all the campaigns for this account. - selector = { - :fields => ['Id', 'Name', 'Impressions', 'Clicks', 'Cost', 'Ctr'], - :predicates => [ - {:field => 'Impressions', :operator => 'GREATER_THAN', :values => [0]} - ], - :date_range => {:min => start_date, :max => end_date}, - :paging => { - :start_index => 0, - :number_results => PAGE_SIZE - } - } - - # Set initial values. - offset, page = 0, {} - - begin - page = campaign_srv.get(selector) - if page[:entries] - page[:entries].each do |campaign| - puts ("Campaign with ID %d, name '%s' had the following stats during" + - " the last week: ") % [campaign[:id], campaign[:name]] - stats = campaign[:campaign_stats] - puts "\tImpressions: %d" % stats[:impressions] - puts "\tClicks: %d" % stats[:clicks] - puts "\tCost: %.2f" % (stats[:cost][:micro_amount] / 1000000) - puts "\tCTR: %.2f%%" % (stats[:ctr] * 100) - end - # Increment values to request the next page. - offset += PAGE_SIZE - selector[:paging][:start_index] = offset - end - end while page[:total_num_entries] > offset - - if page.include?(:total_num_entries) - puts "Total number of campaigns found: %d." % [page[:total_num_entries]] - end -end - -if __FILE__ == $0 - API_VERSION = :v201302 - PAGE_SIZE = 500 - - begin - get_campaign_stats() - - # HTTP errors. - rescue AdsCommon::Errors::HttpError => e - puts "HTTP Error: %s" % e - - # API errors. - rescue AdwordsApi::Errors::ApiException => e - puts "Message: %s" % e.message - puts 'Errors:' - e.errors.each_with_index do |error, index| - puts "\tError [%d]:" % (index + 1) - error.each do |field, value| - puts "\t\t%s: %s" % [field, value] - end - end - end -end diff --git a/adx_buyer_api/examples/v201309/reporting/get_campaign_stats.rb b/adx_buyer_api/examples/v201309/reporting/get_campaign_stats.rb deleted file mode 100755 index 7987632f2..000000000 --- a/adx_buyer_api/examples/v201309/reporting/get_campaign_stats.rb +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env ruby -# Encoding: utf-8 -# -# Author:: api.dklimkin@gmail.com (Danial Klimkin) -# -# Copyright:: Copyright 2012, Google Inc. All Rights Reserved. -# -# License:: Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# 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 gets various statistics for campaigns that received at least one -# impression during the last week. To get campaigns, run get_campaigns.rb. -# -# Tags: CampaignService.get - -require 'adwords_api' -require 'date' - -def get_campaign_stats() - # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml - # when called without parameters. - adwords = AdwordsApi::Api.new - - # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in - # the configuration file or provide your own logger: - # adwords.logger = Logger.new('adwords_xml.log') - - campaign_srv = adwords.service(:CampaignService, API_VERSION) - - # Prepare start and end date for the last week. - start_date = DateTime.parse((Date.today - 7).to_s).strftime("%Y%m%d") - end_date = DateTime.parse((Date.today - 1).to_s).strftime("%Y%m%d") - - # Get all the campaigns for this account. - selector = { - :fields => ['Id', 'Name', 'Impressions', 'Clicks', 'Cost', 'Ctr'], - :predicates => [ - {:field => 'Impressions', :operator => 'GREATER_THAN', :values => [0]} - ], - :date_range => {:min => start_date, :max => end_date}, - :paging => { - :start_index => 0, - :number_results => PAGE_SIZE - } - } - - # Set initial values. - offset, page = 0, {} - - begin - page = campaign_srv.get(selector) - if page[:entries] - page[:entries].each do |campaign| - puts ("Campaign with ID %d, name '%s' had the following stats during" + - " the last week: ") % [campaign[:id], campaign[:name]] - stats = campaign[:campaign_stats] - puts "\tImpressions: %d" % stats[:impressions] - puts "\tClicks: %d" % stats[:clicks] - puts "\tCost: %.2f" % (stats[:cost][:micro_amount] / 1000000) - puts "\tCTR: %.2f%%" % (stats[:ctr] * 100) - end - # Increment values to request the next page. - offset += PAGE_SIZE - selector[:paging][:start_index] = offset - end - end while page[:total_num_entries] > offset - - if page.include?(:total_num_entries) - puts "Total number of campaigns found: %d." % [page[:total_num_entries]] - end -end - -if __FILE__ == $0 - API_VERSION = :v201309 - PAGE_SIZE = 500 - - begin - get_campaign_stats() - - # Authorization error. - rescue AdsCommon::Errors::OAuth2VerificationRequired => e - puts "Authorization credentials are not valid. Edit adwords_api.yml for " + - "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + - "to retrieve and store OAuth2 tokens." - puts "See this wiki page for more details:\n\n " + - 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' - - # HTTP errors. - rescue AdsCommon::Errors::HttpError => e - puts "HTTP Error: %s" % e - - # API errors. - rescue AdwordsApi::Errors::ApiException => e - puts "Message: %s" % e.message - puts 'Errors:' - e.errors.each_with_index do |error, index| - puts "\tError [%d]:" % (index + 1) - error.each do |field, value| - puts "\t\t%s: %s" % [field, value] - end - end - end -end diff --git a/adx_buyer_api/examples/v201302/account_management/get_account_changes.rb b/adx_buyer_api/examples/v201402/account_management/get_account_changes.rb similarity index 91% rename from adx_buyer_api/examples/v201302/account_management/get_account_changes.rb rename to adx_buyer_api/examples/v201402/account_management/get_account_changes.rb index 6c1a6ea6c..bab0576bf 100755 --- a/adx_buyer_api/examples/v201302/account_management/get_account_changes.rb +++ b/adx_buyer_api/examples/v201402/account_management/get_account_changes.rb @@ -114,11 +114,19 @@ def get_account_changes() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin get_account_changes() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/add_ad_group.rb b/adx_buyer_api/examples/v201402/basic_operations/add_ad_group.rb similarity index 86% rename from adx_buyer_api/examples/v201302/basic_operations/add_ad_group.rb rename to adx_buyer_api/examples/v201402/basic_operations/add_ad_group.rb index 45fe4d4fa..0593655da 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/add_ad_group.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/add_ad_group.rb @@ -64,12 +64,20 @@ def add_ad_group(campaign_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i add_ad_group(campaign_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/add_campaign.rb b/adx_buyer_api/examples/v201402/basic_operations/add_campaign.rb similarity index 78% rename from adx_buyer_api/examples/v201302/basic_operations/add_campaign.rb rename to adx_buyer_api/examples/v201402/basic_operations/add_campaign.rb index 436099e59..186733a1b 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/add_campaign.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/add_campaign.rb @@ -55,19 +55,26 @@ def add_campaign() :operand => { :name => 'Interplanetary Cruise #%s' % (Time.new.to_f * 1000).to_i, :status => 'PAUSED', + :advertising_channel_type => 'DISPLAY', :bidding_strategy_configuration => { :bidding_strategy_type => 'MANUAL_CPM' }, :budget => {:budget_id => budget_id}, - # Set the campaign network options to Search and Search Network. + :start_date => (Date.today + 1).strftime('%Y%m%d'), + :end_date => (Date.today + 365).strftime('%Y%m%d'), + :ad_serving_optimization_status => 'ROTATE', :network_setting => { - :target_google_search => false, - :target_search_network => false, :target_content_network => true }, :settings => [ - {:xsi_type => 'RealTimeBiddingSetting', :opt_in => 'true'} - ] + {:xsi_type => 'RealTimeBiddingSetting', :opt_in => 'true'}, + {:xsi_type => 'KeywordMatchSetting', :opt_in => 'true'} + ], + :frequency_cap => { + :impressions => 5, + :time_unit => 'DAY', + :level => 'ADGROUP' + } } } @@ -79,11 +86,19 @@ def add_campaign() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin add_campaign() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/add_placements.rb b/adx_buyer_api/examples/v201402/basic_operations/add_placements.rb similarity index 87% rename from adx_buyer_api/examples/v201302/basic_operations/add_placements.rb rename to adx_buyer_api/examples/v201402/basic_operations/add_placements.rb index b58e0aaf6..056df994a 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/add_placements.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/add_placements.rb @@ -75,12 +75,20 @@ def add_placements(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i add_placements(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/add_thirdparty_redirect_ad.rb b/adx_buyer_api/examples/v201402/basic_operations/add_thirdparty_redirect_ad.rb similarity index 83% rename from adx_buyer_api/examples/v201302/basic_operations/add_thirdparty_redirect_ad.rb rename to adx_buyer_api/examples/v201402/basic_operations/add_thirdparty_redirect_ad.rb index 4281e3623..fbc86b7b0 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/add_thirdparty_redirect_ad.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/add_thirdparty_redirect_ad.rb @@ -49,12 +49,15 @@ def add_thirdparty_redirect_ad(ad_group_id) :width => 300 }, # This field normally contains the javascript ad tag. - :snippet => - '', - :certified_vendor_format_id => 119, + :snippet => '', + # DoubleClick Rich Media Expandable format ID. + :certified_vendor_format_id => 232, :is_cookie_targeted => false, :is_user_interest_targeted => false, - :is_tagged => false + :is_tagged => false, + # Expandable Ad properties. + :expanding_directions => ['EXPANDING_UP', 'EXPANDING_DOWN'], + :ad_attributes => ['ROLL_OVER_TO_EXPAND'] } # Create in-stream third party redirect ad. @@ -101,13 +104,21 @@ def add_thirdparty_redirect_ad(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin # Ad group ID to add text ads to. ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i add_thirdparty_redirect_ad(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/delete_ad.rb b/adx_buyer_api/examples/v201402/basic_operations/delete_ad.rb similarity index 84% rename from adx_buyer_api/examples/v201302/basic_operations/delete_ad.rb rename to adx_buyer_api/examples/v201402/basic_operations/delete_ad.rb index 38fc9e2fc..a9d968fff 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/delete_ad.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/delete_ad.rb @@ -55,13 +55,21 @@ def delete_ad(ad_group_id, ad_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i ad_id = 'INSERT_AD_ID_HERE'.to_i delete_ad(ad_group_id, ad_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/delete_ad_group.rb b/adx_buyer_api/examples/v201402/basic_operations/delete_ad_group.rb similarity index 83% rename from adx_buyer_api/examples/v201302/basic_operations/delete_ad_group.rb rename to adx_buyer_api/examples/v201402/basic_operations/delete_ad_group.rb index 2207a0a40..8e868ac77 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/delete_ad_group.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/delete_ad_group.rb @@ -52,12 +52,20 @@ def delete_ad_group(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i delete_ad_group(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/delete_campaign.rb b/adx_buyer_api/examples/v201402/basic_operations/delete_campaign.rb similarity index 83% rename from adx_buyer_api/examples/v201302/basic_operations/delete_campaign.rb rename to adx_buyer_api/examples/v201402/basic_operations/delete_campaign.rb index 6139b2d97..3f33ca32d 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/delete_campaign.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/delete_campaign.rb @@ -53,12 +53,20 @@ def delete_campaign(campaign_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i delete_campaign(campaign_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/delete_placement.rb b/adx_buyer_api/examples/v201402/basic_operations/delete_placement.rb similarity index 86% rename from adx_buyer_api/examples/v201302/basic_operations/delete_placement.rb rename to adx_buyer_api/examples/v201402/basic_operations/delete_placement.rb index 25b8b3d28..114d68656 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/delete_placement.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/delete_placement.rb @@ -60,7 +60,7 @@ def delete_placement(ad_group_id, criterion_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin # IDs of criterion to delete and its ad group. @@ -68,6 +68,14 @@ def delete_placement(ad_group_id, criterion_id) criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i delete_placement(ad_group_id, criterion_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/get_ad_groups.rb b/adx_buyer_api/examples/v201402/basic_operations/get_ad_groups.rb similarity index 84% rename from adx_buyer_api/examples/v201302/basic_operations/get_ad_groups.rb rename to adx_buyer_api/examples/v201402/basic_operations/get_ad_groups.rb index 0a3112610..6ad877250 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/get_ad_groups.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/get_ad_groups.rb @@ -56,12 +56,20 @@ def get_all_ad_groups(campaign_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i get_all_ad_groups(campaign_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/get_campaigns.rb b/adx_buyer_api/examples/v201402/basic_operations/get_campaigns.rb similarity index 84% rename from adx_buyer_api/examples/v201302/basic_operations/get_campaigns.rb rename to adx_buyer_api/examples/v201402/basic_operations/get_campaigns.rb index 123f11f72..b69a3aec1 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/get_campaigns.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/get_campaigns.rb @@ -54,11 +54,19 @@ def get_all_campaigns() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin get_all_campaigns() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/get_placements.rb b/adx_buyer_api/examples/v201402/basic_operations/get_placements.rb similarity index 86% rename from adx_buyer_api/examples/v201302/basic_operations/get_placements.rb rename to adx_buyer_api/examples/v201402/basic_operations/get_placements.rb index 918d91e84..1ae8871c1 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/get_placements.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/get_placements.rb @@ -68,12 +68,20 @@ def get_placements(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i get_placements(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/get_thirdparty_redirect_ads.rb b/adx_buyer_api/examples/v201402/basic_operations/get_thirdparty_redirect_ads.rb similarity index 87% rename from adx_buyer_api/examples/v201302/basic_operations/get_thirdparty_redirect_ads.rb rename to adx_buyer_api/examples/v201402/basic_operations/get_thirdparty_redirect_ads.rb index a9f2ec2d8..40dad0cdb 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/get_thirdparty_redirect_ads.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/get_thirdparty_redirect_ads.rb @@ -76,12 +76,20 @@ def get_all_ads(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i get_all_ads(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/pause_ad.rb b/adx_buyer_api/examples/v201402/basic_operations/pause_ad.rb similarity index 84% rename from adx_buyer_api/examples/v201302/basic_operations/pause_ad.rb rename to adx_buyer_api/examples/v201402/basic_operations/pause_ad.rb index 95d89854c..90005b498 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/pause_ad.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/pause_ad.rb @@ -56,13 +56,21 @@ def pause_ad(ad_group_id, ad_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i ad_id = 'INSERT_AD_ID_HERE'.to_i pause_ad(ad_group_id, ad_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/update_ad_group.rb b/adx_buyer_api/examples/v201402/basic_operations/update_ad_group.rb similarity index 83% rename from adx_buyer_api/examples/v201302/basic_operations/update_ad_group.rb rename to adx_buyer_api/examples/v201402/basic_operations/update_ad_group.rb index c2221582b..94556bc84 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/update_ad_group.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/update_ad_group.rb @@ -52,12 +52,20 @@ def update_ad_group(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i update_ad_group(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/update_campaign.rb b/adx_buyer_api/examples/v201402/basic_operations/update_campaign.rb similarity index 84% rename from adx_buyer_api/examples/v201302/basic_operations/update_campaign.rb rename to adx_buyer_api/examples/v201402/basic_operations/update_campaign.rb index 39b538cb0..e70fda5f5 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/update_campaign.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/update_campaign.rb @@ -55,12 +55,20 @@ def update_campaign(campaign_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i update_campaign(campaign_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/basic_operations/update_placement.rb b/adx_buyer_api/examples/v201402/basic_operations/update_placement.rb similarity index 87% rename from adx_buyer_api/examples/v201302/basic_operations/update_placement.rb rename to adx_buyer_api/examples/v201402/basic_operations/update_placement.rb index ae7393819..66a51a57b 100755 --- a/adx_buyer_api/examples/v201302/basic_operations/update_placement.rb +++ b/adx_buyer_api/examples/v201402/basic_operations/update_placement.rb @@ -69,13 +69,21 @@ def update_placement(ad_group_id, placement_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i placement_id = 'INSERT_PLACEMENT_ID_HERE'.to_i update_placement(ad_group_id, placement_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/campaign_management/add_placements_in_bulk.rb b/adx_buyer_api/examples/v201402/campaign_management/add_placements_in_bulk.rb similarity index 91% rename from adx_buyer_api/examples/v201302/campaign_management/add_placements_in_bulk.rb rename to adx_buyer_api/examples/v201402/campaign_management/add_placements_in_bulk.rb index 10a2da9bb..44f11f00d 100755 --- a/adx_buyer_api/examples/v201302/campaign_management/add_placements_in_bulk.rb +++ b/adx_buyer_api/examples/v201402/campaign_management/add_placements_in_bulk.rb @@ -124,7 +124,7 @@ def add_placements_in_bulk(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 RETRY_INTERVAL = 30 RETRIES_COUNT = 30 PLACEMENT_NUMBER = 100 @@ -133,6 +133,14 @@ def add_placements_in_bulk(ad_group_id) ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i add_placements_in_bulk(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/campaign_management/get_all_disapproved_ads.rb b/adx_buyer_api/examples/v201402/campaign_management/get_all_disapproved_ads.rb similarity index 87% rename from adx_buyer_api/examples/v201302/campaign_management/get_all_disapproved_ads.rb rename to adx_buyer_api/examples/v201402/campaign_management/get_all_disapproved_ads.rb index 88226aadf..c27451a9f 100755 --- a/adx_buyer_api/examples/v201302/campaign_management/get_all_disapproved_ads.rb +++ b/adx_buyer_api/examples/v201402/campaign_management/get_all_disapproved_ads.rb @@ -68,12 +68,20 @@ def get_all_disapproved_ads(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i get_all_disapproved_ads(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/error_handling/handle_captcha_challenge.rb b/adx_buyer_api/examples/v201402/error_handling/handle_captcha_challenge.rb similarity index 99% rename from adx_buyer_api/examples/v201302/error_handling/handle_captcha_challenge.rb rename to adx_buyer_api/examples/v201402/error_handling/handle_captcha_challenge.rb index e5341953d..3402370a1 100755 --- a/adx_buyer_api/examples/v201302/error_handling/handle_captcha_challenge.rb +++ b/adx_buyer_api/examples/v201402/error_handling/handle_captcha_challenge.rb @@ -69,7 +69,7 @@ def handle_captcha_challenge() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 MAX_RETRIES = 500 begin diff --git a/adx_buyer_api/examples/v201302/error_handling/handle_partial_failures.rb b/adx_buyer_api/examples/v201402/error_handling/handle_partial_failures.rb similarity index 89% rename from adx_buyer_api/examples/v201302/error_handling/handle_partial_failures.rb rename to adx_buyer_api/examples/v201402/error_handling/handle_partial_failures.rb index ea78561eb..8b2ea7814 100755 --- a/adx_buyer_api/examples/v201302/error_handling/handle_partial_failures.rb +++ b/adx_buyer_api/examples/v201402/error_handling/handle_partial_failures.rb @@ -93,12 +93,20 @@ def handle_partial_failures(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i handle_partial_failures(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/error_handling/handle_policy_violation_error.rb b/adx_buyer_api/examples/v201402/error_handling/handle_policy_violation_error.rb similarity index 91% rename from adx_buyer_api/examples/v201302/error_handling/handle_policy_violation_error.rb rename to adx_buyer_api/examples/v201402/error_handling/handle_policy_violation_error.rb index 044f6c155..9db0e6ff6 100755 --- a/adx_buyer_api/examples/v201302/error_handling/handle_policy_violation_error.rb +++ b/adx_buyer_api/examples/v201402/error_handling/handle_policy_violation_error.rb @@ -114,12 +114,20 @@ def handle_policy_violation_error(ad_group_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i handle_policy_violation_error(ad_group_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/error_handling/handle_two_factor_authorization_error.rb b/adx_buyer_api/examples/v201402/error_handling/handle_two_factor_authorization_error.rb similarity index 99% rename from adx_buyer_api/examples/v201302/error_handling/handle_two_factor_authorization_error.rb rename to adx_buyer_api/examples/v201402/error_handling/handle_two_factor_authorization_error.rb index 00baa6170..de8de7dd8 100755 --- a/adx_buyer_api/examples/v201302/error_handling/handle_two_factor_authorization_error.rb +++ b/adx_buyer_api/examples/v201402/error_handling/handle_two_factor_authorization_error.rb @@ -65,7 +65,7 @@ def handle_two_factor_authorization_error() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin handle_two_factor_authorization_error() diff --git a/adx_buyer_api/examples/v201302/misc/get_all_images_and_videos.rb b/adx_buyer_api/examples/v201402/misc/get_all_images_and_videos.rb similarity index 87% rename from adx_buyer_api/examples/v201302/misc/get_all_images_and_videos.rb rename to adx_buyer_api/examples/v201402/misc/get_all_images_and_videos.rb index 3896376fa..c08ac0580 100755 --- a/adx_buyer_api/examples/v201302/misc/get_all_images_and_videos.rb +++ b/adx_buyer_api/examples/v201402/misc/get_all_images_and_videos.rb @@ -76,12 +76,20 @@ def get_all_images_and_videos() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 PAGE_SIZE = 500 begin get_all_images_and_videos() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/misc/use_oauth2.rb b/adx_buyer_api/examples/v201402/misc/setup_oauth2.rb similarity index 74% rename from adx_buyer_api/examples/v201302/misc/use_oauth2.rb rename to adx_buyer_api/examples/v201402/misc/setup_oauth2.rb index 9b29f2b16..f2a6d24be 100755 --- a/adx_buyer_api/examples/v201302/misc/use_oauth2.rb +++ b/adx_buyer_api/examples/v201402/misc/setup_oauth2.rb @@ -3,7 +3,7 @@ # # Author:: api.dklimkin@gmail.com (Danial Klimkin) # -# Copyright:: Copyright 2012, Google Inc. All Rights Reserved. +# Copyright:: Copyright 2013, Google Inc. All Rights Reserved. # # License:: Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,13 +18,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# This example illustrates how to use OAuth2.0 authentication method. +# This example illustrates how to set up OAuth2.0 authentication credentials. # # Tags: CampaignService.get require 'adwords_api' -def use_oauth2() +def setup_oauth2() # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml # when called without parameters. adwords = AdwordsApi::Api.new @@ -42,6 +42,17 @@ def use_oauth2() verification_code = gets.chomp verification_code end + if token + print "\nWould you like to update your adwords_api.yml to save " + + "OAuth2 crdentials? (y/N): " + response = gets.chomp + if ('y'.casecmp(response) == 0) or ('yes'.casecmp(response) == 0) + adwords.save_oauth2_token(token) + puts 'OAuth2 token is now saved to ~/adwords_api.yml and will be ' + + 'automatically used by the library.' + end + end + # Alternatively, you can provide one within the parameters: #token = adwords.authorize({:oauth2_verification_code => verification_code}) @@ -50,34 +61,14 @@ def use_oauth2() # should persist it to be used in subsequent invocations like this: #adwords.authorize({:oauth2_token => token}) - # No exception thrown - we are good to make the request. - campaign_srv = adwords.service(:CampaignService, API_VERSION) - - # Get all the campaigns for this account; empty selector. - selector = { - :fields => ['Id', 'Name', 'Status'], - :ordering => [ - {:field => 'Name', :sort_order => 'ASCENDING'} - ] - } - - response = campaign_srv.get(selector) - if response and response[:entries] - campaigns = response[:entries] - campaigns.each do |campaign| - puts "Campaign ID %d, name '%s' and status '%s'" % - [campaign[:id], campaign[:name], campaign[:status]] - end - else - puts 'No campaigns were found.' - end + # No exception thrown - we are good to make a request. end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin - use_oauth2() + setup_oauth2() # HTTP errors. rescue AdsCommon::Errors::HttpError => e diff --git a/adx_buyer_api/examples/v201302/misc/upload_image.rb b/adx_buyer_api/examples/v201402/misc/upload_image.rb similarity index 86% rename from adx_buyer_api/examples/v201302/misc/upload_image.rb rename to adx_buyer_api/examples/v201402/misc/upload_image.rb index 2c8ec8fd8..a859e6545 100755 --- a/adx_buyer_api/examples/v201302/misc/upload_image.rb +++ b/adx_buyer_api/examples/v201402/misc/upload_image.rb @@ -66,11 +66,19 @@ def upload_image() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin upload_image() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/misc/use_oauth2_jwt.rb b/adx_buyer_api/examples/v201402/misc/use_oauth2_jwt.rb similarity index 99% rename from adx_buyer_api/examples/v201302/misc/use_oauth2_jwt.rb rename to adx_buyer_api/examples/v201402/misc/use_oauth2_jwt.rb index 01b4d843d..cb042a070 100755 --- a/adx_buyer_api/examples/v201302/misc/use_oauth2_jwt.rb +++ b/adx_buyer_api/examples/v201402/misc/use_oauth2_jwt.rb @@ -74,7 +74,7 @@ def use_oauth2_jwt() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin use_oauth2_jwt() diff --git a/adx_buyer_api/examples/v201302/optimization/get_placement_ideas.rb b/adx_buyer_api/examples/v201402/optimization/get_placement_ideas.rb similarity index 87% rename from adx_buyer_api/examples/v201302/optimization/get_placement_ideas.rb rename to adx_buyer_api/examples/v201402/optimization/get_placement_ideas.rb index 2c1c252a2..3bebc8872 100755 --- a/adx_buyer_api/examples/v201302/optimization/get_placement_ideas.rb +++ b/adx_buyer_api/examples/v201402/optimization/get_placement_ideas.rb @@ -79,13 +79,21 @@ def get_placement_ideas(url) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 PAGE_SIZE = 100 begin url = 'INSERT_PLACEMENT_URL_HERE' get_placement_ideas(url) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/remarketing/add_audience.rb b/adx_buyer_api/examples/v201402/remarketing/add_audience.rb similarity index 87% rename from adx_buyer_api/examples/v201302/remarketing/add_audience.rb rename to adx_buyer_api/examples/v201402/remarketing/add_audience.rb index 79a4617c2..3f40610f7 100755 --- a/adx_buyer_api/examples/v201302/remarketing/add_audience.rb +++ b/adx_buyer_api/examples/v201402/remarketing/add_audience.rb @@ -34,7 +34,7 @@ def add_audience() # the configuration file or provide your own logger: # adwords.logger = Logger.new('adwords_xml.log') - user_list_srv = adwords.service(:UserListService, API_VERSION) + user_list_srv = adwords.service(:AdwordsUserListService, API_VERSION) conv_tracker_srv = adwords.service(:ConversionTrackerService, API_VERSION) # Prepare for adding remarketing user list. @@ -45,7 +45,7 @@ def add_audience() # The 'xsi_type' field allows you to specify the xsi:type of the object # being created. It's only necessary when you must provide an explicit # type that the client library can't infer. - :xsi_type => 'RemarketingUserList', + :xsi_type => 'BasicUserList', :name => name, :description => 'A list of mars cruise customers in the last year', :status => 'OPEN', @@ -92,11 +92,19 @@ def add_audience() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin add_audience() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/remarketing/add_conversion_tracker.rb b/adx_buyer_api/examples/v201402/remarketing/add_conversion_tracker.rb similarity index 87% rename from adx_buyer_api/examples/v201302/remarketing/add_conversion_tracker.rb rename to adx_buyer_api/examples/v201402/remarketing/add_conversion_tracker.rb index 3f65f6087..f3893e104 100755 --- a/adx_buyer_api/examples/v201302/remarketing/add_conversion_tracker.rb +++ b/adx_buyer_api/examples/v201402/remarketing/add_conversion_tracker.rb @@ -73,11 +73,19 @@ def add_conversion_tracker() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin add_conversion_tracker() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/reporting/download_criteria_report.rb b/adx_buyer_api/examples/v201402/reporting/download_criteria_report.rb similarity index 85% rename from adx_buyer_api/examples/v201302/reporting/download_criteria_report.rb rename to adx_buyer_api/examples/v201402/reporting/download_criteria_report.rb index 86ef10ddf..1e70d98b7 100755 --- a/adx_buyer_api/examples/v201302/reporting/download_criteria_report.rb +++ b/adx_buyer_api/examples/v201402/reporting/download_criteria_report.rb @@ -61,13 +61,21 @@ def download_criteria_report(file_name) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin # File name to write report to. file_name = 'INSERT_OUTPUT_FILE_NAME_HERE' download_criteria_report(file_name) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/reporting/get_report_fields.rb b/adx_buyer_api/examples/v201402/reporting/get_report_fields.rb similarity index 83% rename from adx_buyer_api/examples/v201302/reporting/get_report_fields.rb rename to adx_buyer_api/examples/v201402/reporting/get_report_fields.rb index a51f04251..240c18c31 100755 --- a/adx_buyer_api/examples/v201302/reporting/get_report_fields.rb +++ b/adx_buyer_api/examples/v201402/reporting/get_report_fields.rb @@ -47,12 +47,20 @@ def get_report_fields(report_type) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin report_type = 'INSERT_REPORT_TYPE_HERE' get_report_fields(report_type) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/targeting/add_campaign_targeting_criteria.rb b/adx_buyer_api/examples/v201402/targeting/add_campaign_targeting_criteria.rb similarity index 88% rename from adx_buyer_api/examples/v201302/targeting/add_campaign_targeting_criteria.rb rename to adx_buyer_api/examples/v201402/targeting/add_campaign_targeting_criteria.rb index 1e707ea1c..fb51510f3 100755 --- a/adx_buyer_api/examples/v201302/targeting/add_campaign_targeting_criteria.rb +++ b/adx_buyer_api/examples/v201402/targeting/add_campaign_targeting_criteria.rb @@ -83,12 +83,20 @@ def add_campaign_targeting_criteria(campaign_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin campaign_id = 'INSERT_CAMPAIGN_ID_HERE' add_campaign_targeting_criteria(campaign_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/targeting/get_campaign_targeting_criteria.rb b/adx_buyer_api/examples/v201402/targeting/get_campaign_targeting_criteria.rb similarity index 87% rename from adx_buyer_api/examples/v201302/targeting/get_campaign_targeting_criteria.rb rename to adx_buyer_api/examples/v201402/targeting/get_campaign_targeting_criteria.rb index dd0d59e93..50c57a41f 100755 --- a/adx_buyer_api/examples/v201302/targeting/get_campaign_targeting_criteria.rb +++ b/adx_buyer_api/examples/v201402/targeting/get_campaign_targeting_criteria.rb @@ -78,7 +78,7 @@ def get_campaign_targeting_criteria(campaign_id) end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 PAGE_SIZE = 500 begin @@ -86,6 +86,14 @@ def get_campaign_targeting_criteria(campaign_id) campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i get_campaign_targeting_criteria(campaign_id) + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/targeting/get_targetable_languages_and_carriers.rb b/adx_buyer_api/examples/v201402/targeting/get_targetable_languages_and_carriers.rb similarity index 85% rename from adx_buyer_api/examples/v201302/targeting/get_targetable_languages_and_carriers.rb rename to adx_buyer_api/examples/v201402/targeting/get_targetable_languages_and_carriers.rb index 3544f1a03..5eadf062a 100755 --- a/adx_buyer_api/examples/v201302/targeting/get_targetable_languages_and_carriers.rb +++ b/adx_buyer_api/examples/v201402/targeting/get_targetable_languages_and_carriers.rb @@ -63,11 +63,19 @@ def get_targetable_languages_and_carriers() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin get_targetable_languages_and_carriers() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/examples/v201302/targeting/lookup_location.rb b/adx_buyer_api/examples/v201402/targeting/lookup_location.rb similarity index 88% rename from adx_buyer_api/examples/v201302/targeting/lookup_location.rb rename to adx_buyer_api/examples/v201402/targeting/lookup_location.rb index 616c33544..4113c5a3b 100755 --- a/adx_buyer_api/examples/v201302/targeting/lookup_location.rb +++ b/adx_buyer_api/examples/v201402/targeting/lookup_location.rb @@ -81,11 +81,19 @@ def lookup_location() end if __FILE__ == $0 - API_VERSION = :v201302 + API_VERSION = :v201402 begin lookup_location() + # Authorization error. + rescue AdsCommon::Errors::OAuth2VerificationRequired => e + puts "Authorization credentials are not valid. Edit adwords_api.yml for " + + "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " + + "to retrieve and store OAuth2 tokens." + puts "See this wiki page for more details:\n\n " + + 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2' + # HTTP errors. rescue AdsCommon::Errors::HttpError => e puts "HTTP Error: %s" % e diff --git a/adx_buyer_api/google-adx-buyer-api.gemspec b/adx_buyer_api/google-adx-buyer-api.gemspec index 54e23378d..7647440e4 100644 --- a/adx_buyer_api/google-adx-buyer-api.gemspec +++ b/adx_buyer_api/google-adx-buyer-api.gemspec @@ -32,5 +32,5 @@ Gem::Specification.new do |s| s.rubyforge_project = 'google-adx-buyer-api' s.require_path = 'lib' s.files = Dir.glob('examples/**/*') + %w(COPYING README ChangeLog) - s.add_dependency('google-adwords-api', '~> 0.11.0') + s.add_dependency('google-adwords-api', '~> 0.11.1') end diff --git a/dfp_api/README b/dfp_api/README.md similarity index 100% rename from dfp_api/README rename to dfp_api/README.md