google-adwords-api 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +8 -8
  2. data/ChangeLog +3 -0
  3. data/examples/v201402/basic_operations/delete_ad_group.rb +1 -22
  4. data/examples/{v201309/basic_operations/delete_ad_group.rb → v201402/basic_operations/delete_ad_group.rb~} +2 -8
  5. data/examples/v201402/basic_operations/delete_campaign.rb +2 -23
  6. data/examples/{v201309/basic_operations/update_campaign.rb → v201402/basic_operations/delete_campaign.rb~} +13 -12
  7. data/examples/v201406/basic_operations/remove_ad_group.rb +1 -22
  8. data/examples/{v201309/basic_operations/update_ad_group.rb → v201406/basic_operations/remove_ad_group.rb~} +14 -13
  9. data/examples/v201406/basic_operations/remove_campaign.rb +4 -24
  10. data/examples/{v201309/basic_operations/delete_campaign.rb → v201406/basic_operations/remove_campaign.rb~} +11 -11
  11. data/lib/adwords_api.rb +5 -8
  12. data/lib/adwords_api/api_config.rb +0 -76
  13. data/lib/adwords_api/report_utils.rb +9 -0
  14. data/lib/adwords_api/report_utils.rb~ +283 -0
  15. data/lib/adwords_api/version.rb +1 -1
  16. data/lib/adwords_api/version.rb~ +26 -0
  17. data/test/adwords_api/test_adwords_api.rb +5 -21
  18. data/test/adwords_api/test_adwords_api.rb~ +114 -0
  19. data/test/adwords_api/test_api_config.rb +8 -8
  20. data/test/adwords_api/test_report_utils.rb +29 -1
  21. data/test/adwords_api/test_report_utils.rb~ +216 -0
  22. data/test/templates/{v201309 → v201402}/basic_operations_get_campaigns.def +7 -7
  23. data/test/templates/{v201309 → v201402}/misc_use_oauth2_jwt.def +7 -7
  24. data/test/templates/v201406/basic_operations_get_campaigns.def +114 -0
  25. data/test/templates/v201406/misc_use_oauth2_jwt.def +131 -0
  26. metadata +14 -139
  27. data/examples/v201309/account_management/create_account.rb +0 -95
  28. data/examples/v201309/account_management/get_account_alerts.rb +0 -122
  29. data/examples/v201309/account_management/get_account_changes.rb +0 -145
  30. data/examples/v201309/account_management/get_account_hierarchy.rb +0 -103
  31. data/examples/v201309/advanced_operations/add_ad_group_bid_modifier.rb +0 -105
  32. data/examples/v201309/advanced_operations/add_click_to_download_ad.rb +0 -137
  33. data/examples/v201309/advanced_operations/add_site_links.rb +0 -306
  34. data/examples/v201309/advanced_operations/create_and_attach_shared_keyword_set.rb +0 -147
  35. data/examples/v201309/advanced_operations/find_and_remove_criteria_from_shared_set.rb +0 -181
  36. data/examples/v201309/advanced_operations/get_ad_group_bid_modifiers.rb +0 -106
  37. data/examples/v201309/advanced_operations/update_site_links.rb +0 -194
  38. data/examples/v201309/advanced_operations/upload_offline_conversions.rb +0 -117
  39. data/examples/v201309/advanced_operations/use_shared_bidding_strategy.rb +0 -163
  40. data/examples/v201309/basic_operations/add_ad_groups.rb +0 -143
  41. data/examples/v201309/basic_operations/add_campaigns.rb +0 -162
  42. data/examples/v201309/basic_operations/add_keywords.rb +0 -116
  43. data/examples/v201309/basic_operations/add_text_ads.rb +0 -113
  44. data/examples/v201309/basic_operations/delete_ad.rb +0 -93
  45. data/examples/v201309/basic_operations/delete_keyword.rb +0 -98
  46. data/examples/v201309/basic_operations/get_ad_groups.rb +0 -106
  47. data/examples/v201309/basic_operations/get_campaigns.rb +0 -101
  48. data/examples/v201309/basic_operations/get_campaigns_with_awql.rb +0 -93
  49. data/examples/v201309/basic_operations/get_keywords.rb +0 -112
  50. data/examples/v201309/basic_operations/get_text_ads.rb +0 -114
  51. data/examples/v201309/basic_operations/pause_ad.rb +0 -92
  52. data/examples/v201309/basic_operations/update_keyword.rb +0 -110
  53. data/examples/v201309/campaign_management/add_experiment.rb +0 -166
  54. data/examples/v201309/campaign_management/add_keywords_in_bulk.rb +0 -158
  55. data/examples/v201309/campaign_management/add_location_extension.rb +0 -125
  56. data/examples/v201309/campaign_management/get_all_disapproved_ads.rb +0 -101
  57. data/examples/v201309/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -93
  58. data/examples/v201309/campaign_management/promote_experiment.rb +0 -85
  59. data/examples/v201309/campaign_management/set_ad_parameters.rb +0 -122
  60. data/examples/v201309/campaign_management/set_criterion_bid_modifier.rb +0 -108
  61. data/examples/v201309/campaign_management/validate_text_ad.rb +0 -114
  62. data/examples/v201309/error_handling/handle_captcha_challenge.rb +0 -93
  63. data/examples/v201309/error_handling/handle_partial_failures.rb +0 -134
  64. data/examples/v201309/error_handling/handle_policy_violation_error.rb +0 -145
  65. data/examples/v201309/error_handling/handle_two_factor_authorization_error.rb +0 -88
  66. data/examples/v201309/misc/get_all_images_and_videos.rb +0 -108
  67. data/examples/v201309/misc/setup_oauth2.rb +0 -88
  68. data/examples/v201309/misc/upload_image.rb +0 -97
  69. data/examples/v201309/misc/use_oauth2_jwt.rb +0 -97
  70. data/examples/v201309/optimization/estimate_keyword_traffic.rb +0 -137
  71. data/examples/v201309/optimization/get_keyword_bid_simulations.rb +0 -100
  72. data/examples/v201309/optimization/get_keyword_ideas.rb +0 -130
  73. data/examples/v201309/optimization/get_placement_ideas.rb +0 -112
  74. data/examples/v201309/remarketing/add_audience.rb +0 -123
  75. data/examples/v201309/remarketing/add_conversion_tracker.rb +0 -104
  76. data/examples/v201309/reporting/download_criteria_report.rb +0 -87
  77. data/examples/v201309/reporting/download_criteria_report_with_awql.rb +0 -86
  78. data/examples/v201309/reporting/get_report_fields.rb +0 -79
  79. data/examples/v201309/reporting/parallel_report_download.rb +0 -171
  80. data/examples/v201309/targeting/add_campaign_targeting_criteria.rb +0 -123
  81. data/examples/v201309/targeting/add_demographic_targeting_criteria.rb +0 -116
  82. data/examples/v201309/targeting/get_campaign_targeting_criteria.rb +0 -110
  83. data/examples/v201309/targeting/get_targetable_languages_and_carriers.rb +0 -94
  84. data/examples/v201309/targeting/lookup_location.rb +0 -112
  85. data/lib/adwords_api/v201309/ad_group_ad_service.rb +0 -42
  86. data/lib/adwords_api/v201309/ad_group_ad_service_registry.rb +0 -46
  87. data/lib/adwords_api/v201309/ad_group_bid_modifier_service.rb +0 -38
  88. data/lib/adwords_api/v201309/ad_group_bid_modifier_service_registry.rb +0 -46
  89. data/lib/adwords_api/v201309/ad_group_criterion_service.rb +0 -42
  90. data/lib/adwords_api/v201309/ad_group_criterion_service_registry.rb +0 -46
  91. data/lib/adwords_api/v201309/ad_group_feed_service.rb +0 -38
  92. data/lib/adwords_api/v201309/ad_group_feed_service_registry.rb +0 -46
  93. data/lib/adwords_api/v201309/ad_group_service.rb +0 -42
  94. data/lib/adwords_api/v201309/ad_group_service_registry.rb +0 -46
  95. data/lib/adwords_api/v201309/ad_param_service.rb +0 -38
  96. data/lib/adwords_api/v201309/ad_param_service_registry.rb +0 -46
  97. data/lib/adwords_api/v201309/adwords_user_list_service.rb +0 -38
  98. data/lib/adwords_api/v201309/adwords_user_list_service_registry.rb +0 -46
  99. data/lib/adwords_api/v201309/alert_service.rb +0 -34
  100. data/lib/adwords_api/v201309/alert_service_registry.rb +0 -46
  101. data/lib/adwords_api/v201309/bidding_strategy_service.rb +0 -38
  102. data/lib/adwords_api/v201309/bidding_strategy_service_registry.rb +0 -46
  103. data/lib/adwords_api/v201309/budget_order_service.rb +0 -42
  104. data/lib/adwords_api/v201309/budget_order_service_registry.rb +0 -46
  105. data/lib/adwords_api/v201309/budget_service.rb +0 -38
  106. data/lib/adwords_api/v201309/budget_service_registry.rb +0 -46
  107. data/lib/adwords_api/v201309/campaign_ad_extension_service.rb +0 -38
  108. data/lib/adwords_api/v201309/campaign_ad_extension_service_registry.rb +0 -46
  109. data/lib/adwords_api/v201309/campaign_criterion_service.rb +0 -42
  110. data/lib/adwords_api/v201309/campaign_criterion_service_registry.rb +0 -46
  111. data/lib/adwords_api/v201309/campaign_feed_service.rb +0 -38
  112. data/lib/adwords_api/v201309/campaign_feed_service_registry.rb +0 -46
  113. data/lib/adwords_api/v201309/campaign_service.rb +0 -42
  114. data/lib/adwords_api/v201309/campaign_service_registry.rb +0 -46
  115. data/lib/adwords_api/v201309/campaign_shared_set_service.rb +0 -38
  116. data/lib/adwords_api/v201309/campaign_shared_set_service_registry.rb +0 -47
  117. data/lib/adwords_api/v201309/constant_data_service.rb +0 -62
  118. data/lib/adwords_api/v201309/constant_data_service_registry.rb +0 -46
  119. data/lib/adwords_api/v201309/conversion_tracker_service.rb +0 -38
  120. data/lib/adwords_api/v201309/conversion_tracker_service_registry.rb +0 -46
  121. data/lib/adwords_api/v201309/customer_service.rb +0 -34
  122. data/lib/adwords_api/v201309/customer_service_registry.rb +0 -46
  123. data/lib/adwords_api/v201309/customer_sync_service.rb +0 -34
  124. data/lib/adwords_api/v201309/customer_sync_service_registry.rb +0 -47
  125. data/lib/adwords_api/v201309/data_service.rb +0 -38
  126. data/lib/adwords_api/v201309/data_service_registry.rb +0 -46
  127. data/lib/adwords_api/v201309/experiment_service.rb +0 -38
  128. data/lib/adwords_api/v201309/experiment_service_registry.rb +0 -46
  129. data/lib/adwords_api/v201309/feed_item_service.rb +0 -38
  130. data/lib/adwords_api/v201309/feed_item_service_registry.rb +0 -46
  131. data/lib/adwords_api/v201309/feed_mapping_service.rb +0 -38
  132. data/lib/adwords_api/v201309/feed_mapping_service_registry.rb +0 -46
  133. data/lib/adwords_api/v201309/feed_service.rb +0 -38
  134. data/lib/adwords_api/v201309/feed_service_registry.rb +0 -46
  135. data/lib/adwords_api/v201309/geo_location_service.rb +0 -34
  136. data/lib/adwords_api/v201309/geo_location_service_registry.rb +0 -46
  137. data/lib/adwords_api/v201309/location_criterion_service.rb +0 -34
  138. data/lib/adwords_api/v201309/location_criterion_service_registry.rb +0 -46
  139. data/lib/adwords_api/v201309/managed_customer_service.rb +0 -50
  140. data/lib/adwords_api/v201309/managed_customer_service_registry.rb +0 -46
  141. data/lib/adwords_api/v201309/media_service.rb +0 -38
  142. data/lib/adwords_api/v201309/media_service_registry.rb +0 -46
  143. data/lib/adwords_api/v201309/mutate_job_service.rb +0 -42
  144. data/lib/adwords_api/v201309/mutate_job_service_registry.rb +0 -46
  145. data/lib/adwords_api/v201309/offline_conversion_feed_service.rb +0 -34
  146. data/lib/adwords_api/v201309/offline_conversion_feed_service_registry.rb +0 -46
  147. data/lib/adwords_api/v201309/report_definition_service.rb +0 -34
  148. data/lib/adwords_api/v201309/report_definition_service_registry.rb +0 -46
  149. data/lib/adwords_api/v201309/shared_criterion_service.rb +0 -38
  150. data/lib/adwords_api/v201309/shared_criterion_service_registry.rb +0 -47
  151. data/lib/adwords_api/v201309/shared_set_service.rb +0 -38
  152. data/lib/adwords_api/v201309/shared_set_service_registry.rb +0 -47
  153. data/lib/adwords_api/v201309/targeting_idea_service.rb +0 -38
  154. data/lib/adwords_api/v201309/targeting_idea_service_registry.rb +0 -46
  155. data/lib/adwords_api/v201309/traffic_estimator_service.rb +0 -34
  156. data/lib/adwords_api/v201309/traffic_estimator_service_registry.rb +0 -46
  157. data/test/bugs/test_issue_00000031.rb +0 -75
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mzc2ZTFhNzVmNzc4ZjMzNTk3YzMwYjRjN2MyZjA2ZmM5NjYwZGFhYQ==
4
+ ODRhZTMxOWI0ZjZlYTZmMDRhZDA1M2I4YjgxNDJiMTU4YTdlMGNkMw==
5
5
  data.tar.gz: !binary |-
6
- M2Q1ZjlhZDNmYTUzNGUzNjAwODczYjhjNjA4MmUwMTgyMDYzYzA0Yg==
6
+ ZThlNzE5ZTUzNWFlMDcyZmU0NTczMjdjOTAyYjdiZDc1ODg4MWMyZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWI2MTQxNWY1YjkyNWYzZWI1NTRkYjhhYzFiNGEzYjIyNWNkOTY3OGU0MTE3
10
- ODRhZTQ3MzRiOGRlYzBjZGQxNzRkZjBkYWU2NDg2MmIxMTcxMzIyZWQyZjI3
11
- ZDk5MGY1NDk0ZmNjMTZjOWRjMmMwZjk3Y2UyY2UwZjFhNTliNWY=
9
+ MTNiZjMxOTEwNjA3MmRkNGYzZjFiMGI1ZmRhODE5NmZlNTBlOGRlNzg3ZWZh
10
+ YTg4MDVhNTlhNWI4Yjg5YjUxZGI2NzRlMDA0ZjJlZTVhZTNkOGU3NzFhMTcx
11
+ MmZkZWUxZDhhMjQzYTZmZGNkZTVjOTkwOTNjYmY1ZjlhNTQwZjQ=
12
12
  data.tar.gz: !binary |-
13
- NDI3OTdjZTkxYjJkMjEwNGE4MTY4NDIxOWNjNGE2NGMyYTk5YmEwM2JlZDZl
14
- NDQ4NTFiMjk0ODMyY2IxMDk2MGY2NDVmMWM4ZDY5N2JjZThkY2VmMjFhMmZi
15
- MjU0YTMwNWU2Yjg4ZDE0Y2RkZmM3MDNlMWI2NzIyYTk5MThjZmI=
13
+ YzI0ZmYxODE3ZmRhNzhlODQ5MmM0OGNhNjM4YjViYzI1Y2U0NDcxNjRhNzU0
14
+ OWJmZWNhZTc4Nzg4NTg1MWJiMmExZWRmZmVmMThkMmIzNjljYjhlNzA5NDc1
15
+ YTliYjMzZjU5YmIwNzE3MDlhMmM5YzY0OTc5YTEzMGE3YzVjNjc=
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ 0.13.0:
2
+ - Removed deprecated API version v201309.
3
+
1
4
  0.12.1:
2
5
  - Support and examples for v201406.
3
6
  - Changed default OAuth scope. See:
@@ -36,31 +36,11 @@ def delete_ad_group(ad_group_id)
36
36
 
37
37
  ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
38
38
 
39
- # Retrieve the ad group to obtain its name. This is optional but recommended
40
- # to keep deleted objects searchable. In production the name is already known
41
- # in most cases.
42
- selector = {
43
- :fields => ['Id', 'Name'],
44
- :predicates => [
45
- {:field => 'Id', :operator => 'EQUALS', :values => [ad_group_id]}
46
- ]
47
- }
48
- result = ad_group_srv.get(selector)
49
-
50
- if result.nil? or result[:entries].empty?
51
- raise StandardError, "Ad group with ID %d was not found." % ad_group_id
52
- end
53
-
54
- # We recommend renaming object on delete to avoid name conflicts later.
55
- ad_group_name = result[:entries].first[:name]
56
- ad_group_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
57
-
58
39
  # Prepare for deleting ad group.
59
40
  operation = {
60
41
  :operator => 'SET',
61
42
  :operand => {
62
43
  :id => ad_group_id,
63
- :name => ad_group_name,
64
44
  :status => 'DELETED'
65
45
  }
66
46
  }
@@ -69,8 +49,7 @@ def delete_ad_group(ad_group_id)
69
49
  response = ad_group_srv.mutate([operation])
70
50
  if response and response[:value]
71
51
  ad_group = response[:value].first
72
- puts "Ad group ID %d was successfully deleted and renamed to '%s'." %
73
- [ad_group[:id], ad_group[:name]]
52
+ puts "Ad group ID %d was successfully deleted." % [ad_group[:id]]
74
53
  else
75
54
  puts 'No ad group was updated.'
76
55
  end
@@ -51,16 +51,11 @@ def delete_ad_group(ad_group_id)
51
51
  raise StandardError, "Ad group with ID %d was not found." % ad_group_id
52
52
  end
53
53
 
54
- # We recommend renaming object on delete to avoid name conflicts later.
55
- ad_group_name = result[:entries].first[:name]
56
- ad_group_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
57
-
58
54
  # Prepare for deleting ad group.
59
55
  operation = {
60
56
  :operator => 'SET',
61
57
  :operand => {
62
58
  :id => ad_group_id,
63
- :name => ad_group_name,
64
59
  :status => 'DELETED'
65
60
  }
66
61
  }
@@ -69,15 +64,14 @@ def delete_ad_group(ad_group_id)
69
64
  response = ad_group_srv.mutate([operation])
70
65
  if response and response[:value]
71
66
  ad_group = response[:value].first
72
- puts "Ad group ID %d was successfully deleted and renamed to '%s'." %
73
- [ad_group[:id], ad_group[:name]]
67
+ puts "Ad group ID %d was successfully deleted." % [ad_group[:id]]
74
68
  else
75
69
  puts 'No ad group was updated.'
76
70
  end
77
71
  end
78
72
 
79
73
  if __FILE__ == $0
80
- API_VERSION = :v201309
74
+ API_VERSION = :v201402
81
75
 
82
76
  begin
83
77
  # ID of an ad group to delete.
@@ -36,32 +36,12 @@ def delete_campaign(campaign_id)
36
36
 
37
37
  campaign_srv = adwords.service(:CampaignService, API_VERSION)
38
38
 
39
- # Retrieve the campaign to obtain its name. This is optional but recommended
40
- # to keep deleted objects searchable. In production the name is already known
41
- # in most cases.
42
- selector = {
43
- :fields => ['Id', 'Name'],
44
- :predicates => [
45
- {:field => 'Id', :operator => 'EQUALS', :values => [campaign_id]}
46
- ]
47
- }
48
- result = campaign_srv.get(selector)
49
-
50
- if result.nil? or result[:entries].empty?
51
- raise StandardError, "Campaign with ID %d was not found." % campaign_id
52
- end
53
-
54
- # We recommend renaming object on delete to avoid name conflicts later.
55
- campaign_name = result[:entries].first[:name]
56
- campaign_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
57
-
58
39
  # Prepare for deleting campaign.
59
40
  operation = {
60
41
  :operator => 'SET',
61
42
  :operand => {
62
43
  :id => campaign_id,
63
- :name => campaign_name,
64
- :status => 'DELETED',
44
+ :status => 'DELETED'
65
45
  }
66
46
  }
67
47
 
@@ -70,8 +50,7 @@ def delete_campaign(campaign_id)
70
50
 
71
51
  if response and response[:value]
72
52
  campaign = response[:value].first
73
- puts "Campaign ID %d was renamed to '%s' and deleted." %
74
- [campaign[:id], campaign[:name]]
53
+ puts "Campaign ID %d was deleted." % [campaign[:id]]
75
54
  else
76
55
  puts 'No campaign was updated.'
77
56
  end
@@ -18,14 +18,14 @@
18
18
  # See the License for the specific language governing permissions and
19
19
  # limitations under the License.
20
20
  #
21
- # This example illustrates how to update a campaign, setting its status to
22
- # 'PAUSED'. To create a campaign, run add_campaigns.rb.
21
+ # This example deletes a campaign by setting the status to 'DELETED'. To get
22
+ # campaigns, run get_campaigns.rb.
23
23
  #
24
24
  # Tags: CampaignService.mutate
25
25
 
26
26
  require 'adwords_api'
27
27
 
28
- def update_campaign(campaign_id)
28
+ def delete_campaign(campaign_id)
29
29
  # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
30
  # when called without parameters.
31
31
  adwords = AdwordsApi::Api.new
@@ -36,33 +36,34 @@ def update_campaign(campaign_id)
36
36
 
37
37
  campaign_srv = adwords.service(:CampaignService, API_VERSION)
38
38
 
39
- # Prepare for updating campaign.
39
+ # Prepare for deleting campaign.
40
40
  operation = {
41
41
  :operator => 'SET',
42
42
  :operand => {
43
43
  :id => campaign_id,
44
- :status => 'PAUSED'
44
+ :status => 'DELETED'
45
45
  }
46
46
  }
47
47
 
48
- # Update campaign.
48
+ # Delete campaign.
49
49
  response = campaign_srv.mutate([operation])
50
+
50
51
  if response and response[:value]
51
52
  campaign = response[:value].first
52
- puts "Campaign ID %d was successfully updated, status was set to '%s'." %
53
- [campaign[:id], campaign[:status]]
53
+ puts "Campaign ID %d was renamed to '%s' and deleted." %
54
+ [campaign[:id], campaign[:name]]
54
55
  else
55
- puts 'No campaigns were updated.'
56
+ puts 'No campaign was updated.'
56
57
  end
57
58
  end
58
59
 
59
60
  if __FILE__ == $0
60
- API_VERSION = :v201309
61
+ API_VERSION = :v201402
61
62
 
62
63
  begin
63
- # ID of a campaign to update.
64
+ # ID of a campaign to delete.
64
65
  campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
65
- update_campaign(campaign_id)
66
+ delete_campaign(campaign_id)
66
67
 
67
68
  # Authorization error.
68
69
  rescue AdsCommon::Errors::OAuth2VerificationRequired => e
@@ -36,31 +36,11 @@ def remove_ad_group(ad_group_id)
36
36
 
37
37
  ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
38
38
 
39
- # Retrieve the ad group to obtain its name. This is optional but recommended
40
- # to keep remove objects searchable. In production the name is already known
41
- # in most cases.
42
- selector = {
43
- :fields => ['Id', 'Name'],
44
- :predicates => [
45
- {:field => 'Id', :operator => 'EQUALS', :values => [ad_group_id]}
46
- ]
47
- }
48
- result = ad_group_srv.get(selector)
49
-
50
- if result.nil? or result[:entries].empty?
51
- raise StandardError, "Ad group with ID %d was not found." % ad_group_id
52
- end
53
-
54
- # We recommend renaming object on remove to avoid name conflicts later.
55
- ad_group_name = result[:entries].first[:name]
56
- ad_group_name += Time.now.strftime(" (removed on %Y-%m-%d %H:%M:%S)")
57
-
58
39
  # Prepare for deleting ad group.
59
40
  operation = {
60
41
  :operator => 'SET',
61
42
  :operand => {
62
43
  :id => ad_group_id,
63
- :name => ad_group_name,
64
44
  :status => 'REMOVED'
65
45
  }
66
46
  }
@@ -69,8 +49,7 @@ def remove_ad_group(ad_group_id)
69
49
  response = ad_group_srv.mutate([operation])
70
50
  if response and response[:value]
71
51
  ad_group = response[:value].first
72
- puts "Ad group ID %d was successfully removed and renamed to '%s'." %
73
- [ad_group[:id], ad_group[:name]]
52
+ puts "Ad group ID %d was successfully removed." % [ad_group[:id]]
74
53
  else
75
54
  puts 'No ad group was updated.'
76
55
  end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Encoding: utf-8
3
3
  #
4
- # Author:: api.sgomes@gmail.com (Sérgio Gomes)
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
5
  #
6
6
  # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
7
7
  #
@@ -18,14 +18,14 @@
18
18
  # See the License for the specific language governing permissions and
19
19
  # limitations under the License.
20
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.
21
+ # This example removes an ad group by setting the status to 'REMOVED'. To get ad
22
+ # groups, run get_ad_groups.rb.
23
23
  #
24
24
  # Tags: AdGroupService.mutate
25
25
 
26
26
  require 'adwords_api'
27
27
 
28
- def update_ad_group(ad_group_id)
28
+ def remove_ad_group(ad_group_id)
29
29
  # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
30
  # when called without parameters.
31
31
  adwords = AdwordsApi::Api.new
@@ -36,32 +36,33 @@ def update_ad_group(ad_group_id)
36
36
 
37
37
  ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
38
38
 
39
- # Prepare for updating ad group.
39
+ # Prepare for deleting ad group.
40
40
  operation = {
41
41
  :operator => 'SET',
42
42
  :operand => {
43
- :status => 'PAUSED',
44
- :id => ad_group_id
43
+ :id => ad_group_id,
44
+ :status => 'REMOVED'
45
45
  }
46
46
  }
47
47
 
48
- # Update ad group.
48
+ # Remove ad group.
49
49
  response = ad_group_srv.mutate([operation])
50
50
  if response and response[:value]
51
51
  ad_group = response[:value].first
52
- puts 'Ad group id %d was successfully updated.' % ad_group[:id]
52
+ puts "Ad group ID %d was successfully removed." %
53
+ [ad_group[:id]]
53
54
  else
54
- puts 'No ad groups were updated.'
55
+ puts 'No ad group was updated.'
55
56
  end
56
57
  end
57
58
 
58
59
  if __FILE__ == $0
59
- API_VERSION = :v201309
60
+ API_VERSION = :v201406
60
61
 
61
62
  begin
62
- # ID of an ad group to update.
63
+ # ID of an ad group to remove.
63
64
  ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
64
- update_ad_group(ad_group_id)
65
+ remove_ad_group(ad_group_id)
65
66
 
66
67
  # Authorization error.
67
68
  rescue AdsCommon::Errors::OAuth2VerificationRequired => e
@@ -36,32 +36,12 @@ def remove_campaign(campaign_id)
36
36
 
37
37
  campaign_srv = adwords.service(:CampaignService, API_VERSION)
38
38
 
39
- # Retrieve the campaign to obtain its name. This is optional but recommended
40
- # to keep removed objects searchable. In production the name is already known
41
- # in most cases.
42
- selector = {
43
- :fields => ['Id', 'Name'],
44
- :predicates => [
45
- {:field => 'Id', :operator => 'EQUALS', :values => [campaign_id]}
46
- ]
47
- }
48
- result = campaign_srv.get(selector)
49
-
50
- if result.nil? or result[:entries].empty?
51
- raise StandardError, "Campaign with ID %d was not found." % campaign_id
52
- end
53
-
54
- # We recommend renaming object on remove to avoid name conflicts later.
55
- campaign_name = result[:entries].first[:name]
56
- campaign_name += Time.now.strftime(" (removed on %Y-%m-%d %H:%M:%S)")
57
-
58
- # Prepare for deleting campaign.
39
+ # Prepare for deleting campaign.
59
40
  operation = {
60
41
  :operator => 'SET',
61
42
  :operand => {
62
43
  :id => campaign_id,
63
- :name => campaign_name,
64
- :status => 'REMOVED',
44
+ :status => 'REMOVED'
65
45
  }
66
46
  }
67
47
 
@@ -70,8 +50,8 @@ def remove_campaign(campaign_id)
70
50
 
71
51
  if response and response[:value]
72
52
  campaign = response[:value].first
73
- puts "Campaign ID %d was renamed to '%s' and removed." %
74
- [campaign[:id], campaign[:name]]
53
+ puts "Campaign ID %d was removed." %
54
+ [campaign[:id]]
75
55
  else
76
56
  puts 'No campaign was updated.'
77
57
  end
@@ -18,14 +18,14 @@
18
18
  # See the License for the specific language governing permissions and
19
19
  # limitations under the License.
20
20
  #
21
- # This example deletes a campaign by setting the status to 'DELETED'. To get
21
+ # This example removes a campaign by setting the status to 'REMOVED'. To get
22
22
  # campaigns, run get_campaigns.rb.
23
23
  #
24
24
  # Tags: CampaignService.mutate
25
25
 
26
26
  require 'adwords_api'
27
27
 
28
- def delete_campaign(campaign_id)
28
+ def remove_campaign(campaign_id)
29
29
  # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
30
30
  # when called without parameters.
31
31
  adwords = AdwordsApi::Api.new
@@ -37,7 +37,7 @@ def delete_campaign(campaign_id)
37
37
  campaign_srv = adwords.service(:CampaignService, API_VERSION)
38
38
 
39
39
  # Retrieve the campaign to obtain its name. This is optional but recommended
40
- # to keep deleted objects searchable. In production the name is already known
40
+ # to keep removed objects searchable. In production the name is already known
41
41
  # in most cases.
42
42
  selector = {
43
43
  :fields => ['Id', 'Name'],
@@ -51,9 +51,9 @@ def delete_campaign(campaign_id)
51
51
  raise StandardError, "Campaign with ID %d was not found." % campaign_id
52
52
  end
53
53
 
54
- # We recommend renaming object on delete to avoid name conflicts later.
54
+ # We recommend renaming object on remove to avoid name conflicts later.
55
55
  campaign_name = result[:entries].first[:name]
56
- campaign_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
56
+ campaign_name += Time.now.strftime(" (removed on %Y-%m-%d %H:%M:%S)")
57
57
 
58
58
  # Prepare for deleting campaign.
59
59
  operation = {
@@ -61,16 +61,16 @@ def delete_campaign(campaign_id)
61
61
  :operand => {
62
62
  :id => campaign_id,
63
63
  :name => campaign_name,
64
- :status => 'DELETED',
64
+ :status => 'REMOVED',
65
65
  }
66
66
  }
67
67
 
68
- # Delete campaign.
68
+ # Remove campaign.
69
69
  response = campaign_srv.mutate([operation])
70
70
 
71
71
  if response and response[:value]
72
72
  campaign = response[:value].first
73
- puts "Campaign ID %d was renamed to '%s' and deleted." %
73
+ puts "Campaign ID %d was renamed to '%s' and removed." %
74
74
  [campaign[:id], campaign[:name]]
75
75
  else
76
76
  puts 'No campaign was updated.'
@@ -78,12 +78,12 @@ def delete_campaign(campaign_id)
78
78
  end
79
79
 
80
80
  if __FILE__ == $0
81
- API_VERSION = :v201309
81
+ API_VERSION = :v201406
82
82
 
83
83
  begin
84
- # ID of a campaign to delete.
84
+ # ID of a campaign to remove.
85
85
  campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
86
- delete_campaign(campaign_id)
86
+ remove_campaign(campaign_id)
87
87
 
88
88
  # Authorization error.
89
89
  rescue AdsCommon::Errors::OAuth2VerificationRequired => e