package Ġcom . ap top ay ments . sdk . features . input data Ċ Ċ import Ġcom . ap top ay ments . mobile . data . user .* Ċ import Ġcom . ap top ay ments . mobile . data . workflow action . Workflow Action Configuration Collect UserData Ċ import Ġcom . ap top ay ments . mobile . exception . Failure Ċ import Ġcom . ap top ay ments . mobile . functional . Either Ċ import Ġcom . ap top ay ments . mobile . functional . right Ċ import Ġcom . ap top ay ments . mobile . platform . A pto Platform Protocol Ċ import Ġcom . ap top ay ments . sdk . core . platform . Base Fragment Ċ import Ġcom . ap top ay ments . sdk . core . platform . flow . Flow Ċ import Ġcom . ap top ay ments . sdk . core . platform . flow . Flow Present able Ċ import Ġcom . ap top ay ments . sdk . features . input data . address . Collect User Address Contract Ċ import Ġcom . ap top ay ments . sdk . features . input data . birth date . Collect User Birth date Contract Ċ import Ġcom . ap top ay ments . sdk . features . input data . email . Collect User Email Contract Ċ import Ġcom . ap top ay ments . sdk . features . input data . id . Collect UserId Contract Ċ import Ġcom . ap top ay ments . sdk . features . input data . name . Collect UserName S urname Contract Ċ import Ġcom . ap top ay ments . sdk . features . input data . phone . Collect User Phone Contract Ċ import Ġorg . k oin . core . inject Ċ Ċ private Ġconst Ġval ĠCOL LECT _ NAME _ TAG Ġ= Ġ" Collect Name Fragment " Ċ private Ġconst Ġval ĠCOL LECT _ EMAIL _ TAG Ġ= Ġ" Collect Email Fragment " Ċ private Ġconst Ġval ĠCOL LECT _ ID _ DOCUMENT _ TAG Ġ= Ġ" Collect Id Document Fragment " Ċ private Ġconst Ġval ĠCOL LECT _ ADDRESS _ TAG Ġ= Ġ" Collect Address Fragment " Ċ private Ġconst Ġval ĠCOL LECT _ B IR TH DATE _ TAG Ġ= Ġ" Collect Birth date Fragment " Ċ private Ġconst Ġval ĠCOL LECT _ PHONE _ TAG Ġ= Ġ" Collect Phone Fragment " Ċ Ċ internal Ġclass ĠCollect UserData Flow ( ĊĠĠĠ Ġprivate Ġval Ġaction Configuration : ĠWorkflow Action Configuration Collect UserData , ĊĠĠĠ Ġprivate Ġval Ġon Back : Ġ() Ġ-> ĠUnit , ĊĠĠĠ Ġprivate Ġval Ġon Finish : Ġ() Ġ-> ĠUnit Ċ ) Ġ: ĠFlow (), ĊĠĠĠ ĠCollect UserName S urname Contract . Delegate , ĊĠĠĠ ĠCollect User Email Contract . Delegate , ĊĠĠĠ ĠCollect UserId Contract . Delegate , ĊĠĠĠ ĠCollect User Address Contract . Delegate , ĊĠĠĠ ĠCollect User Birth date Contract . Delegate , ĊĠĠĠ ĠCollect User Phone Contract . Delegate Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġapt o Platform : ĠA pto Platform Protocol Ġby Ġinject () ĊĠĠĠ Ġprivate Ġvar Ġstep Ġ= Ġ 0 ĊĠĠĠ Ġprivate Ġval Ġdata Point Map Ġ= Ġmutable Map Of < DataPoint . Type , ĠData Point >() ĊĊĠĠĠ Ġoverride Ġfun Ġinit ( on Init Complete : Ġ( Either < Failure , ĠUnit >) Ġ-> ĠUnit ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfragment Ġ= Ġget Fragment For Step ( step ) ĊĠĠĠĠĠĠĠ Ġif Ġ( fragment Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Start Element ( fragment ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Init Complete ( Unit . right ()) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Init Complete ( Either . Left ( No Configuration Step ())) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġhas More Steps () Ġ= Ġstep Ġ< Ġ( action Configuration . data Points . size Ġ- Ġ 1 ) ĊĊĠĠĠ Ġ@ Suppress (" IMP LICIT _ CAST _ TO _ ANY ") ĊĠĠĠ Ġprivate Ġfun Ġget Fragment For Step ( step : ĠInt ): ĠFlow Present able ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrent DataPoint Ġ= Ġaction Configuration . data Points [ step ] ĊĠĠĠĠĠĠĠ Ġval Ġfragment Ġ= Ġwhen Ġ( current DataPoint . type ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠData Point . Type . NAME Ġ-> ĠgetName Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠData Point . Type . EMAIL Ġ-> Ġget Email Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠData Point . Type . ID _ DOCUMENT Ġ-> ĠgetId Fragment ( current DataPoint ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠData Point . Type . ADDRESS Ġ-> Ġget Address Fragment ( current DataPoint ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠData Point . Type . B IR TH DATE Ġ-> Ġget Birth date Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠData Point . Type . PHONE Ġ-> Ġget Phone Fragment ( current DataPoint ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġnull ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġfragment Ġas ĠFlow Present able ? ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetId Fragment ( current DataPoint : ĠRequired DataPoint ) Ġ= ĊĠĠĠĠĠĠĠ Ġfragment Factory . collect Id Document Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdata Point Map [ DataPoint . Type . ID _ DOCUMENT ] Ġas ĠId Document DataPoint ?, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcurrent DataPoint . datap oint Configuration Ġas ĠId DataPoint Configuration , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCOL LECT _ ID _ DOCUMENT _ TAG ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ Ġdelegate Ġ= Ġthis @ Collect UserData Flow Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Birth date Fragment () Ġ= ĊĠĠĠĠĠĠĠ Ġfragment Factory . collect Birth date Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdata Point Map [ DataPoint . Type . B IR TH DATE ] Ġas ĠB irth date DataPoint ?, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCOL LECT _ B IR TH DATE _ TAG ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ Ġdelegate Ġ= Ġthis @ Collect UserData Flow Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetName Fragment () Ġ= ĊĠĠĠĠĠĠĠ Ġfragment Factory . collect Name Fragment ( data Point Map [ DataPoint . Type . NAME ] Ġas ĠName DataPoint ?, ĠCOL LECT _ NAME _ TAG ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. apply Ġ{ Ġdelegate Ġ= Ġthis @ Collect UserData Flow Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Email Fragment () Ġ= ĊĠĠĠĠĠĠĠ Ġfragment Factory . collect Email Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdata Point Map [ DataPoint . Type . EMAIL ] Ġas ĠEmail DataPoint ?, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCOL LECT _ EMAIL _ TAG ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ Ġdelegate Ġ= Ġthis @ Collect UserData Flow Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Address Fragment ( current DataPoint : ĠRequired DataPoint ): ĠCollect User Address Contract . View Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconfiguration Ġ= Ġcurrent DataPoint . datap oint Configuration Ġ?: ĠAllowed Countries Configuration ( emptyList ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġfragment Factory . collect Address Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdata Point Map [ DataPoint . Type . ADDRESS ] Ġas ĠAddress DataPoint ?, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfiguration Ġas ĠAllowed Countries Configuration , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCOL LECT _ ADDRESS _ TAG ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ Ġdelegate Ġ= Ġthis @ Collect UserData Flow Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Phone Fragment ( current DataPoint : ĠRequired DataPoint ): ĠCollect User Phone Contract . View Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconfiguration Ġ= Ġcurrent DataPoint . datap oint Configuration Ġ?: ĠAllowed Countries Configuration ( emptyList ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġfragment Factory . collect Phone Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdata Point Map [ DataPoint . Type . PHONE ] Ġas ĠPhone DataPoint ?, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfiguration Ġas ĠAllowed Countries Configuration , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCOL LECT _ PHONE _ TAG ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ Ġdelegate Ġ= Ġthis @ Collect UserData Flow Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrestore State () Ġ{ ĊĠĠĠĠĠĠĠ Ġ( fragment With Tag ( COLLECT _ NAME _ TAG ) Ġas ? ĠCollect UserName S urname Contract . View )?. let Ġ{ Ġit . delegate Ġ= Ġthis Ġ} ĊĠĠĠĠĠĠĠ Ġ( fragment With Tag ( COLLECT _ EMAIL _ TAG ) Ġas ? ĠCollect User Email Contract . View )?. let Ġ{ Ġit . delegate Ġ= Ġthis Ġ} ĊĠĠĠĠĠĠĠ Ġ( fragment With Tag ( COLLECT _ ID _ DOCUMENT _ TAG ) Ġas ? ĠCollect UserId Contract . View )?. let Ġ{ Ġit . delegate Ġ= Ġthis Ġ} ĊĠĠĠĠĠĠĠ Ġ( fragment With Tag ( COLLECT _ ADDRESS _ TAG ) Ġas ? ĠCollect User Address Contract . View )?. let Ġ{ Ġit . delegate Ġ= Ġthis Ġ} ĊĠĠĠĠĠĠĠ Ġ( fragment With Tag ( COLLECT _ B IR TH DATE _ TAG ) Ġas ? ĠCollect User Birth date Contract . View )?. let Ġ{ Ġit . delegate Ġ= Ġthis Ġ} ĊĠĠĠĠĠĠĠ Ġ( fragment With Tag ( COLLECT _ PHONE _ TAG ) Ġas ? ĠCollect User Phone Contract . View )?. let Ġ{ Ġit . delegate Ġ= Ġthis Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Name Entered Correct ly ( value : ĠName DataPoint ) Ġ= Ġon Value Entered Correct ly ( value ) ĊĊĠĠĠ Ġoverride Ġfun Ġon Back From Input Name () Ġ= Ġon Back Pressed () ĊĊĠĠĠ Ġoverride Ġfun Ġon Email Entered Correct ly ( value : ĠEmail DataPoint ) Ġ= Ġon Value Entered Correct ly ( value ) ĊĊĠĠĠ Ġoverride Ġfun Ġon Back From Collect Email () Ġ= Ġon Back Pressed () ĊĊĠĠĠ Ġoverride Ġfun Ġon Id Entered Correct ly ( value : ĠId Document DataPoint ) Ġ= Ġon Value Entered Correct ly ( value ) ĊĊĠĠĠ Ġoverride Ġfun Ġon Back From Collect Id () Ġ= Ġon Back Pressed () ĊĊĠĠĠ Ġoverride Ġfun Ġon Address Selected ( value : ĠAddress DataPoint ) Ġ= Ġon Value Entered Correct ly ( value ) ĊĊĠĠĠ Ġoverride Ġfun Ġon Back From Address () Ġ= Ġon Back Pressed () ĊĊĠĠĠ Ġoverride Ġfun Ġon Birth date Entered Correct ly ( value : ĠB irth date DataPoint ) Ġ= Ġon Value Entered Correct ly ( value ) ĊĊĠĠĠ Ġoverride Ġfun Ġon Back From Birth date Verification () Ġ= Ġon Back Pressed () ĊĊĠĠĠ Ġoverride Ġfun Ġon Phone Entered Correct ly ( value : ĠPhone DataPoint ) Ġ= Ġon Value Entered Correct ly ( value ) ĊĊĠĠĠ Ġoverride Ġfun Ġon Back From Collect Phone () Ġ= Ġon Back Pressed () ĊĊĠĠĠ Ġprivate Ġfun Ġon Back Pressed () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( step Ġ> Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstep -- ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpop Fragment () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Back . invoke () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Value Entered Correct ly ( data : ĠData Point ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdata Point Map [ data . getType ()] Ġ= Ġdata ĊĠĠĠĠĠĠĠ Ġif Ġ( hasMore Steps ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstep ++ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfragment Ġ= Ġget Fragment For Step ( step ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpush ( fragment Ġas ĠBase Fragment ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupdate User () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate User () Ġ{ ĊĠĠĠĠĠĠĠ Ġshow Loading () ĊĠĠĠĠĠĠĠ Ġval Ġdata Point List Ġ= ĠData Point List ( data Point Map . values . toList ()) ĊĠĠĠĠĠĠĠ Ġapt o Platform . update UserInfo ( data Point List ) Ġ{ Ġresult Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . either (:: handle Failure ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhide Loading () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġon Finish . invoke () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinternal Ġclass ĠNo Configuration Step Ġ: ĠFailure . Feature Failure () Ċ } Ċ