google-adx-buyer-api 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/ChangeLog +5 -0
  2. data/README +35 -24
  3. data/examples/{v201206 → v201306}/account_management/get_account_changes.rb +9 -1
  4. data/examples/{v201206 → v201306}/basic_operations/add_ad_group.rb +19 -11
  5. data/examples/{v201206 → v201306}/basic_operations/add_campaign.rb +27 -14
  6. data/examples/{v201206 → v201306}/basic_operations/add_placements.rb +9 -1
  7. data/examples/{v201206 → v201306}/basic_operations/add_thirdparty_redirect_ad.rb +16 -6
  8. data/examples/{v201206 → v201306}/basic_operations/delete_ad.rb +9 -1
  9. data/examples/{v201206 → v201306}/basic_operations/delete_ad_group.rb +9 -1
  10. data/examples/{v201206 → v201306}/basic_operations/delete_campaign.rb +9 -1
  11. data/examples/{v201206 → v201306}/basic_operations/delete_placement.rb +9 -1
  12. data/examples/{v201206 → v201306}/basic_operations/get_ad_groups.rb +9 -1
  13. data/examples/{v201206 → v201306}/basic_operations/get_campaigns.rb +9 -1
  14. data/examples/{v201206 → v201306}/basic_operations/get_placements.rb +9 -1
  15. data/examples/{v201206 → v201306}/basic_operations/get_thirdparty_redirect_ads.rb +9 -1
  16. data/examples/{v201206 → v201306}/basic_operations/pause_ad.rb +9 -1
  17. data/examples/{v201206 → v201306}/basic_operations/update_ad_group.rb +9 -1
  18. data/examples/{v201206 → v201306}/basic_operations/update_campaign.rb +9 -1
  19. data/examples/{v201206 → v201306}/basic_operations/update_placement.rb +15 -7
  20. data/examples/{v201206 → v201306}/campaign_management/add_placements_in_bulk.rb +10 -2
  21. data/examples/{v201206 → v201306}/campaign_management/get_all_disapproved_ads.rb +10 -2
  22. data/examples/{v201206 → v201306}/error_handling/handle_captcha_challenge.rb +1 -1
  23. data/examples/{v201206 → v201306}/error_handling/handle_partial_failures.rb +9 -1
  24. data/examples/{v201206 → v201306}/error_handling/handle_policy_violation_error.rb +9 -1
  25. data/examples/{v201206 → v201306}/error_handling/handle_two_factor_authorization_error.rb +3 -2
  26. data/examples/{v201206 → v201306}/misc/get_all_images_and_videos.rb +12 -5
  27. data/examples/v201306/misc/setup_oauth2.rb +88 -0
  28. data/examples/{v201206 → v201306}/misc/upload_image.rb +20 -10
  29. data/examples/{v201206/misc/use_oauth.rb → v201306/misc/use_oauth2_jwt.rb} +20 -24
  30. data/examples/{v201206 → v201306}/optimization/get_placement_ideas.rb +10 -4
  31. data/examples/{v201206 → v201306}/remarketing/add_audience.rb +38 -26
  32. data/examples/{v201206 → v201306}/remarketing/add_conversion_tracker.rb +17 -6
  33. data/examples/{v201206 → v201306}/reporting/download_criteria_report.rb +9 -1
  34. data/examples/{v201206 → v201306}/reporting/get_campaign_stats.rb +9 -1
  35. data/examples/{v201206 → v201306}/reporting/get_report_fields.rb +9 -1
  36. data/examples/{v201206 → v201306}/targeting/add_campaign_targeting_criteria.rb +10 -5
  37. data/examples/{v201206 → v201306}/targeting/get_campaign_targeting_criteria.rb +9 -1
  38. data/examples/{v201206 → v201306}/targeting/get_targetable_languages_and_carriers.rb +16 -4
  39. data/examples/{v201206 → v201306}/targeting/lookup_location.rb +9 -1
  40. metadata +41 -41
  41. data/examples/v201206/reporting/parallel_report_download.rb +0 -159
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-adx-buyer-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-26 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-adwords-api
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.8.2
21
+ version: 0.9.3
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 0.8.2
29
+ version: 0.9.3
30
30
  description: AdWords API and DoubleClick Ad Exchange Buyer API client library for
31
31
  Ruby
32
32
  email:
@@ -109,43 +109,43 @@ files:
109
109
  - examples/v201209/misc/use_oauth2.rb
110
110
  - examples/v201209/remarketing/add_conversion_tracker.rb
111
111
  - examples/v201209/remarketing/add_audience.rb
112
- - examples/v201206/reporting/download_criteria_report.rb
113
- - examples/v201206/reporting/get_campaign_stats.rb
114
- - examples/v201206/reporting/parallel_report_download.rb
115
- - examples/v201206/reporting/get_report_fields.rb
116
- - examples/v201206/error_handling/handle_policy_violation_error.rb
117
- - examples/v201206/error_handling/handle_two_factor_authorization_error.rb
118
- - examples/v201206/error_handling/handle_captcha_challenge.rb
119
- - examples/v201206/error_handling/handle_partial_failures.rb
120
- - examples/v201206/targeting/lookup_location.rb
121
- - examples/v201206/targeting/get_targetable_languages_and_carriers.rb
122
- - examples/v201206/targeting/add_campaign_targeting_criteria.rb
123
- - examples/v201206/targeting/get_campaign_targeting_criteria.rb
124
- - examples/v201206/campaign_management/add_placements_in_bulk.rb
125
- - examples/v201206/campaign_management/get_all_disapproved_ads.rb
126
- - examples/v201206/account_management/get_account_changes.rb
127
- - examples/v201206/optimization/get_placement_ideas.rb
128
- - examples/v201206/basic_operations/update_campaign.rb
129
- - examples/v201206/basic_operations/get_thirdparty_redirect_ads.rb
130
- - examples/v201206/basic_operations/get_campaigns.rb
131
- - examples/v201206/basic_operations/get_ad_groups.rb
132
- - examples/v201206/basic_operations/add_campaign.rb
133
- - examples/v201206/basic_operations/add_placements.rb
134
- - examples/v201206/basic_operations/add_ad_group.rb
135
- - examples/v201206/basic_operations/delete_ad_group.rb
136
- - examples/v201206/basic_operations/update_placement.rb
137
- - examples/v201206/basic_operations/delete_ad.rb
138
- - examples/v201206/basic_operations/add_thirdparty_redirect_ad.rb
139
- - examples/v201206/basic_operations/update_ad_group.rb
140
- - examples/v201206/basic_operations/delete_campaign.rb
141
- - examples/v201206/basic_operations/delete_placement.rb
142
- - examples/v201206/basic_operations/pause_ad.rb
143
- - examples/v201206/basic_operations/get_placements.rb
144
- - examples/v201206/misc/upload_image.rb
145
- - examples/v201206/misc/get_all_images_and_videos.rb
146
- - examples/v201206/misc/use_oauth.rb
147
- - examples/v201206/remarketing/add_conversion_tracker.rb
148
- - examples/v201206/remarketing/add_audience.rb
112
+ - examples/v201306/reporting/download_criteria_report.rb
113
+ - examples/v201306/reporting/get_campaign_stats.rb
114
+ - examples/v201306/reporting/get_report_fields.rb
115
+ - examples/v201306/error_handling/handle_policy_violation_error.rb
116
+ - examples/v201306/error_handling/handle_two_factor_authorization_error.rb
117
+ - examples/v201306/error_handling/handle_captcha_challenge.rb
118
+ - examples/v201306/error_handling/handle_partial_failures.rb
119
+ - examples/v201306/targeting/lookup_location.rb
120
+ - examples/v201306/targeting/get_targetable_languages_and_carriers.rb
121
+ - examples/v201306/targeting/add_campaign_targeting_criteria.rb
122
+ - examples/v201306/targeting/get_campaign_targeting_criteria.rb
123
+ - examples/v201306/campaign_management/add_placements_in_bulk.rb
124
+ - examples/v201306/campaign_management/get_all_disapproved_ads.rb
125
+ - examples/v201306/account_management/get_account_changes.rb
126
+ - examples/v201306/optimization/get_placement_ideas.rb
127
+ - examples/v201306/basic_operations/update_campaign.rb
128
+ - examples/v201306/basic_operations/get_thirdparty_redirect_ads.rb
129
+ - examples/v201306/basic_operations/get_campaigns.rb
130
+ - examples/v201306/basic_operations/get_ad_groups.rb
131
+ - examples/v201306/basic_operations/add_campaign.rb
132
+ - examples/v201306/basic_operations/add_placements.rb
133
+ - examples/v201306/basic_operations/add_ad_group.rb
134
+ - examples/v201306/basic_operations/delete_ad_group.rb
135
+ - examples/v201306/basic_operations/update_placement.rb
136
+ - examples/v201306/basic_operations/delete_ad.rb
137
+ - examples/v201306/basic_operations/add_thirdparty_redirect_ad.rb
138
+ - examples/v201306/basic_operations/update_ad_group.rb
139
+ - examples/v201306/basic_operations/delete_campaign.rb
140
+ - examples/v201306/basic_operations/delete_placement.rb
141
+ - examples/v201306/basic_operations/pause_ad.rb
142
+ - examples/v201306/basic_operations/get_placements.rb
143
+ - examples/v201306/misc/upload_image.rb
144
+ - examples/v201306/misc/use_oauth2_jwt.rb
145
+ - examples/v201306/misc/get_all_images_and_videos.rb
146
+ - examples/v201306/misc/setup_oauth2.rb
147
+ - examples/v201306/remarketing/add_conversion_tracker.rb
148
+ - examples/v201306/remarketing/add_audience.rb
149
149
  - COPYING
150
150
  - README
151
151
  - ChangeLog
@@ -1,159 +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 gets and downloads an Ad Hoc report from a XML report definition.
22
-
23
- require 'thread'
24
-
25
- require 'adwords_api'
26
- require 'adwords_api/utils'
27
-
28
- def parallel_report_download()
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
- # Determine list of customer IDs to retrieve report for. For this example we
38
- # will use ServicedAccountService to get all IDs in hierarchy.
39
-
40
- serviced_account_srv = adwords.service(:ServicedAccountService, API_VERSION)
41
-
42
- # Get the account hierarchy for this account.
43
- selector = {:enable_paging => false}
44
-
45
- # Run the request at the MCC level.
46
- graph = adwords.use_mcc() {serviced_account_srv.get(selector)}
47
-
48
- # Using queue to balance load between threads.
49
- queue = Queue.new()
50
-
51
- if graph and graph[:accounts] and !graph[:accounts].empty?
52
- graph[:accounts].each {|account| queue << account[:customer_id]}
53
- else
54
- raise StandardError, 'Can not retrieve any customer ID'
55
- end
56
-
57
- # Get report utilities for the version.
58
- report_utils = adwords.report_utils(API_VERSION)
59
-
60
- # Define report definition. You can also pass your own XML text as a string.
61
- report_definition = {
62
- :selector => {
63
- :fields => ['CampaignId', 'Id', 'Impressions', 'Clicks', 'Cost'],
64
- # Predicates are optional.
65
- :predicates => {
66
- :field => 'Status',
67
- :operator => 'IN',
68
- :values => ['ENABLED', 'PAUSED']
69
- }
70
- },
71
- :report_name => 'Custom ADGROUP_PERFORMANCE_REPORT',
72
- :report_type => 'ADGROUP_PERFORMANCE_REPORT',
73
- :download_format => 'CSV',
74
- :date_range_type => 'LAST_7_DAYS',
75
- # Enable to get rows with zero impressions.
76
- :include_zero_impressions => false
77
- }
78
-
79
- puts "Retrieving %d reports with %d threads:" % [queue.size, THREADS]
80
-
81
- reports_succeeded = Queue.new()
82
- reports_failed = Queue.new()
83
-
84
- # Creating a mutex to control access to the queue.
85
- queue_mutex = Mutex.new
86
-
87
- # Start all the threads.
88
- threads = (1..THREADS).map do |thread_id|
89
- Thread.new(report_definition) do |local_def|
90
- cid = nil
91
- begin
92
- cid = queue_mutex.synchronize {(queue.empty?) ? nil : queue.pop(true)}
93
- if cid
94
- retry_count = 0
95
- file_name = "adgroup_%010d.csv" % cid
96
- puts "[%2d/%d] Loading report for customer ID %s into '%s'..." %
97
- [thread_id, retry_count,
98
- AdwordsApi::Utils.format_id(cid), file_name]
99
- begin
100
- report_utils.download_report_as_file(local_def, file_name, cid)
101
- reports_succeeded << {:cid => cid, :file_name => file_name}
102
- rescue AdwordsApi::Errors::ReportError => e
103
- if e.http_code == 500 && retry_count < MAX_RETRIES
104
- retry_count += 1
105
- sleep(retry_count * BACKOFF_FACTOR)
106
- retry
107
- else
108
- puts(("Report failed for customer ID %s with code %d after %d " +
109
- "retries.") % [cid, e.http_code, retry_count + 1])
110
- reports_failed <<
111
- {:cid => cid, :http_code => e.http_code, :message => e.message}
112
- end
113
- end
114
- end
115
- end while (cid != nil)
116
- end
117
- end
118
-
119
- # Wait for all threads to finish.
120
- threads.each { |aThread| aThread.join }
121
-
122
- puts 'Download completed, results:'
123
- puts 'Successful reports:'
124
- while !reports_succeeded.empty? do
125
- result = reports_succeeded.pop()
126
- puts "\tClient ID %s => '%s'" %
127
- [AdwordsApi::Utils.format_id(result[:cid]), result[:file_name]]
128
- end
129
- puts 'Failed reports:'
130
- while !reports_failed.empty? do
131
- result = reports_failed.pop()
132
- puts "\tClient ID %s => Code: %d, Message: '%s'" %
133
- [AdwordsApi::Utils.format_id(result[:cid]),
134
- result[:http_code], result[:message]]
135
- end
136
- puts 'End of results.'
137
- end
138
-
139
- if __FILE__ == $0
140
- API_VERSION = :v201206
141
- # Number of parallel threads to spawn.
142
- THREADS = 10
143
- # Maximum number of retries for 500 errors.
144
- MAX_RETRIES = 5
145
- # Timeout between retries in seconds.
146
- BACKOFF_FACTOR = 5
147
-
148
- begin
149
- parallel_report_download()
150
-
151
- # HTTP errors.
152
- rescue AdsCommon::Errors::HttpError => e
153
- puts "HTTP Error: %s" % e
154
-
155
- # API errors.
156
- rescue AdwordsApi::Errors::ReportError => e
157
- puts "Reporting Error: %s" % e.message
158
- end
159
- end