Class: LighthouseIntentToFileProvider

Inherits:
Object
  • Object
show all
Includes:
IntentToFileProvider
Defined in:
lib/disability_compensation/providers/intent_to_file/lighthouse_intent_to_file_provider.rb

Instance Method Summary collapse

Methods included from IntentToFileProvider

create_intent_to_file, get_intent_to_file

Constructor Details

#initialize(current_user) ⇒ LighthouseIntentToFileProvider

Returns a new instance of LighthouseIntentToFileProvider.



10
11
12
13
# File 'lib/disability_compensation/providers/intent_to_file/lighthouse_intent_to_file_provider.rb', line 10

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

Instance Method Details

#create_intent_to_file(type, lighthouse_client_id, lighthouse_rsa_key_path) ⇒ Object



20
21
22
23
24
# File 'lib/disability_compensation/providers/intent_to_file/lighthouse_intent_to_file_provider.rb', line 20

def create_intent_to_file(type, lighthouse_client_id, lighthouse_rsa_key_path)
  data = @service.create_intent_to_file(type, @current_user.ssn, lighthouse_client_id,
                                        lighthouse_rsa_key_path)['data']
  transform(data)
end

#get_intent_to_file(type, lighthouse_client_id, lighthouse_rsa_key_path) ⇒ Object



15
16
17
18
# File 'lib/disability_compensation/providers/intent_to_file/lighthouse_intent_to_file_provider.rb', line 15

def get_intent_to_file(type, lighthouse_client_id, lighthouse_rsa_key_path)
  data = @service.get_intent_to_file(type, lighthouse_client_id, lighthouse_rsa_key_path)['data']
  transform(data)
end

#transform(data) ⇒ Object (private)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/disability_compensation/providers/intent_to_file/lighthouse_intent_to_file_provider.rb', line 28

def transform(data)
  DisabilityCompensation::ApiProvider::IntentToFilesResponse.new(
    intent_to_file: [
      DisabilityCompensation::ApiProvider::IntentToFile.new(
        id: data['id'],
        creation_date: data['attributes']['creationDate'],
        expiration_date: data['attributes']['expirationDate'],
        source: '',
        participant_id: 0,
        status: data['attributes']['status'],
        type: data['attributes']['type']
      )
    ]
  )
end