google-dfp-api 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/ChangeLog +4 -0
  2. data/README +17 -2
  3. data/Rakefile +3 -5
  4. data/examples/v201101/common/oauth_handling.rb +128 -0
  5. data/examples/v201101/company_service/create_companies.rb +1 -1
  6. data/examples/v201101/company_service/get_all_companies.rb +1 -1
  7. data/examples/v201101/creative_service/create_creatives.rb +1 -1
  8. data/examples/v201101/creative_service/get_all_creatives.rb +1 -1
  9. data/examples/v201101/custom_targeting_service/delete_custom_targeting_keys.rb +2 -2
  10. data/examples/v201101/custom_targeting_service/delete_custom_targeting_values.rb +2 -2
  11. data/examples/v201101/custom_targeting_service/get_all_custom_targeting_keys_and_values.rb +2 -2
  12. data/examples/v201101/inventory_service/create_ad_units.rb +1 -1
  13. data/examples/v201101/inventory_service/deactivate_ad_units.rb +2 -2
  14. data/examples/v201101/inventory_service/get_ad_units_by_statement.rb +1 -1
  15. data/examples/v201101/inventory_service/get_all_ad_units.rb +1 -1
  16. data/examples/v201101/line_item_creative_association_service/deactivate_licas.rb +2 -2
  17. data/examples/v201101/line_item_creative_association_service/get_all_licas.rb +1 -1
  18. data/examples/v201101/line_item_service/activate_line_items.rb +2 -2
  19. data/examples/v201101/line_item_service/create_line_items.rb +2 -2
  20. data/examples/v201101/line_item_service/get_all_line_items.rb +1 -1
  21. data/examples/v201101/order_service/approve_orders.rb +2 -2
  22. data/examples/v201101/order_service/create_orders.rb +1 -1
  23. data/examples/v201101/order_service/get_all_orders.rb +1 -1
  24. data/examples/v201101/placement_service/create_placements.rb +3 -3
  25. data/examples/v201101/placement_service/deactivate_placements.rb +2 -2
  26. data/examples/v201101/placement_service/get_all_placements.rb +1 -1
  27. data/examples/v201101/user_service/get_all_users.rb +1 -1
  28. data/examples/v201103/common/oauth_handling.rb +128 -0
  29. data/examples/v201103/company_service/create_companies.rb +1 -1
  30. data/examples/v201103/company_service/get_all_companies.rb +1 -1
  31. data/examples/v201103/creative_service/create_creatives.rb +1 -1
  32. data/examples/v201103/creative_service/get_all_creatives.rb +1 -1
  33. data/examples/v201103/custom_targeting_service/delete_custom_targeting_keys.rb +2 -2
  34. data/examples/v201103/custom_targeting_service/delete_custom_targeting_values.rb +2 -2
  35. data/examples/v201103/custom_targeting_service/get_all_custom_targeting_keys_and_values.rb +2 -2
  36. data/examples/v201103/inventory_service/create_ad_units.rb +1 -1
  37. data/examples/v201103/inventory_service/deactivate_ad_units.rb +2 -2
  38. data/examples/v201103/inventory_service/get_ad_units_by_statement.rb +1 -1
  39. data/examples/v201103/inventory_service/get_all_ad_units.rb +1 -1
  40. data/examples/v201103/line_item_creative_association_service/deactivate_licas.rb +2 -2
  41. data/examples/v201103/line_item_creative_association_service/get_all_licas.rb +1 -1
  42. data/examples/v201103/line_item_service/activate_line_items.rb +2 -2
  43. data/examples/v201103/line_item_service/create_line_items.rb +2 -2
  44. data/examples/v201103/line_item_service/get_all_line_items.rb +1 -1
  45. data/examples/v201103/order_service/approve_orders.rb +2 -2
  46. data/examples/v201103/order_service/create_orders.rb +1 -1
  47. data/examples/v201103/order_service/get_all_orders.rb +1 -1
  48. data/examples/v201103/placement_service/create_placements.rb +3 -3
  49. data/examples/v201103/placement_service/deactivate_placements.rb +2 -2
  50. data/examples/v201103/placement_service/get_all_placements.rb +1 -1
  51. data/examples/v201103/user_service/get_all_users.rb +1 -1
  52. data/examples/v201104/common/oauth_handling.rb +128 -0
  53. data/examples/v201104/company_service/create_companies.rb +1 -1
  54. data/examples/v201104/company_service/get_all_companies.rb +1 -1
  55. data/examples/v201104/creative_service/create_creatives.rb +1 -1
  56. data/examples/v201104/creative_service/get_all_creatives.rb +1 -1
  57. data/examples/v201104/custom_targeting_service/delete_custom_targeting_keys.rb +2 -2
  58. data/examples/v201104/custom_targeting_service/delete_custom_targeting_values.rb +2 -2
  59. data/examples/v201104/custom_targeting_service/get_all_custom_targeting_keys_and_values.rb +2 -2
  60. data/examples/v201104/inventory_service/create_ad_units.rb +1 -1
  61. data/examples/v201104/inventory_service/deactivate_ad_units.rb +2 -2
  62. data/examples/v201104/inventory_service/get_ad_units_by_statement.rb +1 -1
  63. data/examples/v201104/inventory_service/get_all_ad_units.rb +1 -1
  64. data/examples/v201104/line_item_creative_association_service/deactivate_licas.rb +2 -2
  65. data/examples/v201104/line_item_creative_association_service/get_all_licas.rb +1 -1
  66. data/examples/v201104/line_item_service/activate_line_items.rb +2 -2
  67. data/examples/v201104/line_item_service/create_line_items.rb +1 -1
  68. data/examples/v201104/line_item_service/get_all_line_items.rb +1 -1
  69. data/examples/v201104/order_service/approve_orders.rb +2 -2
  70. data/examples/v201104/order_service/create_orders.rb +1 -1
  71. data/examples/v201104/order_service/get_all_orders.rb +1 -1
  72. data/examples/v201104/placement_service/create_placements.rb +3 -3
  73. data/examples/v201104/placement_service/deactivate_placements.rb +2 -2
  74. data/examples/v201104/placement_service/get_all_placements.rb +1 -1
  75. data/examples/v201104/user_service/get_all_users.rb +1 -1
  76. data/lib/dfp_api.rb +24 -70
  77. data/lib/dfp_api/api_config.rb +3 -1
  78. data/lib/dfp_api/client_login_header_handler.rb +56 -0
  79. data/lib/dfp_api/credential_handler.rb +19 -14
  80. data/lib/dfp_api/errors.rb +1 -1
  81. data/lib/dfp_api/v201101/company_service.rb +3 -3
  82. data/lib/dfp_api/v201101/company_service_registry.rb +9 -4
  83. data/lib/dfp_api/v201101/creative_service.rb +3 -3
  84. data/lib/dfp_api/v201101/creative_service_registry.rb +9 -4
  85. data/lib/dfp_api/v201101/custom_targeting_service.rb +7 -7
  86. data/lib/dfp_api/v201101/custom_targeting_service_registry.rb +9 -4
  87. data/lib/dfp_api/v201101/forecast_service.rb +3 -3
  88. data/lib/dfp_api/v201101/forecast_service_registry.rb +9 -4
  89. data/lib/dfp_api/v201101/inventory_service.rb +7 -7
  90. data/lib/dfp_api/v201101/inventory_service_registry.rb +9 -4
  91. data/lib/dfp_api/v201101/line_item_creative_association_service.rb +7 -7
  92. data/lib/dfp_api/v201101/line_item_creative_association_service_registry.rb +9 -4
  93. data/lib/dfp_api/v201101/line_item_service.rb +7 -7
  94. data/lib/dfp_api/v201101/line_item_service_registry.rb +9 -4
  95. data/lib/dfp_api/v201101/network_service.rb +7 -7
  96. data/lib/dfp_api/v201101/network_service_registry.rb +9 -4
  97. data/lib/dfp_api/v201101/order_service.rb +11 -11
  98. data/lib/dfp_api/v201101/order_service_registry.rb +9 -4
  99. data/lib/dfp_api/v201101/placement_service.rb +3 -3
  100. data/lib/dfp_api/v201101/placement_service_registry.rb +9 -4
  101. data/lib/dfp_api/v201101/publisher_query_language_service.rb +3 -3
  102. data/lib/dfp_api/v201101/publisher_query_language_service_registry.rb +9 -4
  103. data/lib/dfp_api/v201101/report_service.rb +3 -3
  104. data/lib/dfp_api/v201101/report_service_registry.rb +9 -4
  105. data/lib/dfp_api/v201101/user_service.rb +7 -7
  106. data/lib/dfp_api/v201101/user_service_registry.rb +9 -4
  107. data/lib/dfp_api/v201103/company_service.rb +3 -3
  108. data/lib/dfp_api/v201103/company_service_registry.rb +9 -4
  109. data/lib/dfp_api/v201103/creative_service.rb +3 -3
  110. data/lib/dfp_api/v201103/creative_service_registry.rb +9 -4
  111. data/lib/dfp_api/v201103/custom_targeting_service.rb +7 -7
  112. data/lib/dfp_api/v201103/custom_targeting_service_registry.rb +9 -4
  113. data/lib/dfp_api/v201103/forecast_service.rb +3 -3
  114. data/lib/dfp_api/v201103/forecast_service_registry.rb +9 -4
  115. data/lib/dfp_api/v201103/inventory_service.rb +7 -7
  116. data/lib/dfp_api/v201103/inventory_service_registry.rb +9 -4
  117. data/lib/dfp_api/v201103/line_item_creative_association_service.rb +7 -7
  118. data/lib/dfp_api/v201103/line_item_creative_association_service_registry.rb +9 -4
  119. data/lib/dfp_api/v201103/line_item_service.rb +7 -7
  120. data/lib/dfp_api/v201103/line_item_service_registry.rb +9 -4
  121. data/lib/dfp_api/v201103/network_service.rb +7 -7
  122. data/lib/dfp_api/v201103/network_service_registry.rb +9 -4
  123. data/lib/dfp_api/v201103/order_service.rb +11 -11
  124. data/lib/dfp_api/v201103/order_service_registry.rb +9 -4
  125. data/lib/dfp_api/v201103/placement_service.rb +3 -3
  126. data/lib/dfp_api/v201103/placement_service_registry.rb +9 -4
  127. data/lib/dfp_api/v201103/publisher_query_language_service.rb +3 -3
  128. data/lib/dfp_api/v201103/publisher_query_language_service_registry.rb +9 -4
  129. data/lib/dfp_api/v201103/report_service.rb +3 -3
  130. data/lib/dfp_api/v201103/report_service_registry.rb +9 -4
  131. data/lib/dfp_api/v201103/user_service.rb +7 -7
  132. data/lib/dfp_api/v201103/user_service_registry.rb +9 -4
  133. data/lib/dfp_api/v201104/company_service.rb +3 -3
  134. data/lib/dfp_api/v201104/company_service_registry.rb +9 -4
  135. data/lib/dfp_api/v201104/creative_service.rb +3 -3
  136. data/lib/dfp_api/v201104/creative_service_registry.rb +9 -4
  137. data/lib/dfp_api/v201104/custom_targeting_service.rb +7 -7
  138. data/lib/dfp_api/v201104/custom_targeting_service_registry.rb +9 -4
  139. data/lib/dfp_api/v201104/forecast_service.rb +3 -3
  140. data/lib/dfp_api/v201104/forecast_service_registry.rb +9 -4
  141. data/lib/dfp_api/v201104/inventory_service.rb +7 -7
  142. data/lib/dfp_api/v201104/inventory_service_registry.rb +9 -4
  143. data/lib/dfp_api/v201104/line_item_creative_association_service.rb +7 -7
  144. data/lib/dfp_api/v201104/line_item_creative_association_service_registry.rb +9 -4
  145. data/lib/dfp_api/v201104/line_item_service.rb +7 -7
  146. data/lib/dfp_api/v201104/line_item_service_registry.rb +9 -4
  147. data/lib/dfp_api/v201104/network_service.rb +7 -7
  148. data/lib/dfp_api/v201104/network_service_registry.rb +9 -4
  149. data/lib/dfp_api/v201104/order_service.rb +11 -11
  150. data/lib/dfp_api/v201104/order_service_registry.rb +9 -4
  151. data/lib/dfp_api/v201104/placement_service.rb +3 -3
  152. data/lib/dfp_api/v201104/placement_service_registry.rb +9 -4
  153. data/lib/dfp_api/v201104/publisher_query_language_service.rb +3 -3
  154. data/lib/dfp_api/v201104/publisher_query_language_service_registry.rb +9 -4
  155. data/lib/dfp_api/v201104/report_service.rb +3 -3
  156. data/lib/dfp_api/v201104/report_service_registry.rb +9 -4
  157. data/lib/dfp_api/v201104/user_service.rb +7 -7
  158. data/lib/dfp_api/v201104/user_service_registry.rb +9 -4
  159. data/test/bugs/test_issue_00000016.rb +6 -5
  160. data/test/dfp_api/test_dfp_api.rb +29 -7
  161. metadata +257 -253
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 0.2.2:
2
+ - Support for OAuth authentication method.
3
+ - Require google-ads-common 0.5.0 or later from now on.
4
+
1
5
  0.2.1:
2
6
  - Ruby1.9 compatible.
3
7
  - Fixed issue #16 (deep arrays nesting).
data/README CHANGED
@@ -84,6 +84,21 @@ constructor:
84
84
 
85
85
  An example of configuration file is available as part of this library.
86
86
 
87
+ == Using OAuth
88
+
89
+ It is recommended to use OAuth authentication method instead of explicit
90
+ email/password combination. OAuth support is almost transparent to the library
91
+ user. In order to use OAuth you just need to:
92
+
93
+ - set authentication method to 'OAuth' in configuration;
94
+
95
+ - include oauth_consumer_key and oauth_consumer_secret;
96
+
97
+ - handle OAuthVerificationRequired error and pass verification code to the
98
+ library.
99
+
100
+ See 'dfp_api.yml' configuration file and 'common/oauth_handling.rb' example for
101
+ more details.
87
102
 
88
103
  == Accessing services
89
104
 
@@ -168,8 +183,8 @@ is planned for next releases.
168
183
  External dependencies should be pulled automatically on gem install. Here is the
169
184
  list though:
170
185
 
171
- - Google Ads Common library (google-ads-common-0.4.0);
172
- - Savon 'the heavy metal Ruby SOAP client' (savon-0.9.1 or later).
186
+ - Google Ads Common library (google-ads-common-0.5.0);
187
+ - Savon 'the heavy metal Ruby SOAP client' (savon-0.9.6).
173
188
 
174
189
 
175
190
  = Where do I submit bug reports and feature requests?
data/Rakefile CHANGED
@@ -47,8 +47,8 @@ spec = Gem::Specification.new do |s|
47
47
  s.test_files = tests
48
48
  s.has_rdoc = true
49
49
  s.extra_rdoc_files = docs
50
- s.add_dependency('google-ads-common', '~> 0.4.0')
51
- s.add_dependency('savon', '~> 0.9.1')
50
+ s.add_dependency('google-ads-common', '~> 0.5.0')
51
+ s.add_dependency('savon', '= 0.9.6')
52
52
  end
53
53
 
54
54
  package_task = Gem::PackageTask.new(spec) do |pkg|
@@ -74,10 +74,8 @@ task :generate do
74
74
  wsdls = DfpApi::ApiConfig.get_wsdls(version)
75
75
  wsdls.each do |service_name, wsdl_url|
76
76
  logger.info("Processing %s at [%s]..." % [service_name, wsdl_url])
77
- module_name = "%s::%s::%s" % [api_config.api_name, version.to_s.upcase,
78
- service_name]
79
77
  generator = AdsCommon::Build::SavonGenerator.new(wsdl_url, code_path,
80
- service_name, module_name)
78
+ api_config.api_name, version, service_name)
81
79
  generator.process_wsdl()
82
80
  end
83
81
  package_task.package_files.include(FileList[code_path + '/*'].to_a)
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
4
+ #
5
+ # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
6
+ #
7
+ # License:: Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16
+ # implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # This example shows how to use OAuth authorization method. It is designed to be
21
+ # run from console and requires user input.
22
+ #
23
+ # Tags: UserService.getUsersByStatement
24
+
25
+ require 'rubygems'
26
+ require 'dfp_api'
27
+
28
+ API_VERSION = :v201101
29
+ PAGE_SIZE = 500
30
+ MAX_RETRIES = 3
31
+
32
+ def oauth_handling()
33
+ # Get DfpApi instance and load configuration from ~/dfp_api.yml.
34
+ dfp = DfpApi::Api.new
35
+
36
+ # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
37
+ # the configuration file or provide your own logger:
38
+ # dfp.logger = Logger.new('dfp_xml.log')
39
+
40
+ # Forcing authorization. A callback URL and other parameters could be
41
+ # specified as parameter for OAuth method.
42
+ token = dfp.authorize({:oauth_callback => 'oob'}) do |oauth_url|
43
+ # For command-line we ask user to go to URL and type in code.
44
+ verification_code = get_verification_code(oauth_url)
45
+ # Return verification code from the block.
46
+ (verification_code.empty?) ? nil : verification_code
47
+ end
48
+
49
+ # Get the UserService.
50
+ user_service = dfp.service(:UserService, API_VERSION)
51
+
52
+ # Define initial values.
53
+ offset = 0
54
+ page = Hash.new
55
+ retry_count = 0
56
+
57
+ begin
58
+ # Create statement for one page with current offset.
59
+ statement = {:query => "LIMIT %d OFFSET %d" % [PAGE_SIZE, offset]}
60
+
61
+ begin
62
+ # Get users by statement.
63
+ page = user_service.get_users_by_statement(statement)
64
+
65
+ # The second way to do OAuth authentication is to make a request and catch
66
+ # the OAuthVerificationRequired exception. Add the verification code to the
67
+ # credentials once acquired.
68
+ rescue AdsCommon::Errors::OAuthVerificationRequired => e
69
+ if retry_count < MAX_RETRIES
70
+ verification_code = get_verification_code(e.oauth_url)
71
+ dfp.credential_handler.set_credential(
72
+ :oauth_verification_code, verification_code)
73
+ retry_count += 1
74
+ retry
75
+ else
76
+ raise AdsCommon::Errors::AuthError, 'Failed to authenticate.'
77
+ end
78
+ end
79
+
80
+ if page[:results]
81
+ # Increase query offset by page size.
82
+ offset += PAGE_SIZE
83
+
84
+ # Get the start index for printout.
85
+ start_index = page[:start_index]
86
+
87
+ # Print details about each user in results page.
88
+ page[:results].each_with_index do |user, index|
89
+ puts "%d) User ID: %d, name: %s, email: %s" %
90
+ [index + start_index, user[:id], user[:name], user[:email]]
91
+ end
92
+ end
93
+ end while offset < page[:total_result_set_size]
94
+
95
+ # Print a footer
96
+ if page.include?(:total_result_set_size)
97
+ puts "Total number of users: %d" % page[:total_result_set_size]
98
+ end
99
+ end
100
+
101
+ # Misc util to get the verification code from the console.
102
+ def get_verification_code(url)
103
+ puts "Hit Auth error, please navigate to URL:\n\t%s" % url
104
+ print 'Log in and type the verification code: '
105
+ verification_code = gets.chomp
106
+ return verification_code
107
+ end
108
+
109
+ if __FILE__ == $0
110
+ begin
111
+ oauth_handling()
112
+
113
+ # HTTP errors.
114
+ rescue AdsCommon::Errors::HttpError => e
115
+ puts "HTTP Error: %s" % e
116
+
117
+ # API errors.
118
+ rescue DfpApi::Errors::ApiException => e
119
+ puts "Message: %s" % e.message
120
+ puts 'Errors:'
121
+ e.errors.each_with_index do |error, index|
122
+ puts "\tError [%d]:" % (index + 1)
123
+ error.each do |field, value|
124
+ puts "\t\t%s: %s" % [field, value]
125
+ end
126
+ end
127
+ end
128
+ end
@@ -41,7 +41,7 @@ def create_companies()
41
41
  company_service = dfp.service(:CompanyService, API_VERSION)
42
42
 
43
43
  # Create an array to store local company objects.
44
- companies = Array.new
44
+ companies = []
45
45
  ITEM_COUNT.times do |index|
46
46
  companies << {:name => "Advertiser #%d" % index, :type => 'ADVERTISER'}
47
47
  end
@@ -40,7 +40,7 @@ def get_all_companies()
40
40
 
41
41
  # Define initial values.
42
42
  offset = 0
43
- page = Hash.new
43
+ page = {}
44
44
 
45
45
  begin
46
46
  # Create a statement to get one page with current offset.
@@ -53,7 +53,7 @@ def create_creatives()
53
53
  image_data_base64 = Base64.encode64(image_data)
54
54
 
55
55
  # Create an array to store local creative objects.
56
- creatives = Array.new
56
+ creatives = []
57
57
  ITEM_COUNT.times do |index|
58
58
  creatives << {
59
59
  :xsi_type => 'ImageCreative',
@@ -40,7 +40,7 @@ def get_all_creatives()
40
40
 
41
41
  # Define initial values.
42
42
  offset = 0
43
- page = Hash.new
43
+ page = {}
44
44
 
45
45
  begin
46
46
  # Create a statement to get one page with current offset.
@@ -48,8 +48,8 @@ def delete_custom_targeting_keys()
48
48
 
49
49
  # Define initial values.
50
50
  offset = 0
51
- page = Hash.new
52
- custom_target_key_ids = Array.new
51
+ page = {}
52
+ custom_target_key_ids = []
53
53
  statement = {
54
54
  :values => [
55
55
  {:key => 'name',
@@ -50,8 +50,8 @@ def delete_custom_targeting_values()
50
50
 
51
51
  # Define initial values.
52
52
  offset = 0
53
- page = Hash.new
54
- custom_target_value_ids = Array.new
53
+ page = {}
54
+ custom_target_value_ids = []
55
55
  statement = {
56
56
  :values => [
57
57
  {:key => 'key_id',
@@ -42,7 +42,7 @@ def get_all_custom_targeting_keys_and_values()
42
42
 
43
43
  # Define initial values.
44
44
  offset = 0
45
- page = Hash.new
45
+ page = {}
46
46
 
47
47
  begin
48
48
  # Create a statement to get one page with current offset.
@@ -82,7 +82,7 @@ end
82
82
  def print_all_values_for_key(custom_targeting_service, custom_targeting_key)
83
83
  # Define initial values.
84
84
  offset = 0
85
- page = Hash.new
85
+ page = {}
86
86
 
87
87
  # Create a statement to get values for given key.
88
88
  statement_text = "WHERE customTargetingKeyId = :key_id LIMIT %d" % PAGE_SIZE
@@ -51,7 +51,7 @@ def create_ad_units()
51
51
  puts "Using effective root ad unit: %d" % effective_root_ad_unit_id
52
52
 
53
53
  # Create an array to store local ad unit objects.
54
- ad_units = Array.new
54
+ ad_units = []
55
55
  ITEM_COUNT.times do |index|
56
56
  ad_units << {
57
57
  :name => "Ad_Unit_%d" % index,
@@ -51,8 +51,8 @@ def deactivate_ad_units()
51
51
 
52
52
  # Define initial values.
53
53
  offset = 0
54
- page = Hash.new
55
- ad_unit_ids = Array.new
54
+ page = {}
55
+ ad_unit_ids = []
56
56
 
57
57
  begin
58
58
  # Create a statement to get one page with current offset.
@@ -61,7 +61,7 @@ def get_ad_units_by_statement()
61
61
  page = inventory_service.get_ad_units_by_statement(statement)
62
62
 
63
63
  if page[:results]
64
- # Print details about each creative in results.
64
+ # Print details about each ad unit in results.
65
65
  page[:results].each_with_index do |ad_unit, index|
66
66
  puts "%d) Ad unit ID: %d, name: %s, status: %s." %
67
67
  [index, ad_unit[:id], ad_unit[:name], ad_unit[:status]]
@@ -40,7 +40,7 @@ def get_all_ad_units()
40
40
 
41
41
  # Define initial values.
42
42
  offset = 0
43
- page = Hash.new
43
+ page = {}
44
44
 
45
45
  begin
46
46
  # Create a statement to get one page with current offset.
@@ -58,8 +58,8 @@ def deactivate_licas()
58
58
 
59
59
  # Define initial values.
60
60
  offset = 0
61
- page = Hash.new
62
- creative_ids = Array.new
61
+ page = {}
62
+ creative_ids = []
63
63
 
64
64
  begin
65
65
  # Create a statement to get one page with current offset.
@@ -41,7 +41,7 @@ def get_all_licas()
41
41
 
42
42
  # Define initial values.
43
43
  offset = 0
44
- page = Hash.new
44
+ page = {}
45
45
 
46
46
  begin
47
47
  # Create statement for one page with current offset.
@@ -61,8 +61,8 @@ def activate_line_items()
61
61
 
62
62
  # Define initial values.
63
63
  offset = 0
64
- page = Hash.new
65
- line_item_ids = Array.new
64
+ page = {}
65
+ line_item_ids = []
66
66
 
67
67
  begin
68
68
  # Create a statement to get one page with current offset.
@@ -53,7 +53,7 @@ def create_line_items()
53
53
  inventory_targeting = {:targeted_placement_ids => targeted_placement_ids}
54
54
 
55
55
  # Create geographical targeting.
56
- geo_targeting = Hash.new
56
+ geo_targeting = {}
57
57
  # Include the US and Quebec, Canada.
58
58
  geo_targeting[:targeted_locations] = [
59
59
  {:xsi_type => 'CountryLocation', :country_code => 'US'},
@@ -72,7 +72,7 @@ def create_line_items()
72
72
  :inventory_targeting => inventory_targeting}
73
73
 
74
74
  # Create an array to store local line item objects.
75
- line_items = Array.new
75
+ line_items = []
76
76
  ITEM_COUNT.times do |index|
77
77
  line_item = {:name => "Line item #%d" % index,
78
78
  :order_id => order_id,
@@ -41,7 +41,7 @@ def get_all_line_items()
41
41
 
42
42
  # Define initial values.
43
43
  offset = 0
44
- page = Hash.new
44
+ page = {}
45
45
 
46
46
  begin
47
47
  # Create a statement to get one page with current offset.
@@ -45,8 +45,8 @@ def approve_orders()
45
45
 
46
46
  # Define initial values.
47
47
  offset = 0
48
- page = Hash.new
49
- order_ids = Array.new
48
+ page = {}
49
+ order_ids = []
50
50
 
51
51
  begin
52
52
  # Create a statement to get one page with current offset.
@@ -49,7 +49,7 @@ def create_orders()
49
49
  trafficker_id = 'INSERT_TRAFFICKER_ID_HERE'.to_i
50
50
 
51
51
  # Create an array to store local order objects.
52
- orders = Array.new
52
+ orders = []
53
53
  ITEM_COUNT.times do |index|
54
54
  orders << {:name => "Order #%d" % index,
55
55
  :advertiser_id => advertiser_id,
@@ -40,7 +40,7 @@ def get_all_orders()
40
40
 
41
41
  # Define initial values.
42
42
  offset = 0
43
- page = Hash.new
43
+ page = {}
44
44
 
45
45
  begin
46
46
  # Create statement for one page with current offset.
@@ -46,21 +46,21 @@ def create_placements()
46
46
  skyscraper_ad_unit_placement = {
47
47
  :name => "Skyscraper AdUnit Placement #%d" % (Time.new.to_f * 1000),
48
48
  :description => 'Contains ad units for creatives of size 120x600',
49
- :targeted_ad_unit_ids => Array.new
49
+ :targeted_ad_unit_ids => []
50
50
  }
51
51
 
52
52
  # Create local placement object to store medium square ad units.
53
53
  medium_square_ad_unit_placement = {
54
54
  :name => "Medium Square AdUnit Placement #%d" % (Time.new.to_f * 1000),
55
55
  :description => 'Contains ad units for creatives of size 300x250',
56
- :targeted_ad_unit_ids => Array.new
56
+ :targeted_ad_unit_ids => []
57
57
  }
58
58
 
59
59
  # Create local placement object to store banner ad units.
60
60
  banner_ad_unit_placement = {
61
61
  :name => "Banner AdUnit Placement #%d" % (Time.new.to_f * 1000),
62
62
  :description => 'Contains ad units for creatives of size 468x60',
63
- :targeted_ad_unit_ids => Array.new
63
+ :targeted_ad_unit_ids => []
64
64
  }
65
65
 
66
66
  # Get the first 500 ad units.
@@ -51,8 +51,8 @@ def deactivate_placements()
51
51
 
52
52
  # Define initial values.
53
53
  offset = 0
54
- page = Hash.new
55
- placement_ids = Array.new
54
+ page = {}
55
+ placement_ids = []
56
56
 
57
57
  begin
58
58
  # Modify the statement to get one page with current offset.