google-dfp-api 0.13.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +12 -1
- data/README.md +1 -1
- data/examples/v201508/common/oauth2_jwt_handling.rb +1 -1
- data/examples/v201508/common/setup_oauth2.rb +1 -1
- data/examples/v201511/common/oauth2_jwt_handling.rb +1 -1
- data/examples/v201511/common/setup_oauth2.rb +1 -1
- data/examples/v201602/common/oauth2_jwt_handling.rb +1 -1
- data/examples/v201602/common/setup_oauth2.rb +1 -1
- data/examples/{v201505 → v201605}/activity_group_service/create_activity_groups.rb +1 -1
- data/examples/{v201505 → v201605}/activity_group_service/get_active_activity_groups.rb +1 -1
- data/examples/{v201505 → v201605}/activity_group_service/get_all_activity_groups.rb +1 -1
- data/examples/{v201505 → v201605}/activity_group_service/update_activity_groups.rb +1 -1
- data/examples/{v201505 → v201605}/activity_service/create_activities.rb +1 -1
- data/examples/{v201505 → v201605}/activity_service/get_active_activities.rb +1 -1
- data/examples/{v201505 → v201605}/activity_service/get_all_activities.rb +1 -1
- data/examples/{v201505 → v201605}/activity_service/update_activities.rb +1 -1
- data/examples/{v201505 → v201605}/audience_segment_service/create_audience_segments.rb +1 -1
- data/examples/{v201505 → v201605}/audience_segment_service/get_all_audience_segments.rb +1 -1
- data/examples/{v201505 → v201605}/audience_segment_service/get_first_party_audience_segments.rb +1 -1
- data/examples/{v201505 → v201605}/audience_segment_service/populate_first_party_audience_segments.rb +1 -1
- data/examples/{v201505 → v201605}/audience_segment_service/update_audience_segments.rb +1 -1
- data/examples/{v201505 → v201605}/common/error_handling.rb +1 -1
- data/examples/{v201505 → v201605}/common/oauth2_jwt_handling.rb +1 -1
- data/examples/{v201505 → v201605}/common/setup_oauth2.rb +1 -1
- data/examples/{v201505 → v201605}/company_service/create_companies.rb +3 -2
- data/examples/{v201505 → v201605}/company_service/get_all_companies.rb +1 -1
- data/examples/{v201505 → v201605}/company_service/get_companies_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/company_service/update_companies.rb +1 -1
- data/examples/{v201505 → v201605}/contact_service/create_contacts.rb +1 -1
- data/examples/{v201505 → v201605}/contact_service/get_all_contacts.rb +1 -1
- data/examples/{v201505 → v201605}/contact_service/get_uninvited_contacts.rb +1 -1
- data/examples/{v201505 → v201605}/contact_service/update_contacts.rb +1 -1
- data/examples/{v201505 → v201605}/content_metadata_key_hierarchy_service/create_content_metadata_key_hierarchies.rb +1 -1
- data/examples/{v201505 → v201605}/content_metadata_key_hierarchy_service/delete_content_metadata_key_hierarchies.rb +1 -1
- data/examples/{v201505 → v201605}/content_metadata_key_hierarchy_service/get_all_content_metadata_key_hierarchies.rb +1 -1
- data/examples/{v201505 → v201605}/content_metadata_key_hierarchy_service/update_content_metadata_key_hierarchies.rb +1 -1
- data/examples/{v201505 → v201605}/content_service/get_all_content.rb +1 -1
- data/examples/{v201505 → v201605}/content_service/get_content_by_category.rb +1 -1
- data/examples/{v201505 → v201605}/creative_service/copy_image_creatives.rb +1 -1
- data/examples/{v201505 → v201605}/creative_service/create_creative_from_template.rb +1 -1
- data/examples/{v201505 → v201605}/creative_service/create_creatives.rb +1 -1
- data/examples/{v201505 → v201605}/creative_service/create_custom_creative.rb +9 -6
- data/examples/v201605/creative_service/create_native_creative.rb +189 -0
- data/examples/{v201505 → v201605}/creative_service/get_all_creatives.rb +1 -1
- data/examples/{v201505 → v201605}/creative_service/get_creatives_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/creative_service/update_creatives.rb +1 -1
- data/examples/{v201505 → v201605}/creative_set_service/associate_creative_set_to_line_item.rb +1 -1
- data/examples/{v201505 → v201605}/creative_set_service/create_creative_set.rb +1 -1
- data/examples/{v201505 → v201605}/creative_set_service/get_all_creative_sets.rb +1 -1
- data/examples/{v201505 → v201605}/creative_set_service/get_creative_sets_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/creative_set_service/update_creative_sets.rb +1 -1
- data/examples/{v201505 → v201605}/creative_template_service/get_all_creative_templates.rb +1 -1
- data/examples/{v201505 → v201605}/creative_template_service/get_system_defined_creative_templates.rb +1 -1
- data/examples/{v201505 → v201605}/creative_wrapper_service/create_creative_wrappers.rb +1 -1
- data/examples/{v201505 → v201605}/creative_wrapper_service/deactivate_creative_wrapper.rb +1 -1
- data/examples/{v201505 → v201605}/creative_wrapper_service/get_all_creative_wrappers.rb +1 -1
- data/examples/{v201505 → v201605}/creative_wrapper_service/get_creative_wrappers_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/creative_wrapper_service/update_creative_wrappers.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/create_custom_field_options.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/create_custom_fields.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/deactivate_all_line_item_custom_fields.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/get_all_custom_fields.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/get_all_line_item_custom_fields.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/set_line_item_custom_field_value.rb +1 -1
- data/examples/{v201505 → v201605}/custom_field_service/update_custom_fields.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/create_custom_targeting_keys_and_values.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/delete_custom_targeting_keys.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/delete_custom_targeting_values.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/get_all_custom_targeting_keys_and_values.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/get_custom_targeting_keys_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/get_custom_targeting_values_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/update_custom_targeting_keys.rb +1 -1
- data/examples/{v201505 → v201605}/custom_targeting_service/update_custom_targeting_values.rb +1 -1
- data/examples/{v201505 → v201605}/forecast_service/get_availability_forecast.rb +9 -1
- data/examples/{v201505 → v201605}/forecast_service/get_availability_forecast_for_line_item.rb +5 -1
- data/examples/{v201505 → v201605}/forecast_service/get_delivery_forecast_for_line_items.rb +5 -1
- data/examples/{v201505 → v201605}/inventory_service/create_ad_units.rb +1 -1
- data/examples/{v201505 → v201605}/inventory_service/create_video_ad_unit.rb +1 -2
- data/examples/{v201505 → v201605}/inventory_service/deactivate_ad_units.rb +1 -1
- data/examples/{v201505 → v201605}/inventory_service/get_ad_unit_sizes.rb +1 -1
- data/examples/{v201505 → v201605}/inventory_service/get_ad_units_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/inventory_service/get_all_ad_units.rb +1 -1
- data/examples/{v201505 → v201605}/inventory_service/update_ad_units.rb +1 -1
- data/examples/{v201505 → v201605}/label_service/create_labels.rb +1 -1
- data/examples/{v201505 → v201605}/label_service/deactivate_labels.rb +1 -1
- data/examples/{v201505 → v201605}/label_service/get_all_labels.rb +1 -1
- data/examples/{v201505 → v201605}/label_service/get_labels_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/label_service/update_labels.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_creative_association_service/create_licas.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_creative_association_service/deactivate_licas.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_creative_association_service/get_all_licas.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_creative_association_service/get_licas_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_creative_association_service/update_licas.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/activate_line_items.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/create_line_items.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/create_video_line_item.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/get_all_line_items.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/get_line_items_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/get_recently_updated_line_items.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/target_custom_criteria.rb +1 -1
- data/examples/{v201505 → v201605}/line_item_service/update_line_items.rb +1 -1
- data/examples/{v201505 → v201605}/network_service/get_all_networks.rb +1 -1
- data/examples/{v201505 → v201605}/network_service/get_current_network.rb +1 -1
- data/examples/{v201505 → v201605}/network_service/make_test_network.rb +1 -1
- data/examples/{v201505 → v201605}/order_service/approve_orders.rb +1 -1
- data/examples/{v201505 → v201605}/order_service/create_orders.rb +1 -1
- data/examples/{v201505 → v201605}/order_service/get_all_orders.rb +1 -1
- data/examples/{v201505 → v201605}/order_service/get_orders_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/order_service/update_orders.rb +1 -1
- data/examples/{v201505 → v201605}/placement_service/create_placements.rb +1 -1
- data/examples/{v201505 → v201605}/placement_service/deactivate_placements.rb +1 -1
- data/examples/{v201505 → v201605}/placement_service/get_all_placements.rb +1 -1
- data/examples/{v201505 → v201605}/placement_service/get_placements_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/placement_service/update_placements.rb +2 -2
- data/examples/{v201505 → v201605}/publisher_query_language_service/fetch_match_tables.rb +2 -2
- data/examples/{v201505 → v201605}/publisher_query_language_service/get_all_line_items.rb +1 -1
- data/examples/{v201505 → v201605}/publisher_query_language_service/get_geo_targets.rb +1 -1
- data/examples/{v201505 → v201605}/publisher_query_language_service/get_line_items_named_like.rb +1 -1
- data/examples/{v201505 → v201605}/report_service/display_report.rb +1 -1
- data/examples/{v201505 → v201605}/report_service/download_report.rb +1 -1
- data/examples/{v201505 → v201605}/report_service/run_delivery_report.rb +13 -2
- data/examples/{v201505 → v201605}/report_service/run_inventory_report.rb +1 -1
- data/examples/{v201505 → v201605}/report_service/run_reach_report.rb +1 -1
- data/examples/{v201505 → v201605}/report_service/run_report_with_custom_fields.rb +1 -1
- data/examples/{v201505 → v201605}/report_service/run_sales_report.rb +1 -1
- data/examples/{v201505 → v201605}/suggested_ad_unit_service/approve_all_suggested_ad_units.rb +2 -2
- data/examples/{v201505 → v201605}/suggested_ad_unit_service/get_all_suggested_ad_units.rb +1 -1
- data/examples/{v201505 → v201605}/suggested_ad_unit_service/get_suggested_ad_units_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/team_service/create_teams.rb +1 -1
- data/examples/{v201505 → v201605}/team_service/get_all_teams.rb +1 -1
- data/examples/{v201505 → v201605}/team_service/get_teams_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/team_service/update_teams.rb +1 -1
- data/examples/{v201505 → v201605}/user_service/create_users.rb +2 -2
- data/examples/{v201505 → v201605}/user_service/deactivate_users.rb +1 -1
- data/examples/{v201505 → v201605}/user_service/get_all_roles.rb +1 -1
- data/examples/{v201505 → v201605}/user_service/get_all_users.rb +1 -1
- data/examples/{v201505 → v201605}/user_service/get_current_user.rb +1 -1
- data/examples/{v201505 → v201605}/user_service/get_users_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/user_service/update_users.rb +1 -1
- data/examples/{v201505 → v201605}/user_team_association_service/create_user_team_associations.rb +1 -1
- data/examples/{v201505 → v201605}/user_team_association_service/delete_user_team_associations.rb +1 -1
- data/examples/{v201505 → v201605}/user_team_association_service/get_all_user_team_associations.rb +1 -1
- data/examples/{v201505 → v201605}/user_team_association_service/get_user_team_associations_by_statement.rb +1 -1
- data/examples/{v201505 → v201605}/user_team_association_service/update_user_team_associations.rb +1 -1
- data/lib/dfp_api/api_config.rb +11 -10
- data/lib/dfp_api/version.rb +1 -1
- metadata +140 -140
- data/examples/v201505/inventory_service/create_mobile_ad_unit.rb +0 -97
@@ -0,0 +1,189 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Copyright:: Copyright 2015, Google Inc. All Rights Reserved.
|
5
|
+
#
|
6
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
15
|
+
# implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
# This example creates a new native creative for a given advertiser. To
|
20
|
+
# determine which companies are advertisers, run get_companies_by_statement.rb.
|
21
|
+
# To determine which creatives already exist, run get_all_creatives.rb.
|
22
|
+
#
|
23
|
+
# The code in this example will use app data from the Google sample app
|
24
|
+
# 'Pie Noon':
|
25
|
+
#
|
26
|
+
# https://play.google.com/store/apps/details?id=com.google.fpl.pie_noon&hl=en
|
27
|
+
|
28
|
+
require 'base64'
|
29
|
+
require 'dfp_api'
|
30
|
+
|
31
|
+
API_VERSION = :v201605
|
32
|
+
|
33
|
+
def create_creative_from_template()
|
34
|
+
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
35
|
+
dfp = DfpApi::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
|
+
# dfp.logger = Logger.new('dfp_xml.log')
|
40
|
+
|
41
|
+
# Get the CreativeService.
|
42
|
+
creative_service = dfp.service(:CreativeService, API_VERSION)
|
43
|
+
|
44
|
+
# Set the ID of the advertiser (company) that all creatives will be assigned
|
45
|
+
# to.
|
46
|
+
advertiser_id = 'INSERT_ADVERTISER_COMPANY_ID_HERE'.to_i
|
47
|
+
|
48
|
+
# Set the URLs of the application screenshot and the small application icon to
|
49
|
+
# use and convert them to byte array strings.
|
50
|
+
screenshot_url = 'https://lh4.ggpht.com/GIGNKdGHMEHFDw6TM2bgAUDKPQQRIReKZPq' +
|
51
|
+
'EpMeEhZOPYnTdOQGaSpGSEZflIFs0iw=h300'
|
52
|
+
screenshot_data = AdsCommon::Http.get(screenshot_url, dfp.config)
|
53
|
+
screenshot_data_base64 = Base64.encode64(screenshot_data)
|
54
|
+
|
55
|
+
app_icon = 'https://lh6.ggpht.com/Jzvjne5CLs6fJ1MHF-XeuUfpABzl0YNMlp4' +
|
56
|
+
'RpHnvPRCIj4--eTDwtyouwUDzVVekXw=w300')
|
57
|
+
app_icon_data = AdsCommon::Http.get(app_icon, dfp.config)
|
58
|
+
app_icon_data_base64 = Base64.encode64(app_icon_data)
|
59
|
+
|
60
|
+
# Use the native creative template.
|
61
|
+
creative_template_id = 10004400
|
62
|
+
|
63
|
+
# Create the local custom creative object.
|
64
|
+
creative = {
|
65
|
+
:xsi_type => 'TemplateCreative',
|
66
|
+
:name => "Native creative %d" % Time.new.to_i,
|
67
|
+
:advertiser_id => advertiser_id,
|
68
|
+
:creative_template_id => creative_template_id,
|
69
|
+
:size => {:width => 1, :height => 1, :is_aspect_ratio => false},
|
70
|
+
:destination_url => 'https://play.google.com/store/apps/details?id=' +
|
71
|
+
'com.google.fpl.pie_noon'
|
72
|
+
}
|
73
|
+
|
74
|
+
# Create the Image asset variable value.
|
75
|
+
image_variable_value = {
|
76
|
+
:xsi_type => 'AssetCreativeTemplateVariableValue',
|
77
|
+
:unique_name => 'Image',
|
78
|
+
:asset => {
|
79
|
+
:asset_byte_array => screenshot_data_base64,
|
80
|
+
# Filenames must be unique.
|
81
|
+
:file_name => "image%d.png" % Time.new.to_i
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
# Create the Appicon asset variable value.
|
86
|
+
appicon_variable_value = {
|
87
|
+
:xsi_type => 'AssetCreativeTemplateVariableValue',
|
88
|
+
:unique_name => 'Appicon',
|
89
|
+
:asset => {
|
90
|
+
:asset_byte_array => app_icon_data_base64,
|
91
|
+
# Filenames must be unique.
|
92
|
+
:file_name => "image%d.png" % Time.new.to_i
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
# Create the Price variable value.
|
97
|
+
price_variable_value = {
|
98
|
+
:xsi_type => 'StringCreativeTemplateVariableValue',
|
99
|
+
:unique_name => 'Price',
|
100
|
+
:value => 'Free'
|
101
|
+
}
|
102
|
+
|
103
|
+
# Create the Calltoaction variable value.
|
104
|
+
calltoaction_variable_value = {
|
105
|
+
:xsi_type => 'StringCreativeTemplateVariableValue',
|
106
|
+
:unique_name => 'Calltoaction',
|
107
|
+
:value => 'Install'
|
108
|
+
}
|
109
|
+
|
110
|
+
# Create the Starrating variable value.
|
111
|
+
starrating_variable_value = {
|
112
|
+
:xsi_type => 'StringCreativeTemplateVariableValue',
|
113
|
+
:unique_name => 'Starrating',
|
114
|
+
:value => '4'
|
115
|
+
}
|
116
|
+
|
117
|
+
# Create the Store variable value.
|
118
|
+
store_variable_value = {
|
119
|
+
:xsi_type => 'StringCreativeTemplateVariableValue',
|
120
|
+
:unique_name => 'Store',
|
121
|
+
:value => 'Google Play'
|
122
|
+
}
|
123
|
+
|
124
|
+
# Create the Headline variable value.
|
125
|
+
headline_variable_value = {
|
126
|
+
:xsi_type => 'StringCreativeTemplateVariableValue',
|
127
|
+
:unique_name => 'Headline',
|
128
|
+
:value => 'Pie Noon'
|
129
|
+
}
|
130
|
+
|
131
|
+
# Create the Body variable value.
|
132
|
+
body_variable_value = {
|
133
|
+
:xsi_type => 'StringCreativeTemplateVariableValue',
|
134
|
+
:unique_name => 'Body',
|
135
|
+
:value => 'Try multi-screen mode!'
|
136
|
+
}
|
137
|
+
|
138
|
+
# Create the DeeplinkclickactionURL variable value.
|
139
|
+
deeplinkurl_variable_value = {
|
140
|
+
:xsi_type => 'UrlCreativeTemplateVariableValue',
|
141
|
+
:unique_name => 'DeeplinkclickactionURL',
|
142
|
+
:value => 'market://details?id=com.google.fpl.pie_noon'
|
143
|
+
}
|
144
|
+
|
145
|
+
creative[:creative_template_variable_values] = [
|
146
|
+
deeplinkurl_variable_value,
|
147
|
+
body_variable_value,
|
148
|
+
headline_variable_value,
|
149
|
+
store_variable_value,
|
150
|
+
starrating_variable_value,
|
151
|
+
calltoaction_variable_value,
|
152
|
+
price_variable_value,
|
153
|
+
appicon_variable_value,
|
154
|
+
image_variable_value
|
155
|
+
]
|
156
|
+
|
157
|
+
# Create the creatives on the server.
|
158
|
+
return_creative = creative_service.create_creatives([creative])[0]
|
159
|
+
|
160
|
+
if return_creative
|
161
|
+
puts(("Native creative with ID: %d and name: %s was " +
|
162
|
+
"created and can be previewed at: '%s'") %
|
163
|
+
[return_creative[:id], return_creative[:name],
|
164
|
+
return_creative[:preview_url]])
|
165
|
+
else
|
166
|
+
raise 'No creatives were created.'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
if __FILE__ == $0
|
171
|
+
begin
|
172
|
+
create_creative_from_template()
|
173
|
+
|
174
|
+
# HTTP errors.
|
175
|
+
rescue AdsCommon::Errors::HttpError => e
|
176
|
+
puts "HTTP Error: %s" % e
|
177
|
+
|
178
|
+
# API errors.
|
179
|
+
rescue DfpApi::Errors::ApiException => e
|
180
|
+
puts "Message: %s" % e.message
|
181
|
+
puts 'Errors:'
|
182
|
+
e.errors.each_with_index do |error, index|
|
183
|
+
puts "\tError [%d]:" % (index + 1)
|
184
|
+
error.each do |field, value|
|
185
|
+
puts "\t\t%s: %s" % [field, value]
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|