Class: DebtManagementCenter::PaymentsService

Inherits:
Object
  • Object
show all
Includes:
SentryLogging
Defined in:
lib/debt_management_center/payments_service.rb

Instance Method Summary collapse

Methods included from SentryLogging

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

Constructor Details

#initialize(current_user) ⇒ DebtManagementCenter::PaymentsService

Retrieves the person and payments data, from BGS, that relates to the provided user.

Parameters:

  • current_user (User)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/debt_management_center/payments_service.rb', line 14

def initialize(current_user)
  @person =
    begin
      BGS::People::Request.new.find_person_by_participant_id(user: current_user)
    rescue => e
      report_error(e)
      {}
    end

  @payments =
    begin
      BGS::PaymentService.new(current_user).payment_history(@person)[:payments][:payment].presence || []
    rescue => e
      report_error(e)
      []
    end
end

Instance Method Details

#compensation_and_pensionArray<Hash>?

Returns a list of BGS Payment Hashes filtered by :payment_type == ‘Compensation & Pension - Recurring’ and sorted by :payment_date, ascending.

Pending payments (where :payment_date == nil) are not included in the result.

Returns:

  • (Array<Hash>, nil)


40
41
42
# File 'lib/debt_management_center/payments_service.rb', line 40

def compensation_and_pension
  select_payments :compensation
end

#educationArray<Hash>?

Returns a list of BGS Payment Hashes filtered by :payment_type == ‘Post-9/11 GI Bill’ and sorted by :payment_date, ascending.

Pending payments (where :payment_date == nil) are not included in the result.

Returns:

  • (Array<Hash>, nil)


52
53
54
# File 'lib/debt_management_center/payments_service.rb', line 52

def education
  select_payments :education
end