ppc 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c1ffce2f8c4545b7ae1489322d55a0ef2c03511
4
- data.tar.gz: 58e7f48a6389464bf1c9a68d5f01c6d27f4546d6
3
+ metadata.gz: bb284288f99cec5c5170ca7be5ed1d1905794f8b
4
+ data.tar.gz: c49847b4b734897d5e4358fed6d9b2bed226dd9d
5
5
  SHA512:
6
- metadata.gz: 4e9518dd1d57f4dd9a053b8ba3fc1e18e5821eecc928421e360127d51b2e31203268d830fbd54741b00ab4141258c4baf36ccc084527453b08cdaeee2096f66d
7
- data.tar.gz: e789f19103d66d2cac478bb27372b1c207b2a5b53eaeba1036d380b9d8afa47290d02b672fb7d5cd4d19d8b06559cf4a91f8f29b61c0c5eea5078859eaed9c83
6
+ metadata.gz: dd447a7473731993f10ca59449c25bfd3142043f480fdfe7566a729236aefce86d03bba22c268b15c74b2b0645fef8011ccf61a436e5d47f68029a3c5fafc191
7
+ data.tar.gz: 57c25853c560096966e8541907c1b65afd46fbf5dc6b27f58258057106356134cbd6db260ea4532b44e9705ae54bb40a58c1207943759d20698127cf36b4f963
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.4"
6
+ VERSION = "2.0.5"
7
7
 
8
8
  protected
9
9
  def print_debug(var,varname=nil)
@@ -62,7 +62,8 @@ module PPC
62
62
  else
63
63
  response = http.post(uri.path, http_body, http_header)
64
64
  end
65
- begin JSON.parse(response.body) rescue response.body end
65
+ qihu_quota = begin response.to_hash["quotaremain"][0].to_i rescue nil end
66
+ begin JSON.parse(response.body).merge(qihu_quota: qihu_quota) rescue response.body end
66
67
  end
67
68
 
68
69
  def process( response, key, &func)
@@ -105,6 +105,20 @@ module PPC
105
105
  process(response, 'groupKeywords' ){|x| reverse_type( x , KeywordQualityType) }
106
106
  end
107
107
 
108
+ def self.search( auth, params )
109
+ body = {
110
+ searchWord: params[:keyword],
111
+ startNum: 1,
112
+ endNum: 1000,
113
+ searchLevel: 2,
114
+ searchType: 1,
115
+ }
116
+ body.merge!(campaignId: params[:plan_id]) if params[:plan_id]
117
+ body.merge!(adgroupId: params[:group_id]) if params[:group_id]
118
+ response = request( auth, "Search", 'getMaterialInfoBySearch', body )
119
+ process(response, 'materialSearchInfos' ){|x| x[0]["materialSearchInfos"].map{|tmp| tmp["materialInfos"]} }
120
+ end
121
+
108
122
  end # keyword
109
123
  end # Baidu
110
124
  end # API
@@ -38,6 +38,7 @@ module PPC
38
38
  result[:failure] = response['failures'] || response["failure_key"]
39
39
  result[:result] = (key.empty? ? func[response] : func[response[key]]) rescue nil
40
40
  result[:no_quota] = (response['failures']['code'] == '90401') rescue false
41
+ result[:rquota] = response[:qihu_quota] rescue 0
41
42
  result
42
43
  end
43
44
 
@@ -41,6 +41,10 @@ module PPC
41
41
  # report operations
42
42
  include ::PPC::Operation::Report
43
43
 
44
+ def search_keyword( keyword )
45
+ call( "keyword" ).search( @auth, {keyword: keyword})
46
+ end
47
+
44
48
  end
45
49
  end
46
50
  end
@@ -44,6 +44,10 @@ module PPC
44
44
  def add_creative( creatives )
45
45
  call( "creative" ).add( @auth, creatives.map{|creative| creative.merge(group_id: @id)} )
46
46
  end
47
+
48
+ def search_keyword( keyword )
49
+ call( "keyword" ).search( @auth, {group_id: @id, keyword: keyword})
50
+ end
47
51
 
48
52
  end # Group
49
53
  end # Operation
@@ -53,6 +53,9 @@ module PPC
53
53
  call( "group" ).add( @auth, groups.map{|group| group.merge(plan_id: @id)} )
54
54
  end
55
55
 
56
+ def search_keyword( keyword )
57
+ call( "keyword" ).search( @auth, {plan_id: @id, keyword: keyword})
58
+ end
56
59
 
57
60
  end # class plan
58
61
  end # mudole Opeartion
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.4
4
+ version: 2.0.5
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-11-28 00:00:00.000000000 Z
14
+ date: 2017-03-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.5.1
204
+ rubygems_version: 2.6.10
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: ppc api for baidu qihu sogou sm