Class: PPC::API::Sogou::Bulk
Constant Summary
collapse
- Service =
'AccountDownload'
Class Method Summary
collapse
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
.download(auth, ids = nil) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/ppc/api/sogou/bulk.rb', line 28
def self.download( auth, ids = nil)
result = get_all_object(auth, ids)
field_id = result[:result]
loop do
status = get_file_state(auth, field_id)
return get_file_path(auth, field_id) if status[:result] == '1'
sleep 15
end
end
|
.download_cpc_rank(auth, device = 0) ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/ppc/api/sogou/bulk.rb', line 56
def self.download_cpc_rank(auth, device = 0)
result = get_cpc_rank(auth, device)
rank_id = result[:result]
loop do
status = get_cpc_rank_status(auth, rank_id)
return get_cpc_rank_path(auth, rank_id) if status[:result] == '1'
sleep 15
end
end
|
.get_all_object(auth, ids) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/ppc/api/sogou/bulk.rb', line 8
def self.get_all_object( auth, ids )
body = nil
body = { 'cpcPlanIds' => ids } if ids
response = request( auth, Service, 'getAccountFile', body )
process( response, 'accountFileId' ){ |x| x }
end
|
.get_cpc_rank(auth, device) ⇒ Object
38
39
40
41
42
|
# File 'lib/ppc/api/sogou/bulk.rb', line 38
def self.get_cpc_rank(auth, device)
body = {'deviceType' => device}
response = request(auth, 'CpcRank', 'getCpcRankId', body)
process(response, 'rankId'){|x| x}
end
|
.get_cpc_rank_path(auth, rank_id) ⇒ Object
50
51
52
53
54
|
# File 'lib/ppc/api/sogou/bulk.rb', line 50
def self.get_cpc_rank_path(auth, rank_id)
body = {'rankId' => rank_id}
response = request(auth, 'CpcRank', 'getCpcRankPath', body)
process(response, 'rankPath'){|x| x}
end
|
.get_cpc_rank_status(auth, rank_id) ⇒ Object
44
45
46
47
48
|
# File 'lib/ppc/api/sogou/bulk.rb', line 44
def self.get_cpc_rank_status(auth, rank_id)
body = {'rankId' => rank_id}
response = request(auth, 'CpcRank', 'getCpcRankStatus', body)
process(response, 'isGenerated' ){|x| x }
end
|
.get_file_path(auth, id) ⇒ Object
22
23
24
25
26
|
# File 'lib/ppc/api/sogou/bulk.rb', line 22
def self.get_file_path(auth, id)
body = {'accountFileId' => id}
response = request(auth, Service, 'getAccountFilePath', body)
process(response, 'accountFilePath'){|x| x}
end
|
.get_file_state(auth, id) ⇒ Object
16
17
18
19
20
|
# File 'lib/ppc/api/sogou/bulk.rb', line 16
def self.get_file_state( auth, id )
body = { 'accountFileId' => id }
response = request( auth, Service, 'getAccountFileStatus' , body )
process( response, 'isGenerated' ){ |x| x }
end
|