google-dfp-api 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README +13 -1
- data/Rakefile +7 -1
- data/examples/v201111/third_party_slot_service/archive_third_party_slots.rb +125 -0
- data/examples/v201111/third_party_slot_service/create_third_party_slot.rb +91 -0
- data/examples/v201111/third_party_slot_service/get_all_third_party_slots.rb +93 -0
- data/examples/v201111/third_party_slot_service/get_third_party_slot_by_statement.rb +86 -0
- data/examples/v201111/third_party_slot_service/update_third_party_slots.rb +95 -0
- data/lib/dfp_api/api_config.rb +1 -1
- data/lib/dfp_api/v201103/company_service.rb +13 -13
- data/lib/dfp_api/v201103/company_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/creative_service.rb +5 -5
- data/lib/dfp_api/v201103/creative_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/custom_targeting_service.rb +17 -17
- data/lib/dfp_api/v201103/custom_targeting_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/forecast_service.rb +5 -5
- data/lib/dfp_api/v201103/forecast_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/inventory_service.rb +13 -13
- data/lib/dfp_api/v201103/inventory_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/line_item_creative_association_service.rb +9 -9
- data/lib/dfp_api/v201103/line_item_creative_association_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/line_item_service.rb +13 -13
- data/lib/dfp_api/v201103/line_item_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/network_service.rb +1 -1
- data/lib/dfp_api/v201103/network_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/order_service.rb +5 -5
- data/lib/dfp_api/v201103/order_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/placement_service.rb +13 -13
- data/lib/dfp_api/v201103/placement_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/publisher_query_language_service.rb +1 -1
- data/lib/dfp_api/v201103/publisher_query_language_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/report_service.rb +1 -1
- data/lib/dfp_api/v201103/report_service_registry.rb +3 -3
- data/lib/dfp_api/v201103/user_service.rb +9 -9
- data/lib/dfp_api/v201103/user_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/company_service.rb +13 -13
- data/lib/dfp_api/v201104/company_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/creative_service.rb +5 -5
- data/lib/dfp_api/v201104/creative_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/custom_targeting_service.rb +17 -17
- data/lib/dfp_api/v201104/custom_targeting_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/forecast_service.rb +5 -5
- data/lib/dfp_api/v201104/forecast_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/inventory_service.rb +13 -13
- data/lib/dfp_api/v201104/inventory_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/line_item_creative_association_service.rb +9 -9
- data/lib/dfp_api/v201104/line_item_creative_association_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/line_item_service.rb +13 -13
- data/lib/dfp_api/v201104/line_item_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/network_service.rb +1 -1
- data/lib/dfp_api/v201104/network_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/order_service.rb +5 -5
- data/lib/dfp_api/v201104/order_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/placement_service.rb +13 -13
- data/lib/dfp_api/v201104/placement_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/publisher_query_language_service.rb +1 -1
- data/lib/dfp_api/v201104/publisher_query_language_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/report_service.rb +1 -1
- data/lib/dfp_api/v201104/report_service_registry.rb +3 -3
- data/lib/dfp_api/v201104/user_service.rb +9 -9
- data/lib/dfp_api/v201104/user_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/company_service.rb +13 -13
- data/lib/dfp_api/v201107/company_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/creative_service.rb +5 -5
- data/lib/dfp_api/v201107/creative_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/custom_targeting_service.rb +17 -17
- data/lib/dfp_api/v201107/custom_targeting_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/forecast_service.rb +5 -5
- data/lib/dfp_api/v201107/forecast_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/inventory_service.rb +17 -17
- data/lib/dfp_api/v201107/inventory_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/label_service.rb +13 -13
- data/lib/dfp_api/v201107/label_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/line_item_creative_association_service.rb +9 -9
- data/lib/dfp_api/v201107/line_item_creative_association_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/line_item_service.rb +13 -13
- data/lib/dfp_api/v201107/line_item_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/network_service.rb +1 -1
- data/lib/dfp_api/v201107/network_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/order_service.rb +5 -5
- data/lib/dfp_api/v201107/order_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/placement_service.rb +13 -13
- data/lib/dfp_api/v201107/placement_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/publisher_query_language_service.rb +1 -1
- data/lib/dfp_api/v201107/publisher_query_language_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/report_service.rb +1 -1
- data/lib/dfp_api/v201107/report_service_registry.rb +3 -3
- data/lib/dfp_api/v201107/user_service.rb +13 -13
- data/lib/dfp_api/v201107/user_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/company_service.rb +13 -13
- data/lib/dfp_api/v201108/company_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/creative_service.rb +5 -5
- data/lib/dfp_api/v201108/creative_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/custom_targeting_service.rb +17 -17
- data/lib/dfp_api/v201108/custom_targeting_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/forecast_service.rb +5 -5
- data/lib/dfp_api/v201108/forecast_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/inventory_service.rb +17 -17
- data/lib/dfp_api/v201108/inventory_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/label_service.rb +13 -13
- data/lib/dfp_api/v201108/label_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/line_item_creative_association_service.rb +9 -9
- data/lib/dfp_api/v201108/line_item_creative_association_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/line_item_service.rb +13 -13
- data/lib/dfp_api/v201108/line_item_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/network_service.rb +1 -1
- data/lib/dfp_api/v201108/network_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/order_service.rb +5 -5
- data/lib/dfp_api/v201108/order_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/placement_service.rb +13 -13
- data/lib/dfp_api/v201108/placement_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/publisher_query_language_service.rb +1 -1
- data/lib/dfp_api/v201108/publisher_query_language_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/report_service.rb +1 -1
- data/lib/dfp_api/v201108/report_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/third_party_slot_service.rb +1 -1
- data/lib/dfp_api/v201108/third_party_slot_service_registry.rb +3 -3
- data/lib/dfp_api/v201108/user_service.rb +13 -13
- data/lib/dfp_api/v201108/user_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/company_service.rb +13 -13
- data/lib/dfp_api/v201111/company_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/content_service.rb +1 -1
- data/lib/dfp_api/v201111/content_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/creative_service.rb +5 -5
- data/lib/dfp_api/v201111/creative_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/creative_template_service.rb +1 -1
- data/lib/dfp_api/v201111/creative_template_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/custom_targeting_service.rb +17 -17
- data/lib/dfp_api/v201111/custom_targeting_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/forecast_service.rb +5 -5
- data/lib/dfp_api/v201111/forecast_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/inventory_service.rb +17 -17
- data/lib/dfp_api/v201111/inventory_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/label_service.rb +13 -13
- data/lib/dfp_api/v201111/label_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/line_item_creative_association_service.rb +13 -13
- data/lib/dfp_api/v201111/line_item_creative_association_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/line_item_service.rb +13 -13
- data/lib/dfp_api/v201111/line_item_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/network_service.rb +1 -1
- data/lib/dfp_api/v201111/network_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/order_service.rb +5 -5
- data/lib/dfp_api/v201111/order_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/placement_service.rb +13 -13
- data/lib/dfp_api/v201111/placement_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/publisher_query_language_service.rb +1 -1
- data/lib/dfp_api/v201111/publisher_query_language_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/report_service.rb +1 -1
- data/lib/dfp_api/v201111/report_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/suggested_ad_unit_service.rb +1 -1
- data/lib/dfp_api/v201111/suggested_ad_unit_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/third_party_slot_service.rb +1 -1
- data/lib/dfp_api/v201111/third_party_slot_service_registry.rb +3 -3
- data/lib/dfp_api/v201111/user_service.rb +13 -13
- data/lib/dfp_api/v201111/user_service_registry.rb +3 -3
- data/lib/dfp_api.rb +1 -1
- metadata +17 -9
data/ChangeLog
CHANGED
data/README
CHANGED
@@ -184,13 +184,25 @@ configuration hash:
|
|
184
184
|
|
185
185
|
or via configuration file (see example).
|
186
186
|
|
187
|
+
== How do I enable GZip responses compression?
|
188
|
+
|
189
|
+
The library offers a transparent compression option which can be enabled in the
|
190
|
+
configuration file or by the following setting:
|
191
|
+
|
192
|
+
config[:connection] = {
|
193
|
+
:enable_gzip => true
|
194
|
+
}
|
195
|
+
|
196
|
+
Enabling this option will set the headers required to request the server to
|
197
|
+
respond in gzipped format. All requests are sent uncompressed regardless.
|
198
|
+
|
187
199
|
|
188
200
|
= External dependencies:
|
189
201
|
|
190
202
|
External dependencies should be pulled automatically on gem install. Here is the
|
191
203
|
list though:
|
192
204
|
|
193
|
-
- Google Ads Common library (google-ads-common-0.6.
|
205
|
+
- Google Ads Common library (google-ads-common-0.6.1);
|
194
206
|
- Savon 'the heavy metal Ruby SOAP client' (savon-0.9.7).
|
195
207
|
|
196
208
|
|
data/Rakefile
CHANGED
@@ -24,6 +24,12 @@ require 'rubygems/package_task'
|
|
24
24
|
require 'rake/testtask'
|
25
25
|
require './lib/dfp_api/api_config'
|
26
26
|
|
27
|
+
# Workaround for the current mess of different yamlers in Ruby world.
|
28
|
+
if RUBY_VERSION>='1.9.2'
|
29
|
+
gem 'psych'
|
30
|
+
YAML::ENGINE.yamler = 'psych'
|
31
|
+
end
|
32
|
+
|
27
33
|
# Google common ads library used for wrapper code generation.
|
28
34
|
gem 'google-ads-common'
|
29
35
|
require 'ads_common/build/savon_generator'
|
@@ -47,7 +53,7 @@ spec = Gem::Specification.new do |s|
|
|
47
53
|
s.test_files = tests
|
48
54
|
s.has_rdoc = true
|
49
55
|
s.extra_rdoc_files = docs
|
50
|
-
s.add_dependency('google-ads-common', '~> 0.6.
|
56
|
+
s.add_dependency('google-ads-common', '~> 0.6.1')
|
51
57
|
s.add_dependency('savon', '= 0.9.7')
|
52
58
|
end
|
53
59
|
|
@@ -0,0 +1,125 @@
|
|
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 archives all active third party slots for a company. To determine
|
21
|
+
# which third party slots exist, run get_all_third_party_slots.rb.
|
22
|
+
#
|
23
|
+
# Tags: ThirdPartSlotService.getThirdPartySlotsByStatement,
|
24
|
+
# ThirdPartSlotService.performThirdPartySlotsAction
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'dfp_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201111
|
30
|
+
PAGE_SIZE = 500
|
31
|
+
|
32
|
+
def archive_third_party_slots()
|
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
|
+
# Get the ThirdPartySlotService.
|
41
|
+
third_party_slot_service = dfp.service(:ThirdPartySlotService, API_VERSION)
|
42
|
+
|
43
|
+
# Set the company that the third party slots to archive belong to.
|
44
|
+
company_id = 'INSERT_COMPANY_ID_HERE'.to_i
|
45
|
+
|
46
|
+
# Create a statement to only select active third party slots.
|
47
|
+
statement_text = 'WHERE status = :status AND companyId = :company_id'
|
48
|
+
|
49
|
+
# Create statement bind variables.
|
50
|
+
statement = {
|
51
|
+
:query => statement_text,
|
52
|
+
:values => [
|
53
|
+
{:key => 'status',
|
54
|
+
:value => {:value => 'ARCHIVED', :xsi_type => 'TextValue'}},
|
55
|
+
{:key => 'company_id',
|
56
|
+
:value => {:value => company_id, :xsi_type => 'NumberValue'}},
|
57
|
+
]
|
58
|
+
}
|
59
|
+
|
60
|
+
# Define initial values.
|
61
|
+
offset = 0
|
62
|
+
page = {}
|
63
|
+
third_party_slot_ids = []
|
64
|
+
|
65
|
+
begin
|
66
|
+
# Update the statement to get one page with current offset.
|
67
|
+
statement[:query] =
|
68
|
+
statement_text + " LIMIT %d OFFSET %d" % [PAGE_SIZE, offset]
|
69
|
+
|
70
|
+
# Get third party slots by statement.
|
71
|
+
page = third_party_slot_service.get_third_party_slots_by_statement(statement)
|
72
|
+
|
73
|
+
if page[:results]
|
74
|
+
# Increase query offset by page size.
|
75
|
+
offset += PAGE_SIZE
|
76
|
+
|
77
|
+
page[:results].each do |slot|
|
78
|
+
puts "%d) Third party slot ID: %d and name: '%s' will be archived." %
|
79
|
+
[third_party_slot_ids.size, slot[:id], slot[:name]]
|
80
|
+
third_party_slot_ids << slot[:id]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end while offset < page[:total_result_set_size]
|
84
|
+
|
85
|
+
puts "Number of third party slots to be archived: %d" % third_party_slot_ids.size
|
86
|
+
|
87
|
+
unless third_party_slot_ids.empty?
|
88
|
+
# Create statement for action.
|
89
|
+
statement = {:query => "WHERE id IN (%s)" % third_party_slot_ids.join(', ')}
|
90
|
+
|
91
|
+
# Perform action.
|
92
|
+
result = third_party_slot_service.perform_third_party_slot_action(
|
93
|
+
{:xsi_type => 'ArchiveThirdPartySlots'}, statement)
|
94
|
+
|
95
|
+
# Display results.
|
96
|
+
if result and result[:num_changes] > 0
|
97
|
+
puts "Number of third party slots archived: %d" % result[:num_changes]
|
98
|
+
else
|
99
|
+
puts 'No third party slots were archived.'
|
100
|
+
end
|
101
|
+
else
|
102
|
+
puts 'No third party slots found to archive.'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
if __FILE__ == $0
|
107
|
+
begin
|
108
|
+
archive_third_party_slots()
|
109
|
+
|
110
|
+
# HTTP errors.
|
111
|
+
rescue AdsCommon::Errors::HttpError => e
|
112
|
+
puts "HTTP Error: %s" % e
|
113
|
+
|
114
|
+
# API errors.
|
115
|
+
rescue DfpApi::Errors::ApiException => e
|
116
|
+
puts "Message: %s" % e.message
|
117
|
+
puts 'Errors:'
|
118
|
+
e.errors.each_with_index do |error, index|
|
119
|
+
puts "\tError [%d]:" % (index + 1)
|
120
|
+
error.each do |field, value|
|
121
|
+
puts "\t\t%s: %s" % [field, value]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,91 @@
|
|
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 creates a new third party slot. To determine which third party
|
21
|
+
# slots exist, run get_all_third_party_slots.rb.
|
22
|
+
#
|
23
|
+
# Tags: ThirdPartySlotService.createThirdPartySlot
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
require 'dfp_api'
|
27
|
+
|
28
|
+
API_VERSION = :v201111
|
29
|
+
|
30
|
+
def create_third_party_slot()
|
31
|
+
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
32
|
+
dfp = DfpApi::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
|
+
# dfp.logger = Logger.new('dfp_xml.log')
|
37
|
+
|
38
|
+
# Get the ThirdPartySlotService.
|
39
|
+
third_party_slot_service = dfp.service(:ThirdPartySlotService, API_VERSION)
|
40
|
+
|
41
|
+
# Set the company ID to associate with this third party slot.
|
42
|
+
company_id = 'INSERT_COMPANY_ID_HERE'.to_i
|
43
|
+
|
44
|
+
# Set the external unique ID and name to associate with this third party slot.
|
45
|
+
external_unique_id = 'INSERT_EXTERNAL_UNIQUE_ID_HERE'.to_i
|
46
|
+
external_unique_name = 'INSERT_EXTERNAL_UNIQUE_NAME_HERE'.to_s
|
47
|
+
|
48
|
+
# Set the creative IDs to associate with this third party slot.
|
49
|
+
creative_ids = ['INSERT_CREATIVE_ID_HERE'.to_i]
|
50
|
+
|
51
|
+
# Create the ThirdPartySlot object.
|
52
|
+
third_party_slot = {
|
53
|
+
:company_id => company_id,
|
54
|
+
:description => 'Third party slot description.',
|
55
|
+
:external_unique_id => external_unique_id,
|
56
|
+
:external_unique_name => external_unique_name,
|
57
|
+
:creative_ids => creative_ids
|
58
|
+
}
|
59
|
+
|
60
|
+
# Create the third party slot.
|
61
|
+
return_slot =
|
62
|
+
third_party_slot_service.create_third_party_slot(third_party_slot)
|
63
|
+
|
64
|
+
if return_slot
|
65
|
+
puts "Third party slot with ID: %d and name: '%s' was created." %
|
66
|
+
[return_slot[:id], return_slot[:name]]
|
67
|
+
else
|
68
|
+
raise 'No third party slots were created.'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if __FILE__ == $0
|
73
|
+
begin
|
74
|
+
create_third_party_slot()
|
75
|
+
|
76
|
+
# HTTP errors.
|
77
|
+
rescue AdsCommon::Errors::HttpError => e
|
78
|
+
puts "HTTP Error: %s" % e
|
79
|
+
|
80
|
+
# API errors.
|
81
|
+
rescue DfpApi::Errors::ApiException => e
|
82
|
+
puts "Message: %s" % e.message
|
83
|
+
puts 'Errors:'
|
84
|
+
e.errors.each_with_index do |error, index|
|
85
|
+
puts "\tError [%d]:" % (index + 1)
|
86
|
+
error.each do |field, value|
|
87
|
+
puts "\t\t%s: %s" % [field, value]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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 gets all third party slots. To create third party slots, run
|
21
|
+
# create_third_party_slot.rb.
|
22
|
+
#
|
23
|
+
# Tags: ThirdPartySlotService.getThirdPartySlotsByStatement
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
require 'dfp_api'
|
27
|
+
|
28
|
+
API_VERSION = :v201111
|
29
|
+
PAGE_SIZE = 500
|
30
|
+
|
31
|
+
def get_all_third_party_slots()
|
32
|
+
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
33
|
+
dfp = DfpApi::Api.new
|
34
|
+
|
35
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
36
|
+
# the configuration file or provide your own logger:
|
37
|
+
# dfp.logger = Logger.new('dfp_xml.log')
|
38
|
+
|
39
|
+
# Get the ThirdPartySlotService.
|
40
|
+
third_party_slot_service = dfp.service(:ThirdPartySlotService, API_VERSION)
|
41
|
+
|
42
|
+
# Define initial values.
|
43
|
+
offset = 0
|
44
|
+
page = {}
|
45
|
+
|
46
|
+
begin
|
47
|
+
# Create statement for one page with current offset.
|
48
|
+
statement = {:query => "LIMIT %d OFFSET %d" % [PAGE_SIZE, offset]}
|
49
|
+
|
50
|
+
# Get third party slots by statement.
|
51
|
+
page = third_party_slot_service.get_third_party_slots_by_statement(statement)
|
52
|
+
|
53
|
+
if page[:results]
|
54
|
+
# Increase query offset by page size.
|
55
|
+
offset += PAGE_SIZE
|
56
|
+
|
57
|
+
# Get the start index for printout.
|
58
|
+
start_index = page[:start_index]
|
59
|
+
|
60
|
+
# Print details about each third party slot in results page.
|
61
|
+
page[:results].each_with_index do |slot, index|
|
62
|
+
puts "%d) Third party slot ID: %d, name: '%s'" %
|
63
|
+
[index + start_index, slot[:id], slot[:name]]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end while offset < page[:total_result_set_size]
|
67
|
+
|
68
|
+
# Print a footer
|
69
|
+
if page.include?(:total_result_set_size)
|
70
|
+
puts "Total number of third party slots: %d" % page[:total_result_set_size]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
if __FILE__ == $0
|
75
|
+
begin
|
76
|
+
get_all_third_party_slots()
|
77
|
+
|
78
|
+
# HTTP errors.
|
79
|
+
rescue AdsCommon::Errors::HttpError => e
|
80
|
+
puts "HTTP Error: %s" % e
|
81
|
+
|
82
|
+
# API errors.
|
83
|
+
rescue DfpApi::Errors::ApiException => e
|
84
|
+
puts "Message: %s" % e.message
|
85
|
+
puts 'Errors:'
|
86
|
+
e.errors.each_with_index do |error, index|
|
87
|
+
puts "\tError [%d]:" % (index + 1)
|
88
|
+
error.each do |field, value|
|
89
|
+
puts "\t\t%s: %s" % [field, value]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,86 @@
|
|
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 gets archived third party slots. The statement retrieves up to
|
21
|
+
# the maximum page size limit of 500. To create third party slots, run
|
22
|
+
# create_third_party_slot.rb.
|
23
|
+
#
|
24
|
+
# Tags: ThirdPartySlotService.getThirdPartySlotsByStatement
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'dfp_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201111
|
30
|
+
|
31
|
+
def get_third_party_slot_by_statement()
|
32
|
+
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
33
|
+
dfp = DfpApi::Api.new
|
34
|
+
|
35
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
36
|
+
# the configuration file or provide your own logger:
|
37
|
+
# dfp.logger = Logger.new('dfp_xml.log')
|
38
|
+
|
39
|
+
# Get the ThirdPartySlotService.
|
40
|
+
third_party_slot_service = dfp.service(:ThirdPartySlotService, API_VERSION)
|
41
|
+
|
42
|
+
# Create a statement to get all slots with status 'ARCHIVED'.
|
43
|
+
statement = {
|
44
|
+
:query => 'WHERE status = :status LIMIT 500',
|
45
|
+
:values => [
|
46
|
+
{:key => 'status',
|
47
|
+
:value => {:value => 'ARCHIVED', :xsi_type => 'TextValue'}}
|
48
|
+
]
|
49
|
+
}
|
50
|
+
|
51
|
+
# Get third party slots by statement.
|
52
|
+
page = third_party_slot_service.get_third_party_slots_by_statement(statement)
|
53
|
+
|
54
|
+
if page and page[:results]
|
55
|
+
page[:results].each_with_index do |slot, index|
|
56
|
+
puts "%d) Third party slot ID: %d, name: '%s'" %
|
57
|
+
[index, slot[:id], slot[:name]]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Print a footer.
|
62
|
+
if page.include?(:total_result_set_size)
|
63
|
+
puts "Number of results found: %d" % page[:total_result_set_size]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if __FILE__ == $0
|
68
|
+
begin
|
69
|
+
get_third_party_slot_by_statement()
|
70
|
+
|
71
|
+
# HTTP errors.
|
72
|
+
rescue AdsCommon::Errors::HttpError => e
|
73
|
+
puts "HTTP Error: %s" % e
|
74
|
+
|
75
|
+
# API errors.
|
76
|
+
rescue DfpApi::Errors::ApiException => e
|
77
|
+
puts "Message: %s" % e.message
|
78
|
+
puts 'Errors:'
|
79
|
+
e.errors.each_with_index do |error, index|
|
80
|
+
puts "\tError [%d]:" % (index + 1)
|
81
|
+
error.each do |field, value|
|
82
|
+
puts "\t\t%s: %s" % [field, value]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,95 @@
|
|
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 updates the first third party slot description.
|
21
|
+
#
|
22
|
+
# Tags: ThirdPartySlotService.getThirdPartySlotsByStatement,
|
23
|
+
# ThirdPartySlotService.updateThirdPartySlots
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
require 'dfp_api'
|
27
|
+
|
28
|
+
API_VERSION = :v201111
|
29
|
+
PAGE_SIZE = 500
|
30
|
+
|
31
|
+
def update_third_party_slots()
|
32
|
+
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
33
|
+
dfp = DfpApi::Api.new
|
34
|
+
|
35
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
36
|
+
# the configuration file or provide your own logger:
|
37
|
+
# dfp.logger = Logger.new('dfp_xml.log')
|
38
|
+
|
39
|
+
# Get the ThirdPartySlotService.
|
40
|
+
third_party_slot_service = dfp.service(:ThirdPartySlotService, API_VERSION)
|
41
|
+
|
42
|
+
# Create statement to get one active third party slot.
|
43
|
+
statement = {
|
44
|
+
:query => 'WHERE status = :status LIMIT 1',
|
45
|
+
:values => [
|
46
|
+
{:key => 'status',
|
47
|
+
:value => {:value => 'ACTIVE', :xsi_type => 'TextValue'}},
|
48
|
+
]
|
49
|
+
}
|
50
|
+
|
51
|
+
# Get third party slots by statement.
|
52
|
+
page = third_party_slot_service.get_third_party_slots_by_statement(statement)
|
53
|
+
|
54
|
+
if page[:results] and !page[:results].empty?
|
55
|
+
slot = page[:results].first
|
56
|
+
|
57
|
+
# Update local third party slot by changing its description.
|
58
|
+
slot[:description] = 'Updated description'
|
59
|
+
|
60
|
+
# Update the third party slot on the server.
|
61
|
+
return_slot = third_party_slot_service.update_third_party_slot(slot)
|
62
|
+
|
63
|
+
# Display results.
|
64
|
+
if return_slot
|
65
|
+
puts ("Third party slot with ID %d and name '%s' was updated with " +
|
66
|
+
"description '%s'.") %
|
67
|
+
[return_slot[:id], return_slot[:name], return_slot[:description]]
|
68
|
+
else
|
69
|
+
puts 'No third party slots were updated.'
|
70
|
+
end
|
71
|
+
else
|
72
|
+
puts 'No third party slots found to update.'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if __FILE__ == $0
|
77
|
+
begin
|
78
|
+
update_third_party_slots()
|
79
|
+
|
80
|
+
# HTTP errors.
|
81
|
+
rescue AdsCommon::Errors::HttpError => e
|
82
|
+
puts "HTTP Error: %s" % e
|
83
|
+
|
84
|
+
# API errors.
|
85
|
+
rescue DfpApi::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
|
data/lib/dfp_api/api_config.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
4
4
|
# License:: Licensed under the Apache License,Version 2.0 (the "License").
|
5
5
|
#
|
6
|
-
# Code generated by AdsCommon library 0.6.
|
6
|
+
# Code generated by AdsCommon library 0.6.1 on 2011-12-20 18:01:52.
|
7
7
|
|
8
8
|
require 'ads_common/savon_service'
|
9
9
|
require 'dfp_api/v201103/company_service_registry'
|
@@ -15,18 +15,6 @@ module DfpApi; module V201103; module CompanyService
|
|
15
15
|
super(api, endpoint, namespace, :v201103)
|
16
16
|
end
|
17
17
|
|
18
|
-
def create_companies(*args, &block)
|
19
|
-
return execute_action('create_companies', args, &block)
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_company(*args, &block)
|
23
|
-
return execute_action('create_company', args, &block)
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_companies_by_statement(*args, &block)
|
27
|
-
return execute_action('get_companies_by_statement', args, &block)
|
28
|
-
end
|
29
|
-
|
30
18
|
def get_company(*args, &block)
|
31
19
|
return execute_action('get_company', args, &block)
|
32
20
|
end
|
@@ -39,6 +27,18 @@ module DfpApi; module V201103; module CompanyService
|
|
39
27
|
return execute_action('update_company', args, &block)
|
40
28
|
end
|
41
29
|
|
30
|
+
def create_companies(*args, &block)
|
31
|
+
return execute_action('create_companies', args, &block)
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_company(*args, &block)
|
35
|
+
return execute_action('create_company', args, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_companies_by_statement(*args, &block)
|
39
|
+
return execute_action('get_companies_by_statement', args, &block)
|
40
|
+
end
|
41
|
+
|
42
42
|
private
|
43
43
|
|
44
44
|
def get_service_registry()
|
@@ -3,14 +3,14 @@
|
|
3
3
|
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
4
4
|
# License:: Licensed under the Apache License,Version 2.0 (the "License").
|
5
5
|
#
|
6
|
-
# Code generated by AdsCommon library 0.6.
|
6
|
+
# Code generated by AdsCommon library 0.6.1 on 2011-12-20 18:01:52.
|
7
7
|
|
8
8
|
require 'dfp_api/errors'
|
9
9
|
|
10
10
|
module DfpApi; module V201103; module CompanyService
|
11
11
|
class CompanyServiceRegistry
|
12
|
-
COMPANYSERVICE_METHODS = {:
|
13
|
-
COMPANYSERVICE_TYPES = {:
|
12
|
+
COMPANYSERVICE_METHODS = {:get_company=>{:output=>{:fields=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>1, :name=>:rval}], :name=>"get_company_response"}, :input=>[{:type=>"long", :min_occurs=>0, :max_occurs=>1, :name=>:company_id}]}, :update_companies=>{:output=>{:fields=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:rval}], :name=>"update_companies_response"}, :input=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:companies}]}, :update_company=>{:output=>{:fields=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>1, :name=>:rval}], :name=>"update_company_response"}, :input=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>1, :name=>:company}]}, :create_companies=>{:output=>{:fields=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:rval}], :name=>"create_companies_response"}, :input=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:companies}]}, :create_company=>{:output=>{:fields=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>1, :name=>:rval}], :name=>"create_company_response"}, :input=>[{:type=>"Company", :min_occurs=>0, :max_occurs=>1, :name=>:company}]}, :get_companies_by_statement=>{:output=>{:fields=>[{:type=>"CompanyPage", :min_occurs=>0, :max_occurs=>1, :name=>:rval}], :name=>"get_companies_by_statement_response"}, :input=>[{:type=>"Statement", :min_occurs=>0, :max_occurs=>1, :name=>:filter_statement}]}}
|
13
|
+
COMPANYSERVICE_TYPES = {:Statement=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:query}, {:type=>"String_ValueMapEntry", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:values}]}, :Value=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:value_type}], :abstract=>true}, :PredefinedCustomCriteria=>{:fields=>[{:type=>"long", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:value_ids}], :base=>"CustomCriteria"}, :CompanyPage=>{:fields=>[{:type=>"int", :min_occurs=>0, :max_occurs=>1, :name=>:total_result_set_size}, {:type=>"int", :min_occurs=>0, :max_occurs=>1, :name=>:start_index}, {:type=>"Company", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:results}]}, :String_ValueMapEntry=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:key}, {:type=>"Value", :min_occurs=>0, :max_occurs=>1, :name=>:value}]}, :NumberValue=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:value}], :base=>"Value"}, :CustomCriteria=>{:fields=>[{:type=>"long", :min_occurs=>0, :max_occurs=>1, :name=>:key_id}, {:type=>"CustomCriteria.ComparisonOperator", :min_occurs=>0, :max_occurs=>1, :name=>:operator}], :base=>"CustomCriteriaNode"}, :Authentication=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:authentication_type}], :abstract=>true}, :"CustomTargetingValue.MatchType"=>{:fields=>[]}, :"Company.Type"=>{:fields=>[]}, :CustomCriteriaSet=>{:fields=>[{:type=>"CustomCriteriaSet.LogicalOperator", :min_occurs=>0, :max_occurs=>1, :name=>:logical_operator}, {:type=>"CustomCriteriaNode", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:children}], :base=>"CustomCriteriaNode"}, :BooleanValue=>{:fields=>[{:type=>"boolean", :min_occurs=>0, :max_occurs=>1, :name=>:value}], :base=>"Value"}, :"CustomCriteria.ComparisonOperator"=>{:fields=>[]}, :OAuth=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:parameters}], :base=>"Authentication"}, :SoapRequestHeader=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:network_code}, {:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:application_name}, {:type=>"Authentication", :min_occurs=>0, :max_occurs=>1, :name=>:authentication}]}, :CustomCriteriaNode=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:custom_criteria_node_type}], :abstract=>true}, :ClientLogin=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:token}], :base=>"Authentication"}, :"CustomCriteriaSet.LogicalOperator"=>{:fields=>[]}, :TextValue=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:value}], :base=>"Value"}, :SoapResponseHeader=>{:fields=>[{:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:request_id}, {:type=>"long", :min_occurs=>0, :max_occurs=>1, :name=>:response_time}]}, :FreeFormCustomCriteria=>{:fields=>[{:type=>"CustomTargetingValue", :min_occurs=>0, :max_occurs=>:unbounded, :name=>:values}], :base=>"CustomCriteria"}, :CustomTargetingValue=>{:fields=>[{:type=>"long", :min_occurs=>0, :max_occurs=>1, :name=>:custom_targeting_key_id}, {:type=>"long", :min_occurs=>0, :max_occurs=>1, :name=>:id}, {:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:name}, {:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:display_name}, {:type=>"CustomTargetingValue.MatchType", :min_occurs=>0, :max_occurs=>1, :name=>:match_type}]}, :Company=>{:fields=>[{:type=>"long", :min_occurs=>0, :max_occurs=>1, :name=>:id}, {:type=>"string", :min_occurs=>0, :max_occurs=>1, :name=>:name}, {:type=>"Company.Type", :min_occurs=>0, :max_occurs=>1, :name=>:type}]}}
|
14
14
|
COMPANYSERVICE_NAMESPACES = []
|
15
15
|
|
16
16
|
def self.get_method_signature(method_name)
|