sem4r 0.1.1 → 0.1.2
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/Gemfile +11 -0
- data/Gemfile.lock +36 -0
- data/README.rdoc +30 -0
- data/Rakefile +15 -12
- data/VERSION.yml +1 -1
- data/examples_blog/2009-11-29-hello-world.rb +0 -1
- data/examples_sem4r/01_get_account.rb +1 -1
- data/examples_sem4r/02_get_info.rb +6 -2
- data/examples_sem4r/03_list_ad.rb +1 -1
- data/examples_sem4r/04_list_keywords.rb +1 -1
- data/examples_sem4r/05_request_report.rb +1 -2
- data/examples_sem4r/05_request_report_2010.rb +19 -4
- data/examples_sem4r/06_create_campaigns.rb +1 -1
- data/examples_sem4r/07_create_campaigns_block.rb +1 -1
- data/examples_sem4r/07_create_campaigns_simple.rb +1 -1
- data/examples_sem4r/08_ad_params.rb +1 -1
- data/examples_sem4r/09_targeting_idea.rb +1 -1
- data/examples_sem4r/10_get_location.rb +1 -1
- data/examples_sem4r/11_submit_bulk_job.rb +1 -1
- data/examples_sem4r/12_list_bulk_job.rb +1 -1
- data/examples_sem4r/30_prune_empty_adgroup.rb +1 -1
- data/examples_sem4r/31_empty_accounts.rb +1 -1
- data/examples_sem4r/example_helper.rb +5 -10
- data/lib/sem4r/account.rb +3 -306
- data/lib/sem4r/ad_group/ad_group.rb +16 -14
- data/lib/sem4r/ad_group/ad_group_bids.rb +11 -10
- data/lib/sem4r/ad_group/ad_group_service.rb +5 -5
- data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -1
- data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +5 -5
- data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +9 -9
- data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +9 -9
- data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +6 -6
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +5 -6
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +0 -1
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +4 -4
- data/lib/sem4r/ad_group_criterion/criterion.rb +3 -3
- data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +3 -3
- data/lib/sem4r/ad_group_criterion/criterion_placement.rb +2 -2
- data/lib/sem4r/ad_param/ad_param.rb +3 -3
- data/lib/sem4r/ad_param/ad_param_service.rb +5 -5
- data/lib/sem4r/adwords.rb +1 -0
- data/lib/sem4r/api_counters.rb +1 -0
- data/lib/sem4r/base.rb +1 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +2 -2
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +59 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +5 -5
- data/lib/sem4r/campaign/campaign.rb +10 -10
- data/lib/sem4r/campaign/campaign_account_extension.rb +87 -0
- data/lib/sem4r/campaign/campaign_service.rb +6 -6
- data/lib/sem4r/campaign_target/campaign_target_service.rb +22 -22
- data/lib/sem4r/cli/cli_command.rb +1 -0
- data/lib/sem4r/cli/cli_common_args.rb +10 -3
- data/lib/sem4r/cli/cli_helpers.rb +1 -0
- data/lib/sem4r/cli/cli_sem.rb +1 -0
- data/lib/sem4r/cli/{cli_download_report.rb → commands/cli_download_report.rb} +2 -1
- data/lib/sem4r/cli/{cli_ideas.rb → commands/cli_ideas.rb} +1 -0
- data/lib/sem4r/cli/{cli_commands.rb → commands/cli_info.rb} +3 -23
- data/lib/sem4r/cli/{cli_list_ads.rb → commands/cli_list_ads.rb} +1 -0
- data/lib/sem4r/cli/commands/cli_list_campaign.rb +35 -0
- data/lib/sem4r/cli/commands/cli_list_client.rb +36 -0
- data/lib/sem4r/cli/{cli_list_keywords.rb → commands/cli_list_keywords.rb} +1 -0
- data/lib/sem4r/cli/commands/cli_list_report.rb +34 -0
- data/lib/sem4r/cli/commands/cli_repdef.rb +109 -0
- data/lib/sem4r/cli/commands/cli_report.rb +78 -0
- data/lib/sem4r/cli/{cli_request_report.rb → commands/cli_request_report.rb} +1 -0
- data/lib/sem4r/credentials.rb +1 -0
- data/lib/sem4r/extensions.rb +22 -1
- data/lib/sem4r/geo_location/geo_location_account_extension.rb +43 -0
- data/lib/sem4r/geo_location/geo_location_service.rb +4 -4
- data/lib/sem4r/info/info_account_extension.rb +48 -0
- data/lib/sem4r/info/info_selector.rb +108 -0
- data/lib/sem4r/info/info_service.rb +11 -66
- data/lib/sem4r/{common/operation.rb → operation.rb} +3 -1
- data/lib/sem4r/report_definition/report_definition.rb +75 -15
- data/lib/sem4r/report_definition/report_definition_account_extension.rb +79 -0
- data/lib/sem4r/report_definition/report_definition_operation.rb +3 -1
- data/lib/sem4r/report_definition/report_definition_service.rb +7 -7
- data/lib/sem4r/report_definition/report_field.rb +57 -0
- data/lib/sem4r/sem4r_error.rb +1 -0
- data/lib/sem4r/services/http_connector.rb +93 -0
- data/lib/sem4r/services/service.rb +1 -1
- data/lib/sem4r/services/soap_call.rb +27 -5
- data/lib/sem4r/services/soap_connector.rb +2 -147
- data/lib/sem4r/services/soap_dumper.rb +105 -0
- data/lib/sem4r/services/soap_message_v13.rb +15 -9
- data/lib/sem4r/services/{soap_message_v2009.rb → soap_message_v2010.rb} +26 -12
- data/lib/sem4r/targeting_idea/targeting_idea.rb +16 -11
- data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +52 -0
- data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +36 -10
- data/lib/sem4r/targeting_idea/targeting_idea_service.rb +5 -5
- data/lib/sem4r/v13_account/account_account_extension.rb +103 -0
- data/lib/sem4r/v13_account/billing_address.rb +10 -21
- data/lib/sem4r/v13_report/report.rb +8 -8
- data/lib/sem4r/v13_report/report_account_extension.rb +63 -0
- data/lib/sem4r/v13_report/report_job.rb +1 -1
- data/lib/sem4r.rb +27 -6
- data/lib/sem4r_cli.rb +4 -6
- data/lib/{sem4r → soap_helpers}/soap_attributes.rb +105 -13
- data/sem4r.gemspec +229 -190
- data/spec/{aggregates_spec_helper.rb → aggregates_rspec_helper.rb} +0 -0
- data/spec/build_fixtures.rb +84 -0
- data/spec/rspec_hash.rb +66 -0
- data/spec/{spec_helper.rb → rspec_helper.rb} +4 -2
- data/spec/rspec_matchers.rb +102 -0
- data/spec/rspec_sem4r_helper.rb +88 -0
- data/spec/sem4r/account_spec.rb +3 -4
- data/spec/sem4r/ad_group/ad_group_bids_spec.rb +4 -3
- data/spec/sem4r/ad_group/ad_group_service_spec.rb +8 -7
- data/spec/sem4r/ad_group/ad_group_spec.rb +5 -4
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-res.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-res.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-res.xml +0 -0
- data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
- data/spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb +6 -5
- data/spec/sem4r/ad_group_ad/ad_group_ad_spec.rb +6 -5
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-res.xml +0 -0
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb +5 -4
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb +6 -5
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb +6 -5
- data/spec/sem4r/ad_group_criterion/criterion_spec.rb +5 -4
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-res.xml +0 -0
- data/spec/sem4r/ad_param/ad_param_service_spec.rb +6 -5
- data/spec/sem4r/ad_param/ad_param_spec.rb +3 -2
- data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-req.xml +0 -0
- data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-res.xml +0 -0
- data/spec/sem4r/adwords_spec.rb +1 -1
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +6 -5
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +4 -3
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-req.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-res.xml +0 -0
- data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +3 -2
- data/spec/sem4r/campaign/campaign_service_spec.rb +8 -7
- data/spec/sem4r/campaign/campaign_spec.rb +3 -2
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-res.xml +0 -0
- data/spec/sem4r/cli/cli_spec.rb +2 -3
- data/spec/sem4r/credentials_spec.rb +1 -1
- data/spec/sem4r/info/account_info_extension_spec.rb +51 -0
- data/spec/sem4r/info/fixtures/get_unit_count-req.xml +34 -0
- data/spec/sem4r/info/fixtures/get_unit_count-res.xml +27 -0
- data/spec/sem4r/nokogiri_parsing_spec.rb +105 -0
- data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req_orig.xml +0 -0
- data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -3
- data/spec/sem4r/report_definition/report_definition_spec.rb +6 -3
- data/spec/sem4r/rexml_parsing_spec.rb +22 -22
- data/spec/sem4r/services/service_spec.rb +2 -1
- data/spec/sem4r/services/soap_call_spec.rb +6 -5
- data/spec/sem4r/services/soap_message_v13_spec.rb +5 -11
- data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req-all-options.xml +0 -0
- data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req.xml +9 -11
- data/spec/sem4r/targeting_idea/fixtures/get-res.xml +2276 -0
- data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +30 -11
- data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +4 -3
- data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +5 -4
- data/spec/sem4r/v13_account/account_account_extension_spec.rb +47 -0
- data/spec/sem4r/v13_account/account_service_spec.rb +6 -5
- data/spec/sem4r/v13_account/billing_address_spec.rb +40 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-req.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-res.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-req.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-res.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-req.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-res.xml +2 -2
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-req.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-res.xml +0 -0
- data/spec/sem4r/v13_report/report_service_spec.rb +13 -11
- data/spec/sem4r/v13_report/report_spec.rb +4 -3
- data/spec/sem4r_stubs.rb +182 -0
- data/spec/soap_helpers/soap_attributes_spec.rb +129 -0
- metadata +225 -125
- data/spec/fixtures/services/info/get_unit_count-req.xml +0 -30
- data/spec/fixtures/services/info/get_unit_count-res.xml +0 -29
- data/spec/fixtures/services/targeting_idea/get-res.xml +0 -3601
- data/spec/sem4r/soap_attributes_spec.rb +0 -116
- data/spec/sem4r_spec_helper.rb +0 -353
data/lib/sem4r/account.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
1
2
|
# -------------------------------------------------------------------
|
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
|
3
4
|
#
|
|
@@ -39,311 +40,7 @@ module Sem4r
|
|
|
39
40
|
def client_email
|
|
40
41
|
credentials.client_email
|
|
41
42
|
end
|
|
42
|
-
|
|
43
|
-
############################################################################
|
|
44
|
-
# Info Service
|
|
45
|
-
|
|
46
|
-
# FREE_USAGE_API_UNITS_PER_MONTH
|
|
47
|
-
# Retrieves the number of free API units that can be used by the developer
|
|
48
|
-
# token being used to make the call for this month.
|
|
49
|
-
# Specify only the apiUsageType parameter.
|
|
50
|
-
#
|
|
51
|
-
# TOTAL_USAGE_API_UNITS_PER_MONTH
|
|
52
|
-
# Retrieves the total number of API units for this entire month that can
|
|
53
|
-
# be used by the developer token being used to make this call. Includes
|
|
54
|
-
# both free and paid API units.
|
|
55
|
-
# Specify only the apiUsageType parameter.
|
|
56
|
-
#
|
|
57
|
-
# OPERATION_COUNT
|
|
58
|
-
# Retrieves the number of operations recorded for the developer token
|
|
59
|
-
# being used to make this call over the given date range.
|
|
60
|
-
# The given dates
|
|
61
|
-
# are inclusive; to get the operation count for a single day, supply it as
|
|
62
|
-
# both the start and end date.
|
|
63
|
-
# Specify the apiUsageType and dateRange parameters.
|
|
64
|
-
#
|
|
65
|
-
# UNIT_COUNT
|
|
66
|
-
# Retrieves the number of API units recorded for the developer token being
|
|
67
|
-
# used to make this call.
|
|
68
|
-
# o Specify the apiUsageType and dateRange parameters to retrieve
|
|
69
|
-
# the units recorded over the given date range.
|
|
70
|
-
# o Specify the apiUsageType, serviceName, methodName, operator,
|
|
71
|
-
# dateRange to retrieve the units recorded over the given date
|
|
72
|
-
# range for a specified method.
|
|
73
|
-
#
|
|
74
|
-
# UNIT_COUNT_FOR_CLIENTS
|
|
75
|
-
# Retrieves the number of API units recorded for a subset of clients over
|
|
76
|
-
# the given date range for the developer token being used to make this
|
|
77
|
-
# call.
|
|
78
|
-
# The given dates are inclusive; to get the unit count for a single
|
|
79
|
-
# day, supply it as both the start and end date.
|
|
80
|
-
# Specify the apiUsageType, dateRange and clientEmails parameters.
|
|
81
|
-
#
|
|
82
|
-
# METHOD_COST
|
|
83
|
-
# Retrieves the cost, in API units per operation, of the given method on
|
|
84
|
-
# a specific date for the developer token being used to make this call.
|
|
85
|
-
#
|
|
86
|
-
# Methods default to a cost of 1. Specify the apiUsageType, dateRange
|
|
87
|
-
# (start date and end date should be the same), serviceName, methodName,
|
|
88
|
-
# operator parameters.
|
|
89
|
-
|
|
90
|
-
enum :UsageTypes, [
|
|
91
|
-
:FREE_USAGE_API_UNITS_PER_MONTH,
|
|
92
|
-
:UNIT_COUNT,
|
|
93
|
-
:TOTAL_USAGE_API_UNITS_PER_MONTH,
|
|
94
|
-
:OPERATION_COUNT,
|
|
95
|
-
:UNIT_COUNT_FOR_CLIENTS,
|
|
96
|
-
:METHOD_COST]
|
|
97
|
-
|
|
98
|
-
def year_unit_cost(usage_type)
|
|
99
|
-
raise "usage type '#{usage_type}' not permitted" unless UsageTypes.include?(usage_type)
|
|
100
|
-
soap_message = service.info.unit_cost(@credentials, usage_type)
|
|
101
|
-
add_counters( soap_message.counters )
|
|
102
|
-
cost = REXML::XPath.first( soap_message.response, "//getResponse/rval/cost")
|
|
103
|
-
cost.text.to_i
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
############################################################################
|
|
107
|
-
# Targeting Idea
|
|
108
|
-
|
|
109
|
-
def targeting_idea(&block)
|
|
110
|
-
selector = TargetingIdeaSelector.new(&block)
|
|
111
|
-
soap_message = service.targeting_idea.get(@credentials, selector.to_xml)
|
|
112
|
-
add_counters( soap_message.counters )
|
|
113
|
-
rval = REXML::XPath.first( soap_message.response, "//getResponse/rval")
|
|
114
|
-
els = REXML::XPath.match( rval, "entries")
|
|
115
|
-
els.map do |el|
|
|
116
|
-
TargetingIdea.from_element( el )
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def p_targeting_idea(&block)
|
|
121
|
-
targeting_ideas = targeting_idea(&block)
|
|
122
|
-
targeting_ideas.each{ |idea| puts idea }
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
############################################################################
|
|
126
|
-
# Bulk Jobs
|
|
127
|
-
|
|
128
|
-
def p_jobs
|
|
129
|
-
selector = BulkMutateJobSelector.new
|
|
130
|
-
soap_message = service.bulk_mutate_job.all(credentials, selector)
|
|
131
|
-
add_counters( soap_message.counters )
|
|
132
|
-
els = REXML::XPath.match( soap_message.response, "//getResponse/rval")
|
|
133
|
-
jobs = els.map do |el|
|
|
134
|
-
BulkMutateJob.from_element(el)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
puts "#{jobs.length} bulk mutate jobs"
|
|
138
|
-
jobs.each do |job|
|
|
139
|
-
puts job.to_s
|
|
140
|
-
end
|
|
141
|
-
self
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def job_mutate(bulk_mutate_job)
|
|
145
|
-
soap_message = service.bulk_mutate_job.mutate(credentials, bulk_mutate_job)
|
|
146
|
-
add_counters( soap_message.counters )
|
|
147
|
-
el = REXML::XPath.first( soap_message.response, "//rval")
|
|
148
|
-
BulkMutateJob.from_element(el)
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
############################################################################
|
|
152
|
-
# Geo Location
|
|
153
|
-
|
|
154
|
-
def geo_location
|
|
155
|
-
soap_message = service.geo_location.get(@credentials, "")
|
|
156
|
-
add_counters( soap_message.counters )
|
|
157
|
-
# cost = REXML::XPath.first( soap_message.response, "//getResponse/rval/cost")
|
|
158
|
-
# cost.text.to_i
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
############################################################################
|
|
162
|
-
# Reports - Service Report
|
|
163
|
-
|
|
164
|
-
def report(&block)
|
|
165
|
-
Report.new(self, &block)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def p_reports(refresh = false)
|
|
169
|
-
reports(refresh).each do |report|
|
|
170
|
-
puts report.to_s
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def reports(refresh = false)
|
|
175
|
-
_reports unless @reports and !refresh
|
|
176
|
-
@reports
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
private
|
|
180
|
-
|
|
181
|
-
def _reports
|
|
182
|
-
soap_message = service.report.all(credentials)
|
|
183
|
-
add_counters( soap_message.counters )
|
|
184
|
-
els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
|
|
185
|
-
@reports = els.map do |el|
|
|
186
|
-
Report.from_element(self, el)
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
public
|
|
191
|
-
|
|
192
|
-
############################################################################
|
|
193
|
-
# Report Definitions - Service Report Definition
|
|
194
|
-
|
|
195
|
-
def report_definition(&block)
|
|
196
|
-
ReportDefinition.new(self, &block)
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def p_report_definitions(refresh = false)
|
|
200
|
-
report_definitions(refresh).each do |report_definition|
|
|
201
|
-
puts report_definition.to_s
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def report_definitions(refresh = false)
|
|
206
|
-
_report_definitions unless @report_definitions and !refresh
|
|
207
|
-
@report_definitions
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
private
|
|
211
|
-
|
|
212
|
-
def _report_definitions
|
|
213
|
-
soap_message = service.report_definition.get(credentials, ReportDefinitionSelector.new.to_xml)
|
|
214
|
-
add_counters( soap_message.counters )
|
|
215
|
-
els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
|
|
216
|
-
@report_definitions = els.map do |el|
|
|
217
|
-
ReportDefinition.from_element(self, el)
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
public
|
|
222
|
-
|
|
223
|
-
############################################################################
|
|
224
|
-
# Info Account - Service Account
|
|
225
|
-
|
|
226
|
-
def p_info
|
|
227
|
-
_info unless @currency_code
|
|
228
|
-
puts "currency_code: #{@currency_code}"
|
|
229
|
-
puts "customer_id: #{@customer_id}"
|
|
230
|
-
puts @billing_address
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
def currency_code
|
|
234
|
-
_info unless @currency_code
|
|
235
|
-
@currency_code
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
def customer_id
|
|
239
|
-
_info unless @customer_id
|
|
240
|
-
@customer_id
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
private
|
|
244
|
-
|
|
245
|
-
def _info
|
|
246
|
-
soap_message = service.account.account_info(credentials)
|
|
247
|
-
add_counters( soap_message.counters )
|
|
248
|
-
el = REXML::XPath.first( soap_message.response, "//getAccountInfoResponse/getAccountInfoReturn")
|
|
249
|
-
@currency_code = el.elements['currencyCode'].text.strip
|
|
250
|
-
@customer_id = el.elements['customerId'].text.strip
|
|
251
|
-
@billing_address = BillingAddress.from_element( el.elements['billingAddress'] )
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
public
|
|
255
|
-
|
|
256
|
-
############################################################################
|
|
257
|
-
# Account - Service Account
|
|
258
|
-
|
|
259
|
-
def client_accounts(refresh = false)
|
|
260
|
-
_client_accounts unless @accounts and !refresh
|
|
261
|
-
@accounts
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
def p_client_accounts(refresh = false)
|
|
265
|
-
cs = client_accounts(refresh)
|
|
266
|
-
# puts "#{cs.length} client accounts"
|
|
267
|
-
cs.each do |account|
|
|
268
|
-
puts account.to_s
|
|
269
|
-
end
|
|
270
|
-
self
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
alias clients client_accounts
|
|
274
|
-
alias p_clients p_client_accounts
|
|
275
|
-
|
|
276
|
-
private
|
|
277
|
-
|
|
278
|
-
def _client_accounts
|
|
279
|
-
soap_message = service.account.client_accounts(credentials)
|
|
280
|
-
add_counters( soap_message.counters )
|
|
281
|
-
els = REXML::XPath.match( soap_message.response, "//getClientAccountsReturn")
|
|
282
|
-
@accounts = els.map do |el|
|
|
283
|
-
client_email = el.text
|
|
284
|
-
Account.new( adwords, Credentials.new(@credentials, client_email) )
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
public
|
|
289
|
-
|
|
290
|
-
############################################################################
|
|
291
|
-
# Campaign - Service Campaign
|
|
292
|
-
|
|
293
|
-
# TODO: accettare un parametro opzionale campaign(name=nil,&block)
|
|
294
|
-
# la campagna che verra' creata ha il nome gia' settato
|
|
295
|
-
# se esiste gia' una campagna con quel nome allora fara' da contesto
|
|
296
|
-
# e non verra' creata
|
|
297
|
-
def campaign(name = nil, &block)
|
|
298
|
-
campaign = Campaign.new(self, name, &block)
|
|
299
|
-
campaign.save
|
|
300
|
-
@campaigns ||= []
|
|
301
|
-
@campaigns.push(campaign)
|
|
302
|
-
campaign
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
alias create_campaign campaign
|
|
306
|
-
|
|
307
|
-
def campaigns(refresh = false, opts = {}) # conditions = nil
|
|
308
|
-
if refresh.respond_to?(:keys)
|
|
309
|
-
opts = refresh
|
|
310
|
-
refresh = false
|
|
311
|
-
end
|
|
312
|
-
_campaigns unless @campaigns and !refresh
|
|
313
|
-
@campaigns
|
|
314
|
-
# return @campaigns unless conditions
|
|
315
|
-
# @campaigns.find_all {|c| c.name =~ conditions}
|
|
316
|
-
end
|
|
317
|
-
|
|
318
|
-
def p_campaigns(refresh = false, opts = {}) # conditions = nil
|
|
319
|
-
if refresh.respond_to?(:keys)
|
|
320
|
-
opts = refresh
|
|
321
|
-
refresh = false
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
cs = campaigns(refresh, opts)
|
|
325
|
-
puts "#{cs.length} campaigns"
|
|
326
|
-
campaigns(refresh).each do |campaign|
|
|
327
|
-
puts campaign.to_s
|
|
328
|
-
end
|
|
329
|
-
self
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
private
|
|
333
|
-
|
|
334
|
-
def _campaigns
|
|
335
|
-
soap_message = service.campaign.all(credentials)
|
|
336
|
-
add_counters( soap_message.counters )
|
|
337
|
-
rval = REXML::XPath.first( soap_message.response, "//getResponse/rval")
|
|
338
|
-
els = REXML::XPath.match( rval, "entries")
|
|
339
|
-
@campaigns = els.map do |el|
|
|
340
|
-
Campaign.from_element(self, el)
|
|
341
|
-
end
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
public
|
|
345
|
-
|
|
346
|
-
###########################################################################
|
|
347
|
-
|
|
43
|
+
|
|
348
44
|
end
|
|
45
|
+
|
|
349
46
|
end
|
|
@@ -96,10 +96,10 @@ module Sem4r
|
|
|
96
96
|
|
|
97
97
|
def self.from_element(campaign, el)
|
|
98
98
|
new(campaign) do
|
|
99
|
-
@id = el.
|
|
100
|
-
name el.
|
|
101
|
-
status el.
|
|
102
|
-
bids el.
|
|
99
|
+
@id = el.at_xpath("id").text.strip.to_i
|
|
100
|
+
name el.at_xpath("name").text.strip
|
|
101
|
+
status el.at_xpath("status").text.strip
|
|
102
|
+
bids el.at_xpath("bids")
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -117,8 +117,8 @@ module Sem4r
|
|
|
117
117
|
unless @id
|
|
118
118
|
soap_message = service.ad_group.create(credentials, to_xml("operand"))
|
|
119
119
|
add_counters( soap_message.counters )
|
|
120
|
-
rval =
|
|
121
|
-
id =
|
|
120
|
+
rval = soap_message.response.xpath("//mutateResponse/rval").first
|
|
121
|
+
id = rval.xpath("value/id").first
|
|
122
122
|
@id = id.text.strip.to_i
|
|
123
123
|
end
|
|
124
124
|
end
|
|
@@ -181,8 +181,8 @@ module Sem4r
|
|
|
181
181
|
def _ads
|
|
182
182
|
soap_message = service.ad_group_ad.all(credentials, id)
|
|
183
183
|
add_counters( soap_message.counters )
|
|
184
|
-
rval =
|
|
185
|
-
els =
|
|
184
|
+
rval = soap_message.response.xpath("//getResponse/rval").first
|
|
185
|
+
els = rval.xpath( "entries/ad" )
|
|
186
186
|
@ads = els.map do |el|
|
|
187
187
|
AdGroupAd.from_element( self, el )
|
|
188
188
|
end
|
|
@@ -198,9 +198,11 @@ module Sem4r
|
|
|
198
198
|
o = AdGroupAdOperation.new.add(ad)
|
|
199
199
|
xml + o.to_xml("operations")
|
|
200
200
|
end
|
|
201
|
+
|
|
201
202
|
soap_message = service.ad_group_ad.mutate(credentials, xml)
|
|
202
203
|
add_counters( soap_message.counters )
|
|
203
|
-
els =
|
|
204
|
+
els = soap_message.response.xpath("//mutateResponse/rval/value/ad/id")
|
|
205
|
+
|
|
204
206
|
els.each_with_index do |e,index|
|
|
205
207
|
id = e.text.strip.to_i
|
|
206
208
|
unsaved_ads[index].instance_eval{ @id = id }
|
|
@@ -266,8 +268,8 @@ module Sem4r
|
|
|
266
268
|
def _criterions
|
|
267
269
|
soap_message = service.ad_group_criterion.all(credentials, id)
|
|
268
270
|
add_counters( soap_message.counters )
|
|
269
|
-
rval =
|
|
270
|
-
els =
|
|
271
|
+
rval = soap_message.response.xpath("//getResponse/rval").first
|
|
272
|
+
els = rval.xpath( "entries/criterion" )
|
|
271
273
|
@criterions = els.map do |el|
|
|
272
274
|
Criterion.from_element( self, el )
|
|
273
275
|
end
|
|
@@ -287,7 +289,7 @@ module Sem4r
|
|
|
287
289
|
end
|
|
288
290
|
soap_message = service.ad_group_criterion.mutate(credentials, xml)
|
|
289
291
|
add_counters( soap_message.counters )
|
|
290
|
-
els =
|
|
292
|
+
els = soap_message.response.xpath("//mutateResponse/rval/value/criterion/id")
|
|
291
293
|
els.each_with_index do |e,index|
|
|
292
294
|
id = e.text.strip.to_i
|
|
293
295
|
unsaved_criterions[index].criterion.instance_eval{ @id = id }
|
|
@@ -324,8 +326,8 @@ module Sem4r
|
|
|
324
326
|
def _ad_params
|
|
325
327
|
soap_message = service.ad_param.all(credentials, id)
|
|
326
328
|
add_counters( soap_message.counters )
|
|
327
|
-
rval =
|
|
328
|
-
els =
|
|
329
|
+
rval = soap_message.response.xpath("//getResponse/rval").first
|
|
330
|
+
els = rval.xpath( "entries" )
|
|
329
331
|
@ad_params = els.map do |el|
|
|
330
332
|
AdParam.from_element( self, el )
|
|
331
333
|
end
|
|
@@ -40,7 +40,7 @@ module Sem4r
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def self.from_element(el)
|
|
43
|
-
type =
|
|
43
|
+
type = el.at_xpath("AdGroupBids.Type").text.strip
|
|
44
44
|
klass = Module::const_get(type)
|
|
45
45
|
klass.from_element(el)
|
|
46
46
|
end
|
|
@@ -114,15 +114,15 @@ module Sem4r
|
|
|
114
114
|
|
|
115
115
|
def self.from_element(el)
|
|
116
116
|
new do
|
|
117
|
-
kel = el.
|
|
117
|
+
kel = el.at_xpath("keywordMaxCpc")
|
|
118
118
|
if kel
|
|
119
|
-
el_amount = kel.
|
|
120
|
-
keyword_max_cpc
|
|
119
|
+
el_amount = kel.at_xpath("amount")
|
|
120
|
+
keyword_max_cpc(el_amount.at_xpath("microAmount").text.strip.to_i)
|
|
121
121
|
end
|
|
122
|
-
sel = el.
|
|
122
|
+
sel = el.at_xpath("siteMaxCpc")
|
|
123
123
|
if sel
|
|
124
|
-
el_amount = sel.
|
|
125
|
-
site_max_cpc
|
|
124
|
+
el_amount = sel.at_xpath("amount")
|
|
125
|
+
site_max_cpc(el_amount.at_xpath("microAmount").text.strip.to_i)
|
|
126
126
|
end
|
|
127
127
|
# TODO: it is possible something like:
|
|
128
128
|
# el.elements["maxCpc"] do |el|
|
|
@@ -130,6 +130,7 @@ module Sem4r
|
|
|
130
130
|
# max_cpc el["microAmount"]
|
|
131
131
|
# end
|
|
132
132
|
# end
|
|
133
|
+
|
|
133
134
|
end
|
|
134
135
|
end
|
|
135
136
|
end
|
|
@@ -157,10 +158,10 @@ module Sem4r
|
|
|
157
158
|
|
|
158
159
|
def self.from_element(el)
|
|
159
160
|
new do
|
|
160
|
-
kel = el.
|
|
161
|
+
kel = el.xpath("maxCpm").first
|
|
161
162
|
if kel
|
|
162
|
-
el_amount = kel.
|
|
163
|
-
max_cpm el_amount.
|
|
163
|
+
el_amount = kel.xpath("amount").first
|
|
164
|
+
max_cpm el_amount.xpath("microAmount").first.text.strip.to_i
|
|
164
165
|
end
|
|
165
166
|
end
|
|
166
167
|
end
|
|
@@ -27,14 +27,14 @@ module Sem4r
|
|
|
27
27
|
|
|
28
28
|
def initialize(connector)
|
|
29
29
|
@connector = connector
|
|
30
|
-
@service_namespace = "https://adwords.google.com/api/adwords/cm/
|
|
30
|
+
@service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
|
|
31
31
|
@header_namespace = @service_namespace
|
|
32
|
-
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/
|
|
32
|
+
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdGroupService"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
soap_call_v2010 :all, :mutate => false
|
|
36
|
+
soap_call_v2010 :create, :mutate => true
|
|
37
|
+
soap_call_v2010 :delete, :mutate => true
|
|
38
38
|
|
|
39
39
|
def _all(campaign_id)
|
|
40
40
|
<<-EOFS
|
|
@@ -27,15 +27,15 @@ module Sem4r
|
|
|
27
27
|
|
|
28
28
|
def initialize(connector)
|
|
29
29
|
@connector = connector
|
|
30
|
-
@service_namespace = "https://adwords.google.com/api/adwords/cm/
|
|
30
|
+
@service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
|
|
31
31
|
@header_namespace = @service_namespace
|
|
32
32
|
|
|
33
|
-
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/
|
|
33
|
+
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdGroupAdService"
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
soap_call_v2010 :all, :mutate => false
|
|
37
|
+
soap_call_v2010 :mutate
|
|
38
|
+
|
|
39
39
|
private
|
|
40
40
|
|
|
41
41
|
def _all(ad_group_id)
|
|
@@ -111,13 +111,13 @@ module Sem4r
|
|
|
111
111
|
|
|
112
112
|
def self.from_element(ad_group, el)
|
|
113
113
|
new(ad_group) do
|
|
114
|
-
@id = el.
|
|
115
|
-
# type el.
|
|
116
|
-
headline el.
|
|
117
|
-
description el.
|
|
118
|
-
business_name el.
|
|
119
|
-
country_code el.
|
|
120
|
-
phone_number el.
|
|
114
|
+
@id = el.at_xpath("id").text.strip.to_i
|
|
115
|
+
# type el.at_xpath("Ad.Type").text
|
|
116
|
+
headline el.at_xpath("headline").text.strip
|
|
117
|
+
description el.at_xpath("description").text.strip
|
|
118
|
+
business_name el.at_xpath("businessName").text.strip
|
|
119
|
+
country_code el.at_xpath("countryCode").text.strip
|
|
120
|
+
phone_number el.at_xpath("phoneNumber").text.strip
|
|
121
121
|
# TODO: estrarre le carriers
|
|
122
122
|
end
|
|
123
123
|
end
|
|
@@ -126,8 +126,8 @@ module Sem4r
|
|
|
126
126
|
unless @id
|
|
127
127
|
soap_message = service.ad_group_ad.create(credentials, to_xml("operand"))
|
|
128
128
|
add_counters( soap_message.counters )
|
|
129
|
-
rval =
|
|
130
|
-
id =
|
|
129
|
+
rval = soap_message.response.xpath("//mutateResponse/rval", soap_message.response_headers).first
|
|
130
|
+
id = rval.xpath("value/ad/id").first
|
|
131
131
|
@id = id.text.strip.to_i
|
|
132
132
|
end
|
|
133
133
|
self
|
|
@@ -68,13 +68,13 @@ module Sem4r
|
|
|
68
68
|
|
|
69
69
|
def self.from_element(ad_group, el)
|
|
70
70
|
new(ad_group) do
|
|
71
|
-
@id = el.
|
|
72
|
-
# type el.
|
|
73
|
-
url el.
|
|
74
|
-
display_url el.
|
|
75
|
-
headline el.
|
|
76
|
-
description1 el.
|
|
77
|
-
description2 el.
|
|
71
|
+
@id = el.at_xpath("id").text.strip.to_i
|
|
72
|
+
# type el.at_xpath("Ad.Type").text
|
|
73
|
+
url el.at_xpath("url").text.strip
|
|
74
|
+
display_url el.at_xpath("displayUrl").text.strip
|
|
75
|
+
headline el.at_xpath("headline").text.strip
|
|
76
|
+
description1 el.at_xpath("description1").text.strip
|
|
77
|
+
description2 el.at_xpath("description2").text.strip
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -87,8 +87,8 @@ module Sem4r
|
|
|
87
87
|
ad_operation = AdGroupAdOperation.new.add self
|
|
88
88
|
soap_message = service.ad_group_ad.mutate(credentials, ad_operation.to_xml("operations"))
|
|
89
89
|
add_counters( soap_message.counters )
|
|
90
|
-
rval =
|
|
91
|
-
id =
|
|
90
|
+
rval = soap_message.response.xpath("//mutateResponse/rval").first
|
|
91
|
+
id = rval.xpath("value/ad/id").first
|
|
92
92
|
@id = id.text.strip.to_i
|
|
93
93
|
end
|
|
94
94
|
self
|
|
@@ -38,7 +38,7 @@ module Sem4r
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def self.from_element(ad_group, el)
|
|
41
|
-
type = el.
|
|
41
|
+
type = el.at_xpath("AdGroupCriterion.Type").text.strip
|
|
42
42
|
klass = Module::const_get(type)
|
|
43
43
|
klass.from_element(ad_group, el)
|
|
44
44
|
end
|
|
@@ -53,8 +53,8 @@ module Sem4r
|
|
|
53
53
|
soap_message =
|
|
54
54
|
criterion.service.ad_group_criterion.mutate(criterion.credentials, o.to_xml("operations"))
|
|
55
55
|
criterion.add_counters( soap_message.counters )
|
|
56
|
-
rval =
|
|
57
|
-
id =
|
|
56
|
+
rval = soap_message.response.xpath("//mutateResponse/rval").first
|
|
57
|
+
id = rval.xpath("value/criterion/id").first
|
|
58
58
|
criterion.instance_eval{ @id = id.text.strip.to_i }
|
|
59
59
|
end
|
|
60
60
|
self
|
|
@@ -79,8 +79,8 @@ module Sem4r
|
|
|
79
79
|
|
|
80
80
|
def self.from_element(ad_group, el)
|
|
81
81
|
new(ad_group) do
|
|
82
|
-
criterion Criterion.from_element(ad_group, el.
|
|
83
|
-
bids AdGroupCriterionBids.from_element(el.
|
|
82
|
+
criterion Criterion.from_element(ad_group, el.at_xpath("criterion"))
|
|
83
|
+
bids AdGroupCriterionBids.from_element(el.at_xpath("bids"))
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -119,7 +119,7 @@ module Sem4r
|
|
|
119
119
|
|
|
120
120
|
def self.from_element(ad_group, el)
|
|
121
121
|
new(ad_group) do
|
|
122
|
-
criterion Criterion.from_element(ad_group, el.
|
|
122
|
+
criterion Criterion.from_element(ad_group, el.at_xpath("criterion"))
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
@@ -35,7 +35,7 @@ module Sem4r
|
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
def self.from_element(el)
|
|
38
|
-
type = el.
|
|
38
|
+
type = el.at_xpath("AdGroupCriterionBids.Type").text.strip
|
|
39
39
|
klass = Module::const_get(type)
|
|
40
40
|
klass.from_element(el)
|
|
41
41
|
end
|
|
@@ -63,12 +63,11 @@ module Sem4r
|
|
|
63
63
|
|
|
64
64
|
def self.from_element(el)
|
|
65
65
|
new do
|
|
66
|
-
bid_source el.
|
|
67
|
-
|
|
68
|
-
el_maxCpc = el.elements["maxCpc"]
|
|
69
|
-
el_amount = el_maxCpc.elements["amount"]
|
|
70
|
-
max_cpc el_amount.elements["microAmount"].text.strip.to_i
|
|
66
|
+
bid_source el.at_xpath("bidSource").text.strip
|
|
71
67
|
|
|
68
|
+
el_maxCpc = el.at_xpath("maxCpc")
|
|
69
|
+
el_amount = el_maxCpc.at_xpath("amount")
|
|
70
|
+
max_cpc el_amount.at_xpath("microAmount").text.strip.to_i
|
|
72
71
|
# TODO: it is possible something like:
|
|
73
72
|
# el.elements["maxCpc"] do |el|
|
|
74
73
|
# el.elements["amount"] do el
|
|
@@ -27,14 +27,14 @@ module Sem4r
|
|
|
27
27
|
|
|
28
28
|
def initialize(connector)
|
|
29
29
|
@connector = connector
|
|
30
|
-
@service_namespace = "https://adwords.google.com/api/adwords/cm/
|
|
30
|
+
@service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
|
|
31
31
|
@header_namespace = @service_namespace
|
|
32
32
|
|
|
33
|
-
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/
|
|
33
|
+
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdGroupCriterionService"
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
soap_call_v2010 :all, :mutate => false
|
|
37
|
+
soap_call_v2010 :mutate
|
|
38
38
|
|
|
39
39
|
private
|
|
40
40
|
|
|
@@ -45,9 +45,9 @@ module Sem4r
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def self.from_element( ad_group, el )
|
|
48
|
-
xml_type =
|
|
49
|
-
#
|
|
50
|
-
#
|
|
48
|
+
xml_type = el.at_xpath("Criterion.Type").text.strip
|
|
49
|
+
# klass = Module::const_get(type)
|
|
50
|
+
# klass.from_element(ad_group, el)
|
|
51
51
|
case xml_type
|
|
52
52
|
when Keyword
|
|
53
53
|
CriterionKeyword.from_element(ad_group, el)
|