Class: Qihu::DianJing::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/qihu/dianjing/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @site = options[:site] ? options[:site] : 'https://api.e.360.cn'
  @version = options[:version] ? options[: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

#authObject (readonly)

Returns the value of attribute auth


6
7
8
# File 'lib/qihu/dianjing/client.rb', line 6

def auth
  @auth
end

#siteObject

Returns the value of attribute site


7
8
9
# File 'lib/qihu/dianjing/client.rb', line 7

def site
  @site
end

#uriObject

Returns the value of attribute uri


7
8
9
# File 'lib/qihu/dianjing/client.rb', line 7

def uri
  @uri
end

#versionObject

Returns the value of attribute version


7
8
9
# File 'lib/qihu/dianjing/client.rb', line 7

def version
  @version
end

Instance Method Details

#accountObject


33
34
35
# File 'lib/qihu/dianjing/client.rb', line 33

def 
  @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 authorize_url(redirect_uri:'', scope:'basic', display:'default')
  @redirect_uri = redirect_uri unless redirect_uri.empty?
  @oauth2.auth_code.authorize_url(:redirect_uri => @redirect_uri, :scope => scope, :display => display)
end

#campaignObject


37
38
39
# File 'lib/qihu/dianjing/client.rb', line 37

def campaign
  @campaign ||= Qihu::DianJing::API::Campaign.new(self)
end

#creativeObject


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

#groupObject


41
42
43
# File 'lib/qihu/dianjing/client.rb', line 41

def group
  @group ||= Qihu::DianJing::API::Group.new(self)
end

#keywordObject


49
50
51
# File 'lib/qihu/dianjing/client.rb', line 49

def keyword
  @keyword ||= Qihu::DianJing::API::Keyword.new(self)
end

#reportObject


53
54
55
# File 'lib/qihu/dianjing/client.rb', line 53

def report
  @report ||= Qihu::DianJing::API::Report.new(self)
end

#toolObject


57
58
59
# File 'lib/qihu/dianjing/client.rb', line 57

def tool
  @tool ||= Qihu::DianJing::API::Tool.new(self)
end