google-adwords-api 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/README +3 -3
- data/examples/v201206/basic_operations/add_campaigns.rb +7 -2
- data/examples/v201209/account_management/create_account.rb +84 -0
- data/examples/v201209/account_management/get_account_alerts.rb +111 -0
- data/examples/v201209/account_management/get_account_changes.rb +137 -0
- data/examples/v201209/account_management/get_account_hierarchy.rb +92 -0
- data/examples/v201209/account_management/get_client_customer_id.rb +85 -0
- data/examples/v201209/account_management/get_client_unit_usage.rb +87 -0
- data/examples/v201209/basic_operations/add_ad_groups.rb +136 -0
- data/examples/v201209/basic_operations/add_campaigns.rb +159 -0
- data/examples/v201209/basic_operations/add_keywords.rb +108 -0
- data/examples/v201209/basic_operations/add_text_ads.rb +105 -0
- data/examples/v201209/basic_operations/delete_ad.rb +85 -0
- data/examples/v201209/basic_operations/delete_ad_group.rb +102 -0
- data/examples/v201209/basic_operations/delete_campaign.rb +103 -0
- data/examples/v201209/basic_operations/delete_keyword.rb +90 -0
- data/examples/v201209/basic_operations/get_ad_groups.rb +98 -0
- data/examples/v201209/basic_operations/get_campaigns.rb +93 -0
- data/examples/v201209/basic_operations/get_campaigns_with_awql.rb +85 -0
- data/examples/v201209/basic_operations/get_keywords.rb +104 -0
- data/examples/v201209/basic_operations/get_text_ads.rb +106 -0
- data/examples/v201209/basic_operations/pause_ad.rb +84 -0
- data/examples/v201209/basic_operations/update_ad_group.rb +81 -0
- data/examples/v201209/basic_operations/update_campaign.rb +82 -0
- data/examples/v201209/basic_operations/update_keyword.rb +99 -0
- data/examples/v201209/campaign_management/add_experiment.rb +158 -0
- data/examples/v201209/campaign_management/add_keywords_in_bulk.rb +150 -0
- data/examples/v201209/campaign_management/add_location_extension.rb +117 -0
- data/examples/v201209/campaign_management/add_location_extension_override.rb +83 -0
- data/examples/v201209/campaign_management/get_all_disapproved_ads.rb +93 -0
- data/examples/v201209/campaign_management/get_all_disapproved_ads_with_awql.rb +84 -0
- data/examples/v201209/campaign_management/promote_experiment.rb +77 -0
- data/examples/v201209/campaign_management/set_ad_parameters.rb +114 -0
- data/examples/v201209/campaign_management/validate_text_ad.rb +106 -0
- data/examples/v201209/error_handling/handle_captcha_challenge.rb +93 -0
- data/examples/v201209/error_handling/handle_partial_failures.rb +126 -0
- data/examples/v201209/error_handling/handle_policy_violation_error.rb +137 -0
- data/examples/v201209/error_handling/handle_two_factor_authorization_error.rb +87 -0
- data/examples/v201209/misc/get_all_images_and_videos.rb +100 -0
- data/examples/v201209/misc/upload_image.rb +89 -0
- data/examples/v201209/misc/use_oauth.rb +100 -0
- data/examples/v201209/misc/use_oauth2.rb +97 -0
- data/examples/v201209/optimization/estimate_keyword_traffic.rb +129 -0
- data/examples/v201209/optimization/get_keyword_bid_simulations.rb +92 -0
- data/examples/v201209/optimization/get_keyword_ideas.rb +114 -0
- data/examples/v201209/optimization/get_placement_ideas.rb +104 -0
- data/examples/v201209/remarketing/add_audience.rb +115 -0
- data/examples/v201209/remarketing/add_conversion_tracker.rb +97 -0
- data/examples/v201209/reporting/download_criteria_report.rb +79 -0
- data/examples/v201209/reporting/download_criteria_report_with_awql.rb +78 -0
- data/examples/v201209/reporting/get_campaign_stats.rb +105 -0
- data/examples/v201209/reporting/get_report_fields.rb +71 -0
- data/examples/v201209/reporting/parallel_report_download.rb +160 -0
- data/examples/v201209/targeting/add_campaign_targeting_criteria.rb +118 -0
- data/examples/v201209/targeting/add_demographic_targeting_criteria.rb +108 -0
- data/examples/v201209/targeting/get_campaign_targeting_criteria.rb +102 -0
- data/examples/v201209/targeting/get_targetable_languages_and_carriers.rb +86 -0
- data/examples/v201209/targeting/lookup_location.rb +104 -0
- data/lib/adwords_api/api_config.rb +64 -5
- data/lib/adwords_api/errors.rb +15 -0
- data/lib/adwords_api/report_utils.rb +30 -11
- data/lib/adwords_api/v201209/ad_extension_override_service.rb +38 -0
- data/lib/adwords_api/v201209/ad_extension_override_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/ad_group_ad_service.rb +42 -0
- data/lib/adwords_api/v201209/ad_group_ad_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/ad_group_criterion_service.rb +42 -0
- data/lib/adwords_api/v201209/ad_group_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/ad_group_service.rb +42 -0
- data/lib/adwords_api/v201209/ad_group_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/ad_param_service.rb +38 -0
- data/lib/adwords_api/v201209/ad_param_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/alert_service.rb +34 -0
- data/lib/adwords_api/v201209/alert_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/budget_order_service.rb +42 -0
- data/lib/adwords_api/v201209/budget_order_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/budget_service.rb +38 -0
- data/lib/adwords_api/v201209/budget_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/campaign_ad_extension_service.rb +38 -0
- data/lib/adwords_api/v201209/campaign_ad_extension_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/campaign_criterion_service.rb +42 -0
- data/lib/adwords_api/v201209/campaign_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/campaign_service.rb +42 -0
- data/lib/adwords_api/v201209/campaign_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/constant_data_service.rb +62 -0
- data/lib/adwords_api/v201209/constant_data_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/conversion_tracker_service.rb +38 -0
- data/lib/adwords_api/v201209/conversion_tracker_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/customer_service.rb +34 -0
- data/lib/adwords_api/v201209/customer_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/customer_sync_service.rb +34 -0
- data/lib/adwords_api/v201209/customer_sync_service_registry.rb +47 -0
- data/lib/adwords_api/v201209/data_service.rb +38 -0
- data/lib/adwords_api/v201209/data_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/experiment_service.rb +38 -0
- data/lib/adwords_api/v201209/experiment_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/geo_location_service.rb +34 -0
- data/lib/adwords_api/v201209/geo_location_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/info_service.rb +34 -0
- data/lib/adwords_api/v201209/info_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/location_criterion_service.rb +34 -0
- data/lib/adwords_api/v201209/location_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/managed_customer_service.rb +38 -0
- data/lib/adwords_api/v201209/managed_customer_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/media_service.rb +38 -0
- data/lib/adwords_api/v201209/media_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/mutate_job_service.rb +42 -0
- data/lib/adwords_api/v201209/mutate_job_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/report_definition_service.rb +34 -0
- data/lib/adwords_api/v201209/report_definition_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/targeting_idea_service.rb +38 -0
- data/lib/adwords_api/v201209/targeting_idea_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/traffic_estimator_service.rb +34 -0
- data/lib/adwords_api/v201209/traffic_estimator_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/user_list_service.rb +38 -0
- data/lib/adwords_api/v201209/user_list_service_registry.rb +46 -0
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_report_utils.rb +94 -6
- data/test/examples/v201209/test_account_management.rb +60 -0
- data/test/examples/v201209/test_basic_operations.rb +177 -0
- data/test/examples/v201209/test_campaign_management.rb +124 -0
- data/test/examples/v201209/test_error_handling.rb +63 -0
- data/test/examples/v201209/test_misc.rb +45 -0
- data/test/examples/v201209/test_optimization.rb +63 -0
- data/test/examples/v201209/test_remarketing.rb +39 -0
- data/test/examples/v201209/test_reporting.rb +84 -0
- data/test/examples/v201209/test_targeting.rb +60 -0
- data/test/examples/v201209/utils.rb +238 -0
- data/test/suite_exampletests_v201209.rb +37 -0
- metadata +123 -2
@@ -0,0 +1,38 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
#
|
3
|
+
# This is auto-generated code, changes will be overwritten.
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
6
|
+
# License:: Licensed under the Apache License, Version 2.0.
|
7
|
+
#
|
8
|
+
# Code generated by AdsCommon library 0.8.0 on 2012-10-05 12:16:35.
|
9
|
+
|
10
|
+
require 'ads_common/savon_service'
|
11
|
+
require 'adwords_api/v201209/user_list_service_registry'
|
12
|
+
|
13
|
+
module AdwordsApi; module V201209; module UserListService
|
14
|
+
class UserListService < AdsCommon::SavonService
|
15
|
+
def initialize(config, endpoint)
|
16
|
+
namespace = 'https://adwords.google.com/api/adwords/cm/v201209'
|
17
|
+
super(config, endpoint, namespace, :v201209)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(*args, &block)
|
21
|
+
return execute_action('get', args, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def mutate(*args, &block)
|
25
|
+
return execute_action('mutate', args, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def get_service_registry()
|
31
|
+
return UserListServiceRegistry
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_module()
|
35
|
+
return AdwordsApi::V201209::UserListService
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end; end; end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
#
|
3
|
+
# This is auto-generated code, changes will be overwritten.
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
6
|
+
# License:: Licensed under the Apache License, Version 2.0.
|
7
|
+
#
|
8
|
+
# Code generated by AdsCommon library 0.8.0 on 2012-10-05 12:16:35.
|
9
|
+
|
10
|
+
require 'adwords_api/errors'
|
11
|
+
|
12
|
+
module AdwordsApi; module V201209; module UserListService
|
13
|
+
class UserListServiceRegistry
|
14
|
+
USERLISTSERVICE_METHODS = {:get=>{:input=>[{:name=>:service_selector, :type=>"Selector", :min_occurs=>0, :max_occurs=>1}], :output=>{:name=>"get_response", :fields=>[{:name=>:rval, :type=>"UserListPage", :min_occurs=>0, :max_occurs=>1}]}}, :mutate=>{:input=>[{:name=>:operations, :type=>"UserListOperation", :min_occurs=>0, :max_occurs=>:unbounded}], :output=>{:name=>"mutate_response", :fields=>[{:name=>:rval, :type=>"UserListReturnValue", :min_occurs=>0, :max_occurs=>1}]}}}
|
15
|
+
USERLISTSERVICE_TYPES = {:ApiError=>{:fields=>[{:name=>:field_path, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:trigger, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:error_string, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:api_error_type, :type=>"string", :min_occurs=>0, :max_occurs=>1}], :abstract=>true}, :ApiException=>{:fields=>[{:name=>:errors, :type=>"ApiError", :min_occurs=>0, :max_occurs=>:unbounded}], :base=>"ApplicationException"}, :ApplicationException=>{:fields=>[{:name=>:message, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:application_exception_type, :type=>"string", :min_occurs=>0, :max_occurs=>1}]}, :AuthenticationError=>{:fields=>[{:name=>:reason, :type=>"AuthenticationError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :AuthorizationError=>{:fields=>[{:name=>:reason, :type=>"AuthorizationError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :ExternalRemarketingUserList=>{:fields=>[], :base=>"UserList"}, :ClientTermsError=>{:fields=>[{:name=>:reason, :type=>"ClientTermsError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :UserListConversionType=>{:fields=>[{:name=>:id, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:name, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:category, :type=>"UserListConversionType.Category", :min_occurs=>0, :max_occurs=>1}]}, :DatabaseError=>{:fields=>[{:name=>:reason, :type=>"DatabaseError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :DateRange=>{:fields=>[{:name=>:min, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:max, :type=>"string", :min_occurs=>0, :max_occurs=>1}]}, :DistinctError=>{:fields=>[{:name=>:reason, :type=>"DistinctError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :InternalApiError=>{:fields=>[{:name=>:reason, :type=>"InternalApiError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :ListReturnValue=>{:fields=>[{:name=>:list_return_value_type, :type=>"string", :min_occurs=>0, :max_occurs=>1}], :abstract=>true}, :LogicalUserList=>{:fields=>[{:name=>:rules, :type=>"UserListLogicalRule", :min_occurs=>0, :max_occurs=>:unbounded}], :base=>"UserList"}, :LogicalUserListOperand=>{:fields=>[], :choices=>[{:name=>:user_interest, :type=>"UserInterest", :min_occurs=>1, :max_occurs=>1}, {:name=>:user_list, :type=>"UserList", :min_occurs=>1, :max_occurs=>1}]}, :NotEmptyError=>{:fields=>[{:name=>:reason, :type=>"NotEmptyError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :NotWhitelistedError=>{:fields=>[{:name=>:reason, :type=>"NotWhitelistedError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :Operation=>{:fields=>[{:name=>:operator, :type=>"Operator", :min_occurs=>0, :max_occurs=>1}, {:name=>:operation_type, :type=>"string", :min_occurs=>0, :max_occurs=>1}], :abstract=>true}, :OperationAccessDenied=>{:fields=>[{:name=>:reason, :type=>"OperationAccessDenied.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :OrderBy=>{:fields=>[{:name=>:field, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:sort_order, :type=>"SortOrder", :min_occurs=>0, :max_occurs=>1}]}, :Page=>{:fields=>[{:name=>:total_num_entries, :type=>"int", :min_occurs=>0, :max_occurs=>1}, {:name=>:page_type, :type=>"string", :min_occurs=>0, :max_occurs=>1}], :abstract=>true}, :Paging=>{:fields=>[{:name=>:start_index, :type=>"int", :min_occurs=>0, :max_occurs=>1}, {:name=>:number_results, :type=>"int", :min_occurs=>0, :max_occurs=>1}]}, :Predicate=>{:fields=>[{:name=>:field, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:operator, :type=>"Predicate.Operator", :min_occurs=>0, :max_occurs=>1}, {:name=>:values, :type=>"string", :min_occurs=>0, :max_occurs=>:unbounded}]}, :QuotaCheckError=>{:fields=>[{:name=>:reason, :type=>"QuotaCheckError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :RangeError=>{:fields=>[{:name=>:reason, :type=>"RangeError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :RateExceededError=>{:fields=>[{:name=>:reason, :type=>"RateExceededError.Reason", :min_occurs=>0, :max_occurs=>1}, {:name=>:rate_name, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:rate_scope, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:retry_after_seconds, :type=>"int", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :ReadOnlyError=>{:fields=>[{:name=>:reason, :type=>"ReadOnlyError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :RemarketingUserList=>{:fields=>[{:name=>:conversion_types, :type=>"UserListConversionType", :min_occurs=>0, :max_occurs=>:unbounded}], :base=>"UserList"}, :RequestError=>{:fields=>[{:name=>:reason, :type=>"RequestError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :RequiredError=>{:fields=>[{:name=>:reason, :type=>"RequiredError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :Selector=>{:fields=>[{:name=>:fields, :type=>"string", :min_occurs=>0, :max_occurs=>:unbounded}, {:name=>:predicates, :type=>"Predicate", :min_occurs=>0, :max_occurs=>:unbounded}, {:name=>:date_range, :type=>"DateRange", :min_occurs=>0, :max_occurs=>1}, {:name=>:ordering, :type=>"OrderBy", :min_occurs=>0, :max_occurs=>:unbounded}, {:name=>:paging, :type=>"Paging", :min_occurs=>0, :max_occurs=>1}]}, :SelectorError=>{:fields=>[{:name=>:reason, :type=>"SelectorError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :SizeLimitError=>{:fields=>[{:name=>:reason, :type=>"SizeLimitError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :SoapHeader=>{:fields=>[{:name=>:auth_token, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:client_customer_id, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:developer_token, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:user_agent, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:validate_only, :type=>"boolean", :min_occurs=>0, :max_occurs=>1}, {:name=>:partial_failure, :type=>"boolean", :min_occurs=>0, :max_occurs=>1}]}, :SoapResponseHeader=>{:fields=>[{:name=>:request_id, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:service_name, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:method_name, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:operations, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:response_time, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:units, :type=>"long", :min_occurs=>0, :max_occurs=>1}]}, :UserInterest=>{:fields=>[{:name=>:id, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:name, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:size_range, :type=>"SizeRange", :min_occurs=>0, :max_occurs=>1}]}, :UserList=>{:fields=>[{:name=>:id, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:is_read_only, :type=>"boolean", :min_occurs=>0, :max_occurs=>1}, {:name=>:name, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:description, :type=>"string", :min_occurs=>0, :max_occurs=>1}, {:name=>:status, :type=>"UserListMembershipStatus", :min_occurs=>0, :max_occurs=>1}, {:name=>:access_reason, :type=>"AccessReason", :min_occurs=>0, :max_occurs=>1}, {:name=>:account_user_list_status, :type=>"AccountUserListStatus", :min_occurs=>0, :max_occurs=>1}, {:name=>:membership_life_span, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:size, :type=>"long", :min_occurs=>0, :max_occurs=>1}, {:name=>:size_range, :type=>"SizeRange", :min_occurs=>0, :max_occurs=>1}, {:name=>:type, :type=>"UserList.Type", :min_occurs=>0, :max_occurs=>1}, {:name=>:user_list_type, :type=>"string", :min_occurs=>0, :max_occurs=>1}]}, :UserListError=>{:fields=>[{:name=>:reason, :type=>"UserListError.Reason", :min_occurs=>0, :max_occurs=>1}], :base=>"ApiError"}, :UserListLogicalRule=>{:fields=>[{:name=>:operator, :type=>"UserListLogicalRule.Operator", :min_occurs=>0, :max_occurs=>1}, {:name=>:rule_operands, :type=>"LogicalUserListOperand", :min_occurs=>0, :max_occurs=>:unbounded}]}, :UserListOperation=>{:fields=>[{:name=>:operand, :type=>"UserList", :min_occurs=>0, :max_occurs=>1}], :base=>"Operation"}, :UserListPage=>{:fields=>[{:name=>:entries, :type=>"UserList", :min_occurs=>0, :max_occurs=>:unbounded}], :base=>"Page"}, :UserListReturnValue=>{:fields=>[{:name=>:value, :type=>"UserList", :min_occurs=>0, :max_occurs=>:unbounded}], :base=>"ListReturnValue"}, :AccessReason=>{:fields=>[]}, :AccountUserListStatus=>{:fields=>[]}, :"AuthenticationError.Reason"=>{:fields=>[]}, :"AuthorizationError.Reason"=>{:fields=>[]}, :"ClientTermsError.Reason"=>{:fields=>[]}, :"UserListConversionType.Category"=>{:fields=>[]}, :"DatabaseError.Reason"=>{:fields=>[]}, :"DistinctError.Reason"=>{:fields=>[]}, :"InternalApiError.Reason"=>{:fields=>[]}, :"NotEmptyError.Reason"=>{:fields=>[]}, :"NotWhitelistedError.Reason"=>{:fields=>[]}, :"OperationAccessDenied.Reason"=>{:fields=>[]}, :Operator=>{:fields=>[]}, :"Predicate.Operator"=>{:fields=>[]}, :"QuotaCheckError.Reason"=>{:fields=>[]}, :"RangeError.Reason"=>{:fields=>[]}, :"RateExceededError.Reason"=>{:fields=>[]}, :"ReadOnlyError.Reason"=>{:fields=>[]}, :"RequestError.Reason"=>{:fields=>[]}, :"RequiredError.Reason"=>{:fields=>[]}, :"SelectorError.Reason"=>{:fields=>[]}, :"SizeLimitError.Reason"=>{:fields=>[]}, :SizeRange=>{:fields=>[]}, :SortOrder=>{:fields=>[]}, :"UserList.Type"=>{:fields=>[]}, :"UserListError.Reason"=>{:fields=>[]}, :"UserListLogicalRule.Operator"=>{:fields=>[]}, :UserListMembershipStatus=>{:fields=>[]}}
|
16
|
+
USERLISTSERVICE_NAMESPACES = []
|
17
|
+
|
18
|
+
def self.get_method_signature(method_name)
|
19
|
+
return USERLISTSERVICE_METHODS[method_name.to_sym]
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_type_signature(type_name)
|
23
|
+
return USERLISTSERVICE_TYPES[type_name.to_sym]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_namespace(index)
|
27
|
+
return USERLISTSERVICE_NAMESPACES[index]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Base class for exceptions.
|
32
|
+
class ApplicationException < AdwordsApi::Errors::ApiException
|
33
|
+
attr_reader :message # string
|
34
|
+
attr_reader :application_exception_type # string
|
35
|
+
end
|
36
|
+
|
37
|
+
# Exception class for holding a list of service errors.
|
38
|
+
class ApiException < ApplicationException
|
39
|
+
attr_reader :errors # ApiError
|
40
|
+
def initialize(exception_fault)
|
41
|
+
@array_fields ||= []
|
42
|
+
@array_fields << 'errors'
|
43
|
+
super(exception_fault, UserListServiceRegistry)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end; end; end
|
data/lib/adwords_api/version.rb
CHANGED
@@ -30,6 +30,8 @@ API_VERSION = :v201206
|
|
30
30
|
module AdwordsApi
|
31
31
|
class ReportUtils
|
32
32
|
public :check_for_errors
|
33
|
+
public :check_for_legacy_error
|
34
|
+
public :check_for_xml_error
|
33
35
|
public :add_report_definition_hash_order
|
34
36
|
end
|
35
37
|
end
|
@@ -52,6 +54,13 @@ REPLY_TYPES = [
|
|
52
54
|
:message => "ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT @ ; trigger:'bCampaignId'"}
|
53
55
|
]
|
54
56
|
|
57
|
+
XML_REPLY = {
|
58
|
+
:reply => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT</type><trigger>foo</trigger><fieldPath>bar</fieldPath></ApiError></reportDownloadError>',
|
59
|
+
:type => 'ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT',
|
60
|
+
:trigger => 'foo',
|
61
|
+
:field_path => 'bar'
|
62
|
+
}
|
63
|
+
|
55
64
|
VALID_REPORT = '"Custom ADGROUP_PERFORMANCE_REPORT (Oct 20, 2011-Oct 26, 2011)"\nCampaign ID,Ad group ID,Impressions,Clicks,Cost\nTotal, --,0,0,0.00'
|
56
65
|
GZIPPED_REPORT = "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x00Sr.-.\xC9\xCFUptq\x0F\xF2\x0F\r\x88\x0Fp\rr\xF3\x0F\xF2u\xF4sv\x8D\x0Fr\r\xF0\x0F\nQ\xD0pIMV0\xD2Q0204\xD4\x05\xB1- lM%.\xE7\xC4\xDC\x82\xC4\xCC\xF4<\x05O\x17\x1D\xC7\x14\x85\xF4\xA2\xFC\xD2\x02\x10\xDB3\xB7\xA0(\xB5\xB883?\xAFX\xC79'39\eH\xE5\x17\x97p\x85\xE4\x97$\xE6\xE8(\xE8\xEA\xEA\x18\x80\xA0\x9E\x81\x01\x17\x00\xBE\x1D\xBE\xAD\x81\x00\x00\x00"
|
57
66
|
|
@@ -63,11 +72,12 @@ class TestReportUtils < Test::Unit::TestCase
|
|
63
72
|
end
|
64
73
|
|
65
74
|
# Testing HTTP code 400.
|
66
|
-
def
|
75
|
+
def test_check_for_errors_400_legacy()
|
76
|
+
report_utils = @api.report_utils(:v201206)
|
67
77
|
REPLY_TYPES.each do |reply_type|
|
68
78
|
begin
|
69
79
|
response = ResponseStub.new(400, reply_type[:reply])
|
70
|
-
|
80
|
+
report_utils.check_for_errors(response)
|
71
81
|
assert(false, 'No exception thrown for code 400')
|
72
82
|
rescue AdwordsApi::Errors::ReportError => e
|
73
83
|
assert_equal(400, e.http_code)
|
@@ -76,12 +86,28 @@ class TestReportUtils < Test::Unit::TestCase
|
|
76
86
|
end
|
77
87
|
end
|
78
88
|
|
89
|
+
# Testing HTTP code 400.
|
90
|
+
def test_check_for_errors_400()
|
91
|
+
begin
|
92
|
+
response = ResponseStub.new(400, XML_REPLY[:reply])
|
93
|
+
@report_utils.check_for_errors(response)
|
94
|
+
assert(false, 'No exception thrown for code 400')
|
95
|
+
rescue AdwordsApi::Errors::ReportXmlError => e
|
96
|
+
assert_equal(400, e.http_code)
|
97
|
+
assert_equal(XML_REPLY[:type], e.type)
|
98
|
+
assert_equal(XML_REPLY[:trigger], e.trigger)
|
99
|
+
assert_equal(XML_REPLY[:field_path], e.field_path)
|
100
|
+
assert_not_nil(e.message)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
79
104
|
# Testing HTTP code 500.
|
80
|
-
def
|
105
|
+
def test_check_for_errors_500_legacy()
|
106
|
+
report_utils = @api.report_utils(:v201206)
|
81
107
|
REPLY_TYPES.each do |reply_type|
|
82
108
|
begin
|
83
109
|
response = ResponseStub.new(500, nil)
|
84
|
-
|
110
|
+
report_utils.check_for_errors(response)
|
85
111
|
assert(false, 'No exception thrown for code 500')
|
86
112
|
rescue AdwordsApi::Errors::ReportError => e
|
87
113
|
assert_equal(500, e.http_code)
|
@@ -89,6 +115,40 @@ class TestReportUtils < Test::Unit::TestCase
|
|
89
115
|
end
|
90
116
|
end
|
91
117
|
|
118
|
+
# Testing HTTP code 500.
|
119
|
+
def test_check_for_errors_500()
|
120
|
+
begin
|
121
|
+
response = ResponseStub.new(500, nil)
|
122
|
+
@report_utils.check_for_errors(response)
|
123
|
+
assert(false, 'No exception thrown for code 500')
|
124
|
+
rescue AdwordsApi::Errors::ReportError => e
|
125
|
+
assert_equal(500, e.http_code)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Testing unexpected legacy error for new version.
|
130
|
+
def test_check_for_errors_unexpected_legacy()
|
131
|
+
REPLY_TYPES.each do |reply_type|
|
132
|
+
begin
|
133
|
+
response = ResponseStub.new(400, reply_type[:reply])
|
134
|
+
@report_utils.check_for_errors(response)
|
135
|
+
assert(false, 'No exception thrown for legact error in new handler')
|
136
|
+
rescue AdwordsApi::Errors::ReportError => e
|
137
|
+
assert_equal(400, e.http_code)
|
138
|
+
assert_not_nil(e.message)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Testing HTTP code 200 with success.
|
144
|
+
def test_check_for_errors_200_success_legacy()
|
145
|
+
report_utils = @api.report_utils(:v201206)
|
146
|
+
response = ResponseStub.new(200, VALID_REPORT)
|
147
|
+
assert_nothing_raised do
|
148
|
+
report_utils.check_for_errors(response)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
92
152
|
# Testing HTTP code 200 with success.
|
93
153
|
def test_check_for_errors_200_success()
|
94
154
|
response = ResponseStub.new(200, VALID_REPORT)
|
@@ -98,11 +158,12 @@ class TestReportUtils < Test::Unit::TestCase
|
|
98
158
|
end
|
99
159
|
|
100
160
|
# Testing HTTP code 200 with failure.
|
101
|
-
def
|
161
|
+
def test_check_for_errors_200_success_legacy()
|
162
|
+
report_utils = @api.report_utils(:v201206)
|
102
163
|
REPLY_TYPES.each do |reply_type|
|
103
164
|
begin
|
104
165
|
response = ResponseStub.new(200, reply_type[:reply])
|
105
|
-
|
166
|
+
report_utils.check_for_errors(response)
|
106
167
|
assert(false, 'No exception thrown for code 200')
|
107
168
|
rescue AdwordsApi::Errors::ReportError => e
|
108
169
|
assert_equal(200, e.http_code)
|
@@ -185,4 +246,31 @@ class TestReportUtils < Test::Unit::TestCase
|
|
185
246
|
assert_equal(expected3, node[:selector][:date_range][:order!])
|
186
247
|
assert_equal(expected4, node[:selector][:predicates][:order!])
|
187
248
|
end
|
249
|
+
|
250
|
+
# Testing check_for_legacy_error.
|
251
|
+
def test_check_for_legacy_error()
|
252
|
+
REPLY_TYPES.each do |reply_type|
|
253
|
+
begin
|
254
|
+
@report_utils.check_for_legacy_error(reply_type[:reply], 42)
|
255
|
+
assert(false, 'No exception thrown for code 42')
|
256
|
+
rescue AdwordsApi::Errors::ReportError => e
|
257
|
+
assert_equal(42, e.http_code)
|
258
|
+
assert(e.message.include?(reply_type[:message]))
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# Testing check_for_xml_error.
|
264
|
+
def check_for_xml_error()
|
265
|
+
begin
|
266
|
+
@report_utils.check_for_xml_error(XML_REPLY[:reply], 42)
|
267
|
+
assert(false, 'No exception thrown for code 42')
|
268
|
+
rescue AdwordsApi::Errors::ReportXmlError => e
|
269
|
+
assert_equal(42, e.http_code)
|
270
|
+
assert_equal(XML_REPLY[:type], e.type)
|
271
|
+
assert_equal(XML_REPLY[:trigger], e.trigger)
|
272
|
+
assert_equal(XML_REPLY[:field_path], e.field_path)
|
273
|
+
assert_not_nil(e.message)
|
274
|
+
end
|
275
|
+
end
|
188
276
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
+
# implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
# Tests the account managements examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
require 'account_management/create_account'
|
26
|
+
require 'account_management/get_account_alerts'
|
27
|
+
require 'account_management/get_account_changes'
|
28
|
+
require 'account_management/get_account_hierarchy'
|
29
|
+
require 'account_management/get_client_customer_id'
|
30
|
+
require 'account_management/get_client_unit_usage'
|
31
|
+
|
32
|
+
class TestAccountManagementV201209 < Test::Unit::TestCase
|
33
|
+
def setup
|
34
|
+
end
|
35
|
+
|
36
|
+
# This test is disabled to avoid creating too many accounts.
|
37
|
+
def disabled_test_create_account
|
38
|
+
create_account()
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_get_account_alerts
|
42
|
+
get_account_alerts()
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_get_account_changes
|
46
|
+
get_account_changes()
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_get_account_hierarchy
|
50
|
+
get_account_hierarchy()
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_get_client_customer_id
|
54
|
+
get_client_customer_id('user@example.com')
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_get_client_unit_usage
|
58
|
+
get_client_unit_usage(1234567890)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
+
# implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
# Tests the basic operations examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
require 'basic_operations/add_ad_groups'
|
26
|
+
require 'basic_operations/add_campaigns'
|
27
|
+
require 'basic_operations/add_keywords'
|
28
|
+
require 'basic_operations/add_text_ads'
|
29
|
+
require 'basic_operations/delete_ad_group'
|
30
|
+
require 'basic_operations/delete_ad'
|
31
|
+
require 'basic_operations/delete_campaign'
|
32
|
+
require 'basic_operations/delete_keyword'
|
33
|
+
require 'basic_operations/get_ad_groups'
|
34
|
+
require 'basic_operations/get_campaigns'
|
35
|
+
require 'basic_operations/get_campaigns_with_awql'
|
36
|
+
require 'basic_operations/get_keywords'
|
37
|
+
require 'basic_operations/get_text_ads'
|
38
|
+
require 'basic_operations/pause_ad'
|
39
|
+
require 'basic_operations/update_ad_group'
|
40
|
+
require 'basic_operations/update_campaign'
|
41
|
+
require 'basic_operations/update_keyword'
|
42
|
+
|
43
|
+
class TestBasicOperationsV201209 < Test::Unit::TestCase
|
44
|
+
def setup
|
45
|
+
@logger = Logger.new(STDOUT)
|
46
|
+
@logger.level = Logger::ERROR
|
47
|
+
@adwords = AdwordsApi::Api.new
|
48
|
+
@adwords.logger = @logger
|
49
|
+
@utils = UtilsV201209.new(@adwords)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_add_campaigns
|
53
|
+
add_campaigns()
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_get_campaigns
|
57
|
+
get_campaigns()
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_get_campaigns_with_awql
|
61
|
+
get_campaigns_with_awql()
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_add_ad_groups
|
65
|
+
campaign = @utils.get_campaign()
|
66
|
+
assert_not_nil(campaign)
|
67
|
+
assert_not_nil(campaign[:id])
|
68
|
+
add_ad_groups(campaign[:id])
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_add_keywords
|
72
|
+
ad_group = @utils.get_ad_group()
|
73
|
+
assert_not_nil(ad_group)
|
74
|
+
assert_not_nil(ad_group[:id])
|
75
|
+
add_keywords(ad_group[:id])
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_get_keywords
|
79
|
+
ad_group = @utils.get_ad_group()
|
80
|
+
assert_not_nil(ad_group)
|
81
|
+
assert_not_nil(ad_group[:id])
|
82
|
+
get_keywords(ad_group[:id])
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_add_text_ads
|
86
|
+
ad_group = @utils.get_ad_group()
|
87
|
+
assert_not_nil(ad_group)
|
88
|
+
assert_not_nil(ad_group[:id])
|
89
|
+
add_text_ads(ad_group[:id])
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_get_text_ads
|
93
|
+
ad_group = @utils.get_ad_group()
|
94
|
+
assert_not_nil(ad_group)
|
95
|
+
assert_not_nil(ad_group[:id])
|
96
|
+
get_text_ads(ad_group[:id])
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_pause_ad
|
100
|
+
ad_group = @utils.get_ad_group()
|
101
|
+
assert_not_nil(ad_group)
|
102
|
+
assert_not_nil(ad_group[:id])
|
103
|
+
ad = @utils.get_ad()
|
104
|
+
assert_not_nil(ad)
|
105
|
+
assert_not_nil(ad[:ad])
|
106
|
+
assert_not_nil(ad[:ad][:id])
|
107
|
+
pause_ad(ad_group[:id], ad[:ad][:id])
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_update_ad_group
|
111
|
+
ad_group = @utils.get_ad_group()
|
112
|
+
assert_not_nil(ad_group)
|
113
|
+
assert_not_nil(ad_group[:id])
|
114
|
+
update_ad_group(ad_group[:id])
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_update_campaign
|
118
|
+
campaign = @utils.get_campaign()
|
119
|
+
assert_not_nil(campaign)
|
120
|
+
assert_not_nil(campaign[:id])
|
121
|
+
update_campaign(campaign[:id])
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_update_keyword
|
125
|
+
ad_group = @utils.get_ad_group()
|
126
|
+
assert_not_nil(ad_group)
|
127
|
+
assert_not_nil(ad_group[:id])
|
128
|
+
keyword = @utils.get_keyword()
|
129
|
+
assert_not_nil(keyword)
|
130
|
+
assert_not_nil(keyword[:criterion])
|
131
|
+
assert_not_nil(keyword[:criterion][:id])
|
132
|
+
update_keyword(ad_group[:id], keyword[:criterion][:id])
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_delete_keyword
|
136
|
+
ad_group = @utils.get_ad_group()
|
137
|
+
assert_not_nil(ad_group)
|
138
|
+
assert_not_nil(ad_group[:id])
|
139
|
+
keyword = @utils.get_keyword()
|
140
|
+
assert_not_nil(keyword)
|
141
|
+
assert_not_nil(keyword[:criterion])
|
142
|
+
assert_not_nil(keyword[:criterion][:id])
|
143
|
+
delete_keyword(ad_group[:id], keyword[:criterion][:id])
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_delete_ad
|
147
|
+
ad_group = @utils.get_ad_group()
|
148
|
+
assert_not_nil(ad_group)
|
149
|
+
assert_not_nil(ad_group[:id])
|
150
|
+
ad = @utils.get_ad()
|
151
|
+
assert_not_nil(ad)
|
152
|
+
assert_not_nil(ad[:ad])
|
153
|
+
assert_not_nil(ad[:ad][:id])
|
154
|
+
delete_ad(ad_group[:id], ad[:ad][:id])
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_delete_ad_group
|
158
|
+
ad_group = @utils.get_ad_group()
|
159
|
+
assert_not_nil(ad_group)
|
160
|
+
assert_not_nil(ad_group[:id])
|
161
|
+
delete_ad_group(ad_group[:id])
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_delete_campaign
|
165
|
+
campaign = @utils.get_campaign()
|
166
|
+
assert_not_nil(campaign)
|
167
|
+
assert_not_nil(campaign[:id])
|
168
|
+
delete_campaign(campaign[:id])
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_get_ad_groups
|
172
|
+
campaign = @utils.get_campaign()
|
173
|
+
assert_not_nil(campaign)
|
174
|
+
assert_not_nil(campaign[:id])
|
175
|
+
get_ad_groups(campaign[:id])
|
176
|
+
end
|
177
|
+
end
|