Class: FinAppsCore::REST::Resources
Overview
Constant Summary
Utils::ParameterFilter::PROTECTED_KEYS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#skip_sensitive_data
Constructor Details
12
13
14
15
|
# File 'lib/finapps_core/rest/resources.rb', line 12
def initialize(client)
raise MissingArgumentsError.new 'Missing argument: client.' if client.nil?
@client = client
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8
9
10
|
# File 'lib/finapps_core/rest/resources.rb', line 8
def client
@client
end
|
Instance Method Details
#create(params = {}, path = nil) ⇒ Object
22
23
24
|
# File 'lib/finapps_core/rest/resources.rb', line 22
def create(params={}, path=nil)
request_with_body(path, :post, params)
end
|
#destroy(id = nil, path = nil) ⇒ Object
34
35
36
|
# File 'lib/finapps_core/rest/resources.rb', line 34
def destroy(id=nil, path=nil)
request_without_body(path, :delete, id)
end
|
#list(path = nil) ⇒ Object
17
18
19
20
|
# File 'lib/finapps_core/rest/resources.rb', line 17
def list(path=nil)
path = end_point.to_s if path.nil?
request_with_body(path, :get, {})
end
|
#request_with_body(path, method, params) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/finapps_core/rest/resources.rb', line 44
def request_with_body(path, method, params)
path = end_point if path.nil?
logger.debug "#{self.class.name}##{__method__} => path: #{path} params: #{skip_sensitive_data(params)}"
client.send_request path, method, params
end
|
#request_without_body(path, method, id) ⇒ Object
38
39
40
41
42
|
# File 'lib/finapps_core/rest/resources.rb', line 38
def request_without_body(path, method, id)
raise MissingArgumentsError.new 'Missing argument: id.' if id.nil? && path.nil?
path = "#{end_point}/:id".sub ':id', ERB::Util.url_encode(id) if path.nil?
request_with_body path, method, {}
end
|
#show(id = nil, path = nil) ⇒ Object
30
31
32
|
# File 'lib/finapps_core/rest/resources.rb', line 30
def show(id=nil, path=nil)
request_without_body(path, :get, id)
end
|
#update(params = {}, path = nil) ⇒ Object
26
27
28
|
# File 'lib/finapps_core/rest/resources.rb', line 26
def update(params={}, path=nil)
request_with_body(path, :put, params)
end
|