Class: LighthouseClaimsServiceProvider

Inherits:
Object
  • Object
show all
Includes:
ClaimsServiceProvider
Defined in:
lib/disability_compensation/providers/claims_service/lighthouse_claims_service_provider.rb

Instance Method Summary collapse

Methods included from ClaimsServiceProvider

all_claims

Constructor Details

#initialize(icn) ⇒ LighthouseClaimsServiceProvider

Returns a new instance of LighthouseClaimsServiceProvider.



10
11
12
# File 'lib/disability_compensation/providers/claims_service/lighthouse_claims_service_provider.rb', line 10

def initialize(icn)
  @service = BenefitsClaims::Service.new(icn)
end

Instance Method Details

#all_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil) ⇒ Object



14
15
16
17
18
# File 'lib/disability_compensation/providers/claims_service/lighthouse_claims_service_provider.rb', line 14

def all_claims(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil)
  # the below call to get_claims only gets potential OPEN claims
  data = @service.get_claims(lighthouse_client_id, lighthouse_rsa_key_path)['data']
  transform(data)
end

#transform(data) ⇒ Object (private)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/disability_compensation/providers/claims_service/lighthouse_claims_service_provider.rb', line 22

def transform(data)
  open_claims = data.map do |open_claim|
    DisabilityCompensation::ApiProvider::Claim.new(
      id: open_claim['id'],
      base_end_product_code: open_claim['attributes']['baseEndProductCode'],
      claim_date: open_claim['attributes']['claimDate'],
      claim_phase_dates: open_claim['attributes']['claimPhaseDates'],
      development_letter_sent: open_claim['attributes']['developmentLetterSent'],
      status: open_claim['attributes']['status'] # make sure words/strings syntax is perfect match
    )
  end

  DisabilityCompensation::ApiProvider::ClaimsServiceResponse.new(open_claims:)
end