sem4r 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -2
- data/Gemfile.lock +13 -7
- data/README.rdoc +44 -7
- data/Rakefile +2 -122
- data/VERSION.yml +1 -1
- data/bin/sem +1 -0
- data/examples_sem4r/01_get_account.rb +1 -0
- data/examples_sem4r/02_get_info.rb +1 -0
- data/examples_sem4r/03_list_ad.rb +1 -0
- data/examples_sem4r/04_list_keywords.rb +1 -0
- data/examples_sem4r/05_request_report.rb +25 -14
- data/examples_sem4r/{05_request_report_2010.rb → 06_request_report_definition.rb} +2 -4
- data/examples_sem4r/{06_create_campaigns.rb → 07_create_campaigns.rb} +1 -0
- data/examples_sem4r/{07_create_campaigns_block.rb → 08_create_campaigns_block.rb} +1 -0
- data/examples_sem4r/{07_create_campaigns_simple.rb → 09_create_campaigns_simple.rb} +1 -0
- data/examples_sem4r/{08_ad_params.rb → 10_ad_params.rb} +1 -0
- data/examples_sem4r/{09_targeting_idea.rb → 11_targeting_idea.rb} +1 -0
- data/examples_sem4r/{10_get_location.rb → 12_get_location.rb} +1 -0
- data/examples_sem4r/{11_submit_bulk_job.rb → 13_submit_bulk_job.rb} +1 -1
- data/examples_sem4r/{12_list_bulk_job.rb → 14_list_bulk_job.rb} +3 -0
- data/examples_sem4r/30_prune_empty_adgroup.rb +1 -0
- data/examples_sem4r/31_empty_accounts.rb +1 -0
- data/examples_sem4r/example_helper.rb +2 -1
- data/lib/sem4r/ad_group/ad_group.rb +22 -7
- data/lib/sem4r/ad_group/ad_group_bids.rb +1 -1
- data/lib/sem4r/ad_group/ad_group_service.rb +12 -5
- data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad_operations.rb +1 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +14 -9
- data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +16 -25
- data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +18 -14
- data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +27 -19
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +2 -1
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +1 -0
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +9 -4
- data/lib/sem4r/ad_group_criterion/criterion.rb +1 -0
- data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +1 -0
- data/lib/sem4r/ad_group_criterion/criterion_placement.rb +1 -0
- data/lib/sem4r/ad_param/ad_param.rb +24 -8
- data/lib/sem4r/ad_param/ad_param_service.rb +8 -5
- data/lib/sem4r/adwords.rb +232 -76
- data/lib/sem4r/base.rb +1 -1
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +41 -35
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +49 -15
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_selector.rb +29 -20
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +13 -14
- data/lib/sem4r/bulk_mutate_job/job_operations.rb +1 -1
- data/lib/sem4r/campaign/campaign.rb +1 -0
- data/lib/sem4r/campaign/campaign_account_extension.rb +2 -1
- data/lib/sem4r/campaign/campaign_service.rb +9 -5
- data/lib/sem4r/credentials.rb +11 -5
- data/lib/sem4r/geo_location/address.rb +56 -0
- data/lib/sem4r/geo_location/geo_location_account_extension.rb +27 -6
- data/lib/sem4r/geo_location/geo_location_selector.rb +57 -0
- data/lib/sem4r/geo_location/geo_location_service.rb +9 -16
- data/lib/sem4r/info/info_account_extension.rb +3 -2
- data/lib/sem4r/info/info_selector.rb +2 -1
- data/lib/sem4r/info/info_service.rb +10 -3
- data/lib/sem4r/operation.rb +39 -20
- data/lib/sem4r/report_definition/report_definition.rb +37 -19
- data/lib/sem4r/report_definition/report_definition_account_extension.rb +66 -16
- data/lib/sem4r/report_definition/report_definition_operation.rb +2 -2
- data/lib/sem4r/report_definition/report_definition_selector.rb +1 -1
- data/lib/sem4r/report_definition/report_definition_service.rb +11 -7
- data/lib/sem4r/report_definition/report_field.rb +3 -2
- data/lib/sem4r/sem4r_templates.rb +77 -0
- data/lib/sem4r/{services/service.rb → service.rb} +23 -23
- data/lib/sem4r/targeting_idea/targeting_idea.rb +4 -4
- data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +1 -1
- data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +6 -6
- data/lib/sem4r/targeting_idea/targeting_idea_service.rb +7 -5
- data/lib/sem4r/v13_account/account_account_extension.rb +7 -10
- data/lib/sem4r/v13_account/account_service.rb +10 -4
- data/lib/sem4r/v13_account/billing_address.rb +2 -2
- data/lib/sem4r/v13_report/report_service.rb +11 -9
- data/lib/sem4r.rb +46 -31
- data/lib/{sem4r/cli → sem4r_cli}/cli_helpers.rb +3 -2
- data/lib/{sem4r/cli/cli_command.rb → sem4r_cli/cli_mini_framework.rb} +77 -32
- data/lib/{sem4r/cli/cli_common_args.rb → sem4r_cli/cli_sem.rb} +177 -157
- data/lib/{sem4r/cli/commands/cli_list_ads.rb → sem4r_cli/commands/cli_ads.rb} +7 -9
- data/lib/sem4r_cli/commands/cli_campaign.rb +69 -0
- data/lib/{sem4r/cli/commands/cli_list_client.rb → sem4r_cli/commands/cli_clients.rb} +2 -2
- data/lib/{sem4r/cli → sem4r_cli}/commands/cli_ideas.rb +35 -27
- data/lib/{sem4r/cli → sem4r_cli}/commands/cli_info.rb +3 -4
- data/lib/{sem4r/cli/commands/cli_repdef.rb → sem4r_cli/commands/cli_job.rb} +57 -55
- data/lib/{sem4r/cli/commands/cli_list_keywords.rb → sem4r_cli/commands/cli_keywords.rb} +14 -13
- data/lib/sem4r_cli/commands/cli_profile.rb +138 -0
- data/lib/{sem4r/cli/commands/cli_report.rb → sem4r_cli/commands/cli_repdef.rb} +67 -20
- data/lib/{sem4r/cli/commands/cli_request_report.rb → sem4r_cli/commands/cli_report.rb} +82 -19
- data/lib/sem4r_cli.rb +5 -7
- data/lib/sem4r_soap/http_connector.rb +206 -0
- data/lib/{soap_helpers → sem4r_soap}/soap_attributes.rb +8 -3
- data/lib/{sem4r/services → sem4r_soap}/soap_dumper.rb +36 -20
- data/lib/{sem4r/services → sem4r_soap}/soap_error.rb +5 -2
- data/lib/sem4r_soap/soap_response.rb +75 -0
- data/lib/sem4r_soap/soap_service.rb +137 -0
- data/lib/{sem4r/cli/cli_sem.rb → sem4r_soap/soap_service_v13.rb} +27 -28
- data/lib/sem4r_soap/soap_service_v2010.rb +80 -0
- data/lib/sem4r_soap.rb +17 -0
- data/sem4r.gemspec +93 -58
- data/spec/build_fixtures.rb +49 -42
- data/spec/fixtures/password.example.yml +3 -0
- data/spec/fixtures/sem4r.example.yml +6 -0
- data/spec/fixtures/{services/error.xml → soap_error.xml} +0 -0
- data/spec/fixtures/soap_error2.xml +29 -0
- data/spec/helpers/dump_interceptor.rb +90 -0
- data/spec/helpers/fixtures_bulk_mutate_job.rb +48 -0
- data/spec/helpers/fixtures_geo_location.rb +45 -0
- data/{lib/sem4r/campaign_criterion/campaign_criterion_service.rb → spec/helpers/fixtures_info.rb} +10 -6
- data/spec/helpers/fixtures_report_definition.rb +65 -0
- data/spec/{rspec_hash.rb → helpers/rspec_hash.rb} +1 -0
- data/spec/{rspec_matchers.rb → helpers/rspec_matchers.rb} +46 -19
- data/spec/{rspec_sem4r_helper.rb → helpers/rspec_sem4r_helper.rb} +19 -16
- data/spec/{sem4r_stubs.rb → helpers/sem4r_stubs.rb} +5 -4
- data/spec/rspec_helper.rb +4 -4
- data/spec/sem4r/account_spec.rb +2 -3
- data/spec/sem4r/ad_group/ad_group_service_spec.rb +1 -1
- data/spec/sem4r/ad_group/ad_group_spec.rb +1 -1
- data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
- data/spec/sem4r/adwords_spec.rb +62 -39
- data/{lib/sem4r/cli/commands/cli_list_campaign.rb → spec/sem4r/bulk_mutate_job/bulk_mutate_job_selector_spec.rb} +14 -11
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +2 -3
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +23 -17
- data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-req.xml +35 -0
- data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-res.xml +417 -0
- data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-req.xml +106 -0
- data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-res.xml +48 -0
- data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +5 -7
- data/spec/sem4r/campaign/campaign_service_spec.rb +2 -2
- data/spec/sem4r/credentials_spec.rb +10 -8
- data/spec/sem4r/geo_location/address_spec.rb +62 -0
- data/spec/sem4r/geo_location/fixtures/get-req.xml +42 -0
- data/spec/sem4r/geo_location/fixtures/get-res.xml +60 -0
- data/spec/sem4r/info/fixtures/get-req.xml +34 -0
- data/spec/sem4r/info/fixtures/get-res.xml +27 -0
- data/spec/sem4r/nokogiri_parsing_spec.rb +1 -0
- data/spec/sem4r/operation_spec.rb +72 -0
- data/spec/sem4r/report_definition/fixtures/get-list-repdef-req.xml +22 -0
- data/spec/sem4r/report_definition/fixtures/get-list-repdef-res.xml +73 -0
- data/spec/sem4r/report_definition/fixtures/getReportFields-req.xml +24 -0
- data/spec/sem4r/report_definition/fixtures/getReportFields-res.xml +1199 -0
- data/spec/sem4r/report_definition/fixtures/mutate-add-report-req.xml +63 -0
- data/spec/sem4r/report_definition/fixtures/mutate-add-report-res.xml +68 -0
- data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -5
- data/spec/sem4r/report_definition/report_definition_spec.rb +28 -43
- data/{lib/sem4r/cli/commands/cli_list_report.rb → spec/sem4r/report_definition/report_field_spec.rb} +12 -10
- data/spec/sem4r/rexml_parsing_spec.rb +1 -0
- data/spec/sem4r/{services/service_spec.rb → service_spec.rb} +1 -1
- data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +1 -1
- data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +1 -1
- data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +1 -1
- data/spec/sem4r/v13_account/account_service_spec.rb +2 -2
- data/spec/sem4r/v13_report/report_service_spec.rb +2 -2
- data/spec/{sem4r/cli → sem4r_cli}/cli_spec.rb +22 -27
- data/spec/{soap_helpers → sem4r_soap}/soap_attributes_spec.rb +3 -3
- data/spec/{sem4r/services/soap_message_v13_spec.rb → sem4r_soap/soap_response_spec.rb} +10 -15
- data/spec/{sem4r/services/soap_call_spec.rb → sem4r_soap/soap_service_spec.rb} +35 -54
- data/tasks/jeweler.rake +66 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/sem4r.rake +25 -0
- data/tasks/yard.rake +31 -0
- metadata +173 -76
- data/lib/sem4r/ad_extension_override/ad_extension_override_service.rb +0 -30
- data/lib/sem4r/api_counters.rb +0 -8
- data/lib/sem4r/campaign_target/campaign_target_service.rb +0 -30
- data/lib/sem4r/cli/commands/cli_download_report.rb +0 -82
- data/lib/sem4r/services/http_connector.rb +0 -93
- data/lib/sem4r/services/soap_call.rb +0 -122
- data/lib/sem4r/services/soap_connector.rb +0 -139
- data/lib/sem4r/services/soap_message_v13.rb +0 -135
- data/lib/sem4r/services/soap_message_v2010.rb +0 -184
- data/lib/sem4r/v13_traffic_estimator/traffic_estimator_service.rb +0 -30
- data/spec/aggregates_rspec_helper.rb +0 -59
- data/spec/sem4r/report_definition/fixtures/mutate_add-req.xml +0 -24
- data/spec/sem4r/report_definition/fixtures/mutate_add-req_orig.xml +0 -45
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -61,7 +62,10 @@ module Sem4r
|
|
61
62
|
@image = MobileAdImage.new(self, &block)
|
62
63
|
end
|
63
64
|
|
64
|
-
|
65
|
+
#
|
66
|
+
# @private
|
67
|
+
#
|
68
|
+
def _xml(t)
|
65
69
|
t.adGroupId ad_group.id
|
66
70
|
t.ad("xsi:type" => "MobileAd") do |ad|
|
67
71
|
ad.headline headline
|
@@ -83,32 +87,19 @@ module Sem4r
|
|
83
87
|
t.status status
|
84
88
|
end
|
85
89
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
# t.ad("xsi:type" => "MobileAd") do |ad|
|
92
|
-
# ad.headline headline
|
93
|
-
# ad.description description
|
94
|
-
# unless markups.empty?
|
95
|
-
# markups.each do |m|
|
96
|
-
# ad.markupLanguages m
|
97
|
-
# end
|
98
|
-
# end
|
99
|
-
# unless carriers.empty?
|
100
|
-
# carriers.each do |carrier|
|
101
|
-
# ad.mobileCarriers carrier
|
102
|
-
# end
|
103
|
-
# end
|
104
|
-
# ad.businessName business_name
|
105
|
-
# ad.countryCode country_code
|
106
|
-
# ad.phoneNumber phone_number
|
107
|
-
# end
|
108
|
-
# t.status status
|
90
|
+
def xml(t, tag = nil)
|
91
|
+
if tag
|
92
|
+
t.__send__(tag, {"xsi:type" => "AdGroupAd"}) { |t| _xml(t) }
|
93
|
+
else
|
94
|
+
_xml(t)
|
109
95
|
end
|
110
96
|
end
|
111
97
|
|
98
|
+
def to_xml(tag)
|
99
|
+
xml(Builder::XmlMarkup.new, tag)
|
100
|
+
end
|
101
|
+
|
102
|
+
|
112
103
|
def self.from_element(ad_group, el)
|
113
104
|
new(ad_group) do
|
114
105
|
@id = el.at_xpath("id").text.strip.to_i
|
@@ -124,7 +115,7 @@ module Sem4r
|
|
124
115
|
|
125
116
|
def save
|
126
117
|
unless @id
|
127
|
-
soap_message = service.ad_group_ad.create(credentials, to_xml("operand"))
|
118
|
+
soap_message = service.ad_group_ad.create( credentials, to_xml("operand") )
|
128
119
|
add_counters( soap_message.counters )
|
129
120
|
rval = soap_message.response.xpath("//mutateResponse/rval", soap_message.response_headers).first
|
130
121
|
id = rval.xpath("value/ad/id").first
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -38,7 +39,10 @@ module Sem4r
|
|
38
39
|
"#{@id} textad '#{headline}' #{url}"
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
|
+
#
|
43
|
+
# @private
|
44
|
+
#
|
45
|
+
def _xml(t)
|
42
46
|
t.adGroupId ad_group.id
|
43
47
|
t.ad("xsi:type" => "TextAd") do |ad|
|
44
48
|
ad.url url
|
@@ -50,22 +54,22 @@ module Sem4r
|
|
50
54
|
t.status status
|
51
55
|
end
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# ad.headline headline
|
62
|
-
# ad.description1 description1
|
63
|
-
# ad.description2 description2
|
64
|
-
# end
|
65
|
-
# t.status status
|
57
|
+
#
|
58
|
+
# Marshall with Builder::XmlMarkup
|
59
|
+
#
|
60
|
+
def xml(t, tag = nil)
|
61
|
+
if tag
|
62
|
+
t.__send__(tag, "xsi:type" => "AdGroupAd") { |t| _xml(t) }
|
63
|
+
else
|
64
|
+
_xml(t)
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
68
|
+
def to_xml(tag)
|
69
|
+
xml(Builder::XmlMarkup.new, tag)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
69
73
|
def self.from_element(ad_group, el)
|
70
74
|
new(ad_group) do
|
71
75
|
@id = el.at_xpath("id").text.strip.to_i
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -27,7 +28,7 @@ module Sem4r
|
|
27
28
|
# http://code.google.com/apis/adwords/v2009/docs/reference/AdGroupCriterionService.AdGroupCriterion.html
|
28
29
|
#
|
29
30
|
class AdGroupCriterion
|
30
|
-
include SoapAttributes
|
31
|
+
include Sem4rSoap::SoapAttributes
|
31
32
|
|
32
33
|
g_accessor :criterion
|
33
34
|
|
@@ -51,7 +52,7 @@ module Sem4r
|
|
51
52
|
unless criterion.saved?
|
52
53
|
o = AdGroupCriterionOperation.new.add(self)
|
53
54
|
soap_message =
|
54
|
-
criterion.service.ad_group_criterion.mutate(
|
55
|
+
criterion.service.ad_group_criterion.mutate( credentials, o.to_xml("operations") )
|
55
56
|
criterion.add_counters( soap_message.counters )
|
56
57
|
rval = soap_message.response.xpath("//mutateResponse/rval").first
|
57
58
|
id = rval.xpath("value/criterion/id").first
|
@@ -84,24 +85,25 @@ module Sem4r
|
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
def
|
88
|
+
def _xml(t)
|
88
89
|
t.adGroupId @ad_group.id
|
89
90
|
# t.status "ENABLED"
|
90
91
|
criterion.xml(t)
|
91
92
|
@bids.xml(t) if @bids
|
92
93
|
end
|
93
94
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
# # t.status "ENABLED"
|
100
|
-
# criterion.to_xml(t)
|
101
|
-
# @bids.to_xml(t) if @bids
|
95
|
+
def xml(t, tag = nil)
|
96
|
+
if tag
|
97
|
+
t.__send__(tag, {"xsi:type" => "BiddableAdGroupCriterion"}) { |t| _xml(t) }
|
98
|
+
else
|
99
|
+
_xml(t)
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
103
|
+
def to_xml(tag)
|
104
|
+
xml(Builder::XmlMarkup.new, tag)
|
105
|
+
end
|
106
|
+
|
105
107
|
end
|
106
108
|
|
107
109
|
class NegativeAdGroupCriterion < AdGroupCriterion
|
@@ -123,22 +125,28 @@ module Sem4r
|
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
126
|
-
|
128
|
+
# @private
|
129
|
+
#
|
130
|
+
#
|
131
|
+
def _xml(t)
|
127
132
|
t.adGroupId criterion.ad_group.id
|
128
133
|
# t.status "ENABLED"
|
129
134
|
criterion.xml(t)
|
130
135
|
end
|
131
136
|
|
132
|
-
def
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
# # t.status "ENABLED"
|
138
|
-
# criterion.to_xml(t)
|
137
|
+
def xml(t, tag = nil)
|
138
|
+
if tag
|
139
|
+
t.__send__(tag, {"xsi:type" => "NegativeAdGroupCriterion"}) { |t| _xml(t) }
|
140
|
+
else
|
141
|
+
_xml(t)
|
139
142
|
end
|
140
143
|
end
|
141
144
|
|
145
|
+
def to_xml(tag)
|
146
|
+
xml(Builder::XmlMarkup.new, tag)
|
147
|
+
end
|
148
|
+
|
149
|
+
|
142
150
|
end
|
143
151
|
|
144
152
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -25,7 +26,7 @@
|
|
25
26
|
module Sem4r
|
26
27
|
|
27
28
|
class AdGroupCriterionBids
|
28
|
-
include SoapAttributes
|
29
|
+
include Sem4rSoap::SoapAttributes
|
29
30
|
|
30
31
|
enum :Types, [
|
31
32
|
:BudgetOptimizerAdGroupCriterionBids,
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,8 +23,11 @@
|
|
22
23
|
# -------------------------------------------------------------------
|
23
24
|
|
24
25
|
module Sem4r
|
25
|
-
|
26
|
-
|
26
|
+
|
27
|
+
#
|
28
|
+
# @private
|
29
|
+
#
|
30
|
+
class AdGroupCriterionService < Sem4rSoap::SoapServiceV2010 #:nodoc: all
|
27
31
|
|
28
32
|
def initialize(connector)
|
29
33
|
@connector = connector
|
@@ -31,10 +35,11 @@ module Sem4r
|
|
31
35
|
@header_namespace = @service_namespace
|
32
36
|
|
33
37
|
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdGroupCriterionService"
|
38
|
+
init(@header_namespace, @service_namespace)
|
34
39
|
end
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
soap_call :all, :mutate => false
|
42
|
+
soap_call :mutate
|
38
43
|
|
39
44
|
private
|
40
45
|
|
@@ -52,6 +52,8 @@ module Sem4r
|
|
52
52
|
"#{@id} #{@index} #{@text}"
|
53
53
|
end
|
54
54
|
|
55
|
+
# @private
|
56
|
+
#
|
55
57
|
# adGroupId Id of ad_group This field is required and should not be null.
|
56
58
|
# criterionId The id of the Keyword criterion that this ad parameter applies to.
|
57
59
|
# The keyword must be associated with the same ad_group as this AdParam.
|
@@ -61,16 +63,30 @@ module Sem4r
|
|
61
63
|
# within Operators : SET. The length of this string should be
|
62
64
|
# between 1 and 25, inclusive.
|
63
65
|
# paramIndex
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
def _xml(t)
|
67
|
+
t.adGroupId @ad_group.id
|
68
|
+
t.criterionId @criterion.id
|
69
|
+
t.insertionText @text
|
70
|
+
t.paramIndex @index
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Marshall to xml
|
75
|
+
# @param [Builder::XmlMarkup]
|
76
|
+
#
|
77
|
+
def xml(t, tag = nil)
|
78
|
+
if tag
|
79
|
+
t.__send__(tag) { |t| _xml(t) }
|
80
|
+
else
|
81
|
+
_xml(t)
|
71
82
|
end
|
72
83
|
end
|
73
84
|
|
85
|
+
def to_xml(tag)
|
86
|
+
xml(Builder::XmlMarkup.new, tag)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
74
90
|
def self.from_element(ad_group, el)
|
75
91
|
criterion_id = el.at_xpath("criterionId").text.strip.to_i
|
76
92
|
criterion = ad_group.find_criterion(criterion_id)
|
@@ -85,7 +101,7 @@ module Sem4r
|
|
85
101
|
def save
|
86
102
|
return if @saved
|
87
103
|
o = AdParamOperation.new.set( self )
|
88
|
-
soap_message = service.ad_param.mutate(credentials, o.to_xml("operations") )
|
104
|
+
soap_message = service.ad_param.mutate( credentials, o.to_xml("operations") )
|
89
105
|
add_counters( soap_message.counters )
|
90
106
|
# ignore response ad_param doesn't have id
|
91
107
|
@saved = true
|
@@ -23,21 +23,24 @@
|
|
23
23
|
# -------------------------------------------------------------------------
|
24
24
|
|
25
25
|
module Sem4r
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
#
|
28
|
+
# @private
|
29
|
+
#
|
30
|
+
class AdParamService < Sem4rSoap::SoapServiceV2010
|
28
31
|
|
29
32
|
def initialize(connector)
|
30
33
|
@connector = connector
|
31
|
-
|
32
34
|
@service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
|
33
35
|
@header_namespace = @service_namespace
|
34
36
|
|
35
37
|
@sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdParamService"
|
36
38
|
@production_service_url = "https://adwords.google.com/api/adwords/cm/v201008/AdParamService"
|
39
|
+
init(@header_namespace, @service_namespace)
|
37
40
|
end
|
38
41
|
|
39
|
-
|
40
|
-
|
42
|
+
soap_call :all, :mutate => false
|
43
|
+
soap_call :mutate
|
41
44
|
|
42
45
|
private
|
43
46
|
|