Class: Qihu::DianJing::Client
- Inherits:
-
Object
- Object
- Qihu::DianJing::Client
- Defined in:
- lib/qihu/dianjing/client.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#site ⇒ Object
Returns the value of attribute site.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #account ⇒ Object
- #authorize_url(redirect_uri: '', scope: 'basic', display: 'default') ⇒ Object
- #campaign ⇒ Object
- #creative ⇒ Object
- #get_token(code, redirect_uri: '') ⇒ Object
- #group ⇒ Object
-
#initialize(auth, options = {}) ⇒ Client
constructor
A new instance of Client.
- #keyword ⇒ Object
- #report ⇒ Object
- #tool ⇒ Object
Constructor Details
#initialize(auth, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/qihu/dianjing/client.rb', line 9 def initialize(auth, ={}) @site = [:site] ? [:site] : 'https://api.e.360.cn' @version = [:version] ? [:version] : '1.0' if auth.is_a?(Qihu::Auth) auth.token.client.site = @site @auth = auth else raise 'auth must be "DianJing::Auth" instance.' end end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
6 7 8 |
# File 'lib/qihu/dianjing/client.rb', line 6 def auth @auth end |
#site ⇒ Object
Returns the value of attribute site.
7 8 9 |
# File 'lib/qihu/dianjing/client.rb', line 7 def site @site end |
#uri ⇒ Object
Returns the value of attribute uri.
7 8 9 |
# File 'lib/qihu/dianjing/client.rb', line 7 def uri @uri end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/qihu/dianjing/client.rb', line 7 def version @version end |
Instance Method Details
#account ⇒ Object
33 34 35 |
# File 'lib/qihu/dianjing/client.rb', line 33 def account @account ||= Qihu::DianJing::API::Account.new(self) end |
#authorize_url(redirect_uri: '', scope: 'basic', display: 'default') ⇒ Object
21 22 23 24 |
# File 'lib/qihu/dianjing/client.rb', line 21 def (redirect_uri:'', scope:'basic', display:'default') @redirect_uri = redirect_uri unless redirect_uri.empty? @oauth2.auth_code.(:redirect_uri => @redirect_uri, :scope => scope, :display => display) end |
#campaign ⇒ Object
37 38 39 |
# File 'lib/qihu/dianjing/client.rb', line 37 def campaign @campaign ||= Qihu::DianJing::API::Campaign.new(self) end |
#creative ⇒ Object
45 46 47 |
# File 'lib/qihu/dianjing/client.rb', line 45 def creative @creative ||= Qihu::DianJing::API::Creative.new(self) end |
#get_token(code, redirect_uri: '') ⇒ Object
26 27 28 29 30 31 |
# File 'lib/qihu/dianjing/client.rb', line 26 def get_token(code, redirect_uri:'') @redirect_uri = redirect_uri unless redirect_uri.empty? @token = @oauth2.auth_code.get_token(code, :redirect_uri => @redirect_uri) @token = _get_api_token(@token.token) end |
#group ⇒ Object
41 42 43 |
# File 'lib/qihu/dianjing/client.rb', line 41 def group @group ||= Qihu::DianJing::API::Group.new(self) end |
#keyword ⇒ Object
49 50 51 |
# File 'lib/qihu/dianjing/client.rb', line 49 def keyword @keyword ||= Qihu::DianJing::API::Keyword.new(self) end |
#report ⇒ Object
53 54 55 |
# File 'lib/qihu/dianjing/client.rb', line 53 def report @report ||= Qihu::DianJing::API::Report.new(self) end |
#tool ⇒ Object
57 58 59 |
# File 'lib/qihu/dianjing/client.rb', line 57 def tool @tool ||= Qihu::DianJing::API::Tool.new(self) end |