sogou-search-api 0.0.2 → 1.0.0
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 +4 -4
- data/README.md +2 -2
- data/examples/account.rb +1 -1
- data/examples/{promotion_group.rb → group.rb} +2 -2
- data/examples/keyword.rb +2 -2
- data/examples/plan.rb +1 -1
- data/examples/report.rb +9 -6
- data/lib/sogou/search/api/service/account.rb +1 -1
- data/lib/sogou/search/api/service/{promotion_group.rb → group.rb} +3 -3
- data/lib/sogou/search/api/service/keyword.rb +2 -2
- data/lib/sogou/search/api/service/plan.rb +2 -2
- data/lib/sogou/search/api/service/report.rb +28 -11
- data/lib/sogou/search/api/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 212e0b4f9985d050cfea03fab33a37fc5afeebd8
|
4
|
+
data.tar.gz: a93c9352ce35f492c48ab48c695e3e2d15d4997d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d10c831226a9f614729525e78cc61ff9debc9f30aab980b6464af7885beee853a70fb9dda12c0dc7bd90f7bba4860175ac3c8ad4ce31c81321da6771d6f1e9da
|
7
|
+
data.tar.gz: f7d0e47364f63f6409244a0f0f57f71acc0fac2e1b06cc5f37296509d433e41fb377b329488366b73cd879830335beaf17f64caca7f07aef31d8cb7544dc0316
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ include Sogou::Search::Api
|
|
45
45
|
|
46
46
|
account = Service::Account.new
|
47
47
|
account.authorization = Auth.get_application_default
|
48
|
-
account.get_account_info(convert_regions_to_string: true) do |result, err|
|
48
|
+
account.get_account_info(options: { convert_regions_to_string: true }) do |result, err|
|
49
49
|
if err != nil
|
50
50
|
p err
|
51
51
|
else
|
@@ -62,7 +62,7 @@ returning the result from the call or raising the error. Example:
|
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
# Read account info
|
65
|
-
account.get_account_info(convert_regions_to_string: true) do |result, err|
|
65
|
+
account.get_account_info(options: { convert_regions_to_string: true }) do |result, err|
|
66
66
|
if err
|
67
67
|
# Handle error
|
68
68
|
else
|
data/examples/account.rb
CHANGED
@@ -13,7 +13,7 @@ include Sogou::Search::Api
|
|
13
13
|
|
14
14
|
account = Service::Account.new
|
15
15
|
account.authorization = Auth.get_application_default
|
16
|
-
account.get_account_info(convert_regions_to_string: true) do |result, err|
|
16
|
+
account.get_account_info(options: {convert_regions_to_string: true}) do |result, err|
|
17
17
|
if err != nil
|
18
18
|
p err
|
19
19
|
else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'sogou/search/api/auth'
|
2
2
|
require 'sogou/search/api/service/plan'
|
3
|
-
require 'sogou/search/api/service/
|
3
|
+
require 'sogou/search/api/service/group'
|
4
4
|
|
5
5
|
#
|
6
6
|
# Set your Sogou api credentials to ENVs
|
@@ -15,7 +15,7 @@ plan = Service::Plan.new
|
|
15
15
|
plan.authorization = Auth.get_application_default
|
16
16
|
plan_ids = plan.get_all_cpc_plan_id.slice(0, 2)
|
17
17
|
|
18
|
-
group = Service::
|
18
|
+
group = Service::Group.new
|
19
19
|
group.authorization = Auth.get_application_default
|
20
20
|
group.get_cpc_grp_by_cpc_plan_id(plan_ids) do |result, err|
|
21
21
|
if err != nil
|
data/examples/keyword.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'sogou/search/api/auth'
|
2
2
|
require 'sogou/search/api/service/plan'
|
3
|
-
require 'sogou/search/api/service/
|
3
|
+
require 'sogou/search/api/service/group'
|
4
4
|
require 'sogou/search/api/service/keyword'
|
5
5
|
|
6
6
|
#
|
@@ -16,7 +16,7 @@ plan = Service::Plan.new
|
|
16
16
|
plan.authorization = Auth.get_application_default
|
17
17
|
plan_ids = plan.get_all_cpc_plan_id.slice(0, 2)
|
18
18
|
|
19
|
-
group = Service::
|
19
|
+
group = Service::Group.new
|
20
20
|
group.authorization = Auth.get_application_default
|
21
21
|
group_ids = group.get_cpc_grp_id_by_cpc_plan_id(plan_ids).
|
22
22
|
map { |id| id['cpc_grp_ids'] }.flatten.slice(0, 2)
|
data/examples/plan.rb
CHANGED
@@ -12,7 +12,7 @@ include Sogou::Search::Api
|
|
12
12
|
|
13
13
|
plan = Service::Plan.new
|
14
14
|
plan.authorization = Auth.get_application_default
|
15
|
-
plan.get_all_cpc_plan(convert_regions_to_string: true) do |result, err|
|
15
|
+
plan.get_all_cpc_plan(options: {convert_regions_to_string: true}) do |result, err|
|
16
16
|
if err != nil
|
17
17
|
p err
|
18
18
|
else
|
data/examples/report.rb
CHANGED
@@ -12,12 +12,15 @@ include Sogou::Search::Api
|
|
12
12
|
|
13
13
|
report = Service::Report.new
|
14
14
|
report.authorization = Auth.get_application_default
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
|
16
|
+
request = Service::ReportRequest.new
|
17
|
+
request.fields = %w[cost cpc click ctr impression position]
|
18
|
+
request.start_date = '2018-02-20T00:00:00'
|
19
|
+
request.end_date = '2018-02-20T23:59:59'
|
20
|
+
request.type = 2
|
21
|
+
request.platform = 2
|
22
|
+
|
23
|
+
report_id = report.get_report_id(request)
|
21
24
|
|
22
25
|
state = '0'
|
23
26
|
max_try = 10
|
@@ -4,12 +4,12 @@ module Sogou
|
|
4
4
|
module Search
|
5
5
|
module Api
|
6
6
|
module Service
|
7
|
-
class
|
7
|
+
class Group < Core::BaseService
|
8
8
|
def initialize
|
9
9
|
super('CpcGrpService')
|
10
10
|
end
|
11
11
|
|
12
|
-
def get_cpc_grp_by_cpc_plan_id(plan_ids, options
|
12
|
+
def get_cpc_grp_by_cpc_plan_id(plan_ids, options: {}, &block)
|
13
13
|
command = make_command(
|
14
14
|
:get_cpc_grp_by_cpc_plan_id,
|
15
15
|
params: { cpc_plan_ids: plan_ids },
|
@@ -18,7 +18,7 @@ module Sogou
|
|
18
18
|
execute_command(command, &block)
|
19
19
|
end
|
20
20
|
|
21
|
-
def get_cpc_grp_id_by_cpc_plan_id(plan_ids, options
|
21
|
+
def get_cpc_grp_id_by_cpc_plan_id(plan_ids, options: {}, &block)
|
22
22
|
command = make_command(
|
23
23
|
:get_cpc_grp_id_by_cpc_plan_id,
|
24
24
|
params: { cpc_plan_ids: plan_ids },
|
@@ -9,7 +9,7 @@ module Sogou
|
|
9
9
|
super('CpcService')
|
10
10
|
end
|
11
11
|
|
12
|
-
def get_cpc_by_cpc_grp_id(grp_ids, valid_keyword_only
|
12
|
+
def get_cpc_by_cpc_grp_id(grp_ids, valid_keyword_only: true, options: {}, &block)
|
13
13
|
command = make_command(
|
14
14
|
:get_cpc_by_cpc_grp_id,
|
15
15
|
params: {
|
@@ -21,7 +21,7 @@ module Sogou
|
|
21
21
|
execute_command(command, &block)
|
22
22
|
end
|
23
23
|
|
24
|
-
def get_cpc_id_by_cpc_grp_id(grp_ids, valid_keyword_only
|
24
|
+
def get_cpc_id_by_cpc_grp_id(grp_ids, valid_keyword_only: true, options: {}, &block)
|
25
25
|
command = make_command(
|
26
26
|
:get_cpc_id_by_cpc_grp_id,
|
27
27
|
params: {
|
@@ -9,12 +9,12 @@ module Sogou
|
|
9
9
|
super('CpcPlanService')
|
10
10
|
end
|
11
11
|
|
12
|
-
def get_all_cpc_plan_id(options
|
12
|
+
def get_all_cpc_plan_id(options: {}, &block)
|
13
13
|
command = make_command(:get_all_cpc_plan_id, options: options)
|
14
14
|
execute_command(command, &block)
|
15
15
|
end
|
16
16
|
|
17
|
-
def get_all_cpc_plan(options
|
17
|
+
def get_all_cpc_plan(options: {}, &block)
|
18
18
|
command = make_command(:get_all_cpc_plan, options: options)
|
19
19
|
execute_command(command, &block)
|
20
20
|
end
|
@@ -4,28 +4,45 @@ module Sogou
|
|
4
4
|
module Search
|
5
5
|
module Api
|
6
6
|
module Service
|
7
|
+
ReportRequest = Struct.new(
|
8
|
+
:fields,
|
9
|
+
:start_date,
|
10
|
+
:end_date,
|
11
|
+
:type,
|
12
|
+
:platform,
|
13
|
+
:stat_range,
|
14
|
+
:format
|
15
|
+
)
|
16
|
+
|
7
17
|
class Report < Core::BaseService
|
8
18
|
def initialize
|
9
19
|
super('ReportService')
|
10
20
|
end
|
11
21
|
|
12
|
-
def get_report_id(
|
22
|
+
def get_report_id(request, options: {}, &block)
|
23
|
+
unless request.fields && request.start_date && request.end_date && request.type
|
24
|
+
raise ArgumentError, 'fields, start_date, end_date, and type cannot be nil'
|
25
|
+
end
|
26
|
+
|
27
|
+
report_request = {
|
28
|
+
performance_data: request.fields,
|
29
|
+
start_date: request.start_date,
|
30
|
+
end_date: request.end_date,
|
31
|
+
report_type: request.type,
|
32
|
+
}
|
33
|
+
report_request.merge!(platform: request.platform) if request.platform
|
34
|
+
report_request.merge!(format: request.format) if request.format
|
35
|
+
report_request.merge!(stat_range: request.stat_range) if request.stat_range
|
36
|
+
|
13
37
|
command = make_command(
|
14
38
|
:get_report_id,
|
15
|
-
params: {
|
16
|
-
report_request_type: {
|
17
|
-
performance_data: fields,
|
18
|
-
start_date: start_date,
|
19
|
-
end_date: end_date,
|
20
|
-
report_type: type
|
21
|
-
}
|
22
|
-
},
|
39
|
+
params: { report_request_type: report_request },
|
23
40
|
options: options
|
24
41
|
)
|
25
42
|
execute_command(command, &block)
|
26
43
|
end
|
27
44
|
|
28
|
-
def get_report_state(report_id, options
|
45
|
+
def get_report_state(report_id, options: {}, &block)
|
29
46
|
command = make_command(
|
30
47
|
:get_report_state,
|
31
48
|
params: { report_id: report_id },
|
@@ -34,7 +51,7 @@ module Sogou
|
|
34
51
|
execute_command(command, &block)
|
35
52
|
end
|
36
53
|
|
37
|
-
def get_report_path(report_id, options
|
54
|
+
def get_report_path(report_id, options: {}, &block)
|
38
55
|
command = make_command(
|
39
56
|
:get_report_path,
|
40
57
|
params: { report_id: report_id },
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sogou-search-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Min Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -96,9 +96,9 @@ files:
|
|
96
96
|
- bin/console
|
97
97
|
- bin/setup
|
98
98
|
- examples/account.rb
|
99
|
+
- examples/group.rb
|
99
100
|
- examples/keyword.rb
|
100
101
|
- examples/plan.rb
|
101
|
-
- examples/promotion_group.rb
|
102
102
|
- examples/report.rb
|
103
103
|
- lib/sogou/search/api.rb
|
104
104
|
- lib/sogou/search/api/auth.rb
|
@@ -109,9 +109,9 @@ files:
|
|
109
109
|
- lib/sogou/search/api/errors.rb
|
110
110
|
- lib/sogou/search/api/options.rb
|
111
111
|
- lib/sogou/search/api/service/account.rb
|
112
|
+
- lib/sogou/search/api/service/group.rb
|
112
113
|
- lib/sogou/search/api/service/keyword.rb
|
113
114
|
- lib/sogou/search/api/service/plan.rb
|
114
|
-
- lib/sogou/search/api/service/promotion_group.rb
|
115
115
|
- lib/sogou/search/api/service/report.rb
|
116
116
|
- lib/sogou/search/api/version.rb
|
117
117
|
- sogou-search-api.gemspec
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.6.
|
138
|
+
rubygems_version: 2.6.10
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Sogou Search API ruby client
|