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
-
Base.v6_categories
-
Base.wapi_categories
-
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_", "")
media_url + 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_url ⇒ Object
18
19
20
|
# File 'lib/qingting/api/base.rb', line 18
def access_url
base_url + '/access'
end
|
#base_url ⇒ Object
6
7
8
|
# File 'lib/qingting/api/base.rb', line 6
def base_url
Config::get('base_url')
end
|
10
11
12
|
# File 'lib/qingting/api/base.rb', line 10
def media_url
base_url + '/v6/media/'
end
|
#params ⇒ Object
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
|
#wapi_url ⇒ Object
14
15
16
|
# File 'lib/qingting/api/base.rb', line 14
def wapi_url
base_url + '/wapi/'
end
|