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
|
# 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]
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.
11
12
13
|
# File 'lib/viki/request.rb', line 11
def access_token
@access_token
end
|
Instance Method Details
#get ⇒ Object
15
16
17
18
19
|
# File 'lib/viki/request.rb', line 15
def get
current_chain = @call_chain
@call_chain = []
request(current_chain)
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)
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]}" }
"#{path.chop}?#{url_params}"
end
|