Class: DirectDeposit::Client

Inherits:
Common::Client::Base show all
Defined in:
lib/lighthouse/direct_deposit/client.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'api.direct_deposit'

Instance Method Summary collapse

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Constructor Details

#initialize(icn) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


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

#get_payment_infoObject



20
21
22
23
24
25
# File 'lib/lighthouse/direct_deposit/client.rb', line 20

def get_payment_info
  response = config.get("?icn=#{@icn}")
  handle_response(response)
rescue Faraday::ClientError, Faraday::ServerError => e
  handle_error(e, config.settings.client_id, config.base_path)
end

#update_payment_info(params) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/lighthouse/direct_deposit/client.rb', line 27

def update_payment_info(params)
  body = build_request_body(params)

  response = config.put("?icn=#{@icn}", body)
  handle_response(response)
rescue Faraday::ClientError, Faraday::ServerError => e
  handle_error(e, config.settings.client_id, config.base_path)
end