google-adwords-api 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/ChangeLog +4 -0
  2. data/README +124 -107
  3. data/examples/v201306/misc/use_oauth2_jwt.rb +5 -1
  4. data/examples/v201309/misc/use_oauth2_jwt.rb +5 -1
  5. data/examples/v201402/account_management/create_account.rb +95 -0
  6. data/examples/v201402/account_management/get_account_alerts.rb +122 -0
  7. data/examples/v201402/account_management/get_account_changes.rb +145 -0
  8. data/examples/v201402/account_management/get_account_hierarchy.rb +103 -0
  9. data/examples/v201402/advanced_operations/add_ad_group_bid_modifier.rb +105 -0
  10. data/examples/v201402/advanced_operations/add_click_to_download_ad.rb +137 -0
  11. data/examples/v201402/advanced_operations/add_places_location_extensions.rb +159 -0
  12. data/examples/v201402/advanced_operations/add_places_location_extensions.rb~ +159 -0
  13. data/examples/v201402/advanced_operations/add_site_links.rb +306 -0
  14. data/examples/v201402/advanced_operations/get_ad_group_bid_modifiers.rb +106 -0
  15. data/examples/v201402/advanced_operations/update_site_links.rb +194 -0
  16. data/examples/v201402/advanced_operations/upload_offline_conversions.rb +117 -0
  17. data/examples/v201402/advanced_operations/use_shared_bidding_strategy.rb +163 -0
  18. data/examples/v201402/basic_operations/add_ad_groups.rb +142 -0
  19. data/examples/v201402/basic_operations/add_ad_groups.rb~ +147 -0
  20. data/examples/v201402/basic_operations/add_campaigns.rb +153 -0
  21. data/examples/v201402/basic_operations/add_keywords.rb +116 -0
  22. data/examples/v201402/basic_operations/add_text_ads.rb +113 -0
  23. data/examples/v201402/basic_operations/delete_ad.rb +93 -0
  24. data/examples/v201402/basic_operations/delete_ad_group.rb +110 -0
  25. data/examples/v201402/basic_operations/delete_campaign.rb +111 -0
  26. data/examples/v201402/basic_operations/delete_keyword.rb +98 -0
  27. data/examples/v201402/basic_operations/get_ad_groups.rb +106 -0
  28. data/examples/v201402/basic_operations/get_campaigns.rb +101 -0
  29. data/examples/v201402/basic_operations/get_campaigns_with_awql.rb +93 -0
  30. data/examples/v201402/basic_operations/get_keywords.rb +112 -0
  31. data/examples/v201402/basic_operations/get_text_ads.rb +114 -0
  32. data/examples/v201402/basic_operations/pause_ad.rb +92 -0
  33. data/examples/v201402/basic_operations/update_ad_group.rb +89 -0
  34. data/examples/v201402/basic_operations/update_campaign.rb +90 -0
  35. data/examples/v201402/basic_operations/update_keyword.rb +110 -0
  36. data/examples/v201402/campaign_management/add_experiment.rb +166 -0
  37. data/examples/v201402/campaign_management/add_keywords_in_bulk.rb +158 -0
  38. data/examples/v201402/campaign_management/add_location_extension.rb +125 -0
  39. data/examples/v201402/campaign_management/get_all_disapproved_ads.rb +101 -0
  40. data/examples/v201402/campaign_management/get_all_disapproved_ads_with_awql.rb +93 -0
  41. data/examples/v201402/campaign_management/promote_experiment.rb +85 -0
  42. data/examples/v201402/campaign_management/set_ad_parameters.rb +122 -0
  43. data/examples/v201402/campaign_management/set_criterion_bid_modifier.rb +108 -0
  44. data/examples/v201402/campaign_management/validate_text_ad.rb +114 -0
  45. data/examples/v201402/error_handling/handle_captcha_challenge.rb +93 -0
  46. data/examples/v201402/error_handling/handle_partial_failures.rb +134 -0
  47. data/examples/v201402/error_handling/handle_policy_violation_error.rb +145 -0
  48. data/examples/v201402/error_handling/handle_two_factor_authorization_error.rb +88 -0
  49. data/examples/v201402/misc/create_ad_words_session_without_properties_file.rb +94 -0
  50. data/examples/v201402/misc/create_ad_words_session_without_properties_file.rb~ +94 -0
  51. data/examples/v201402/misc/get_all_images_and_videos.rb +108 -0
  52. data/examples/v201402/misc/setup_oauth2.rb +88 -0
  53. data/examples/v201402/misc/upload_image.rb +97 -0
  54. data/examples/v201402/misc/use_oauth2_jwt.rb +97 -0
  55. data/examples/v201402/optimization/estimate_keyword_traffic.rb +137 -0
  56. data/examples/v201402/optimization/get_keyword_bid_simulations.rb +100 -0
  57. data/examples/v201402/optimization/get_keyword_ideas.rb +130 -0
  58. data/examples/v201402/optimization/get_placement_ideas.rb +112 -0
  59. data/examples/v201402/remarketing/add_audience.rb +123 -0
  60. data/examples/v201402/remarketing/add_conversion_tracker.rb +105 -0
  61. data/examples/v201402/remarketing/add_conversion_tracker.rb~ +109 -0
  62. data/examples/v201402/reporting/download_criteria_report.rb +87 -0
  63. data/examples/v201402/reporting/download_criteria_report_with_awql.rb +86 -0
  64. data/examples/v201402/reporting/get_report_fields.rb +79 -0
  65. data/examples/v201402/reporting/parallel_report_download.rb +171 -0
  66. data/examples/v201402/shopping_campaigns/add_product_partition_tree.rb +269 -0
  67. data/examples/v201402/shopping_campaigns/add_product_partition_tree.rb~ +269 -0
  68. data/examples/v201402/shopping_campaigns/add_product_scope.rb +133 -0
  69. data/examples/v201402/shopping_campaigns/add_shopping_campaign.rb +135 -0
  70. data/examples/v201402/shopping_campaigns/add_shopping_campaign.rb~ +136 -0
  71. data/examples/v201402/shopping_campaigns/get_product_category_taxonomy.rb +117 -0
  72. data/examples/v201402/shopping_campaigns/get_product_category_taxonomy.rb~ +128 -0
  73. data/examples/v201402/shopping_campaigns/set_product_sales_channel.rb +98 -0
  74. data/examples/v201402/shopping_campaigns/set_product_sales_channel.rb~ +98 -0
  75. data/examples/v201402/targeting/add_campaign_targeting_criteria.rb +157 -0
  76. data/examples/v201402/targeting/add_demographic_targeting_criteria.rb +116 -0
  77. data/examples/v201402/targeting/get_campaign_targeting_criteria.rb +110 -0
  78. data/examples/v201402/targeting/get_targetable_languages_and_carriers.rb +94 -0
  79. data/examples/v201402/targeting/lookup_location.rb +112 -0
  80. data/lib/adwords_api.rb +7 -0
  81. data/lib/adwords_api/api_config.rb +76 -4
  82. data/lib/adwords_api/report_header_handler.rb +1 -1
  83. data/lib/adwords_api/v201402/ad_group_ad_service.rb +42 -0
  84. data/lib/adwords_api/v201402/ad_group_ad_service_registry.rb +46 -0
  85. data/lib/adwords_api/v201402/ad_group_bid_modifier_service.rb +42 -0
  86. data/lib/adwords_api/v201402/ad_group_bid_modifier_service_registry.rb +46 -0
  87. data/lib/adwords_api/v201402/ad_group_criterion_service.rb +42 -0
  88. data/lib/adwords_api/v201402/ad_group_criterion_service_registry.rb +46 -0
  89. data/lib/adwords_api/v201402/ad_group_feed_service.rb +42 -0
  90. data/lib/adwords_api/v201402/ad_group_feed_service_registry.rb +46 -0
  91. data/lib/adwords_api/v201402/ad_group_service.rb +42 -0
  92. data/lib/adwords_api/v201402/ad_group_service_registry.rb +46 -0
  93. data/lib/adwords_api/v201402/ad_param_service.rb +38 -0
  94. data/lib/adwords_api/v201402/ad_param_service_registry.rb +46 -0
  95. data/lib/adwords_api/v201402/adwords_user_list_service.rb +38 -0
  96. data/lib/adwords_api/v201402/adwords_user_list_service_registry.rb +46 -0
  97. data/lib/adwords_api/v201402/alert_service.rb +34 -0
  98. data/lib/adwords_api/v201402/alert_service_registry.rb +46 -0
  99. data/lib/adwords_api/v201402/bidding_strategy_service.rb +42 -0
  100. data/lib/adwords_api/v201402/bidding_strategy_service_registry.rb +46 -0
  101. data/lib/adwords_api/v201402/budget_order_service.rb +42 -0
  102. data/lib/adwords_api/v201402/budget_order_service_registry.rb +46 -0
  103. data/lib/adwords_api/v201402/budget_service.rb +42 -0
  104. data/lib/adwords_api/v201402/budget_service_registry.rb +46 -0
  105. data/lib/adwords_api/v201402/campaign_ad_extension_service.rb +38 -0
  106. data/lib/adwords_api/v201402/campaign_ad_extension_service_registry.rb +46 -0
  107. data/lib/adwords_api/v201402/campaign_criterion_service.rb +42 -0
  108. data/lib/adwords_api/v201402/campaign_criterion_service_registry.rb +46 -0
  109. data/lib/adwords_api/v201402/campaign_feed_service.rb +42 -0
  110. data/lib/adwords_api/v201402/campaign_feed_service_registry.rb +46 -0
  111. data/lib/adwords_api/v201402/campaign_service.rb +42 -0
  112. data/lib/adwords_api/v201402/campaign_service_registry.rb +46 -0
  113. data/lib/adwords_api/v201402/constant_data_service.rb +66 -0
  114. data/lib/adwords_api/v201402/constant_data_service_registry.rb +46 -0
  115. data/lib/adwords_api/v201402/conversion_tracker_service.rb +38 -0
  116. data/lib/adwords_api/v201402/conversion_tracker_service_registry.rb +46 -0
  117. data/lib/adwords_api/v201402/customer_feed_service.rb +42 -0
  118. data/lib/adwords_api/v201402/customer_feed_service_registry.rb +46 -0
  119. data/lib/adwords_api/v201402/customer_service.rb +38 -0
  120. data/lib/adwords_api/v201402/customer_service_registry.rb +46 -0
  121. data/lib/adwords_api/v201402/customer_sync_service.rb +34 -0
  122. data/lib/adwords_api/v201402/customer_sync_service_registry.rb +47 -0
  123. data/lib/adwords_api/v201402/data_service.rb +46 -0
  124. data/lib/adwords_api/v201402/data_service_registry.rb +46 -0
  125. data/lib/adwords_api/v201402/experiment_service.rb +38 -0
  126. data/lib/adwords_api/v201402/experiment_service_registry.rb +46 -0
  127. data/lib/adwords_api/v201402/feed_item_service.rb +42 -0
  128. data/lib/adwords_api/v201402/feed_item_service_registry.rb +46 -0
  129. data/lib/adwords_api/v201402/feed_mapping_service.rb +42 -0
  130. data/lib/adwords_api/v201402/feed_mapping_service_registry.rb +46 -0
  131. data/lib/adwords_api/v201402/feed_service.rb +42 -0
  132. data/lib/adwords_api/v201402/feed_service_registry.rb +46 -0
  133. data/lib/adwords_api/v201402/geo_location_service.rb +34 -0
  134. data/lib/adwords_api/v201402/geo_location_service_registry.rb +46 -0
  135. data/lib/adwords_api/v201402/location_criterion_service.rb +38 -0
  136. data/lib/adwords_api/v201402/location_criterion_service_registry.rb +46 -0
  137. data/lib/adwords_api/v201402/managed_customer_service.rb +50 -0
  138. data/lib/adwords_api/v201402/managed_customer_service_registry.rb +46 -0
  139. data/lib/adwords_api/v201402/media_service.rb +42 -0
  140. data/lib/adwords_api/v201402/media_service_registry.rb +46 -0
  141. data/lib/adwords_api/v201402/mutate_job_service.rb +42 -0
  142. data/lib/adwords_api/v201402/mutate_job_service_registry.rb +46 -0
  143. data/lib/adwords_api/v201402/offline_conversion_feed_service.rb +34 -0
  144. data/lib/adwords_api/v201402/offline_conversion_feed_service_registry.rb +46 -0
  145. data/lib/adwords_api/v201402/report_definition_service.rb +34 -0
  146. data/lib/adwords_api/v201402/report_definition_service_registry.rb +46 -0
  147. data/lib/adwords_api/v201402/targeting_idea_service.rb +38 -0
  148. data/lib/adwords_api/v201402/targeting_idea_service_registry.rb +46 -0
  149. data/lib/adwords_api/v201402/traffic_estimator_service.rb +34 -0
  150. data/lib/adwords_api/v201402/traffic_estimator_service_registry.rb +46 -0
  151. data/lib/adwords_api/version.rb +1 -1
  152. data/test/adwords_api/test_adwords_api.rb +15 -2
  153. data/test/adwords_api/test_adwords_api.rb~ +127 -0
  154. data/test/templates/v201306/basic_operations_get_campaigns.def +1 -1
  155. data/test/templates/v201306/misc_use_oauth2_jwt.def +1 -1
  156. data/test/templates/v201309/basic_operations_get_campaigns.def +1 -1
  157. data/test/templates/v201309/misc_use_oauth2_jwt.def +1 -1
  158. metadata +146 -2
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 0.11.1:
2
+ - Support and examples for v201402.
3
+ - Removed support for ClientLogin for versions > v201309.
4
+
1
5
  0.11.0:
2
6
  - Removed deprecated API version v201302.
3
7
 
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = Google AdWords and DoubleClick Ad Exchange Buyer Client Library
1
+ # Google AdWords and DoubleClick Ad Exchange Buyer Client Library
2
2
 
3
3
  Welcome to the next generation Google-developed Ruby client library for the
4
4
  AdWords and DoubleClick Ad Exchange Buyer API!
@@ -8,216 +8,230 @@ programming interface that lets you handle everything in native Ruby
8
8
  collections.
9
9
 
10
10
 
11
- = Docs for Users
11
+ # Docs for Users
12
12
 
13
- == 1 - Installation:
13
+ ## 1 - Installation
14
14
 
15
- google-adwords-api and google-adx-buyer-api are ruby gems.
16
- See http://docs.rubygems.org/read/book/1
15
+ `google-adwords-api` and `google-adx-buyer-api` are ruby gems. See
16
+ [http://docs.rubygems.org/read/book/1]().
17
17
 
18
18
  Install them using the gem install command:
19
- $ gem install --remote google-adwords-api
20
- $ gem install --remote google-adx-buyer-api
19
+
20
+ $ gem install --remote google-adwords-api
21
+ $ gem install --remote google-adx-buyer-api
21
22
 
22
23
  Please note the google-adx-buyer-api gem contains only DoubleClick Ad Exchange
23
24
  Buyer client library examples. You need the AdWords library in order to use it
24
25
  which is installed automatically as a dependency.
25
26
 
26
27
  The following gem libraries are required:
27
- - savon;
28
- - google-ads-common.
28
+
29
+ - savon
30
+ - google-ads-common
29
31
 
30
32
 
31
- == 2 - Using the client library:
33
+ ## 2 - Using the client library
32
34
 
33
35
  Include the library with 'require':
34
- require 'adwords_api'
36
+
37
+ require 'adwords_api'
35
38
 
36
39
  Then create an API instance:
37
- adwords = AdwordsApi::Api.new
40
+
41
+ adwords = AdwordsApi::Api.new
38
42
 
39
43
  The created API object will grant you access to all the services for all of the
40
- currently supported vesions of the APIs. It uses a config file in:
41
- ENV['HOME']/adwords_api.yml to read all of your configurations by default.
44
+ currently supported vesions of the APIs. It uses a config file in
45
+ `ENV['HOME']/adwords_api.yml` to read all of your configurations by default.
42
46
 
43
47
  There is an example configuration file shipped with these libraries.
44
48
 
45
49
  You can also pass API a manually constructed config hash like:
46
- adwords = AdwordsApi::Api.new({
47
- :authentication => {
48
- :method => 'OAuth2',
49
- :oauth2_client_id: 'INSERT_OAUTH2_CLIENT_ID_HERE'
50
- :oauth2_client_secret: 'INSERT_OAUTH2_CLIENT_SECRET_HERE'
51
- :developer_token => 'DEVELOPER_TOKEN',
52
- :client_customer_id => '012-345-6789',
53
- :user_agent => 'Ruby Sample'
54
- },
55
- :service => {
56
- :environment => 'PRODUCTION'
57
- }
58
- })
59
-
60
- To obtain OAuth2 client credentials, follow instructions on the wiki:
61
-
62
- http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2
63
-
64
- Once the library instance is create, specify which service you're looking to
50
+
51
+ adwords = AdwordsApi::Api.new({
52
+ :authentication => {
53
+ :method => 'OAuth2',
54
+ :oauth2_client_id => 'INSERT_OAUTH2_CLIENT_ID_HERE',
55
+ :oauth2_client_secret => 'INSERT_OAUTH2_CLIENT_SECRET_HERE',
56
+ :developer_token => 'DEVELOPER_TOKEN',
57
+ :client_customer_id => '012-345-6789',
58
+ :user_agent => 'Ruby Sample'
59
+ },
60
+ :service => {
61
+ :environment => 'PRODUCTION'
62
+ }
63
+ })
64
+
65
+ To obtain OAuth2 client credentials, follow the instructions
66
+ [on the wiki](https://github.com/googleads/google-api-ads-ruby/wiki/OAuth2).
67
+
68
+ Once the library instance is created, specify which service you're looking to
65
69
  use, and which version:
66
- campaign_srv = adwords.service(:CampaignService, :v201309)
67
70
 
68
- and you should now be able to just use the API methods in the object you were
71
+ campaign_srv = adwords.service(:CampaignService, :v201309)
72
+
73
+ You should now be able to just use the API methods in the object you were
69
74
  returned:
70
- # Get 'Id', 'Name' and 'Status' fields of all campaigns.
71
- campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']})
75
+
76
+ # Get 'Id', 'Name' and 'Status' fields of all campaigns.
77
+ campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']})
72
78
 
73
79
  See the code in the examples directory for working examples you can build from.
74
80
 
75
- *Note*: if your setup requires you to send connections through a proxy server,
76
- please set the appropriate options in the config file or config hash. E.g.:
77
- config[:connection] = {
78
- :proxy => 'http://user:password@proxy_hostname:8080'
79
- }
81
+ *Note*: If your setup requires you to send connections through a proxy server,
82
+ please set the appropriate options in the config file or config hash.
83
+ For example:
80
84
 
81
- *Note*: if you are using Ruby 1.8 you may need to include RubyGems to be able
85
+ config[:connection] = {
86
+ :proxy => 'http://user:password@proxy_hostname:8080'
87
+ }
88
+
89
+ *Note*: If you are using Ruby 1.8 you may need to include RubyGems to be able
82
90
  to require other gems code. There are several ways to do it, the easiest one is
83
91
  to pass '-rubygems' parameter to the ruby interpreter:
84
- $ ruby -rubygems my_program_that_uses_gems
92
+
93
+ $ ruby -rubygems my_program_that_uses_gems
85
94
 
86
95
  you can also set this up in the environment:
87
- $ export RUBYOPT="rubygems"
96
+
97
+ $ export RUBYOPT="rubygems"
88
98
 
89
99
  or add it to the bash configuration file:
90
- $ echo 'export RUBYOPT="rubygems"' >> ~/.bashrc
100
+
101
+ $ echo 'export RUBYOPT="rubygems"' >> ~/.bashrc
91
102
 
92
103
 
93
- === 2.1 - Ruby names for a Ruby library:
104
+ ### 2.1 - Ruby names for a Ruby library
94
105
 
95
106
  In order to make things more Ruby-like for our Ruby developers, we've renamed
96
107
  API objects and methods to more closely match Ruby conventions. This means using
97
108
  snake_case for methods and parameters, and UpperCamelCase for class names.
98
109
 
99
- For example, the 'startDate' field of the Campaign object is named 'start_date'
100
- in the client library. The 'get' method, returns a CampaignPage object which has
101
- an 'entries' and a 'total_num_entries' field. So, to access the return
110
+ For example, the `startDate` field of the Campaign object is named `start_date`
111
+ in the client library. The `get` method, returns a CampaignPage object which has
112
+ `entries` and `total_num_entries` fields. So, to access the return
102
113
  values, you would do this:
103
114
 
104
- response = campaign_srv.get(selector)
105
- num_entries = response[:total_num_entries]
115
+ response = campaign_srv.get(selector)
116
+ num_entries = response[:total_num_entries]
106
117
 
107
118
  Essentially, all you have to do is follow Ruby conventions, and the library will
108
119
  do the rest. All of the examples are written following this standard.
109
120
 
110
121
 
111
- === 2.2 - Using the Test Account:
122
+ ### 2.2 - Using the Test Account
112
123
 
113
124
  For testing purposes, obtain a Test Account in the production environment. Any
114
- request against a Test Account inccurs no API units charge. See this guide for
115
- more details:
125
+ request against a Test Account inccurs no API units charge. See
126
+ [this guide](https://developers.google.com/adwords/api/docs/test-accounts) for
127
+ more details.
116
128
 
117
- https://developers.google.com/adwords/api/docs/test-accounts
118
-
119
- To use the library against a Test Account, set client_customer_id property in
129
+ To use the library against a Test Account, set the `client_customer_id` property in
120
130
  the configuration file to its client customer ID.
121
131
 
122
132
 
123
- === 2.3 - Logging:
133
+ ### 2.3 - Logging
124
134
 
125
135
  It is often useful to see a trace of the raw SOAP XML being sent and received.
126
136
  The quickest way of achieving this when debugging your application is by setting
127
- the library.log_level configuration variable to 'DEBUG':
128
- config[:library] = {
129
- :log_level => 'DEBUG'
130
- }
131
- or via configuration file (see example).
137
+ the `library.log_level` configuration variable to DEBUG.
138
+
139
+ config[:library] = {
140
+ :log_level => 'DEBUG'
141
+ }
142
+
143
+ This can alternatively be done via a configuration file.
132
144
 
133
- This will output the SOAP XML to stderr, which will usually show up in your
145
+ This will output the SOAP XML to `stderr`, which will usually show up in your
134
146
  terminal window.
135
147
 
136
148
  There's also an option of logging requests and XML to a file. In order to enable
137
149
  this, you should create a standard Logger object and pass it to the library:
138
- require 'logger'
139
- logger = Logger.new('path/to/log_filename')
140
- logger.level = Logger::DEBUG
141
- adwords = AdwordsApi::Api.new
142
- adwords.logger = logger
150
+
151
+ require 'logger'
152
+ logger = Logger.new('path/to/log_filename')
153
+ logger.level = Logger::DEBUG
154
+ adwords = AdwordsApi::Api.new
155
+ adwords.logger = logger
143
156
 
144
157
  Request details and units spend are logged at the INFO log level, while raw HTTP
145
158
  headers and XML dumps are logged at the DEBUG log level. For more details on
146
159
  using Logger refer to the Ruby Logger documentation.
147
160
 
148
- === 2.4 - Calculating operations usage
149
161
 
150
- Each AdWords API operation performed consumes a certain number of operations as
151
- described in the rate sheet:
162
+ ### 2.4 - Calculating operations usage
152
163
 
153
- https://developers.google.com/adwords/api/docs/ratesheet
164
+ Each AdWords API operation performed consumes a certain number of operations as
165
+ described in the
166
+ [rate sheet](https://developers.google.com/adwords/api/docs/ratesheet).
154
167
 
155
168
  The amount of operations consumed is returned in the header part of the SOAP
156
169
  response. This information can be obtained by passing a user block during the
157
170
  method call:
158
171
 
159
- response = campaign_srv.get(selector) do |header|
160
- puts "Operations consumed: %d" % header[:operations]
161
- end
172
+ response = campaign_srv.get(selector) do |header|
173
+ puts "Operations consumed: %d" % header[:operations]
174
+ end
162
175
 
163
176
  You can also retrieve the response body as the second block parameter:
164
- campaign_srv.get(selector) {|header, body| ... }
165
177
 
166
- === 2.5 - GZip compression
178
+ campaign_srv.get(selector) {|header, body| ... }
179
+
180
+
181
+ ### 2.5 - GZip compression
167
182
 
168
183
  The library offers a transparent compression option which can be enabled in the
169
184
  configuration file or by the following setting:
170
185
 
171
- config[:connection] = {
172
- :enable_gzip => true
173
- }
186
+ config[:connection] = {
187
+ :enable_gzip => true
188
+ }
174
189
 
175
190
  Enabling this option will set the headers required to request the server to
176
191
  respond in gzipped format. All requests are sent uncompressed regardless.
177
192
 
178
193
 
179
- = Docs for Developers
194
+ # Docs for Developers
180
195
 
181
- == Rake targets
196
+ ## Rake targets
182
197
 
183
- $ rake generate
184
- to regenerate the stubs if needed
198
+ $ rake generate
185
199
 
186
- $ gem build google-adwords-api.gemspec
187
- $ gem build google-adx-buyer-api.gemspec
188
- to build the gems
200
+ to regenerate the stubs if needed
189
201
 
190
- $ rake test
191
- to run unit tests on the library
202
+ $ gem build google-adwords-api.gemspec
203
+ $ gem build google-adx-buyer-api.gemspec
192
204
 
205
+ to build the gems
193
206
 
194
- == Where do I submit bug reports and feature requests?
207
+ $ rake test
195
208
 
196
- Bug reports and feature requests can be posted on the library page:
209
+ to run unit tests on the library
197
210
 
198
- http://code.google.com/p/google-api-ads-ruby/issues
199
211
 
200
- Questions can be asked on forum
212
+ ## Where do I submit bug reports and feature requests?
201
213
 
202
- http://groups.google.com/group/adwords-api
214
+ Bug reports and feature requests can be posted
215
+ [on the library page](https://github.com/googleads/google-api-ads-ruby/issues).
203
216
 
204
- Make sure to subscribe to our Google Plus page for API change announcements and
205
- other news:
217
+ Questions can be asked [on the forum](http://groups.google.com/group/adwords-api).
206
218
 
207
- https://plus.google.com/+GoogleAdsDevelopers
219
+ Make sure to subscribe to our
220
+ [Google Plus page](https://plus.google.com/+GoogleAdsDevelopers) for API change
221
+ announcements and other news.
208
222
 
209
223
 
210
- = Copyright/License Info
224
+ # Copyright/License Info
211
225
 
212
- == Licence
226
+ ## Licence
213
227
 
214
228
  Copyright 2010-2013, Google Inc. All Rights Reserved.
215
229
 
216
230
  Licensed under the Apache License, Version 2.0 (the "License");
217
231
  you may not use this file except in compliance with the License.
218
- You may obtain a copy of the License at
232
+ You may obtain a copy of the License at:
219
233
 
220
- http://www.apache.org/licenses/LICENSE-2.0
234
+ > [http://www.apache.org/licenses/LICENSE-2.0]()
221
235
 
222
236
  Unless required by applicable law or agreed to in writing, software
223
237
  distributed under the License is distributed on an "AS IS" BASIS,
@@ -225,11 +239,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
225
239
  See the License for the specific language governing permissions and
226
240
  limitations under the License.
227
241
 
228
- == Authors
242
+ ## Authors
229
243
 
230
244
  Authors:
231
- api.sgomes (Sérgio Gomes)
232
- api.dklimkin@gmail.com (Danial Klimkin)
245
+
246
+ - api.sgomes (Sérgio Gomes)
247
+ - api.dklimkin@gmail.com (Danial Klimkin)
248
+ - api.mcloonan@gmail.com (Michael Cloonan)
233
249
 
234
250
  Maintainer:
235
- api.dklimkin@gmail.com (Danial Klimkin)
251
+
252
+ - api.mcloonan@gmail.com (Michael Cloonan)
@@ -19,7 +19,11 @@
19
19
  # limitations under the License.
20
20
  #
21
21
  # This example illustrates how to use OAuth2.0 authentication method with
22
- # Service Account (JWT).
22
+ # Service Account (JWT). For this example to work, your Service Account must be
23
+ # a Google Apps for Business Account.
24
+ #
25
+ # See https://developers.google.com/adwords/api/docs/guides/service-accounts
26
+ # for more information.
23
27
  #
24
28
  # Tags: CampaignService.get
25
29
 
@@ -19,7 +19,11 @@
19
19
  # limitations under the License.
20
20
  #
21
21
  # This example illustrates how to use OAuth2.0 authentication method with
22
- # Service Account (JWT).
22
+ # Service Account (JWT). For this example to work, your Service Account must be
23
+ # a Google Apps for Business Account.
24
+ #
25
+ # See https://developers.google.com/adwords/api/docs/guides/service-accounts
26
+ # for more information.
23
27
  #
24
28
  # Tags: CampaignService.get
25
29
 
@@ -0,0 +1,95 @@
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 create an account. Note by default this
22
+ # account will only be accessible via parent MCC.
23
+ #
24
+ # Note: This code example uses MCC-level calls and won't work with Test
25
+ # Accounts, see: https://developers.google.com/adwords/api/docs/test-accounts
26
+ #
27
+ # Tags: ManagedCustomerService.mutate
28
+
29
+ require 'adwords_api'
30
+ require 'adwords_api/utils'
31
+
32
+ def create_account()
33
+ # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
34
+ # when called without parameters.
35
+ adwords = AdwordsApi::Api.new
36
+
37
+ # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
38
+ # the configuration file or provide your own logger:
39
+ # adwords.logger = Logger.new('adwords_xml.log')
40
+
41
+ managed_customer_srv = adwords.service(:ManagedCustomerService, API_VERSION)
42
+
43
+ # Create a local Customer object.
44
+ customer = {
45
+ :name => 'Account created with ManagedCustomerService',
46
+ :currency_code => 'EUR',
47
+ :date_time_zone => 'Europe/London'
48
+ }
49
+
50
+ # Prepare operation to create an account.
51
+ operation = {
52
+ :operator => 'ADD',
53
+ :operand => customer
54
+ }
55
+
56
+ # Create the account. It is possible to create multiple accounts with one
57
+ # request by sending an array of operations.
58
+ response = managed_customer_srv.mutate([operation])
59
+
60
+ response[:value].each do |new_account|
61
+ puts "Account with customer ID '%s' was successfully created." %
62
+ AdwordsApi::Utils.format_id(new_account[:customer_id])
63
+ end
64
+ end
65
+
66
+ if __FILE__ == $0
67
+ API_VERSION = :v201402
68
+
69
+ begin
70
+ create_account()
71
+
72
+ # Authorization error.
73
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
74
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
75
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
76
+ "to retrieve and store OAuth2 tokens."
77
+ puts "See this wiki page for more details:\n\n " +
78
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
79
+
80
+ # HTTP errors.
81
+ rescue AdsCommon::Errors::HttpError => e
82
+ puts "HTTP Error: %s" % e
83
+
84
+ # API errors.
85
+ rescue AdwordsApi::Errors::ApiException => e
86
+ puts "Message: %s" % e.message
87
+ puts 'Errors:'
88
+ e.errors.each_with_index do |error, index|
89
+ puts "\tError [%d]:" % (index + 1)
90
+ error.each do |field, value|
91
+ puts "\t\t%s: %s" % [field, value]
92
+ end
93
+ end
94
+ end
95
+ end