@@ -3,6 +3,7 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
33 import HELF.Flow
44
55 alias Helix.Event
6+ alias Helix.Entity.Model.Entity
67 alias Helix.Entity.Query.Entity , as: EntityQuery
78 alias Helix.Network.Action.Flow.Tunnel , as: TunnelFlow
89 alias Helix.Network.Query.Network , as: NetworkQuery
@@ -15,6 +16,8 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
1516
1617 alias Helix.Universe.Bank.Process.Bank.Account.AccountCreate ,
1718 as: BankAccountCreateProcess
19+ alias Helix.Universe.Bank.Process.Bank.Account.AccountClose ,
20+ as: BankAccountCloseProcess
1821 alias Helix.Universe.Bank.Process.Bank.Account.RevealPassword ,
1922 as: BankAccountRevealPasswordProcess
2023 alias Helix.Universe.Bank.Process.Bank.Account.ChangePassword ,
@@ -62,29 +65,36 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
6265 Starts the `bank_account_create` process.
6366 """
6467 def open ( gateway , account_id , atm , relay ) do
65- entity_id = Entity.ID . cast! ( to_string ( account_id . id ) )
68+ entity_id = Entity.ID . cast! ( to_string ( account_id ) )
69+ atm_id = atm . server_id
6670
6771 meta = % {
68- src_atm_id: atm . server_id ,
72+ network_id: NetworkQuery . internet ( ) . network_id ,
73+ bounce: nil ,
6974 source_entity_id: entity_id
7075 }
7176
72- BankAccountCreateProcess . execute ( gateway , atm , % { } , meta , relay )
77+ BankAccountCreateProcess . execute ( gateway , atm , % { atm_id: atm_id } , meta , relay )
7378 end
7479
75- @ spec close ( BankAccount . t ) ::
80+ @ spec close ( Server . t , BankAccount . t , Server . t , relay ) ::
7681 { :ok , Process . t }
7782 | BankAccountCloseProcess . executable_error
7883 @ doc """
7984 Starts the `bank_account_close` process.
8085 """
8186 def close ( gateway , bank_account , atm , relay ) do
8287 meta = % {
83- src_atm_id: bank_account . server_id ,
84- src_account_number: bank_account . account_number
88+ network_id: NetworkQuery . internet ( ) . network_id ,
89+ bounce: nil
90+ }
91+
92+ params = % {
93+ atm_id: bank_account . atm_id ,
94+ account_number: bank_account . account_number
8595 }
8696
87- BankAccountCloseProcess . execute ( gateway , atm , % { } , meta , relay )
97+ BankAccountCloseProcess . execute ( gateway , atm , params , meta , relay )
8898 end
8999
90100 @ spec change_password ( BankAccount . t , Server . t , Server . t , relay ) ::
@@ -118,7 +128,7 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
118128
119129 Emits: BankAccountLoginEvent, (ConnectionStartedEvent)
120130 """
121- def login_password ( atm_id , account_number , gateway_id , bounce_id , password ) do
131+ def login_password ( atm_id , account_number , gateway_id , bounce_id , password , relay ) do
122132 acc = BankQuery . fetch_account ( atm_id , account_number )
123133 entity = EntityQuery . fetch_by_server ( gateway_id )
124134
@@ -137,7 +147,7 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
137147 with \
138148 true <- not is_nil ( acc ) ,
139149 { :ok , _ , events } <- BankAction . login_password ( acc , password , entity ) ,
140- on_success ( fn -> Event . emit ( events ) end ) ,
150+ on_success ( fn -> Event . emit ( events , from: relay ) end ) ,
141151
142152 { :ok , tunnel , connection } <- start_connection . ( )
143153 do
@@ -153,7 +163,7 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
153163
154164 Emits: BankAccountLoginEvent, (ConnectionStartedEvent)
155165 """
156- def login_token ( atm_id , account_number , gateway_id , bounce_id , token ) do
166+ def login_token ( atm_id , account_number , gateway_id , bounce_id , token , relay ) do
157167 acc = BankQuery . fetch_account ( atm_id , account_number )
158168 entity = EntityQuery . fetch_by_server ( gateway_id )
159169
@@ -172,7 +182,7 @@ defmodule Helix.Universe.Bank.Action.Flow.BankAccount do
172182 with \
173183 true <- not is_nil ( acc ) ,
174184 { :ok , _ , events } <- BankAction . login_token ( acc , token , entity ) ,
175- on_success ( fn -> Event . emit ( events ) end ) ,
185+ on_success ( fn -> Event . emit ( events , from: relay ) end ) ,
176186
177187 { :ok , tunnel , connection } <- start_connection . ( )
178188 do
0 commit comments