Class: AgendrixBankingDetailsResolver

Inherits:
Object
  • Object
show all
Defined in:
app/resolver/agendrix_banking_details_resolver.rb

Defined Under Namespace

Classes: Actions

Constant Summary collapse

HR_PRIVATE_DATA_BANKING_DETAILS_KEY =
'3128733b-e2e9-40c5-8569-5ee9a816fe3e'
USER_NAME =
'SYSTEM'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(company_id:, employee_id:, member_id:, hr_private_data:) ⇒ AgendrixBankingDetailsResolver

Returns a new instance of AgendrixBankingDetailsResolver.



14
15
16
17
18
19
# File 'app/resolver/agendrix_banking_details_resolver.rb', line 14

def initialize(company_id:, employee_id:, member_id:, hr_private_data:)
  @company_id = company_id
  @employee_id = employee_id
  @member_id = member_id
  @hr_private_data = hr_private_data.with_indifferent_access
end

Instance Attribute Details

#company_idObject (readonly)

Returns the value of attribute company_id.



12
13
14
# File 'app/resolver/agendrix_banking_details_resolver.rb', line 12

def company_id
  @company_id
end

#employee_idObject (readonly)

Returns the value of attribute employee_id.



12
13
14
# File 'app/resolver/agendrix_banking_details_resolver.rb', line 12

def employee_id
  @employee_id
end

#hr_private_dataObject (readonly)

Returns the value of attribute hr_private_data.



12
13
14
# File 'app/resolver/agendrix_banking_details_resolver.rb', line 12

def hr_private_data
  @hr_private_data
end

#member_idObject (readonly)

Returns the value of attribute member_id.



12
13
14
# File 'app/resolver/agendrix_banking_details_resolver.rb', line 12

def member_id
  @member_id
end

Instance Method Details

#resolveObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/resolver/agendrix_banking_details_resolver.rb', line 21

def resolve
  ActiveRecord::Base.transaction do
    if 
      

      { action: Actions::UPDATE, hr_private_data: hr_private_data, bank_account: @bank_account }
    elsif 
      
      

      { action: Actions::INTEGRATE, hr_private_data: hr_private_data, bank_account: @bank_account }
    elsif 
      

      { action: Actions::CREATE, hr_private_data: hr_private_data, bank_account: @bank_account }
    end
  end
rescue StandardError => e
  Rails.logger.error "Failed to resolve Agendrix member: #{e.message}"
  raise e
end