google-adx-buyer-api 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/ChangeLog +4 -0
  2. data/README +5 -5
  3. data/examples/v201109/basic_operations/add_campaign.rb +4 -5
  4. data/examples/v201109/targeting/add_campaign_targeting_criteria.rb +2 -2
  5. data/examples/v201109_1/account_management/get_account_changes.rb +137 -0
  6. data/examples/v201109_1/basic_operations/add_ad_group.rb +88 -0
  7. data/examples/v201109_1/basic_operations/add_campaign.rb +98 -0
  8. data/examples/v201109_1/basic_operations/add_placements.rb +99 -0
  9. data/examples/v201109_1/basic_operations/add_thirdparty_redirect_ad.rb +105 -0
  10. data/examples/v201109_1/basic_operations/delete_ad.rb +80 -0
  11. data/examples/v201109_1/basic_operations/delete_ad_group.rb +76 -0
  12. data/examples/v201109_1/basic_operations/delete_campaign.rb +77 -0
  13. data/examples/v201109_1/basic_operations/delete_placement.rb +86 -0
  14. data/examples/v201109_1/basic_operations/get_ad_groups.rb +80 -0
  15. data/examples/v201109_1/basic_operations/get_campaigns.rb +77 -0
  16. data/examples/v201109_1/basic_operations/get_placements.rb +92 -0
  17. data/examples/v201109_1/basic_operations/get_thirdparty_redirect_ads.rb +100 -0
  18. data/examples/v201109_1/basic_operations/pause_ad.rb +81 -0
  19. data/examples/v201109_1/basic_operations/update_ad_group.rb +76 -0
  20. data/examples/v201109_1/basic_operations/update_campaign.rb +79 -0
  21. data/examples/v201109_1/basic_operations/update_placement.rb +94 -0
  22. data/examples/v201109_1/campaign_management/add_placements_in_bulk.rb +151 -0
  23. data/examples/v201109_1/campaign_management/get_all_disapproved_ads.rb +92 -0
  24. data/examples/v201109_1/error_handling/handle_captcha_challenge.rb +93 -0
  25. data/examples/v201109_1/error_handling/handle_partial_failures.rb +117 -0
  26. data/examples/v201109_1/error_handling/handle_policy_violation_error.rb +138 -0
  27. data/examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb +87 -0
  28. data/examples/v201109_1/misc/get_all_images_and_videos.rb +101 -0
  29. data/examples/v201109_1/misc/upload_image.rb +87 -0
  30. data/examples/v201109_1/misc/use_oauth.rb +97 -0
  31. data/examples/v201109_1/optimization/get_placement_ideas.rb +106 -0
  32. data/examples/v201109_1/remarketing/add_audience.rb +111 -0
  33. data/examples/v201109_1/remarketing/add_conversion_tracker.rb +93 -0
  34. data/examples/v201109_1/reporting/download_criteria_report.rb +79 -0
  35. data/examples/v201109_1/reporting/download_defined_report.rb +67 -0
  36. data/examples/v201109_1/reporting/get_campaign_stats.rb +105 -0
  37. data/examples/v201109_1/reporting/get_defined_reports.rb +75 -0
  38. data/examples/v201109_1/reporting/get_report_fields.rb +71 -0
  39. data/examples/v201109_1/reporting/parallel_report_download.rb +159 -0
  40. data/examples/v201109_1/targeting/add_campaign_targeting_criteria.rb +110 -0
  41. data/examples/v201109_1/targeting/get_campaign_targeting_criteria.rb +104 -0
  42. data/examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb +82 -0
  43. data/examples/v201109_1/targeting/lookup_location.rb +103 -0
  44. metadata +48 -11
@@ -0,0 +1,104 @@
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 retrieve all the campaign targets. To set
22
+ # campaign targets, run add_campaign_targeting_criteria.rb.
23
+ #
24
+ # Tags: CampaignCriterionService.get
25
+
26
+ require 'adwords_api'
27
+
28
+ def get_campaign_targeting_criteria(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_criterion_srv =
38
+ adwords.service(:CampaignCriterionService, API_VERSION)
39
+
40
+ # Selector to get all the targeting for this campaign.
41
+ selector = {
42
+ :fields => ['Id', 'CriteriaType', 'PlacementUrl'],
43
+ :predicates => [
44
+ {:field => 'CampaignId', :operator => 'EQUALS', :values => [campaign_id]},
45
+ {
46
+ :field => 'CriteriaType',
47
+ :operator => 'EQUALS',
48
+ :values => ['PLACEMENT']
49
+ }
50
+ ],
51
+ :paging => {
52
+ :start_index => 0,
53
+ :number_results => PAGE_SIZE
54
+ }
55
+ }
56
+
57
+ # Set initial values.
58
+ offset, page = 0, {}
59
+
60
+ begin
61
+ page = campaign_criterion_srv.get(selector)
62
+ if page[:entries]
63
+ page[:entries].each do |criterion|
64
+ placement = criterion[:criterion]
65
+ puts "Placement with ID %d, type '%s' and URL '%s' was found." %
66
+ [placement[:id], placement[:type], placement[:url]]
67
+ end
68
+ # Increment values to request the next page.
69
+ offset += PAGE_SIZE
70
+ selector[:paging][:start_index] = offset
71
+ end
72
+ end while page[:total_num_entries] > offset
73
+
74
+ if page.include?(:total_num_entries)
75
+ puts "\tCampaign ID %d has %d placements." %
76
+ [campaign_id, page[:total_num_entries]]
77
+ end
78
+ end
79
+
80
+ if __FILE__ == $0
81
+ API_VERSION = :v201109_1
82
+ PAGE_SIZE = 500
83
+
84
+ begin
85
+ # Specify campaign ID to get targeting for.
86
+ campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
87
+ get_campaign_targeting_criteria(campaign_id)
88
+
89
+ # HTTP errors.
90
+ rescue AdsCommon::Errors::HttpError => e
91
+ puts "HTTP Error: %s" % e
92
+
93
+ # API errors.
94
+ rescue AdwordsApi::Errors::ApiException => e
95
+ puts "Message: %s" % e.message
96
+ puts 'Errors:'
97
+ e.errors.each_with_index do |error, index|
98
+ puts "\tError [%d]:" % (index + 1)
99
+ error.each do |field, value|
100
+ puts "\t\t%s: %s" % [field, value]
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,82 @@
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 retrieve all languages and carriers available
22
+ # for targeting.
23
+ #
24
+ # Tags: ConstantDataService.getLanguageCriterion
25
+ # Tags: ConstantDataService.getCarrierCriterion
26
+
27
+ require 'adwords_api'
28
+
29
+ def get_targetable_languages_and_carriers()
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
+ constant_data_srv = adwords.service(:ConstantDataService, API_VERSION)
39
+
40
+ # Get all languages from ConstantDataService.
41
+ languages = constant_data_srv.get_language_criterion()
42
+
43
+ if languages
44
+ languages.each do |language|
45
+ puts "Language name is '%s', ID is %d and code is '%s'." %
46
+ [language[:name], language[:id], language[:code]]
47
+ end
48
+ else
49
+ puts 'No languages were found.'
50
+ end
51
+
52
+ # Get all carriers from ConstantDataService.
53
+ carriers = constant_data_srv.get_carrier_criterion()
54
+
55
+ carriers.each do |carrier|
56
+ puts "Carrier name is '%s', ID is %d and country code is '%s'." %
57
+ [carrier[:name], carrier[:id], carrier[:country_code]]
58
+ end
59
+ end
60
+
61
+ if __FILE__ == $0
62
+ API_VERSION = :v201109_1
63
+
64
+ begin
65
+ get_targetable_languages_and_carriers()
66
+
67
+ # HTTP errors.
68
+ rescue AdsCommon::Errors::HttpError => e
69
+ puts "HTTP Error: %s" % e
70
+
71
+ # API errors.
72
+ rescue AdwordsApi::Errors::ApiException => e
73
+ puts "Message: %s" % e.message
74
+ puts 'Errors:'
75
+ e.errors.each_with_index do |error, index|
76
+ puts "\tError [%d]:" % (index + 1)
77
+ error.each do |field, value|
78
+ puts "\t\t%s: %s" % [field, value]
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,103 @@
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 location criteria by name.
22
+ #
23
+ # Tags: LocationCriterionService.get
24
+
25
+ require 'adwords_api'
26
+
27
+ def lookup_location()
28
+ # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
29
+ # when called without parameters.
30
+ adwords = AdwordsApi::Api.new
31
+
32
+ # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
33
+ # the configuration file or provide your own logger:
34
+ # adwords.logger = Logger.new('adwords_xml.log')
35
+
36
+ location_criterion_srv =
37
+ adwords.service(:LocationCriterionService, API_VERSION)
38
+
39
+ # List of locations to look up.
40
+ location_names = ['Paris', 'Quebec', 'Spain', 'Deutschland']
41
+ # Locale to retrieve names in.
42
+ locale = 'en'
43
+
44
+ # Get the criteria by names.
45
+ selector = {
46
+ :fields => ['Id', 'LocationName', 'CanonicalName', 'DisplayType',
47
+ 'ParentLocations', 'Reach'],
48
+ :predicates => [
49
+ # Location names must match exactly, only EQUALS and IN are supported.
50
+ {:field => 'LocationName',
51
+ :operator => 'IN',
52
+ :values => location_names},
53
+ # Set the locale of the returned location names.
54
+ {:field => 'Locale', :operator => 'EQUALS', :values => [locale]}
55
+ ]
56
+ }
57
+ criteria = location_criterion_srv.get(selector)
58
+
59
+ if criteria
60
+ criteria.each do |criterion|
61
+ # Extract all parent location names as one comma-separated string.
62
+ parent_location = if criterion[:location][:parent_locations] and
63
+ !criterion[:location][:parent_locations].empty?
64
+ locations_array = criterion[:location][:parent_locations].map do |loc|
65
+ loc[:location_name]
66
+ end
67
+ locations_array.join(', ')
68
+ else
69
+ 'N/A'
70
+ end
71
+ puts ("The search term '%s' returned the location '%s' of type '%s' " +
72
+ "with ID %d, parent locations '%s' and reach %d") %
73
+ [criterion[:search_term], criterion[:location][:location_name],
74
+ criterion[:location][:criterion_type], criterion[:location][:id],
75
+ parent_location, criterion[:reach]]
76
+ end
77
+ else
78
+ puts 'No criteria were returned.'
79
+ end
80
+ end
81
+
82
+ if __FILE__ == $0
83
+ API_VERSION = :v201109_1
84
+
85
+ begin
86
+ lookup_location()
87
+
88
+ # HTTP errors.
89
+ rescue AdsCommon::Errors::HttpError => e
90
+ puts "HTTP Error: %s" % e
91
+
92
+ # API errors.
93
+ rescue AdwordsApi::Errors::ApiException => e
94
+ puts "Message: %s" % e.message
95
+ puts 'Errors:'
96
+ e.errors.each_with_index do |error, index|
97
+ puts "\tError [%d]:" % (index + 1)
98
+ error.each do |field, value|
99
+ puts "\t\t%s: %s" % [field, value]
100
+ end
101
+ end
102
+ end
103
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-adx-buyer-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Danial Klimkin
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-20 00:00:00 +04:00
19
- default_executable:
18
+ date: 2012-06-18 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: google-adwords-api
@@ -26,12 +25,12 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 9
28
+ hash: 5
30
29
  segments:
31
30
  - 0
32
- - 5
31
+ - 6
33
32
  - 1
34
- version: 0.5.1
33
+ version: 0.6.1
35
34
  type: :runtime
36
35
  version_requirements: *id001
37
36
  description: AdWords API and DoubleClick Ad Exchange Buyer API client library for Ruby
@@ -44,6 +43,45 @@ extensions: []
44
43
  extra_rdoc_files: []
45
44
 
46
45
  files:
46
+ - examples/v201109_1/reporting/download_criteria_report.rb
47
+ - examples/v201109_1/reporting/download_defined_report.rb
48
+ - examples/v201109_1/reporting/get_defined_reports.rb
49
+ - examples/v201109_1/reporting/get_campaign_stats.rb
50
+ - examples/v201109_1/reporting/parallel_report_download.rb
51
+ - examples/v201109_1/reporting/get_report_fields.rb
52
+ - examples/v201109_1/error_handling/handle_policy_violation_error.rb
53
+ - examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb
54
+ - examples/v201109_1/error_handling/handle_captcha_challenge.rb
55
+ - examples/v201109_1/error_handling/handle_partial_failures.rb
56
+ - examples/v201109_1/targeting/lookup_location.rb
57
+ - examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb
58
+ - examples/v201109_1/targeting/add_campaign_targeting_criteria.rb
59
+ - examples/v201109_1/targeting/get_campaign_targeting_criteria.rb
60
+ - examples/v201109_1/campaign_management/add_placements_in_bulk.rb
61
+ - examples/v201109_1/campaign_management/get_all_disapproved_ads.rb
62
+ - examples/v201109_1/account_management/get_account_changes.rb
63
+ - examples/v201109_1/optimization/get_placement_ideas.rb
64
+ - examples/v201109_1/basic_operations/update_campaign.rb
65
+ - examples/v201109_1/basic_operations/get_thirdparty_redirect_ads.rb
66
+ - examples/v201109_1/basic_operations/get_campaigns.rb
67
+ - examples/v201109_1/basic_operations/get_ad_groups.rb
68
+ - examples/v201109_1/basic_operations/add_campaign.rb
69
+ - examples/v201109_1/basic_operations/add_placements.rb
70
+ - examples/v201109_1/basic_operations/add_ad_group.rb
71
+ - examples/v201109_1/basic_operations/delete_ad_group.rb
72
+ - examples/v201109_1/basic_operations/update_placement.rb
73
+ - examples/v201109_1/basic_operations/delete_ad.rb
74
+ - examples/v201109_1/basic_operations/add_thirdparty_redirect_ad.rb
75
+ - examples/v201109_1/basic_operations/update_ad_group.rb
76
+ - examples/v201109_1/basic_operations/delete_campaign.rb
77
+ - examples/v201109_1/basic_operations/delete_placement.rb
78
+ - examples/v201109_1/basic_operations/pause_ad.rb
79
+ - examples/v201109_1/basic_operations/get_placements.rb
80
+ - examples/v201109_1/misc/upload_image.rb
81
+ - examples/v201109_1/misc/get_all_images_and_videos.rb
82
+ - examples/v201109_1/misc/use_oauth.rb
83
+ - examples/v201109_1/remarketing/add_conversion_tracker.rb
84
+ - examples/v201109_1/remarketing/add_audience.rb
47
85
  - examples/v201109/reporting/download_criteria_report.rb
48
86
  - examples/v201109/reporting/download_defined_report.rb
49
87
  - examples/v201109/reporting/get_defined_reports.rb
@@ -86,7 +124,6 @@ files:
86
124
  - COPYING
87
125
  - README
88
126
  - ChangeLog
89
- has_rdoc: true
90
127
  homepage: http://code.google.com/p/google-api-ads-ruby/
91
128
  licenses: []
92
129
 
@@ -118,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
155
  requirements: []
119
156
 
120
157
  rubyforge_project: google-adx-buyer-api
121
- rubygems_version: 1.3.7
158
+ rubygems_version: 1.8.24
122
159
  signing_key:
123
160
  specification_version: 3
124
161
  summary: Ruby examples for DoubleClick Ad Exchange Buyer API