ppc 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19d5dd3425ac8c7c2b9220fd545f142f11cda038
4
- data.tar.gz: abdcd8fa6abc20899bec3ccaee42114706a8e457
3
+ metadata.gz: 9bc06d2e73e1d498cbf369c743fd5fdcb7015114
4
+ data.tar.gz: 0cef07098f06fc77cd474a38629d759094463ef7
5
5
  SHA512:
6
- metadata.gz: ecc13b4fc4854e868b71c15c74b340fcd7c830e458b890cc5eeec09b1e2819919ab49e1c85850e186ee4796c55fe547b5b8b2905154effbe3ae2c2b1222a0917
7
- data.tar.gz: cf417167ce262fd231be55a72394b398368fb49b11ee74a1f252810ede2a59d2a3253d9acc5ba39d8b2a3be0c47a78f7db59e364f0b9e6c16f1e058b0ce5dfee
6
+ metadata.gz: 793f672f0b5e77ce0ed4fda22c5bbb0b3155616f9e37d0b34b23431a6e7b33f2e72d9717de3c489283639d248998250c0c66d14a3911406de1e8c0e326990454
7
+ data.tar.gz: 5990ce108ac0dc8b29d0a73e7bffb4be9f891dd13aba13e86d7655e2f70f8c7111b4986eb6a60bfaad27ca9b7313bf55b4fa1473972e8c63e10fb9a285325e16
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/ppc.svg)](https://badge.fury.io/rb/ppc)
2
+
1
3
  ppc
2
4
  ===
3
5
 
data/lib/ppc.rb CHANGED
@@ -3,7 +3,7 @@ require 'ppc/operation'
3
3
  require 'ppc/ext'
4
4
  module PPC
5
5
 
6
- VERSION = "2.0.0"
6
+ VERSION = "2.0.1"
7
7
 
8
8
  protected
9
9
  def print_debug(var,varname=nil)
@@ -11,6 +11,7 @@ module PPC
11
11
  queryword: :queryword,
12
12
  plan_id: :campaignId,
13
13
  creative_id: :creativeId,
14
+ creative_name: :creativeName,
14
15
  keyword: :keyword,
15
16
  views: :views,
16
17
  clicks: :clicks,
@@ -1,4 +1,6 @@
1
1
  # -*- coding:utf-8 -*-
2
+ require "open-uri"
3
+ require "zip"
2
4
  module PPC
3
5
  module API
4
6
  class Sogou
@@ -63,6 +65,18 @@ module PPC
63
65
  end
64
66
  end
65
67
 
68
+ def self.rank_report(auth, device = 0, debug)
69
+ url = download_cpc_rank(auth, device)[:result]
70
+ file = "sogou_rank_#{Time.now.to_i}.zip"
71
+ File.open(file, "w"){|f| f.puts open(url).read}
72
+ content = Zip::File.open(file) do |zip_file|
73
+ entry = zip_file.glob('*.csv').first
74
+ content = entry.get_input_stream.read.force_encoding('gb18030').encode('utf-8')
75
+ end
76
+ File.delete(file)
77
+ content
78
+ end
79
+
66
80
  end
67
81
  end
68
82
  end
@@ -81,8 +81,7 @@ module PPC
81
81
  end
82
82
  end
83
83
 
84
- def self.query_report( auth, param = nil, debug = false )
85
- param = {} if not param
84
+ def self.query_report( auth, param = {}, debug = false )
86
85
  param[:type] ||= 'query'
87
86
  param[:fields] ||= %w(click)
88
87
  param[:range] ||= 'account'
@@ -90,16 +89,14 @@ module PPC
90
89
  download_report( auth, param, debug )
91
90
  end
92
91
 
93
- def self.creative_report( auth, param = nil, debug = false )
94
- param = {} if not param
92
+ def self.creative_report( auth, param = {}, debug = false )
95
93
  param[:type] ||= 'creative'
96
94
  param[:fields] ||= %w( cost cpc click impression ctr )
97
95
  param[:range] ||= 'account'
98
96
  download_report( auth, param, debug )
99
97
  end
100
98
 
101
- def self.keyword_report( auth, param = nil, debug = false )
102
- param = {} if not param
99
+ def self.keyword_report( auth, param = {}, debug = false )
103
100
  param[:type] ||= 'keyword'
104
101
  param[:fields] ||= %w( cost cpc click impression ctr )
105
102
  param[:range] ||= 'account'
@@ -2,22 +2,26 @@ module PPC
2
2
  module Operation
3
3
  module Report
4
4
 
5
- def download_report( param = nil, debug = false )
5
+ def download_report( param = {}, debug = false )
6
6
  call( "report" ).download_report( @auth, param, debug )
7
7
  end
8
8
 
9
- def query_report( param = nil, debug = false )
9
+ def query_report( param = {}, debug = false )
10
10
  call( "report" ).query_report( @auth, param, debug )
11
11
  end
12
12
 
13
- def creative_report( param = nil, debug = false )
13
+ def creative_report( param = {}, debug = false )
14
14
  call( "report" ).creative_report( @auth, param, debug )
15
15
  end
16
16
 
17
- def keyword_report( param = nil, debug = false )
17
+ def keyword_report( param = {}, debug = false )
18
18
  call( "report" ).keyword_report( @auth, param, debug )
19
19
  end
20
20
 
21
+ def rank_report( device = 0, debug = false )
22
+ call( "bulk" ).rank_report( @auth, device, debug)
23
+ end
24
+
21
25
  end
22
26
  end
23
27
  end
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'httparty', '~> 0.13', '>= 0.13.0'
30
30
  spec.add_dependency 'savon', '~> 3.0', '>= 3.0.0'
31
31
  spec.add_dependency 'awesome_print'
32
+ spec.add_dependency 'rubyzip'
32
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chienli Ma
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-08-04 00:00:00.000000000 Z
14
+ date: 2016-08-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubyzip
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
70
84
  description: ppc api for baidu qihu sogou sm
71
85
  email:
72
86
  - maqianlie@gmail.com