finapps 1.0.8 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rspec +1 -2
- data/.rubocop.yml +102 -0
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/Rakefile +1 -1
- data/finapps.gemspec +10 -10
- data/lib/finapps/core_extensions/hash/compact.rb +22 -0
- data/lib/finapps/core_extensions/integerable.rb +14 -0
- data/lib/finapps/core_extensions/object/blank.rb +145 -0
- data/lib/finapps/error.rb +7 -0
- data/lib/finapps/hash_constructable.rb +9 -0
- data/lib/finapps/middleware/raise_error.rb +46 -0
- data/lib/finapps/middleware/tenant_authentication.rb +19 -0
- data/lib/finapps/rest/base_client.rb +96 -0
- data/lib/finapps/rest/client.rb +11 -199
- data/lib/finapps/rest/configuration.rb +55 -0
- data/lib/finapps/rest/connection.rb +14 -33
- data/lib/finapps/rest/defaults.rb +55 -64
- data/lib/finapps/rest/resource.rb +3 -6
- data/lib/finapps/rest/resources.rb +11 -6
- data/lib/finapps/rest/users.rb +17 -57
- data/lib/finapps/utils/loggeable.rb +13 -0
- data/lib/finapps/version.rb +1 -1
- data/lib/finapps.rb +11 -23
- data/lib/tasks/releaser.rake +2 -2
- data/spec/middleware/tenant_authentication_spec.rb +29 -0
- data/spec/rest/base_client_spec.rb +89 -0
- data/spec/rest/client_spec.rb +16 -102
- data/spec/rest/configuration_spec.rb +75 -0
- data/spec/spec_helper.rb +10 -7
- data/spec/support/fake_api.rb +9 -2
- data/spec/support/fixtures/error.json +5 -0
- data/spec/support/fixtures/relevance_ruleset_names.json +47 -0
- metadata +49 -57
- data/lib/finapps/middleware/api_token.rb +0 -26
- data/lib/finapps/middleware/raise_http_exceptions.rb +0 -92
- data/lib/finapps/middleware/response_logger.rb +0 -37
- data/lib/finapps/rest/alert.rb +0 -62
- data/lib/finapps/rest/alert_definition.rb +0 -40
- data/lib/finapps/rest/alert_preferences.rb +0 -40
- data/lib/finapps/rest/alert_settings.rb +0 -40
- data/lib/finapps/rest/budget_calculation.rb +0 -45
- data/lib/finapps/rest/budget_models.rb +0 -42
- data/lib/finapps/rest/budgets.rb +0 -103
- data/lib/finapps/rest/cashflows.rb +0 -87
- data/lib/finapps/rest/categories.rb +0 -21
- data/lib/finapps/rest/errors.rb +0 -155
- data/lib/finapps/rest/institutions.rb +0 -47
- data/lib/finapps/rest/relevance/rulesets.rb +0 -64
- data/lib/finapps/rest/transactions.rb +0 -45
- data/lib/finapps/rest/user_institutions.rb +0 -138
- data/lib/finapps/utils/logging.rb +0 -95
- data/lib/finapps/utils/utils.rb +0 -57
- data/spec/middleware/api_token_spec.rb +0 -32
- data/spec/rest/connection_spec.rb +0 -40
- data/spec/rest/users_spec.rb +0 -24
- data/spec/utils/logging_spec.rb +0 -28
data/lib/finapps/rest/budgets.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class Budgets < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# Shows budget results for a given date range.
|
10
|
-
# @param [Date] start_date
|
11
|
-
# @param [Date] end_date
|
12
|
-
# @return [Hash, Array<String>]
|
13
|
-
def show(start_date, end_date)
|
14
|
-
raise MissingArgumentsError.new 'Missing argument: start_date.' if start_date.blank?
|
15
|
-
logger.debug "##{__method__} => start_date: #{start_date}"
|
16
|
-
raise MissingArgumentsError.new 'Missing argument: end_date.' if end_date.blank?
|
17
|
-
logger.debug "##{__method__} => end_date: #{end_date}"
|
18
|
-
|
19
|
-
budget = Budget.new({:start_date => start_date, :end_date => end_date, :details => []})
|
20
|
-
|
21
|
-
end_point = Defaults::END_POINTS[:budget_show]
|
22
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
23
|
-
|
24
|
-
path = end_point.sub(':start_date', ERB::Util.url_encode(start_date)).sub(':end_date', ERB::Util.url_encode(end_date))
|
25
|
-
logger.debug "##{__method__} => path: #{path}"
|
26
|
-
|
27
|
-
result, error_messages = client.send_request(path, :get)
|
28
|
-
if result.present? && error_messages.blank?
|
29
|
-
categories = result_categories(result)
|
30
|
-
raise 'Category results-set for budget is not an array.' unless categories.respond_to?(:each)
|
31
|
-
|
32
|
-
transactions = result_transactions(result)
|
33
|
-
categories.each { |category| budget.details << result_category_to_budget_detail(category, transactions) }
|
34
|
-
end
|
35
|
-
|
36
|
-
return budget, error_messages
|
37
|
-
end
|
38
|
-
|
39
|
-
# Updates the budget parameters.
|
40
|
-
# @param [Hash] params
|
41
|
-
# @return [Array<Hash>, Array<String>]
|
42
|
-
def update(params={})
|
43
|
-
raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
|
44
|
-
|
45
|
-
end_point = Defaults::END_POINTS[:budget_update]
|
46
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
47
|
-
|
48
|
-
budget, error_messages = client.send_request(end_point, :put, params)
|
49
|
-
return budget, error_messages
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def result_categories(result)
|
55
|
-
extract_array(result, 'cats')
|
56
|
-
end
|
57
|
-
|
58
|
-
def result_category_to_budget_detail(category, transactions)
|
59
|
-
raise 'Unable to locate category id for current category record.' unless category.key?('cat_id')
|
60
|
-
category_id = category['cat_id']
|
61
|
-
|
62
|
-
raise 'Unable to locate category name for current category record.' unless category.key?('name')
|
63
|
-
category_name = category['name']
|
64
|
-
|
65
|
-
raise 'Unable to locate budget_amount for current category record.' unless category.key?('budget_amount')
|
66
|
-
budget_amount = category['budget_amount']
|
67
|
-
|
68
|
-
BudgetDetail.new({:category_id => category_id,
|
69
|
-
:category_name => category_name,
|
70
|
-
:budget_amount => budget_amount,
|
71
|
-
:expense_amount => expense_amount(category_id, transactions)})
|
72
|
-
end
|
73
|
-
|
74
|
-
def result_transactions(result)
|
75
|
-
extract_array(result, 'trans')
|
76
|
-
end
|
77
|
-
|
78
|
-
def extract_array(result, array_identifier)
|
79
|
-
array_container = result.find { |r| r.has_key?(array_identifier) }
|
80
|
-
array_container.present? ? array_container[array_identifier] : nil
|
81
|
-
end
|
82
|
-
|
83
|
-
def expense_amount(category_id, transactions = [])
|
84
|
-
amount = 0
|
85
|
-
if category_id.present? && transactions.respond_to?(:find)
|
86
|
-
transaction = transactions.find { |t| t['category_id'] == category_id }
|
87
|
-
amount = transaction['expense_amount'].to_f if transaction.present? && transaction.key?('expense_amount')
|
88
|
-
end
|
89
|
-
amount
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
class Budget < FinApps::REST::Resource
|
95
|
-
attr_accessor :start_date, :end_date, :details
|
96
|
-
end
|
97
|
-
|
98
|
-
class BudgetDetail < FinApps::REST::Resource
|
99
|
-
attr_accessor :category_id, :category_name, :budget_amount, :expense_amount
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class Cashflows < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# @param [Date] start_date
|
10
|
-
# @param [Date] end_date
|
11
|
-
# @return [Hash, Array<String>]
|
12
|
-
def show(start_date, end_date)
|
13
|
-
raise MissingArgumentsError.new 'Missing argument: start_date.' if start_date.blank?
|
14
|
-
logger.debug "##{__method__} => start_date: #{start_date}"
|
15
|
-
raise MissingArgumentsError.new 'Missing argument: end_date.' if end_date.blank?
|
16
|
-
logger.debug "##{__method__} => end_date: #{end_date}"
|
17
|
-
|
18
|
-
cashflow = Cashflow.new({:start_date => start_date,
|
19
|
-
:end_date => end_date,
|
20
|
-
:total_income_amount => 0,
|
21
|
-
:total_expenses_amount => 0,
|
22
|
-
:total_leftover_amount => 0,
|
23
|
-
:details => []})
|
24
|
-
|
25
|
-
end_point = Defaults::END_POINTS[:cashflow_show]
|
26
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
27
|
-
|
28
|
-
path = end_point.sub(':start_date', ERB::Util.url_encode(start_date)).sub(':end_date', ERB::Util.url_encode(end_date))
|
29
|
-
logger.debug "##{__method__} => path: #{path}"
|
30
|
-
|
31
|
-
result, error_messages = client.send_request(path, :get)
|
32
|
-
if result.present? && error_messages.blank?
|
33
|
-
|
34
|
-
summary = extract_value(result, 'summary')
|
35
|
-
raise 'Summary result-set for cashflow is not present.' if summary.nil?
|
36
|
-
raise 'Summary result-set for cashflow is not a hash.' unless summary.respond_to?(:key?)
|
37
|
-
|
38
|
-
raise 'Total income (inflow) value for cashflow is not present.' unless summary.key?('inflow')
|
39
|
-
cashflow.total_income_amount = summary['inflow']
|
40
|
-
|
41
|
-
raise 'Total expenses (outflow) value for cashflow is not present.' unless summary.key?('outflow')
|
42
|
-
cashflow.total_expenses_amount = summary['outflow']
|
43
|
-
|
44
|
-
raise 'Total left-over (diff) value for cashflow is not present.' unless summary.key?('diff')
|
45
|
-
cashflow.total_leftover_amount = summary['diff']
|
46
|
-
|
47
|
-
categories = extract_value(result, 'details')
|
48
|
-
raise 'Category results-set for cashflow is not an array.' unless categories.respond_to?(:each)
|
49
|
-
|
50
|
-
categories.each { |category| cashflow.details << result_category_to_cashflow_detail(category) }
|
51
|
-
end
|
52
|
-
|
53
|
-
return cashflow, error_messages
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def extract_value(result, array_identifier)
|
59
|
-
array_container = result.find { |r| r.has_key?(array_identifier) }
|
60
|
-
array_container.present? ? array_container[array_identifier] : nil
|
61
|
-
end
|
62
|
-
|
63
|
-
def result_category_to_cashflow_detail(category)
|
64
|
-
raise 'Unable to locate category id for current category record.' unless category.key?('cat')
|
65
|
-
raise 'Unable to locate credits amount for current category record.' unless category.key?('inflow')
|
66
|
-
raise 'Unable to locate debits amount for current category record.' unless category.key?('outflow')
|
67
|
-
raise 'Unable to locate balance amount for current category record.' unless category.key?('diff')
|
68
|
-
|
69
|
-
CashflowDetail.new({:category_id => category['cat'],
|
70
|
-
:credits => category['inflow'],
|
71
|
-
:debits => category['outflow'],
|
72
|
-
:balance => category['diff']})
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
class Cashflow < FinApps::REST::Resource
|
78
|
-
attr_accessor :start_date, :end_date,
|
79
|
-
:total_income_amount, :total_expenses_amount, :total_leftover_amount, :details
|
80
|
-
end
|
81
|
-
|
82
|
-
class CashflowDetail < FinApps::REST::Resource
|
83
|
-
attr_accessor :category_id, :credits, :debits, :balance
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
class Categories < FinApps::REST::Resources
|
4
|
-
include FinApps::REST::Defaults
|
5
|
-
|
6
|
-
# Lists all categories.
|
7
|
-
# @return [Array<Hash>, Array<String>]
|
8
|
-
def list
|
9
|
-
end_point = Defaults::END_POINTS[:categories_list]
|
10
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
11
|
-
|
12
|
-
path = end_point
|
13
|
-
logger.debug "##{__method__} => path: #{path}"
|
14
|
-
|
15
|
-
categories, error_messages = client.send_request(path, :get)
|
16
|
-
return categories, error_messages
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/finapps/rest/errors.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
# Custom error class for rescuing from all FinApps errors
|
5
|
-
class Error < StandardError;
|
6
|
-
attr_reader :response
|
7
|
-
|
8
|
-
def initialize(ex, response = nil)
|
9
|
-
@wrapped_exception = nil
|
10
|
-
@response = response
|
11
|
-
|
12
|
-
if ex.respond_to?(:backtrace)
|
13
|
-
super(ex.message)
|
14
|
-
@wrapped_exception = ex
|
15
|
-
elsif ex.respond_to?(:each_key)
|
16
|
-
super("the server responded with status #{ex[:status]}")
|
17
|
-
@response = ex
|
18
|
-
else
|
19
|
-
super(ex.to_s)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def backtrace
|
24
|
-
if @wrapped_exception
|
25
|
-
@wrapped_exception.backtrace
|
26
|
-
else
|
27
|
-
super
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def inspect
|
32
|
-
%(#<#{self.class}>)
|
33
|
-
end
|
34
|
-
|
35
|
-
# @return [Array<String>]
|
36
|
-
def error_messages
|
37
|
-
message_array = []
|
38
|
-
body = response_body
|
39
|
-
|
40
|
-
if body.present? && body.kind_of?(String)
|
41
|
-
begin
|
42
|
-
parsed = ::JSON.parse(body)
|
43
|
-
if parsed
|
44
|
-
body = parsed
|
45
|
-
else
|
46
|
-
logger.info "##{__method__} => Cannot extract errors: unexpected error while parsing response."
|
47
|
-
end
|
48
|
-
rescue ::JSON::ParserError => e
|
49
|
-
logger.error "##{__method__} => Unable to parse JSON response."
|
50
|
-
logger.error e
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if body.present? && body.is_a?(Hash)
|
55
|
-
|
56
|
-
if body.key?(:error_messages)
|
57
|
-
message_array = body[:error_messages]
|
58
|
-
else
|
59
|
-
if body.key?('error_messages')
|
60
|
-
message_array = body['error_messages']
|
61
|
-
else
|
62
|
-
if body.key?(:messages)
|
63
|
-
message_array = body[:messages]
|
64
|
-
else
|
65
|
-
message_array = body['messages'] if body.key?('messages')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
message_array
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
def response_body
|
77
|
-
body = nil
|
78
|
-
if @response.present?
|
79
|
-
@response.key?(:body) ? body = @response[:body] : body = @response
|
80
|
-
end
|
81
|
-
|
82
|
-
body
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
# Raised when required arguments are missing
|
88
|
-
class MissingArgumentsError < Error
|
89
|
-
def initialize(message)
|
90
|
-
super(message)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# Raised when invalid arguments are detected
|
95
|
-
class InvalidArgumentsError < Error
|
96
|
-
def initialize(message)
|
97
|
-
super(message)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
# Client Error 4xx
|
103
|
-
# The 4xx class of status code is intended for cases in which the client seems to have erred.
|
104
|
-
class ClientError < Error
|
105
|
-
end
|
106
|
-
|
107
|
-
class BadRequest < ClientError
|
108
|
-
end
|
109
|
-
|
110
|
-
class Unauthorized < ClientError
|
111
|
-
end
|
112
|
-
|
113
|
-
class Forbidden < ClientError
|
114
|
-
end
|
115
|
-
|
116
|
-
class NotFound < ClientError
|
117
|
-
end
|
118
|
-
|
119
|
-
class MethodNotAllowed < ClientError
|
120
|
-
end
|
121
|
-
|
122
|
-
class NotAcceptable < ClientError
|
123
|
-
end
|
124
|
-
|
125
|
-
class ConnectionFailed < ClientError
|
126
|
-
end
|
127
|
-
|
128
|
-
class Conflict < ClientError
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
# Server Error 5xx
|
133
|
-
#
|
134
|
-
# Response status codes beginning with the digit "5" indicate cases in which the server is aware
|
135
|
-
# that it has erred or is incapable of performing the request.
|
136
|
-
class ServerError < Error
|
137
|
-
end
|
138
|
-
|
139
|
-
class InternalServerError < ServerError
|
140
|
-
end
|
141
|
-
|
142
|
-
class BadGateway < ServerError
|
143
|
-
end
|
144
|
-
|
145
|
-
class ServiceUnavailable < ServerError
|
146
|
-
end
|
147
|
-
|
148
|
-
class GatewayTimeout < ServerError
|
149
|
-
end
|
150
|
-
|
151
|
-
class VersionNotSupported < ServerError
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class Institutions < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
# @param [String] term
|
10
|
-
# @return [Array<FinApps::REST::Institution>, Array<String>]
|
11
|
-
def search(term)
|
12
|
-
raise MissingArgumentsError.new 'Missing argument: term.' if term.blank?
|
13
|
-
logger.debug "##{__method__} => term: #{term}"
|
14
|
-
|
15
|
-
end_point = Defaults::END_POINTS[:institutions_list]
|
16
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
17
|
-
|
18
|
-
path = end_point.sub ':search_term', ERB::Util.url_encode(term)
|
19
|
-
logger.debug "##{__method__} => path: #{path}"
|
20
|
-
|
21
|
-
institutions, error_messages = client.send_request(path, :get)
|
22
|
-
return institutions, error_messages
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param [Integer] site_id
|
26
|
-
def form(site_id)
|
27
|
-
raise MissingArgumentsError.new 'Missing argument: site_id.' if site_id.blank?
|
28
|
-
logger.debug "##{__method__} => site_id: #{site_id}"
|
29
|
-
|
30
|
-
end_point = Defaults::END_POINTS[:institutions_form]
|
31
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
32
|
-
|
33
|
-
path = end_point.sub ':site_id', ERB::Util.url_encode(site_id)
|
34
|
-
logger.debug "##{__method__} => path: #{path}"
|
35
|
-
|
36
|
-
institution, error_messages = client.send_request(path, :get) { |r| Institution.new(r.body) }
|
37
|
-
return institution, error_messages
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
class Institution < FinApps::REST::Resource
|
43
|
-
attr_accessor :login_form_html
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
module Relevance
|
4
|
-
|
5
|
-
require 'erb'
|
6
|
-
|
7
|
-
class Rulesets < FinApps::REST::Resources
|
8
|
-
|
9
|
-
def list
|
10
|
-
|
11
|
-
|
12
|
-
end_point = Defaults::END_POINTS[:relevance_rulesets_list]
|
13
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
14
|
-
|
15
|
-
path = end_point
|
16
|
-
logger.debug "##{__method__} => path: #{path}"
|
17
|
-
|
18
|
-
results, error_messages = @client.send_request(path, :get)
|
19
|
-
|
20
|
-
|
21
|
-
return results, error_messages
|
22
|
-
end
|
23
|
-
|
24
|
-
def show(ruleset_name)
|
25
|
-
|
26
|
-
|
27
|
-
raise MissingArgumentsError.new 'Missing argument: ruleset_name.' if ruleset_name.blank?
|
28
|
-
logger.debug "##{__method__} => ruleset_name: #{ruleset_name}"
|
29
|
-
|
30
|
-
end_point = Defaults::END_POINTS[:relevance_rulesets_show]
|
31
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
32
|
-
|
33
|
-
path = end_point.sub ':ruleset_name', ERB::Util.url_encode(ruleset_name)
|
34
|
-
logger.debug "##{__method__} => path: #{path}"
|
35
|
-
|
36
|
-
results, error_messages = @client.send_request(path, :get)
|
37
|
-
|
38
|
-
|
39
|
-
return results, error_messages
|
40
|
-
end
|
41
|
-
|
42
|
-
def run(params = {})
|
43
|
-
|
44
|
-
|
45
|
-
raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
|
46
|
-
logger.debug "##{__method__} => params: #{params.inspect}"
|
47
|
-
|
48
|
-
end_point = Defaults::END_POINTS[:relevance_rulesets_run]
|
49
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
50
|
-
|
51
|
-
path = end_point
|
52
|
-
logger.debug "##{__method__} => path: #{path}"
|
53
|
-
|
54
|
-
results, error_messages = @client.send_request(path, :post, params)
|
55
|
-
|
56
|
-
|
57
|
-
return results, error_messages
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
class Transactions < FinApps::REST::Resources
|
5
|
-
include FinApps::REST::Defaults
|
6
|
-
|
7
|
-
# @transaction_id [String]
|
8
|
-
# # @return [Hash, Array<String>]
|
9
|
-
def show(transaction_id)
|
10
|
-
end_point = Defaults::END_POINTS[:transactions_show]
|
11
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
12
|
-
|
13
|
-
path = end_point.sub ':transaction_id', ERB::Util.url_encode(transaction_id)
|
14
|
-
logger.debug "##{__method__} => path: #{path}"
|
15
|
-
|
16
|
-
transaction, error_messages = client.send_request(path, :get)
|
17
|
-
return transaction, error_messages
|
18
|
-
end
|
19
|
-
|
20
|
-
# @param [Hash] params
|
21
|
-
# @return [Array<Hash>, Array<String>]
|
22
|
-
def search(params={})
|
23
|
-
end_point = Defaults::END_POINTS[:transactions_list]
|
24
|
-
|
25
|
-
path = end_point
|
26
|
-
logger.debug "##{__method__} => path: #{path}"
|
27
|
-
|
28
|
-
transactions, error_messages = client.send_request(path, :post, params.compact)
|
29
|
-
return transactions, error_messages
|
30
|
-
end
|
31
|
-
|
32
|
-
# @param [Hash] params
|
33
|
-
# @return [Array<Hash>, Array<String>]
|
34
|
-
def update(params={})
|
35
|
-
path = Defaults::END_POINTS[:transactions_update]
|
36
|
-
logger.debug "##{__method__} => path: #{path}"
|
37
|
-
|
38
|
-
_, error_messages = client.send_request(path, :put, params.compact)
|
39
|
-
error_messages
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
module FinApps
|
2
|
-
module REST
|
3
|
-
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
class UserInstitutions < FinApps::REST::Resources
|
7
|
-
include FinApps::REST::Defaults
|
8
|
-
|
9
|
-
def list
|
10
|
-
path = Defaults::END_POINTS[:user_institutions_list]
|
11
|
-
logger.debug "##{__method__} => path: #{path}"
|
12
|
-
|
13
|
-
user_institutions, error_messages = client.send_request(path, :get)
|
14
|
-
return user_institutions, error_messages
|
15
|
-
end
|
16
|
-
|
17
|
-
def add(site_id, parameters)
|
18
|
-
|
19
|
-
raise MissingArgumentsError.new 'Missing argument: site_id.' if site_id.blank?
|
20
|
-
logger.debug "##{__method__} => site_id: #{site_id}"
|
21
|
-
|
22
|
-
raise MissingArgumentsError.new 'Missing argument: parameters.' if parameters.blank?
|
23
|
-
logger.debug "##{__method__} => parameters: #{skip_sensitive_data parameters}"
|
24
|
-
|
25
|
-
end_point = Defaults::END_POINTS[:user_institutions_add]
|
26
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
27
|
-
|
28
|
-
path = end_point.sub ':site_id', ERB::Util.url_encode(site_id)
|
29
|
-
logger.debug "##{__method__} => path: #{path}"
|
30
|
-
|
31
|
-
user_institution, error_messages = client.send_request(path, :post, :parameters => parameters)
|
32
|
-
return user_institution, error_messages
|
33
|
-
end
|
34
|
-
|
35
|
-
def show(user_institution_id)
|
36
|
-
|
37
|
-
raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
|
38
|
-
logger.debug "##{__method__} => user_institution_id: #{user_institution_id}"
|
39
|
-
|
40
|
-
end_point = Defaults::END_POINTS[:user_institutions_show]
|
41
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
42
|
-
|
43
|
-
path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
|
44
|
-
logger.debug "##{__method__} => path: #{path}"
|
45
|
-
|
46
|
-
user_institution, error_messages = client.send_request(path, :get)
|
47
|
-
return user_institution, error_messages
|
48
|
-
end
|
49
|
-
|
50
|
-
def form(user_institution_id)
|
51
|
-
raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
|
52
|
-
logger.debug "##{__method__} => user_institution_id: #{user_institution_id}"
|
53
|
-
|
54
|
-
end_point = Defaults::END_POINTS[:user_institutions_form]
|
55
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
56
|
-
|
57
|
-
path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
|
58
|
-
logger.debug "##{__method__} => path: #{path}"
|
59
|
-
|
60
|
-
user_institution, error_messages = client.send_request(path, :get)
|
61
|
-
return user_institution, error_messages
|
62
|
-
end
|
63
|
-
|
64
|
-
def status(user_institution_id)
|
65
|
-
raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
|
66
|
-
logger.debug "##{__method__} => user_institution_id: #{user_institution_id}"
|
67
|
-
|
68
|
-
end_point = Defaults::END_POINTS[:user_institutions_status]
|
69
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
70
|
-
|
71
|
-
path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
|
72
|
-
logger.debug "##{__method__} => path: #{path}"
|
73
|
-
|
74
|
-
user_institution, error_messages = client.send_request(path, :get)
|
75
|
-
return user_institution, error_messages
|
76
|
-
end
|
77
|
-
|
78
|
-
def mfa(user_institution_id, parameters)
|
79
|
-
raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
|
80
|
-
logger.debug "##{__method__} => user_institution_id: #{user_institution_id}"
|
81
|
-
|
82
|
-
raise MissingArgumentsError.new 'Missing argument: parameters.' if parameters.blank?
|
83
|
-
logger.debug "##{__method__} => parameters: #{skip_sensitive_data parameters}"
|
84
|
-
|
85
|
-
end_point = Defaults::END_POINTS[:user_institutions_mfa]
|
86
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
87
|
-
|
88
|
-
path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
|
89
|
-
logger.debug "##{__method__} => path: #{path}"
|
90
|
-
|
91
|
-
user_institution, error_messages = client.send_request(path, :put, :parameters => parameters)
|
92
|
-
return user_institution, error_messages
|
93
|
-
end
|
94
|
-
|
95
|
-
def update(user_institution_id, parameters)
|
96
|
-
raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
|
97
|
-
logger.debug "##{__method__} => user_institution_id: #{user_institution_id}"
|
98
|
-
|
99
|
-
raise MissingArgumentsError.new 'Missing argument: parameters.' if parameters.blank?
|
100
|
-
logger.debug "##{__method__} => parameters: #{skip_sensitive_data parameters}"
|
101
|
-
|
102
|
-
end_point = Defaults::END_POINTS[:user_institutions_update]
|
103
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
104
|
-
|
105
|
-
path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
|
106
|
-
logger.debug "##{__method__} => path: #{path}"
|
107
|
-
|
108
|
-
user_institution, error_messages = client.send_request(path, :put, :parameters => parameters)
|
109
|
-
return user_institution, error_messages
|
110
|
-
end
|
111
|
-
|
112
|
-
def refresh
|
113
|
-
path = Defaults::END_POINTS[:user_institutions_refresh]
|
114
|
-
logger.debug "##{__method__} => path: #{path}"
|
115
|
-
|
116
|
-
user_institutions, error_messages = client.send_request(path, :get)
|
117
|
-
return user_institutions, error_messages
|
118
|
-
end
|
119
|
-
|
120
|
-
# @return [Hash, Array<String>]
|
121
|
-
def delete(user_institution_id)
|
122
|
-
raise MissingArgumentsError.new 'Missing argument: user_institution_id.' if user_institution_id.blank?
|
123
|
-
logger.debug "##{__method__} => user_institution_id: #{user_institution_id.inspect}"
|
124
|
-
|
125
|
-
end_point = Defaults::END_POINTS[:user_institutions_delete]
|
126
|
-
logger.debug "##{__method__} => end_point: #{end_point}"
|
127
|
-
|
128
|
-
path = end_point.sub ':user_institution_id', ERB::Util.url_encode(user_institution_id)
|
129
|
-
logger.debug "##{__method__} => path: #{path}"
|
130
|
-
|
131
|
-
_, error_messages = client.send_request(path, :delete)
|
132
|
-
error_messages
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|