Class: Viki::Request
Constant Summary
Constants included
from Utilities
Utilities::URL_NAMESPACES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(auth_data, name, *args) ⇒ Request
Returns a new instance of Request.
3
4
5
6
7
8
9
10
|
# File 'lib/viki/request.rb', line 3
def initialize(auth_data, name, *args)
@access_token = auth_data[:access_token]
@client_id = auth_data[:client_id]
@client_secret = auth_data[:client_secret]
@host = auth_data[:host]
build_call_chain(name, *args)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
36
37
38
39
|
# File 'lib/viki/request.rb', line 36
def method_missing(name, *args)
build_call_chain(name, *args)
self
end
|
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
12
13
14
|
# File 'lib/viki/request.rb', line 12
def access_token
@access_token
end
|
Instance Method Details
#get ⇒ Object
16
17
18
19
|
# File 'lib/viki/request.rb', line 16
def get
current_chain = @call_chain
request(current_chain, @host)
end
|
#reset_access_token ⇒ Object
21
22
23
|
# File 'lib/viki/request.rb', line 21
def reset_access_token
@access_token = auth_request(@client_id, @client_secret, @host)
end
|
#url ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/viki/request.rb', line 25
def url
path, params = build_url(@call_chain)
params.delete(:access_token)
url_params = ""
params.keys.each { |key| url_params += "#{key}=#{params[key]}&" }
url_params.empty? ? path.chop : "#{path.chop}?#{url_params.chop}"
end
|