Class: PPC::API::Baidu::Group
Constant Summary
collapse
- Service =
'Adgroup'
- GroupType =
{
plan_id: :campaignId,
id: :adgroupId,
name: :adgroupName,
price: :maxPrice,
negative: :negativeWords,
exact_negative: :exactNegativeWords,
pause: :pause,
status: :status,
price_ratio: :priceRatio,
accu_price_factor: :accuPriceFactor,
word_price_factor: :wordPriceFactor,
wide_price_factor: :widePriceFactor,
match_price_status: :matchPriceStatus,
}
Class Method Summary
collapse
process, request_uri
Methods included from PPC::API
#make_type, #process, #request, #request_http_body, #request_http_header, #request_uri, #reverse_type
Class Method Details
.add(auth, groups) ⇒ Object
49
50
51
52
53
|
# File 'lib/ppc/api/baidu/group.rb', line 49
def self.add( auth, groups )
body = {adgroupTypes: make_type( groups ) }
response = request( auth, Service, "addAdgroup", body )
process( response, 'adgroupTypes' ){ |x| reverse_type(x) }
end
|
.all(auth, plan_ids) ⇒ Object
31
32
33
34
35
|
# File 'lib/ppc/api/baidu/group.rb', line 31
def self.all( auth, plan_ids )
body = { ids: plan_ids, idType: 3, adgroupFields: GroupType.values}
response = request(auth, Service, 'getAdgroup', body)
process( response, 'campaignAdgroups' ){ |x|reverse_type(x) }
end
|
.delete(auth, ids) ⇒ Object
61
62
63
64
65
|
# File 'lib/ppc/api/baidu/group.rb', line 61
def self.delete( auth, ids )
body = { adgroupIds: ids }
response = request( auth, Service,"deleteAdgroup", body )
process( response, 'nil' ){ |x| x }
end
|
.enable(auth, ids) ⇒ Object
67
68
69
70
|
# File 'lib/ppc/api/baidu/group.rb', line 67
def self.enable( auth, ids )
groups = ids.map{|id| {id: id, pause: false} }
self.update( auth, groups )
end
|
.get(auth, ids) ⇒ Object
43
44
45
46
47
|
# File 'lib/ppc/api/baidu/group.rb', line 43
def self.get( auth, ids )
body = {ids: ids, idType: 5, adgroupFields: GroupType.values}
response = request(auth, Service, "getAdgroup",body )
process( response, 'adgroupTypes' ){ |x| reverse_type( x ) }
end
|
.ids(auth, plan_ids) ⇒ Object
37
38
39
40
41
|
# File 'lib/ppc/api/baidu/group.rb', line 37
def self.ids( auth, plan_ids )
body = {ids: plan_ids, idType: 3, adgroupFields: [:adgroupId]}
response = request(auth, Service, "getAdgroup",body )
process( response, 'campaignAdgroupIds' ){ |x| reverse_type( x ) }
end
|
.info(auth, ids) ⇒ Object
25
26
27
28
29
|
# File 'lib/ppc/api/baidu/group.rb', line 25
def self.info( auth, ids)
body = {ids: ids, idType: 5, adgroupFields: GroupType.values}
response = request(auth, Service, "getAdgroup",body )
process( response, 'adgroupType' ){ |x| reverse_type( x )[0] }
end
|
.pause(auth, ids) ⇒ Object
72
73
74
75
|
# File 'lib/ppc/api/baidu/group.rb', line 72
def self.pause( auth, ids )
groups = ids.map{|id| {id: id, pause: true} }
self.update( auth, groups )
end
|
.update(auth, groups) ⇒ Object
55
56
57
58
59
|
# File 'lib/ppc/api/baidu/group.rb', line 55
def self.update( auth, groups )
body = {adgroupTypes: make_type( groups )}
response = request( auth, Service, "updateAdgroup",body )
process( response, 'adgroupTypes' ){ |x| reverse_type(x) }
end
|