Module: Qingting::Api::Base

Extended by:
Base
Included in:
Base
Defined in:
lib/qingting/api/base.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

  1. Base.v6_categories

  2. Base.wapi_categories

  3. Base.get_client_id



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/qingting/api/base.rb', line 32

def method_missing(name, *args)
	if name =~ /^v6_[\w]+/
		name = name.to_s.gsub("v6_", "")
		# puts name
		media_url + name.to_s.gsub('_',"/")

		# puts base_url + '/v6/media/' + name.to_s.gsub('_',"/")

	elsif  name =~ /^wapi_[\w]+/
		name = name.to_s.gsub("wapi_", "")
		base_url + '/wapi/' + name.to_s.gsub('_',"/")

	elsif  name =~ /^get_[\w]+/
		name = name.to_s.gsub("get_", "")
		Config::get(name)
	end
end

Instance Method Details

#access_urlObject



18
19
20
# File 'lib/qingting/api/base.rb', line 18

def access_url
	base_url + '/access'
end

#base_urlObject



6
7
8
# File 'lib/qingting/api/base.rb', line 6

def base_url
	Config::get('base_url')
end

#media_urlObject



10
11
12
# File 'lib/qingting/api/base.rb', line 10

def media_url
	base_url + '/v6/media/'
end

#paramsObject



22
23
24
25
26
# File 'lib/qingting/api/base.rb', line 22

def params
	{
		access_token: token
	}
end

#request(url) ⇒ Object



55
56
57
# File 'lib/qingting/api/base.rb', line 55

def request(url)
	Utils::Request.get(url, params: params)
end

#tokenObject



50
51
52
# File 'lib/qingting/api/base.rb', line 50

def token
	Account.access_token
end

#wapi_urlObject



14
15
16
# File 'lib/qingting/api/base.rb', line 14

def wapi_url
	base_url + '/wapi/'
end