Class: NikeV2::Resource
- Inherits:
-
Base
- Object
- Base
- NikeV2::Resource
show all
- Includes:
- HTTParty, HTTParty::Sober
- Defined in:
- lib/nike_v2/resource.rb
Constant Summary
collapse
- RESP_MSG_INVALID_TOKEN =
'invalid_token'
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Resource
Returns a new instance of Resource.
16
17
18
|
# File 'lib/nike_v2/resource.rb', line 16
def initialize(attributes={})
super(attributes)
end
|
Instance Method Details
#fetch_data(*args) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/nike_v2/resource.rb', line 20
def fetch_data(*args)
args.unshift(api_url)
resp = get(*args).parsed_response.clone
if !resp['error'].nil? && resp['error'] == RESP_MSG_INVALID_TOKEN
raise "#{self.class} invalid or expired token, can not fetch data from server."
end
resp
end
|
#get(*args, &block) ⇒ Object
30
31
32
33
|
# File 'lib/nike_v2/resource.rb', line 30
def get(*args, &block)
build_options(args)
self.class.send(get_method, *args, &block)
end
|