google-dfp-api 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/README.md +1 -3
- data/dfp_api.yml +1 -9
- data/examples/v201408/report_service/run_sales_report.rb +3 -3
- data/examples/v201411/report_service/run_sales_report.rb +3 -3
- data/examples/v201502/report_service/run_sales_report.rb +3 -3
- data/examples/{v201405 → v201505}/activity_group_service/create_activity_groups.rb +1 -1
- data/examples/{v201405 → v201505}/activity_group_service/get_active_activity_groups.rb +18 -27
- data/examples/{v201405 → v201505}/activity_group_service/get_all_activity_groups.rb +13 -23
- data/examples/{v201405 → v201505}/activity_group_service/update_activity_groups.rb +11 -9
- data/examples/{v201405 → v201505}/activity_service/create_activities.rb +1 -1
- data/examples/{v201405 → v201505}/activity_service/get_active_activities.rb +15 -27
- data/examples/{v201405 → v201505}/activity_service/get_all_activities.rb +10 -21
- data/examples/{v201405 → v201505}/activity_service/update_activities.rb +9 -7
- data/examples/{v201405 → v201505}/audience_segment_service/create_audience_segments.rb +1 -1
- data/examples/{v201405 → v201505}/audience_segment_service/get_all_audience_segments.rb +10 -19
- data/examples/{v201405 → v201505}/audience_segment_service/get_first_party_audience_segments.rb +14 -21
- data/examples/{v201405 → v201505}/audience_segment_service/populate_first_party_audience_segments.rb +16 -14
- data/examples/{v201405 → v201505}/audience_segment_service/update_audience_segments.rb +12 -11
- data/examples/{v201405 → v201505}/common/error_handling.rb +1 -1
- data/examples/{v201405 → v201505}/common/oauth2_jwt_handling.rb +9 -17
- data/examples/{v201405 → v201505}/common/setup_oauth2.rb +1 -1
- data/examples/{v201405 → v201505}/company_service/create_companies.rb +1 -1
- data/examples/{v201405 → v201505}/company_service/get_all_companies.rb +10 -18
- data/examples/{v201405 → v201505}/company_service/get_companies_by_statement.rb +21 -16
- data/examples/{v201405 → v201505}/company_service/update_companies.rb +13 -10
- data/examples/{v201405 → v201505}/contact_service/create_contacts.rb +1 -1
- data/examples/{v201405 → v201505}/contact_service/get_all_contacts.rb +11 -19
- data/examples/{v201405 → v201505}/contact_service/get_uninvited_contacts.rb +18 -22
- data/examples/{v201405 → v201505}/contact_service/update_contacts.rb +9 -7
- data/examples/{v201405 → v201505}/content_metadata_key_hierarchy_service/create_content_metadata_key_hierarchies.rb +1 -1
- data/examples/{v201405 → v201505}/content_metadata_key_hierarchy_service/delete_content_metadata_key_hierarchies.rb +11 -8
- data/examples/{v201405 → v201505}/content_metadata_key_hierarchy_service/get_all_content_metadata_key_hierarchies.rb +8 -18
- data/examples/{v201405 → v201505}/content_metadata_key_hierarchy_service/update_content_metadata_key_hierarchies.rb +9 -7
- data/examples/{v201405 → v201505}/content_service/get_all_content.rb +9 -18
- data/examples/{v201405 → v201505}/content_service/get_content_by_category.rb +18 -28
- data/examples/{v201405 → v201505}/creative_service/copy_image_creatives.rb +7 -7
- data/examples/{v201405 → v201505}/creative_service/create_creative_from_template.rb +1 -1
- data/examples/{v201405 → v201505}/creative_service/create_creatives.rb +1 -1
- data/examples/{v201405 → v201505}/creative_service/create_custom_creative.rb +1 -1
- data/examples/{v201405 → v201505}/creative_service/get_all_creatives.rb +8 -17
- data/examples/{v201405 → v201505}/creative_service/get_creatives_by_statement.rb +18 -13
- data/examples/{v201405 → v201505}/creative_service/update_creatives.rb +16 -11
- data/examples/{v201405 → v201505}/creative_set_service/associate_creative_set_to_line_item.rb +1 -1
- data/examples/{v201405 → v201505}/creative_set_service/create_creative_set.rb +1 -1
- data/examples/{v201405 → v201505}/creative_set_service/get_all_creative_sets.rb +9 -17
- data/examples/{v201405 → v201505}/creative_set_service/get_creative_sets_by_statement.rb +20 -14
- data/examples/{v201405 → v201505}/creative_set_service/update_creative_sets.rb +10 -7
- data/examples/{v201405 → v201505}/creative_template_service/get_all_creative_templates.rb +9 -17
- data/examples/{v201405/creative_template_service/get_creative_templates_by_statement.rb → v201505/creative_template_service/get_system_defined_creative_templates.rb} +24 -13
- data/examples/{v201405 → v201505}/creative_wrapper_service/create_creative_wrappers.rb +1 -1
- data/examples/{v201405 → v201505}/creative_wrapper_service/deactivate_creative_wrapper.rb +9 -7
- data/examples/{v201405 → v201505}/creative_wrapper_service/get_all_creative_wrappers.rb +10 -18
- data/examples/{v201405 → v201505}/creative_wrapper_service/get_creative_wrappers_by_statement.rb +17 -12
- data/examples/{v201405 → v201505}/creative_wrapper_service/update_creative_wrappers.rb +10 -7
- data/examples/{v201405 → v201505}/custom_field_service/create_custom_field_options.rb +1 -1
- data/examples/{v201405 → v201505}/custom_field_service/create_custom_fields.rb +1 -1
- data/examples/{v201405 → v201505}/custom_field_service/deactivate_all_line_item_custom_fields.rb +13 -23
- data/examples/{v201405 → v201505}/custom_field_service/get_all_custom_fields.rb +11 -19
- data/examples/{v201405 → v201505}/custom_field_service/get_all_line_item_custom_fields.rb +19 -14
- data/examples/{v201405 → v201505}/custom_field_service/set_line_item_custom_field_value.rb +24 -19
- data/examples/{v201405 → v201505}/custom_field_service/update_custom_fields.rb +10 -7
- data/examples/{v201405 → v201505}/custom_targeting_service/create_custom_targeting_keys_and_values.rb +1 -1
- data/examples/{v201405 → v201505}/custom_targeting_service/delete_custom_targeting_keys.rb +16 -20
- data/examples/{v201405 → v201505}/custom_targeting_service/delete_custom_targeting_values.rb +23 -21
- data/examples/{v201405 → v201505}/custom_targeting_service/get_all_custom_targeting_keys_and_values.rb +15 -36
- data/examples/{v201405 → v201505}/custom_targeting_service/get_custom_targeting_keys_by_statement.rb +20 -16
- data/examples/{v201405 → v201505}/custom_targeting_service/get_custom_targeting_values_by_statement.rb +19 -15
- data/examples/{v201405 → v201505}/custom_targeting_service/update_custom_targeting_keys.rb +4 -3
- data/examples/{v201405 → v201505}/custom_targeting_service/update_custom_targeting_values.rb +34 -30
- data/examples/{v201405/forecast_service/get_forecast.rb → v201505/forecast_service/get_availability_forecast.rb} +38 -16
- data/examples/{v201405/forecast_service/get_forecast_by_id.rb → v201505/forecast_service/get_availability_forecast_for_line_item.rb} +18 -11
- data/examples/v201505/forecast_service/get_delivery_forecast_for_line_items.rb +81 -0
- data/examples/{v201405 → v201505}/inventory_service/create_ad_units.rb +1 -1
- data/examples/{v201405 → v201505}/inventory_service/create_mobile_ad_unit.rb +1 -1
- data/examples/{v201405 → v201505}/inventory_service/create_video_ad_unit.rb +1 -1
- data/examples/{v201405 → v201505}/inventory_service/deactivate_ad_units.rb +19 -23
- data/examples/{v201405 → v201505}/inventory_service/get_ad_unit_sizes.rb +7 -14
- data/examples/{v201405 → v201505}/inventory_service/get_ad_units_by_statement.rb +18 -13
- data/examples/{v201405 → v201505}/inventory_service/get_all_ad_units.rb +8 -17
- data/examples/{v201405 → v201505}/inventory_service/update_ad_units.rb +23 -11
- data/examples/{v201405 → v201505}/label_service/create_labels.rb +1 -1
- data/examples/{v201405 → v201505}/label_service/deactivate_labels.rb +15 -22
- data/examples/{v201405 → v201505}/label_service/get_all_labels.rb +9 -18
- data/examples/{v201405 → v201505}/label_service/get_labels_by_statement.rb +16 -11
- data/examples/{v201405 → v201505}/label_service/update_labels.rb +24 -26
- data/examples/{v201405 → v201505}/line_item_creative_association_service/create_licas.rb +1 -1
- data/examples/{v201405 → v201505}/line_item_creative_association_service/deactivate_licas.rb +15 -24
- data/examples/{v201405 → v201505}/line_item_creative_association_service/get_all_licas.rb +8 -17
- data/examples/{v201405 → v201505}/line_item_creative_association_service/get_licas_by_statement.rb +10 -8
- data/examples/{v201405 → v201505}/line_item_creative_association_service/update_licas.rb +16 -7
- data/examples/{v201405 → v201505}/line_item_service/activate_line_items.rb +13 -21
- data/examples/{v201405 → v201505}/line_item_service/create_line_items.rb +11 -4
- data/examples/{v201405 → v201505}/line_item_service/create_video_line_item.rb +13 -3
- data/examples/{v201405 → v201505}/line_item_service/get_all_line_items.rb +9 -17
- data/examples/{v201405 → v201505}/line_item_service/get_line_items_by_statement.rb +19 -17
- data/examples/{v201405 → v201505}/line_item_service/get_recently_updated_line_items.rb +19 -13
- data/examples/{v201405 → v201505}/line_item_service/target_custom_criteria.rb +9 -7
- data/examples/{v201405 → v201505}/line_item_service/update_line_items.rb +9 -9
- data/examples/{v201405 → v201505}/network_service/get_all_networks.rb +1 -1
- data/examples/{v201405 → v201505}/network_service/get_current_network.rb +1 -1
- data/examples/{v201405 → v201505}/network_service/make_test_network.rb +1 -1
- data/examples/{v201405 → v201505}/order_service/approve_orders.rb +16 -24
- data/examples/{v201405 → v201505}/order_service/create_orders.rb +1 -1
- data/examples/{v201405 → v201505}/order_service/get_all_orders.rb +8 -17
- data/examples/{v201405 → v201505}/order_service/get_orders_by_statement.rb +18 -14
- data/examples/{v201405 → v201505}/order_service/update_orders.rb +15 -7
- data/examples/{v201405 → v201505}/placement_service/create_placements.rb +4 -2
- data/examples/{v201405 → v201505}/placement_service/deactivate_placements.rb +14 -22
- data/examples/{v201405 → v201505}/placement_service/get_all_placements.rb +9 -17
- data/examples/{v201405 → v201505}/placement_service/get_placements_by_statement.rb +18 -13
- data/examples/{v201405 → v201505}/placement_service/update_placements.rb +16 -6
- data/examples/{v201405 → v201505}/publisher_query_language_service/fetch_match_tables.rb +8 -11
- data/examples/{v201405 → v201505}/publisher_query_language_service/get_all_line_items.rb +8 -9
- data/examples/{v201405 → v201505}/publisher_query_language_service/get_geo_targets.rb +10 -10
- data/examples/{v201405 → v201505}/publisher_query_language_service/get_line_items_named_like.rb +10 -10
- data/examples/{v201405 → v201505}/report_service/display_report.rb +1 -1
- data/examples/{v201405 → v201505}/report_service/download_report.rb +1 -1
- data/examples/{v201405 → v201505}/report_service/run_delivery_report.rb +6 -5
- data/examples/{v201405 → v201505}/report_service/run_inventory_report.rb +6 -5
- data/examples/{v201405 → v201505}/report_service/run_reach_report.rb +6 -5
- data/examples/{v201405/report_service/run_merged_delivery_report.rb → v201505/report_service/run_report_with_custom_fields.rb} +17 -18
- data/examples/{v201405 → v201505}/report_service/run_sales_report.rb +6 -5
- data/examples/{v201405 → v201505}/suggested_ad_unit_service/approve_all_suggested_ad_units.rb +25 -21
- data/examples/{v201405 → v201505}/suggested_ad_unit_service/get_all_suggested_ad_units.rb +9 -18
- data/examples/{v201405 → v201505}/suggested_ad_unit_service/get_suggested_ad_units_by_statement.rb +24 -21
- data/examples/{v201405 → v201505}/team_service/create_teams.rb +1 -1
- data/examples/{v201405 → v201505}/team_service/get_all_teams.rb +8 -17
- data/examples/{v201405 → v201505}/team_service/get_teams_by_statement.rb +15 -11
- data/examples/{v201405 → v201505}/team_service/update_teams.rb +4 -3
- data/examples/{v201405 → v201505}/user_service/create_users.rb +1 -1
- data/examples/{v201405 → v201505}/user_service/deactivate_users.rb +7 -7
- data/examples/{v201405 → v201505}/user_service/get_all_roles.rb +1 -1
- data/examples/{v201405 → v201505}/user_service/get_all_users.rb +8 -18
- data/examples/{v201405 → v201505}/user_service/get_current_user.rb +1 -1
- data/examples/{v201405 → v201505}/user_service/get_users_by_statement.rb +17 -12
- data/examples/{v201405 → v201505}/user_service/update_users.rb +15 -6
- data/examples/{v201405 → v201505}/user_team_association_service/create_user_team_associations.rb +1 -1
- data/examples/{v201405 → v201505}/user_team_association_service/delete_user_team_associations.rb +13 -21
- data/examples/{v201405 → v201505}/user_team_association_service/get_all_user_team_associations.rb +10 -17
- data/examples/{v201405 → v201505}/user_team_association_service/get_user_team_associations_by_statement.rb +20 -16
- data/examples/{v201405 → v201505}/user_team_association_service/update_user_team_associations.rb +8 -7
- data/lib/dfp_api/api_config.rb +27 -4
- data/lib/dfp_api/v201505/activity_group_service.rb +42 -0
- data/lib/dfp_api/v201505/activity_group_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/activity_service.rb +42 -0
- data/lib/dfp_api/v201505/activity_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/ad_exclusion_rule_service.rb +46 -0
- data/lib/dfp_api/v201505/ad_exclusion_rule_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/ad_rule_service.rb +46 -0
- data/lib/dfp_api/v201505/ad_rule_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/audience_segment_service.rb +46 -0
- data/lib/dfp_api/v201505/audience_segment_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/base_rate_service.rb +46 -0
- data/lib/dfp_api/v201505/base_rate_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/company_service.rb +42 -0
- data/lib/dfp_api/v201505/company_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/contact_service.rb +42 -0
- data/lib/dfp_api/v201505/contact_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/content_bundle_service.rb +46 -0
- data/lib/dfp_api/v201505/content_bundle_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/content_metadata_key_hierarchy_service.rb +46 -0
- data/lib/dfp_api/v201505/content_metadata_key_hierarchy_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/content_service.rb +38 -0
- data/lib/dfp_api/v201505/content_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/creative_service.rb +42 -0
- data/lib/dfp_api/v201505/creative_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/creative_set_service.rb +42 -0
- data/lib/dfp_api/v201505/creative_set_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/creative_template_service.rb +34 -0
- data/lib/dfp_api/v201505/creative_template_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/creative_wrapper_service.rb +46 -0
- data/lib/dfp_api/v201505/creative_wrapper_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/custom_field_service.rb +58 -0
- data/lib/dfp_api/v201505/custom_field_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/custom_targeting_service.rb +62 -0
- data/lib/dfp_api/v201505/custom_targeting_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/exchange_rate_service.rb +46 -0
- data/lib/dfp_api/v201505/exchange_rate_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/forecast_service.rb +46 -0
- data/lib/dfp_api/v201505/forecast_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/inventory_service.rb +50 -0
- data/lib/dfp_api/v201505/inventory_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/label_service.rb +46 -0
- data/lib/dfp_api/v201505/label_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/line_item_creative_association_service.rb +50 -0
- data/lib/dfp_api/v201505/line_item_creative_association_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/line_item_service.rb +46 -0
- data/lib/dfp_api/v201505/line_item_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/line_item_template_service.rb +34 -0
- data/lib/dfp_api/v201505/line_item_template_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/live_stream_event_service.rb +46 -0
- data/lib/dfp_api/v201505/live_stream_event_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/network_service.rb +46 -0
- data/lib/dfp_api/v201505/network_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/order_service.rb +46 -0
- data/lib/dfp_api/v201505/order_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/package_service.rb +46 -0
- data/lib/dfp_api/v201505/package_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/placement_service.rb +46 -0
- data/lib/dfp_api/v201505/placement_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/premium_rate_service.rb +42 -0
- data/lib/dfp_api/v201505/premium_rate_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/product_package_item_service.rb +46 -0
- data/lib/dfp_api/v201505/product_package_item_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/product_package_service.rb +46 -0
- data/lib/dfp_api/v201505/product_package_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/product_service.rb +42 -0
- data/lib/dfp_api/v201505/product_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/product_template_service.rb +46 -0
- data/lib/dfp_api/v201505/product_template_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/proposal_line_item_service.rb +46 -0
- data/lib/dfp_api/v201505/proposal_line_item_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/proposal_service.rb +46 -0
- data/lib/dfp_api/v201505/proposal_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/publisher_query_language_service.rb +34 -0
- data/lib/dfp_api/v201505/publisher_query_language_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/rate_card_service.rb +46 -0
- data/lib/dfp_api/v201505/rate_card_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/reconciliation_order_report_service.rb +38 -0
- data/lib/dfp_api/v201505/reconciliation_order_report_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/reconciliation_report_row_service.rb +38 -0
- data/lib/dfp_api/v201505/reconciliation_report_row_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/reconciliation_report_service.rb +38 -0
- data/lib/dfp_api/v201505/reconciliation_report_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/report_service.rb +46 -0
- data/lib/dfp_api/v201505/report_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/shared_ad_unit_service.rb +38 -0
- data/lib/dfp_api/v201505/shared_ad_unit_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/suggested_ad_unit_service.rb +38 -0
- data/lib/dfp_api/v201505/suggested_ad_unit_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/team_service.rb +42 -0
- data/lib/dfp_api/v201505/team_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/user_service.rb +54 -0
- data/lib/dfp_api/v201505/user_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/user_team_association_service.rb +46 -0
- data/lib/dfp_api/v201505/user_team_association_service_registry.rb +45 -0
- data/lib/dfp_api/v201505/workflow_request_service.rb +38 -0
- data/lib/dfp_api/v201505/workflow_request_service_registry.rb +45 -0
- data/lib/dfp_api/version.rb +1 -1
- data/test/bugs/test_issue_00000016.rb +1 -1
- data/test/dfp_api/test_config.yml +6 -5
- data/test/dfp_api/test_dfp_api.rb +32 -32
- metadata +234 -140
- data/examples/v201405/creative_template_service/get_creative_template.rb +0 -74
- data/examples/v201405/report_service/run_report_with_custom_fields.rb +0 -135
- data/examples/v201405/suggested_ad_unit_service/get_suggested_ad_unit.rb +0 -75
data/examples/{v201405 → v201505}/line_item_creative_association_service/deactivate_licas.rb
RENAMED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
# Tags: InventoryService.performAdUnitAction
|
|
27
27
|
|
|
28
28
|
require 'dfp_api'
|
|
29
|
+
require 'dfp_api_statement'
|
|
29
30
|
|
|
30
|
-
API_VERSION = :
|
|
31
|
-
PAGE_SIZE = 500
|
|
31
|
+
API_VERSION = :v201505
|
|
32
32
|
|
|
33
33
|
def deactivate_licas()
|
|
34
34
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -44,36 +44,25 @@ def deactivate_licas()
|
|
|
44
44
|
# Set the line item to get LICAs by.
|
|
45
45
|
line_item_id = 'INSERT_LINE_ITEM_ID_HERE'.to_i
|
|
46
46
|
|
|
47
|
-
# Create statement
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
:values => [
|
|
47
|
+
# Create statement to select active LICAs for a given line item.
|
|
48
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
49
|
+
'WHERE lineItemId = :line_item_id AND status = :status',
|
|
50
|
+
[
|
|
52
51
|
{:key => 'line_item_id',
|
|
53
52
|
:value => {:value => line_item_id, :xsi_type => 'NumberValue'}},
|
|
54
53
|
{:key => 'status',
|
|
55
54
|
:value => {:value => 'ACTIVE', :xsi_type => 'TextValue'}}
|
|
56
55
|
]
|
|
57
|
-
|
|
56
|
+
)
|
|
58
57
|
|
|
59
|
-
# Define initial values.
|
|
60
|
-
offset = 0
|
|
61
|
-
page = {}
|
|
62
58
|
creative_ids = []
|
|
63
59
|
|
|
64
60
|
begin
|
|
65
|
-
# Create a statement to get one page with current offset.
|
|
66
|
-
statement[:query] = statement_text +
|
|
67
|
-
" LIMIT %d OFFSET %d" % [PAGE_SIZE, offset]
|
|
68
|
-
|
|
69
61
|
# Get LICAs by statement.
|
|
70
|
-
page =
|
|
71
|
-
|
|
62
|
+
page = lica_service.get_line_item_creative_associations_by_statement(
|
|
63
|
+
statement.toStatement())
|
|
72
64
|
|
|
73
65
|
if page[:results]
|
|
74
|
-
# Increase query offset by page size.
|
|
75
|
-
offset += PAGE_SIZE
|
|
76
|
-
|
|
77
66
|
page[:results].each do |lica|
|
|
78
67
|
puts ("%d) LICA with line item ID: %d, creative ID: %d and status: %s" +
|
|
79
68
|
" will be deactivated.") % [creative_ids.size, lica[:line_item_id],
|
|
@@ -81,18 +70,20 @@ def deactivate_licas()
|
|
|
81
70
|
creative_ids << lica[:creative_id]
|
|
82
71
|
end
|
|
83
72
|
end
|
|
84
|
-
|
|
73
|
+
statement.offset += DfpApiStatement::SUGGESTED_PAGE_LIMIT
|
|
74
|
+
end while statement.offset < page[:total_result_set_size]
|
|
85
75
|
|
|
86
76
|
puts "Number of LICAs to be deactivated: %d" % creative_ids.size
|
|
87
77
|
|
|
88
78
|
if !creative_ids.empty?
|
|
89
79
|
# Modify statement for action. Note, the values are still present.
|
|
90
|
-
statement
|
|
91
|
-
creative_ids.join(', ')
|
|
80
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
81
|
+
"WHERE creativeId IN (%s)" % creative_ids.join(', '))
|
|
92
82
|
|
|
93
83
|
# Perform action.
|
|
94
84
|
result = lica_service.perform_line_item_creative_association_action(
|
|
95
|
-
{:xsi_type => 'DeactivateLineItemCreativeAssociations'},
|
|
85
|
+
{:xsi_type => 'DeactivateLineItemCreativeAssociations'},
|
|
86
|
+
statement.toStatement())
|
|
96
87
|
|
|
97
88
|
# Display results.
|
|
98
89
|
if result and result[:num_changes] > 0
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
# Tags: LineItemCreativeAssociationService.getLineItemCreativeAssociationsByStatement
|
|
25
25
|
|
|
26
26
|
require 'dfp_api'
|
|
27
|
+
require 'dfp_api_statement'
|
|
27
28
|
|
|
28
|
-
API_VERSION = :
|
|
29
|
-
PAGE_SIZE = 500
|
|
29
|
+
API_VERSION = :v201505
|
|
30
30
|
|
|
31
31
|
def get_all_licas()
|
|
32
32
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -39,36 +39,27 @@ def get_all_licas()
|
|
|
39
39
|
# Get the LineItemCreativeAssociationService.
|
|
40
40
|
lica_service = dfp.service(:LineItemCreativeAssociationService, API_VERSION)
|
|
41
41
|
|
|
42
|
-
# Define initial values.
|
|
43
|
-
offset = 0
|
|
44
|
-
page = {}
|
|
45
|
-
|
|
46
42
|
begin
|
|
47
43
|
# Create statement for one page with current offset.
|
|
48
|
-
statement =
|
|
44
|
+
statement = DfpApiStatement::FilterStatement.new('ORDER BY lineItemId ASC')
|
|
49
45
|
|
|
50
46
|
# Get LICAs by statement.
|
|
51
|
-
page =
|
|
52
|
-
|
|
47
|
+
page = lica_service.get_line_item_creative_associations_by_statement(
|
|
48
|
+
statement.toStatement())
|
|
53
49
|
|
|
54
50
|
if page[:results]
|
|
55
|
-
# Increase query offset by page size.
|
|
56
|
-
offset += PAGE_SIZE
|
|
57
|
-
|
|
58
|
-
# Get the start index for printout.
|
|
59
|
-
start_index = page[:start_index]
|
|
60
|
-
|
|
61
51
|
# Print details about each LICA in results page.
|
|
62
52
|
page[:results].each_with_index do |lica, index|
|
|
63
53
|
creative_text = (lica[:creative_set_id] != nil) ?
|
|
64
54
|
'creative set ID %d' % lica[:creative_set_id] :
|
|
65
55
|
'creative ID %d' % lica[:creative_id]
|
|
66
56
|
puts '%d) LICA with line item ID: %d, %s and status: %s' %
|
|
67
|
-
[index +
|
|
57
|
+
[index + statement.offset, lica[:line_item_id], creative_text,
|
|
68
58
|
lica[:status]]
|
|
69
59
|
end
|
|
70
60
|
end
|
|
71
|
-
|
|
61
|
+
statement.offset += DfpApiStatement::SUGGESTED_PAGE_LIMIT
|
|
62
|
+
end while statement.offset < page[:total_result_set_size]
|
|
72
63
|
|
|
73
64
|
# Print a footer
|
|
74
65
|
if page.include?(:total_result_set_size)
|
data/examples/{v201405 → v201505}/line_item_creative_association_service/get_licas_by_statement.rb
RENAMED
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
# Tags: LineItemCreativeAssociationService.getLineItemCreativeAssociationsByStatement
|
|
27
27
|
|
|
28
28
|
require 'dfp_api'
|
|
29
|
+
require 'dfp_api_statement'
|
|
29
30
|
|
|
30
|
-
API_VERSION = :
|
|
31
|
+
API_VERSION = :v201505
|
|
31
32
|
|
|
32
33
|
def get_licas_by_statement()
|
|
33
34
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -44,22 +45,23 @@ def get_licas_by_statement()
|
|
|
44
45
|
line_item_id = 'INSERT_LINE_ITEM_ID_HERE'.to_i
|
|
45
46
|
|
|
46
47
|
# Create a statement to only select LICAs for the given line item ID.
|
|
47
|
-
statement =
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
49
|
+
'WHERE lineItemId = :line_item_id ORDER BY lineItemId, orderId ASC',
|
|
50
|
+
[
|
|
50
51
|
{:key => 'line_item_id',
|
|
51
52
|
:value => {:value => line_item_id, :xsi_type => 'NumberValue'}}
|
|
52
53
|
]
|
|
53
|
-
|
|
54
|
+
)
|
|
54
55
|
|
|
55
56
|
# Get LICAs by statement.
|
|
56
|
-
page =
|
|
57
|
-
|
|
57
|
+
page = lica_service.get_line_item_creative_associations_by_statement(
|
|
58
|
+
statement.toStatement())
|
|
58
59
|
|
|
59
60
|
if page and page[:results]
|
|
60
61
|
page[:results].each_with_index do |lica, index|
|
|
61
62
|
puts "%d) LICA with line item ID: %d, creative ID: %d and status: %s." %
|
|
62
|
-
[index
|
|
63
|
+
[index + statement.offset,
|
|
64
|
+
lica[:line_item_id], lica[:creative_id], lica[:status]]
|
|
63
65
|
end
|
|
64
66
|
end
|
|
65
67
|
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example updates the destination URL of all LICAs
|
|
22
|
-
# determine which LICAs exist, run get_all_licas.rb.
|
|
21
|
+
# This example updates the destination URL of all LICAs belonging to a line item.
|
|
22
|
+
# To determine which LICAs exist, run get_all_licas.rb.
|
|
23
23
|
#
|
|
24
24
|
# Tags: LineItemCreativeAssociationService.getLineItemCreativeAssociationsByStatement
|
|
25
25
|
# Tags: LineItemCreativeAssociationService.updateLineItemCreativeAssociations
|
|
26
26
|
|
|
27
27
|
require 'dfp_api'
|
|
28
28
|
|
|
29
|
-
API_VERSION = :
|
|
29
|
+
API_VERSION = :v201505
|
|
30
30
|
|
|
31
31
|
def update_licas()
|
|
32
32
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -39,12 +39,21 @@ def update_licas()
|
|
|
39
39
|
# Get the LineItemCreativeAssociationService.
|
|
40
40
|
lica_service = dfp.service(:LineItemCreativeAssociationService, API_VERSION)
|
|
41
41
|
|
|
42
|
-
#
|
|
43
|
-
|
|
42
|
+
# Set the line item to get LICAs by.
|
|
43
|
+
line_item_id = 'INSERT_LINE_ITEM_ID_HERE'.to_i
|
|
44
|
+
|
|
45
|
+
# Create a statement to only select LICAs for the given line item ID.
|
|
46
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
47
|
+
'WHERE lineItemId = :line_item_id ORDER BY lineItemId, creativeId ASC',
|
|
48
|
+
[
|
|
49
|
+
{:key => 'line_item_id',
|
|
50
|
+
:value => {:value => line_item_id, :xsi_type => 'NumberValue'}}
|
|
51
|
+
]
|
|
52
|
+
)
|
|
44
53
|
|
|
45
54
|
# Get LICAs by statement.
|
|
46
|
-
page =
|
|
47
|
-
|
|
55
|
+
page = lica_service.get_line_item_creative_associations_by_statement(
|
|
56
|
+
statement.toStatement())
|
|
48
57
|
|
|
49
58
|
if page[:results]
|
|
50
59
|
licas = page[:results]
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
# Tags: LineItemService.performLineItemAction
|
|
30
30
|
|
|
31
31
|
require 'dfp_api'
|
|
32
|
+
require 'dfp_api_statement'
|
|
32
33
|
|
|
33
|
-
API_VERSION = :
|
|
34
|
-
PAGE_SIZE = 500
|
|
34
|
+
API_VERSION = :v201505
|
|
35
35
|
|
|
36
36
|
def activate_line_items()
|
|
37
37
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -49,33 +49,24 @@ def activate_line_items()
|
|
|
49
49
|
|
|
50
50
|
# Create a statement to only select line items from the specified order that
|
|
51
51
|
# are in the approved (needs creatives) state.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
53
|
+
'WHERE orderID = :order_id AND status = :status',
|
|
54
|
+
[
|
|
55
55
|
{:key => 'order_id',
|
|
56
56
|
:value => {:value => order_id, :xsi_type => 'NumberValue'}},
|
|
57
57
|
{:key => 'status',
|
|
58
58
|
:value => {:value => 'NEEDS_CREATIVES', :xsi_type => 'TextValue'}}
|
|
59
59
|
]
|
|
60
|
-
|
|
60
|
+
)
|
|
61
61
|
|
|
62
|
-
# Define initial values.
|
|
63
|
-
offset = 0
|
|
64
|
-
page = {}
|
|
65
62
|
line_item_ids = []
|
|
66
63
|
|
|
67
64
|
begin
|
|
68
|
-
# Create a statement to get one page with current offset.
|
|
69
|
-
statement[:query] = statement_text +
|
|
70
|
-
" LIMIT %d OFFSET %d" % [PAGE_SIZE, offset]
|
|
71
|
-
|
|
72
65
|
# Get line items by statement.
|
|
73
|
-
page = line_item_service.get_line_items_by_statement(
|
|
66
|
+
page = line_item_service.get_line_items_by_statement(
|
|
67
|
+
statement.toStatement())
|
|
74
68
|
|
|
75
69
|
if page[:results]
|
|
76
|
-
# Increase query offset by page size.
|
|
77
|
-
offset += PAGE_SIZE
|
|
78
|
-
|
|
79
70
|
page[:results].each do |line_item|
|
|
80
71
|
if !line_item[:is_archived]
|
|
81
72
|
puts ("%d) Line item with ID: %d, order ID: %d and name: %s will " +
|
|
@@ -85,18 +76,19 @@ def activate_line_items()
|
|
|
85
76
|
end
|
|
86
77
|
end
|
|
87
78
|
end
|
|
88
|
-
|
|
79
|
+
statement.offset += DfpApiStatement::SUGGESTED_PAGE_LIMIT
|
|
80
|
+
end while statement.offset < page[:total_result_set_size]
|
|
89
81
|
|
|
90
82
|
puts "Number of line items to be activated: %d" % line_item_ids.size
|
|
91
83
|
|
|
92
84
|
if !line_item_ids.empty?
|
|
93
85
|
# Modify statement for action. Note, the values are still present.
|
|
94
|
-
statement
|
|
95
|
-
line_item_ids.join(', ')
|
|
86
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
87
|
+
"WHERE id IN (%s)" % line_item_ids.join(', '))
|
|
96
88
|
|
|
97
89
|
# Perform action.
|
|
98
90
|
result = line_item_service.perform_line_item_action(
|
|
99
|
-
{:xsi_type => 'ActivateLineItems'}, statement)
|
|
91
|
+
{:xsi_type => 'ActivateLineItems'}, statement.toStatement())
|
|
100
92
|
|
|
101
93
|
# Display results.
|
|
102
94
|
if result and result[:num_changes] > 0
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
require 'dfp_api'
|
|
31
31
|
|
|
32
|
-
API_VERSION = :
|
|
32
|
+
API_VERSION = :v201505
|
|
33
33
|
# Number of line items to create.
|
|
34
34
|
ITEM_COUNT = 5
|
|
35
35
|
|
|
@@ -125,7 +125,13 @@ def create_line_items()
|
|
|
125
125
|
|
|
126
126
|
# Set the length of the line item to run.
|
|
127
127
|
line_item[:start_date_time_type] = 'IMMEDIATELY'
|
|
128
|
-
line_item[:end_date_time] =
|
|
128
|
+
line_item[:end_date_time] = {:date => {:year => Time.now.year + 1,
|
|
129
|
+
:month => 9,
|
|
130
|
+
:day => 30},
|
|
131
|
+
:hour => 0,
|
|
132
|
+
:minute => 0,
|
|
133
|
+
:second => 0,
|
|
134
|
+
:time_zone_id => 'America/Los_Angeles'}
|
|
129
135
|
|
|
130
136
|
# Set the cost per unit to $2.
|
|
131
137
|
line_item[:cost_type] = 'CPM'
|
|
@@ -135,9 +141,10 @@ def create_line_items()
|
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
# Set the number of units bought to 500,000 so that the budget is $1,000.
|
|
138
|
-
line_item[:primary_goal] = {
|
|
144
|
+
line_item[:primary_goal] = {
|
|
139
145
|
:units => '500000',
|
|
140
|
-
:unit_type => 'IMPRESSIONS'
|
|
146
|
+
:unit_type => 'IMPRESSIONS',
|
|
147
|
+
:goal_type => 'LIFETIME'
|
|
141
148
|
}
|
|
142
149
|
|
|
143
150
|
line_item
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
require 'dfp_api'
|
|
32
32
|
|
|
33
|
-
API_VERSION = :
|
|
33
|
+
API_VERSION = :v201505
|
|
34
34
|
|
|
35
35
|
def create_video_line_item()
|
|
36
36
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -103,12 +103,22 @@ def create_video_line_item()
|
|
|
103
103
|
:companion_delivery_option => 'OPTIONAL',
|
|
104
104
|
# Set the length of the line item to run.
|
|
105
105
|
:start_date_time_type => 'IMMEDIATELY',
|
|
106
|
-
:end_date_time => Time.
|
|
106
|
+
line_item[:end_date_time] = {:date => {:year => Time.now.year + 1,
|
|
107
|
+
:month => 9,
|
|
108
|
+
:day => 30},
|
|
109
|
+
:hour => 0,
|
|
110
|
+
:minute => 0,
|
|
111
|
+
:second => 0,
|
|
112
|
+
:time_zone_id => 'America/Los_Angeles'}
|
|
107
113
|
# Set the cost per day to $1.
|
|
108
114
|
:cost_type => 'CPD',
|
|
109
115
|
:cost_per_unit => {:currency_code => 'USD', :micro_amount => 1000000},
|
|
110
116
|
# Set the percentage to be 100%.
|
|
111
|
-
:primary_goal => {
|
|
117
|
+
:primary_goal => {
|
|
118
|
+
:units => '100',
|
|
119
|
+
:unit_type => 'IMPRESSIONS',
|
|
120
|
+
:goal_type => 'DAILY'
|
|
121
|
+
}
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
# Create the master creative placeholder and companion creative placeholders.
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
# Tags: LineItemService.getLineItemsByStatement
|
|
25
25
|
|
|
26
26
|
require 'dfp_api'
|
|
27
|
+
require 'dfp_api_statement'
|
|
27
28
|
|
|
28
|
-
API_VERSION = :
|
|
29
|
-
PAGE_SIZE = 500
|
|
29
|
+
API_VERSION = :v201505
|
|
30
30
|
|
|
31
31
|
def get_all_line_items()
|
|
32
32
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -39,32 +39,24 @@ def get_all_line_items()
|
|
|
39
39
|
# Get the LineItemService.
|
|
40
40
|
line_item_service = dfp.service(:LineItemService, API_VERSION)
|
|
41
41
|
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
page = {}
|
|
42
|
+
# Create a statement to get one page with current offset.
|
|
43
|
+
statement = DfpApiStatement::FilterStatement.new('ORDER BY id ASC')
|
|
45
44
|
|
|
46
45
|
begin
|
|
47
|
-
# Create a statement to get one page with current offset.
|
|
48
|
-
statement = {:query => "LIMIT %d OFFSET %d" % [PAGE_SIZE, offset]}
|
|
49
|
-
|
|
50
46
|
# Get line items by statement.
|
|
51
|
-
page = line_item_service.get_line_items_by_statement(
|
|
47
|
+
page = line_item_service.get_line_items_by_statement(
|
|
48
|
+
statement.toStatement())
|
|
52
49
|
|
|
53
50
|
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
51
|
# Print details about each line item in results.
|
|
61
52
|
page[:results].each_with_index do |line_item, index|
|
|
62
53
|
puts "%d) Line item ID: %d, order ID: %d, name: %s" %
|
|
63
|
-
[index +
|
|
54
|
+
[index + statement.offset, line_item[:id],
|
|
64
55
|
line_item[:order_id], line_item[:name]]
|
|
65
56
|
end
|
|
66
57
|
end
|
|
67
|
-
|
|
58
|
+
statement.offset += DfpApiStatement::SUGGESTED_PAGE_LIMIT
|
|
59
|
+
end while statement.offset < page[:total_result_set_size]
|
|
68
60
|
|
|
69
61
|
# Print a footer.
|
|
70
62
|
if page.include?(:total_result_set_size)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# Encoding: utf-8
|
|
3
3
|
#
|
|
4
|
-
# Author:: api.
|
|
4
|
+
# Author:: api.nicholaschen@gmail.com (Nicholas Chen)
|
|
5
5
|
#
|
|
6
|
-
# Copyright:: Copyright
|
|
6
|
+
# Copyright:: Copyright 2014, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example gets all line items
|
|
22
|
-
# statement retrieves up to the maximum page size limit of 500. To create line
|
|
21
|
+
# This example gets all line items for a given order. To create line
|
|
23
22
|
# items, run create_line_items.rb. To determine which orders exist, run
|
|
24
23
|
# get_all_orders.rb.
|
|
25
24
|
#
|
|
26
25
|
# Tags: LineItemService.getLineItemsByStatement
|
|
27
26
|
|
|
28
27
|
require 'dfp_api'
|
|
28
|
+
require 'dfp_api_statement'
|
|
29
29
|
|
|
30
|
-
API_VERSION = :
|
|
30
|
+
API_VERSION = :v201505
|
|
31
31
|
|
|
32
32
|
def get_line_items_by_statement()
|
|
33
33
|
# Get DfpApi instance and load configuration from ~/dfp_api.yml.
|
|
@@ -43,26 +43,28 @@ def get_line_items_by_statement()
|
|
|
43
43
|
# Set the ID of the order to get line items from.
|
|
44
44
|
order_id = 'INSERT_ORDER_ID_HERE'.to_i
|
|
45
45
|
|
|
46
|
-
# Create a statement to only select line items
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
:values => [
|
|
46
|
+
# Create a statement to only select line items from a given order.
|
|
47
|
+
statement = DfpApiStatement::FilterStatement.new(
|
|
48
|
+
'WHERE orderId = :order_id ORDER BY id ASC',
|
|
49
|
+
[
|
|
51
50
|
{:key => 'order_id',
|
|
52
|
-
:value => {:value => order_id, :xsi_type => 'NumberValue'}}
|
|
53
|
-
{:key => 'status',
|
|
54
|
-
:value => {:value => 'NEEDS_CREATIVES', :xsi_type => 'TextValue'}}
|
|
51
|
+
:value => {:value => order_id, :xsi_type => 'NumberValue'}}
|
|
55
52
|
]
|
|
56
|
-
|
|
53
|
+
)
|
|
54
|
+
|
|
57
55
|
|
|
58
56
|
# Get line items by statement.
|
|
59
|
-
page = line_item_service.get_line_items_by_statement(statement)
|
|
57
|
+
page = line_item_service.get_line_items_by_statement(statement.toStatement())
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
while page and page[:results] do
|
|
62
60
|
page[:results].each_with_index do |line_item, index|
|
|
63
|
-
puts "%d) [%d] belongs to order ID %d, name: %s." % [
|
|
61
|
+
puts "%d) [%d] belongs to order ID %d, name: %s." % [
|
|
62
|
+
index + statement.offset,
|
|
64
63
|
line_item[:id], line_item[:order_id], line_item[:name]]
|
|
65
64
|
end
|
|
65
|
+
statement.offset += DfpApiStatement::SUGGESTED_PAGE_LIMIT
|
|
66
|
+
page = line_item_service.get_line_items_by_statement(
|
|
67
|
+
statement.toStatement())
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
# Print a footer.
|