google-adx-buyer-api 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/ChangeLog +5 -1
  2. data/README +12 -9
  3. data/examples/v201206/campaign_management/add_placements_in_bulk.rb +1 -1
  4. data/examples/v201209/campaign_management/add_placements_in_bulk.rb +1 -1
  5. data/examples/v201209/error_handling/handle_two_factor_authorization_error.rb +2 -1
  6. data/examples/v201209/misc/get_all_images_and_videos.rb +3 -4
  7. data/examples/v201209/misc/upload_image.rb +11 -9
  8. data/examples/{v201109_1/misc/use_oauth.rb → v201209/misc/use_oauth2.rb} +24 -24
  9. data/examples/v201209/misc/{use_oauth.rb → use_oauth2_jwt.rb} +19 -23
  10. data/examples/v201209/optimization/get_placement_ideas.rb +1 -3
  11. data/examples/v201209/remarketing/add_audience.rb +27 -23
  12. data/examples/v201209/remarketing/add_conversion_tracker.rb +8 -4
  13. data/examples/v201209/targeting/get_targetable_languages_and_carriers.rb +7 -3
  14. metadata +34 -132
  15. data/examples/v201109/account_management/get_account_changes.rb +0 -137
  16. data/examples/v201109/basic_operations/add_ad_group.rb +0 -88
  17. data/examples/v201109/basic_operations/add_campaign.rb +0 -98
  18. data/examples/v201109/basic_operations/add_placements.rb +0 -99
  19. data/examples/v201109/basic_operations/add_thirdparty_redirect_ad.rb +0 -105
  20. data/examples/v201109/basic_operations/delete_ad.rb +0 -80
  21. data/examples/v201109/basic_operations/delete_ad_group.rb +0 -76
  22. data/examples/v201109/basic_operations/delete_campaign.rb +0 -77
  23. data/examples/v201109/basic_operations/delete_placement.rb +0 -86
  24. data/examples/v201109/basic_operations/get_ad_groups.rb +0 -80
  25. data/examples/v201109/basic_operations/get_campaigns.rb +0 -77
  26. data/examples/v201109/basic_operations/get_placements.rb +0 -92
  27. data/examples/v201109/basic_operations/get_thirdparty_redirect_ads.rb +0 -100
  28. data/examples/v201109/basic_operations/pause_ad.rb +0 -81
  29. data/examples/v201109/basic_operations/update_ad_group.rb +0 -76
  30. data/examples/v201109/basic_operations/update_campaign.rb +0 -79
  31. data/examples/v201109/basic_operations/update_placement.rb +0 -94
  32. data/examples/v201109/campaign_management/add_placements_in_bulk.rb +0 -151
  33. data/examples/v201109/campaign_management/get_all_disapproved_ads.rb +0 -92
  34. data/examples/v201109/error_handling/handle_captcha_challenge.rb +0 -93
  35. data/examples/v201109/error_handling/handle_partial_failures.rb +0 -117
  36. data/examples/v201109/error_handling/handle_policy_violation_error.rb +0 -138
  37. data/examples/v201109/error_handling/handle_two_factor_authorization_error.rb +0 -87
  38. data/examples/v201109/misc/get_all_images_and_videos.rb +0 -101
  39. data/examples/v201109/misc/upload_image.rb +0 -87
  40. data/examples/v201109/misc/use_oauth.rb +0 -97
  41. data/examples/v201109/optimization/get_placement_ideas.rb +0 -106
  42. data/examples/v201109/remarketing/add_audience.rb +0 -111
  43. data/examples/v201109/remarketing/add_conversion_tracker.rb +0 -93
  44. data/examples/v201109/reporting/download_criteria_report.rb +0 -79
  45. data/examples/v201109/reporting/download_defined_report.rb +0 -67
  46. data/examples/v201109/reporting/get_campaign_stats.rb +0 -105
  47. data/examples/v201109/reporting/get_defined_reports.rb +0 -75
  48. data/examples/v201109/reporting/get_report_fields.rb +0 -71
  49. data/examples/v201109/reporting/parallel_report_download.rb +0 -159
  50. data/examples/v201109/targeting/add_campaign_targeting_criteria.rb +0 -110
  51. data/examples/v201109/targeting/get_campaign_targeting_criteria.rb +0 -104
  52. data/examples/v201109/targeting/get_targetable_languages_and_carriers.rb +0 -82
  53. data/examples/v201109/targeting/lookup_location.rb +0 -103
  54. data/examples/v201109_1/account_management/get_account_changes.rb +0 -137
  55. data/examples/v201109_1/basic_operations/add_ad_group.rb +0 -88
  56. data/examples/v201109_1/basic_operations/add_campaign.rb +0 -98
  57. data/examples/v201109_1/basic_operations/add_placements.rb +0 -99
  58. data/examples/v201109_1/basic_operations/add_thirdparty_redirect_ad.rb +0 -105
  59. data/examples/v201109_1/basic_operations/delete_ad.rb +0 -80
  60. data/examples/v201109_1/basic_operations/delete_ad_group.rb +0 -76
  61. data/examples/v201109_1/basic_operations/delete_campaign.rb +0 -77
  62. data/examples/v201109_1/basic_operations/delete_placement.rb +0 -86
  63. data/examples/v201109_1/basic_operations/get_ad_groups.rb +0 -80
  64. data/examples/v201109_1/basic_operations/get_campaigns.rb +0 -77
  65. data/examples/v201109_1/basic_operations/get_placements.rb +0 -92
  66. data/examples/v201109_1/basic_operations/get_thirdparty_redirect_ads.rb +0 -100
  67. data/examples/v201109_1/basic_operations/pause_ad.rb +0 -81
  68. data/examples/v201109_1/basic_operations/update_ad_group.rb +0 -76
  69. data/examples/v201109_1/basic_operations/update_campaign.rb +0 -79
  70. data/examples/v201109_1/basic_operations/update_placement.rb +0 -94
  71. data/examples/v201109_1/campaign_management/add_placements_in_bulk.rb +0 -151
  72. data/examples/v201109_1/campaign_management/get_all_disapproved_ads.rb +0 -92
  73. data/examples/v201109_1/error_handling/handle_captcha_challenge.rb +0 -93
  74. data/examples/v201109_1/error_handling/handle_partial_failures.rb +0 -117
  75. data/examples/v201109_1/error_handling/handle_policy_violation_error.rb +0 -138
  76. data/examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb +0 -87
  77. data/examples/v201109_1/misc/get_all_images_and_videos.rb +0 -101
  78. data/examples/v201109_1/misc/upload_image.rb +0 -87
  79. data/examples/v201109_1/optimization/get_placement_ideas.rb +0 -106
  80. data/examples/v201109_1/remarketing/add_audience.rb +0 -111
  81. data/examples/v201109_1/remarketing/add_conversion_tracker.rb +0 -93
  82. data/examples/v201109_1/reporting/download_criteria_report.rb +0 -79
  83. data/examples/v201109_1/reporting/download_defined_report.rb +0 -67
  84. data/examples/v201109_1/reporting/get_campaign_stats.rb +0 -105
  85. data/examples/v201109_1/reporting/get_defined_reports.rb +0 -75
  86. data/examples/v201109_1/reporting/get_report_fields.rb +0 -71
  87. data/examples/v201109_1/reporting/parallel_report_download.rb +0 -159
  88. data/examples/v201109_1/targeting/add_campaign_targeting_criteria.rb +0 -110
  89. data/examples/v201109_1/targeting/get_campaign_targeting_criteria.rb +0 -104
  90. data/examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb +0 -82
  91. data/examples/v201109_1/targeting/lookup_location.rb +0 -103
  92. data/examples/v201209/reporting/parallel_report_download.rb +0 -159
@@ -1,81 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # Encoding: utf-8
3
- #
4
- # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
- #
6
- # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
7
- #
8
- # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
- # implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
- # This example illustrates how to pause an ad, setting its status to 'PAUSED'.
22
- # To create ads, run add_thirdparty_redirect_ad.rb.
23
- #
24
- # Tags: AdGroupAdService.mutate
25
-
26
- require 'adwords_api'
27
-
28
- def pause_ad(ad_group_id, ad_id)
29
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
- # when called without parameters.
31
- adwords = AdwordsApi::Api.new
32
-
33
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
34
- # the configuration file or provide your own logger:
35
- # adwords.logger = Logger.new('adwords_xml.log')
36
-
37
- ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
38
-
39
- # Prepare for updating ad.
40
- operation = {
41
- :operator => 'SET',
42
- :operand => {
43
- :ad_group_id => ad_group_id,
44
- :status => 'PAUSED',
45
- :ad => {
46
- :id => ad_id
47
- }
48
- }
49
- }
50
-
51
- # Update ad.
52
- response = ad_group_ad_srv.mutate([operation])
53
- ad = response[:value].first
54
- puts "Ad ID %d was successfully updated, status set to '%s'." %
55
- [ad[:ad][:id], ad[:status]]
56
- end
57
-
58
- if __FILE__ == $0
59
- API_VERSION = :v201109_1
60
-
61
- begin
62
- ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
63
- ad_id = 'INSERT_AD_ID_HERE'.to_i
64
- pause_ad(ad_group_id, ad_id)
65
-
66
- # HTTP errors.
67
- rescue AdsCommon::Errors::HttpError => e
68
- puts "HTTP Error: %s" % e
69
-
70
- # API errors.
71
- rescue AdwordsApi::Errors::ApiException => e
72
- puts "Message: %s" % e.message
73
- puts 'Errors:'
74
- e.errors.each_with_index do |error, index|
75
- puts "\tError [%d]:" % (index + 1)
76
- error.each do |field, value|
77
- puts "\t\t%s: %s" % [field, value]
78
- end
79
- end
80
- end
81
- end
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # Encoding: utf-8
3
- #
4
- # Author:: api.sgomes@gmail.com (Sérgio Gomes)
5
- #
6
- # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
7
- #
8
- # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
- # implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
- # This example illustrates how to update an ad group, setting its status to
22
- # 'PAUSED'. To create an ad group, run add_ad_group.rb.
23
- #
24
- # Tags: AdGroupService.mutate
25
-
26
- require 'adwords_api'
27
-
28
- def update_ad_group(ad_group_id)
29
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
- # when called without parameters.
31
- adwords = AdwordsApi::Api.new
32
-
33
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
34
- # the configuration file or provide your own logger:
35
- # adwords.logger = Logger.new('adwords_xml.log')
36
-
37
- ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
38
-
39
- # Prepare for updating ad group.
40
- operation = {
41
- :operator => 'SET',
42
- :operand => {
43
- :status => 'PAUSED',
44
- :id => ad_group_id
45
- }
46
- }
47
-
48
- # Update ad group.
49
- response = ad_group_srv.mutate([operation])
50
- ad_group = response[:value].first
51
- puts "Ad group ID %d was successfully updated." % ad_group[:id]
52
- end
53
-
54
- if __FILE__ == $0
55
- API_VERSION = :v201109_1
56
-
57
- begin
58
- ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
59
- update_ad_group(ad_group_id)
60
-
61
- # HTTP errors.
62
- rescue AdsCommon::Errors::HttpError => e
63
- puts "HTTP Error: %s" % e
64
-
65
- # API errors.
66
- rescue AdwordsApi::Errors::ApiException => e
67
- puts "Message: %s" % e.message
68
- puts 'Errors:'
69
- e.errors.each_with_index do |error, index|
70
- puts "\tError [%d]:" % (index + 1)
71
- error.each do |field, value|
72
- puts "\t\t%s: %s" % [field, value]
73
- end
74
- end
75
- end
76
- end
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # Encoding: utf-8
3
- #
4
- # Author:: api.sgomes@gmail.com (Sérgio Gomes)
5
- #
6
- # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
7
- #
8
- # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
- # implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
- # This example illustrates how to update a campaign, setting its budget delivery
22
- # to 'ACCELERATED'. To create a campaign, run add_campaign.rb.
23
- #
24
- # Tags: CampaignService.mutate
25
-
26
- require 'adwords_api'
27
-
28
- def update_campaign(campaign_id)
29
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
- # when called without parameters.
31
- adwords = AdwordsApi::Api.new
32
-
33
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
34
- # the configuration file or provide your own logger:
35
- # adwords.logger = Logger.new('adwords_xml.log')
36
-
37
- campaign_srv = adwords.service(:CampaignService, API_VERSION)
38
-
39
- # Prepare for updating campaign.
40
- operation = {
41
- :operator => 'SET',
42
- :operand => {
43
- :id => campaign_id,
44
- :budget => {
45
- :delivery_method => 'ACCELERATED'
46
- }
47
- }
48
- }
49
-
50
- # Update campaign.
51
- response = campaign_srv.mutate([operation])
52
- campaign = response[:value].first
53
- puts "Campaign ID %d successfully updated, delivery method set to '%s'." %
54
- [campaign[:id], campaign[:budget][:delivery_method]]
55
- end
56
-
57
- if __FILE__ == $0
58
- API_VERSION = :v201109_1
59
-
60
- begin
61
- campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
62
- update_campaign(campaign_id)
63
-
64
- # HTTP errors.
65
- rescue AdsCommon::Errors::HttpError => e
66
- puts "HTTP Error: %s" % e
67
-
68
- # API errors.
69
- rescue AdwordsApi::Errors::ApiException => e
70
- puts "Message: %s" % e.message
71
- puts 'Errors:'
72
- e.errors.each_with_index do |error, index|
73
- puts "\tError [%d]:" % (index + 1)
74
- error.each do |field, value|
75
- puts "\t\t%s: %s" % [field, value]
76
- end
77
- end
78
- end
79
- end
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # Encoding: utf-8
3
- #
4
- # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
- #
6
- # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
7
- #
8
- # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
- # implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
- # This example illustrates how to update a placement, setting its bid. To create
22
- # a placement, run add_placements.rb.
23
- #
24
- # Tags: AdGroupCriterionService.mutate
25
-
26
- require 'adwords_api'
27
-
28
- def update_placement(ad_group_id, placement_id)
29
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
- # when called without parameters.
31
- adwords = AdwordsApi::Api.new
32
-
33
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
34
- # the configuration file or provide your own logger:
35
- # adwords.logger = Logger.new('adwords_xml.log')
36
-
37
- ad_group_criterion_srv =
38
- adwords.service(:AdGroupCriterionService, API_VERSION)
39
-
40
- # Prepare for updating a placement.
41
- operation = {
42
- :operator => 'SET',
43
- :operand => {
44
- # The 'xsi_type' field allows you to specify the xsi:type of the object
45
- # being created. It's only necessary when you must provide an explicit
46
- # type that the client library can't infer.
47
- :xsi_type => 'BiddableAdGroupCriterion',
48
- :ad_group_id => ad_group_id,
49
- :criterion => {
50
- :id => placement_id
51
- },
52
- :bids => {
53
- :xsi_type => 'ManualCPMAdGroupCriterionBids',
54
- :max_cpm => {
55
- :amount => {
56
- :micro_amount => 1000000
57
- }
58
- }
59
- }
60
- }
61
- }
62
-
63
- # Update the placement.
64
- response = ad_group_criterion_srv.mutate([operation])
65
- ad_group_criterion = response[:value].first
66
- puts "Placement ID %d was successfully updated, bid set to %.2f." %
67
- [ad_group_criterion[:criterion][:id],
68
- ad_group_criterion[:bids][:max_cpm][:amount][:micro_amount] / 1000000]
69
- end
70
-
71
- if __FILE__ == $0
72
- API_VERSION = :v201109_1
73
-
74
- begin
75
- ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
76
- placement_id = 'INSERT_PLACEMENT_ID_HERE'.to_i
77
- update_placement(ad_group_id, placement_id)
78
-
79
- # HTTP errors.
80
- rescue AdsCommon::Errors::HttpError => e
81
- puts "HTTP Error: %s" % e
82
-
83
- # API errors.
84
- rescue AdwordsApi::Errors::ApiException => e
85
- puts "Message: %s" % e.message
86
- puts 'Errors:'
87
- e.errors.each_with_index do |error, index|
88
- puts "\tError [%d]:" % (index + 1)
89
- error.each do |field, value|
90
- puts "\t\t%s: %s" % [field, value]
91
- end
92
- end
93
- end
94
- end
@@ -1,151 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # Encoding: utf-8
3
- #
4
- # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
- #
6
- # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
7
- #
8
- # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
- # implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
- # This code sample illustrates how to perform asynchronous requests using the
22
- # MutateJobService.
23
- #
24
- # Tags: MutateJobService.mutate, MutateJobService.get,
25
- # MutateJobService.getResult
26
-
27
- require 'adwords_api'
28
-
29
- def add_placements_in_bulk(ad_group_id)
30
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
31
- # when called without parameters.
32
- adwords = AdwordsApi::Api.new
33
-
34
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
35
- # the configuration file or provide your own logger:
36
- # adwords.logger = Logger.new('adwords_xml.log')
37
-
38
- mutate_job_srv = adwords.service(:MutateJobService, API_VERSION)
39
-
40
- # Create AdGroupCriterionOperations to add placements.
41
- operations = (1..PLACEMENT_NUMBER).map do |index|
42
- # Add small fraction of invalid URLs to demonstrate errors.
43
- url = (rand(10) == 0) ? 'invalid-url' : 'http://mars.google.com/'
44
- {:xsi_type => 'AdGroupCriterionOperation',
45
- :operator => 'ADD',
46
- :operand => {
47
- :xsi_type => 'BiddableAdGroupCriterion',
48
- :ad_group_id => ad_group_id,
49
- :criterion => {
50
- :xsi_type => 'Placement',
51
- :url => url
52
- }}}
53
- end
54
-
55
- # You can specify up to 3 job IDs that must successfully complete before
56
- # this job can be processed.
57
- policy = {:prerequisite_job_ids => []}
58
-
59
- # Call mutate to create a new job.
60
- response = mutate_job_srv.mutate(operations, policy)
61
-
62
- raise StandardError, 'Failed to submit a job; aborting.' unless response
63
-
64
- job_id = response[:id]
65
- puts "Job ID %d was successfully created." % job_id
66
-
67
- # Creating selector to retrive hob status and wait for it to complete.
68
- selector = {
69
- :xsi_type => 'BulkMutateJobSelector',
70
- :job_ids => [job_id]
71
- }
72
-
73
- status = nil
74
-
75
- # Poll for job status until it's finished.
76
- puts 'Retrieving job status...'
77
- RETRIES_COUNT.times do |retry_attempt|
78
- job_status_response = mutate_job_srv.get(selector)
79
- if job_status_response
80
- status = job_status_response.first[:status]
81
- case status
82
- when 'FAILED'
83
- raise StandardError, "Job failed with reason: '%s'" %
84
- job_status_response.first[:failure_reason]
85
- when 'COMPLETED'
86
- puts "[%d] Job finished with status '%s'" % [retry_attempt, status]
87
- break
88
- else
89
- puts "[%d] Current status is '%s', waiting %d seconds to retry..." %
90
- [retry_attempt, status, RETRY_INTERVAL]
91
- sleep(RETRY_INTERVAL)
92
- end
93
- else
94
- raise StandardError, 'Error retrieving job status; aborting.'
95
- end
96
- end
97
-
98
- if status == 'COMPLETED'
99
- # Get the job result. Here we re-use the same selector.
100
- result_response = mutate_job_srv.get_result(selector)
101
-
102
- if result_response and result_response[:simple_mutate_result]
103
- results = result_response[:simple_mutate_result][:results]
104
- if results
105
- results.each_with_index do |result, index|
106
- result_message = result.include?(:place_holder) ?
107
- 'FAILED' : 'SUCCEEDED'
108
- puts "Operation [%d] - %s" % [index, result_message]
109
- end
110
- end
111
- errors = result_response[:simple_mutate_result][:errors]
112
- if errors
113
- errors.each do |error|
114
- puts "Error, reason: '%s', trigger: '%s', field path: '%s'" %
115
- [error[:reason], error[:trigger], error[:field_path]]
116
- end
117
- end
118
- else
119
- raise StandardError, 'Error retrieving job results; aborting.'
120
- end
121
- else
122
- puts "Job failed to complete after %d retries" % RETRY_COUNT
123
- end
124
- end
125
-
126
- if __FILE__ == $0
127
- API_VERSION = :v201109_1
128
- RETRY_INTERVAL = 30
129
- RETRIES_COUNT = 30
130
- PLACEMENT_NUMBER = 100
131
-
132
- begin
133
- ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
134
- add_placements_in_bulk(ad_group_id)
135
-
136
- # HTTP errors.
137
- rescue AdsCommon::Errors::HttpError => e
138
- puts "HTTP Error: %s" % e
139
-
140
- # API errors.
141
- rescue AdwordsApi::Errors::ApiException => e
142
- puts "Message: %s" % e.message
143
- puts 'Errors:'
144
- e.errors.each_with_index do |error, index|
145
- puts "\tError [%d]:" % (index + 1)
146
- error.each do |field, value|
147
- puts "\t\t%s: %s" % [field, value]
148
- end
149
- end
150
- end
151
- end