Class: PPC::API::Sogou::Group

Inherits:
PPC::API::Sogou show all
Defined in:
lib/ppc/api/sogou/group.rb

Constant Summary collapse

Service =
'CpcGrp'
GroupType =
{
  plan_id:        :cpcPlanId,
  id:             :cpcGrpId,
  name:           :cpcGrpName,
  price:          :maxPrice,
  negative:       :negativeWords,
  exact_negative: :exactNegativeWords,
  pause:          :pause,
  status:         :status,
  opt:            :opt,
  "plan_id" =>    :cpc_plan_id,
  "id" =>         :cpc_grp_id,
  "plan_name" =>  :cpc_plan_name,
  "name" =>       :cpc_grp_name,
  "price" =>      :max_price,
}

Class Method Summary collapse

Methods inherited from PPC::API::Sogou

debug_print, process, request

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



46
47
48
49
50
# File 'lib/ppc/api/sogou/group.rb', line 46

def self.add( auth, groups )
  body = {cpcGrpTypes: make_type( groups ) }
  response = request( auth, Service, "addCpcGrp", body  )
  process( response, 'cpc_grp_types' ){ |x| reverse_type(x) }
end

.all(auth, plan_ids) ⇒ Object



31
32
33
34
# File 'lib/ppc/api/sogou/group.rb', line 31

def self.all( auth, plan_ids )
  response = request( auth, Service ,"getCpcGrpByCpcPlanId",  {cpcPlanIds: plan_ids} )
  process( response, 'cpc_plan_grps' ){ |x| reverse_type( x[:cpc_grp_types] ) }
end

.delete(auth, ids) ⇒ Object



58
59
60
61
# File 'lib/ppc/api/sogou/group.rb', line 58

def self.delete( auth, ids )
  response = request( auth, Service,"deleteCpcGrp", {cpcGrpIds: ids} )
  process( response, '' ){ |x| x }
end

.enable(auth, ids) ⇒ Object



63
64
65
66
# File 'lib/ppc/api/sogou/group.rb', line 63

def self.enable( auth, ids )
  groups = ids.map{|id| {id: id, pause: false} }
  self.update( auth, groups )
end

.get(auth, ids) ⇒ Object



41
42
43
44
# File 'lib/ppc/api/sogou/group.rb', line 41

def self.get( auth, ids )
  response = request(auth, Service, "getCpcGrpByCpcGrpId", {cpcGrpIds: ids} )
  process( response, 'cpc_grp_types' ){ |x| reverse_type(x) }
end

.ids(auth, plan_ids) ⇒ Object



36
37
38
39
# File 'lib/ppc/api/sogou/group.rb', line 36

def self.ids( auth, plan_ids )
  response = request( auth, Service ,"getCpcGrpIdByCpcPlanId",  {cpcPlanIds: plan_ids} )
  process( response, 'cpcPlanGrpIds' ){ |x| reverse_type( x ) }
end

.info(auth, ids) ⇒ Object



26
27
28
29
# File 'lib/ppc/api/sogou/group.rb', line 26

def self.info( auth, ids)
  response = request(auth, Service, "getCpcGrpByCpcGrpId", {cpcGrpIds: ids} )
  process( response, 'cpc_grp_types' ){ |x| reverse_type(x)[0] }
end

.pause(auth, ids) ⇒ Object



68
69
70
71
# File 'lib/ppc/api/sogou/group.rb', line 68

def self.pause( auth, ids )
  groups = ids.map{|id| {id: id, pause: true} }
  self.update( auth, groups )
end

.update(auth, groups) ⇒ Object



52
53
54
55
56
# File 'lib/ppc/api/sogou/group.rb', line 52

def self.update( auth, groups )
  body = {cpcGrpTypes: make_type( groups )}
  response = request( auth, Service, "updateCpcGrp",body )
  process( response, 'cpc_grp_types' ){ |x| reverse_type(x) }
end