Class: DirectDeposit::Client
Constant Summary
collapse
- STATSD_KEY_PREFIX =
'api.direct_deposit'
Instance Method Summary
collapse
#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Constructor Details
#initialize(icn) ⇒ Client
Returns a new instance of Client.
13
14
15
16
17
18
|
# File 'lib/lighthouse/direct_deposit/client.rb', line 13
def initialize(icn)
@icn = icn
raise ArgumentError, 'no ICN passed in for Lighthouse API request.' if icn.blank?
super()
end
|
Instance Method Details
#build_request_body(payment_account) ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/lighthouse/direct_deposit/client.rb', line 55
def build_request_body(payment_account)
{
'paymentAccount' =>
{
'accountNumber' => payment_account.account_number,
'accountType' => payment_account.account_type,
'financialInstitutionRoutingNumber' => payment_account.routing_number
}
}.to_json
end
|
#get_payment_info ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/lighthouse/direct_deposit/client.rb', line 20
def get_payment_info
response = config.get("?icn=#{@icn}")
handle_response(response)
rescue Timeout::Error, Faraday::TimeoutError => e
raise Common::Exceptions::GatewayTimeout, e.class.name
rescue Faraday::ClientError, Faraday::ServerError => e
handle_error(e, config.settings.client_id, config.base_path)
end
|
#handle_error(error, lighthouse_client_id, base_path) ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/lighthouse/direct_deposit/client.rb', line 46
def handle_error(error, lighthouse_client_id, base_path)
Lighthouse::ServiceException.send_error(
error,
self.class.to_s.underscore,
lighthouse_client_id,
base_path
)
end
|
#handle_response(response) ⇒ Object
#update_payment_info(params) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/lighthouse/direct_deposit/client.rb', line 29
def update_payment_info(params)
body = build_request_body(params)
response = config.put("?icn=#{@icn}", body)
handle_response(response)
rescue Timeout::Error, Faraday::TimeoutError => e
raise Common::Exceptions::GatewayTimeout, e.class.name
rescue Faraday::ClientError, Faraday::ServerError => e
handle_error(e, config.settings.client_id, config.base_path)
end
|