Class: PPC::API::Sogou::Plan

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

Constant Summary collapse

Service =
'CpcPlan'

Class Method Summary collapse

Methods inherited from PPC::API::Sogou

debug_print, process, request, reverse_type

Methods included from PPC::API

#debug_off, #debug_on, #is_no_quota, #make_type, #process, #request, #request_http_body, #request_http_header, #request_uri, #reverse_type

Class Method Details

.add(auth, plans) ⇒ Object



42
43
44
45
46
47
# File 'lib/ppc/api/sogou/plan.rb', line 42

def self.add( auth, plans )
  cpcPlanTypes = make_type( plans )
  body = { cpcPlanTypes: cpcPlanTypes }
  response = request( auth, Service, 'addCpcPlan', body)
  process( response, 'cpcPlanTypes' ){ |x| reverse_type(x) }
end

.all(auth) ⇒ Object



25
26
27
28
# File 'lib/ppc/api/sogou/plan.rb', line 25

def self.all( auth )
  response = request( auth, Service, 'getAllCpcPlan' )
  process( response, 'cpcPlanTypes' ){ |x| reverse_type(x) }
end

.delete(auth, ids) ⇒ Object



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

def self.delete(auth, ids )
  ids = [ ids ] unless ids.class == Array
  body = { cpcPlanIds: ids }
  response = request( auth, Service, 'deleteCpcPlan', body)
  process( response, '' ){ |x| x }
end

.get(auth, ids) ⇒ Object



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

def self.get( auth, ids )
  ids = [ ids ] unless ids.is_a? Array
  body = { cpcPlanIds: ids }
  response = request( auth, Service, 'getCpcPlanByCpcPlanId', body)
  process( response, 'cpcPlanTypes' ){ |x| reverse_type(x) }
end

.ids(auth) ⇒ Object



30
31
32
33
# File 'lib/ppc/api/sogou/plan.rb', line 30

def self.ids( auth )
  response = request( auth, Service, 'getAllCpcPlanId' )
  process( response, 'cpcPlanIds' ){ |x| x }
end

.update(auth, plans) ⇒ Object



49
50
51
52
53
54
# File 'lib/ppc/api/sogou/plan.rb', line 49

def self.update( auth, plans )
  cpcPlanTypes = make_type( plans )
  body = { cpcPlanTypes: cpcPlanTypes }
  response = request( auth, Service, 'updateCpcPlan', body)
  process( response, 'cpcPlanTypes' ){ |x| reverse_type(x) }
end