sogou-search-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ module Sogou
2
+ module Search
3
+ module Api
4
+ class Error < StandardError
5
+ attr_reader :code
6
+ attr_reader :message
7
+ attr_reader :header
8
+
9
+ def initialize(err, code: nil, header: nil)
10
+ @cause = nil
11
+
12
+ if err.respond_to?(:backtrace)
13
+ super(err.message)
14
+ @cause = err
15
+ else
16
+ super(err.to_s)
17
+ end
18
+ @code = code
19
+ @header = header unless header.nil?
20
+ end
21
+
22
+ def backtrace
23
+ if @cause
24
+ @cause.backtrace
25
+ else
26
+ super
27
+ end
28
+ end
29
+ end # Error
30
+
31
+ InvalidTokenError = Class.new(Error)
32
+
33
+ InvalidUserNameError = Class.new(Error)
34
+
35
+ WrongPasswordError = Class.new(Error)
36
+
37
+ RateLimitError = Class.new(Error)
38
+
39
+ UnknownError = Class.new(Error)
40
+
41
+ TransmissionError = Class.new(Error)
42
+
43
+ PlanIDNotExistError = Class.new(Error)
44
+
45
+ PromotionGroupIDNotExistError = Class.new(Error)
46
+
47
+ KeywordIDNotExistError = Class.new(Error)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,17 @@
1
+ module Sogou
2
+ module Search
3
+ module Api
4
+ ClientOptions = Struct.new(
5
+ :proxy_url,
6
+ :open_timeout_sec,
7
+ :read_timeout_sec,
8
+ )
9
+
10
+ class ClientOptions
11
+ def self.default
12
+ @options ||= ClientOptions.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../core/base_service'
2
+
3
+ module Sogou
4
+ module Search
5
+ module Api
6
+ module Service
7
+ class Account < Core::BaseService
8
+ def initialize
9
+ super('AccountService')
10
+ end
11
+
12
+ def get_account_info(options = {}, &block)
13
+ command = make_command(:get_account_info, options: options)
14
+ execute_command(command, &block)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ require_relative '../core/base_service'
2
+
3
+ module Sogou
4
+ module Search
5
+ module Api
6
+ module Service
7
+ class Keyword < Core::BaseService
8
+ def initialize
9
+ super('CpcService')
10
+ end
11
+
12
+ def get_cpc_by_cpc_grp_id(grp_ids, valid_keyword_only = true, options = {}, &block)
13
+ command = make_command(
14
+ :get_cpc_by_cpc_grp_id,
15
+ params: {
16
+ cpc_grp_ids: grp_ids,
17
+ get_temp: valid_keyword_only(valid_keyword_only)
18
+ },
19
+ options: options
20
+ )
21
+ execute_command(command, &block)
22
+ end
23
+
24
+ def get_cpc_id_by_cpc_grp_id(grp_ids, valid_keyword_only = true, options = {}, &block)
25
+ command = make_command(
26
+ :get_cpc_id_by_cpc_grp_id,
27
+ params: {
28
+ cpc_grp_ids: grp_ids,
29
+ get_temp: valid_keyword_only(valid_keyword_only)
30
+ },
31
+ options: options
32
+ )
33
+ execute_command(command, &block)
34
+ end
35
+
36
+ private
37
+
38
+ def valid_keyword_only(only)
39
+ only ? 0 : 1
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../core/base_service'
2
+
3
+ module Sogou
4
+ module Search
5
+ module Api
6
+ module Service
7
+ class Plan < Core::BaseService
8
+ def initialize
9
+ super('CpcPlanService')
10
+ end
11
+
12
+ def get_all_cpc_plan_id(options = {}, &block)
13
+ command = make_command(:get_all_cpc_plan_id, options: options)
14
+ execute_command(command, &block)
15
+ end
16
+
17
+ def get_all_cpc_plan(options = {}, &block)
18
+ command = make_command(:get_all_cpc_plan, options: options)
19
+ execute_command(command, &block)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ require_relative '../core/base_service'
2
+
3
+ module Sogou
4
+ module Search
5
+ module Api
6
+ module Service
7
+ class PromotionGroup < Core::BaseService
8
+ def initialize
9
+ super('CpcGrpService')
10
+ end
11
+
12
+ def get_cpc_grp_by_cpc_plan_id(plan_ids, options = {}, &block)
13
+ command = make_command(
14
+ :get_cpc_grp_by_cpc_plan_id,
15
+ params: { cpc_plan_ids: plan_ids },
16
+ options: options
17
+ )
18
+ execute_command(command, &block)
19
+ end
20
+
21
+ def get_cpc_grp_id_by_cpc_plan_id(plan_ids, options = {}, &block)
22
+ command = make_command(
23
+ :get_cpc_grp_id_by_cpc_plan_id,
24
+ params: { cpc_plan_ids: plan_ids },
25
+ options: options
26
+ )
27
+ execute_command(command, &block)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,49 @@
1
+ require_relative '../core/base_service'
2
+
3
+ module Sogou
4
+ module Search
5
+ module Api
6
+ module Service
7
+ class Report < Core::BaseService
8
+ def initialize
9
+ super('ReportService')
10
+ end
11
+
12
+ def get_report_id(start_date, end_date, type, fields, options = {}, &block)
13
+ command = make_command(
14
+ :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
+ },
23
+ options: options
24
+ )
25
+ execute_command(command, &block)
26
+ end
27
+
28
+ def get_report_state(report_id, options = {}, &block)
29
+ command = make_command(
30
+ :get_report_state,
31
+ params: { report_id: report_id },
32
+ options: options
33
+ )
34
+ execute_command(command, &block)
35
+ end
36
+
37
+ def get_report_path(report_id, options = {}, &block)
38
+ command = make_command(
39
+ :get_report_path,
40
+ params: { report_id: report_id },
41
+ options: options
42
+ )
43
+ execute_command(command, &block)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,24 @@
1
+ module Sogou
2
+ module Search
3
+ module Api
4
+ VERSION = '0.0.1'
5
+
6
+ OS_VERSION = begin
7
+ if RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/
8
+ `ver`.sub(/\s*\[Version\s*/, '/').sub(']', '').strip
9
+ elsif RUBY_PLATFORM =~ /darwin/i
10
+ "Mac OS X/#{`sw_vers -productVersion`}"
11
+ elsif RUBY_PLATFORM == 'java'
12
+ require 'java'
13
+ name = java.lang.System.getProperty('os.name')
14
+ version = java.lang.System.getProperty('os.version')
15
+ "#{name}/#{version}"
16
+ else
17
+ `uname -sr`.sub(' ', '/')
18
+ end
19
+ rescue
20
+ RUBY_PLATFORM
21
+ end.gsub("\n", '')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sogou/search/api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'sogou-search-api'
8
+ spec.version = Sogou::Search::Api::VERSION
9
+ spec.authors = ['Min Kim']
10
+ spec.email = %w[developers@forward3d.com min.kim@forward3d.com]
11
+
12
+ spec.summary = %q(Sogou Search API ruby client)
13
+ spec.description = %q(Sogou Search API ruby client)
14
+ spec.homepage = 'https://github.com/forward3d/sogou-search-api'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_runtime_dependency 'savon', '~> 2.12'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.14'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.14'
30
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sogou-search-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Min Kim
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.14'
83
+ description: Sogou Search API ruby client
84
+ email:
85
+ - developers@forward3d.com
86
+ - min.kim@forward3d.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - examples/account.rb
99
+ - examples/keyword.rb
100
+ - examples/plan.rb
101
+ - examples/promotion_group.rb
102
+ - examples/report.rb
103
+ - lib/sogou/search/api.rb
104
+ - lib/sogou/search/api/auth.rb
105
+ - lib/sogou/search/api/core/api_command.rb
106
+ - lib/sogou/search/api/core/base_service.rb
107
+ - lib/sogou/search/api/core/logging.rb
108
+ - lib/sogou/search/api/core/regions.rb
109
+ - lib/sogou/search/api/errors.rb
110
+ - lib/sogou/search/api/options.rb
111
+ - lib/sogou/search/api/service/account.rb
112
+ - lib/sogou/search/api/service/keyword.rb
113
+ - lib/sogou/search/api/service/plan.rb
114
+ - lib/sogou/search/api/service/promotion_group.rb
115
+ - lib/sogou/search/api/service/report.rb
116
+ - lib/sogou/search/api/version.rb
117
+ - sogou-search-api.gemspec
118
+ homepage: https://github.com/forward3d/sogou-search-api
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.6.14
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Sogou Search API ruby client
142
+ test_files: []