@startuml
title CreateProfileViaSignup API
autonumber "<color:red><b>00 "
skinparam backgroundColor #FFFFFF
skinparam sequence {
    TitleFontSize 20
    ActorFontSize 12
    ParticipantFontSize 12
    ParticipantPadding 40
    ArrowFontSize 12
}
actor       "        User       " as USR
box "<size:16>Secure ID" #Beige
participant "   EUI App  " as EUI_PROFILE
participant "  EUI App Services " as EUI_SERVICES
end box
participant "      IAM    " as IAM
USR -> EUI_PROFILE:     <b>User clicked on `Signup` button on registration page)</b>
EUI_PROFILE -> EUI_SERVICES:          <b>POST</b> /createprofileViaSignup
EUI_SERVICES -> EUI_SERVICES: Check for users system(flow )
alt If flow is connectMeUser or djn
      EUI_SERVICES -> IAM:     <b> Invoke encrypt api</b>
      IAM -> EUI_SERVICES: <b> Returns success response </b>
      EUI_SERVICES -> IAM:     <b> Invoke checkpassword api</b>
      IAM -> EUI_SERVICES: <b> Returns success response </b>
      EUI_SERVICES -> IAM:     <b> Invoke checkEmail api</b>
      IAM -> EUI_SERVICES: <b> Returns success response </b>
      note right of EUI_PROFILE: Upon all success, will check \nfor placeholder and create profile \n
      alt If email is PLACEHOLDER
         EUI_SERVICES -> IAM:     <b> Invoke createProfile api</b>
         IAM -> EUI_SERVICES: <b> Returns success response </b>
         alt check for network msisdn
           EUI_SERVICES -> EUI_SERVICES:  <b> entered msisdn is equal to network msisdn 
           EUI_SERVICES -> IAM:     <b> Invoke linkPhone api</b>
           IAM -> EUI_SERVICES: <b> Returns success response </b>
         else 
           EUI_SERVICES -> IAM:     <b> Invoke sendsmspintomsisdn api</b>
           IAM -> EUI_SERVICES: <b> Returns success response </b>
           EUI_SERVICES -> EUI_PROFILE: <b> Returns success response
           EUI_PROFILE -> USR:         <b>User will be navigated to otp screen.</b>
         end
      else not placeholder
           EUI_SERVICES -> IAM:     <b> Invoke authenticate api</b>
           IAM -> EUI_SERVICES: <b> Returns success response </b>
           note right of EUI_PROFILE:  \n if it's success, \nwill return email_already exists error \n 
           EUI_SERVICES -> EUI_PROFILE: <b> Returns error response
           EUI_PROFILE -> USR:         <b>Page level error message displayed.</b>
      end
else regular flow
      EUI_SERVICES -> IAM:     <b> Invoke /v1/user/profile api</b>
      IAM -> EUI_SERVICES: <b> Returns success response </b>
      EUI_SERVICES -> IAM:     <b> Invoke checkMsisdn api</b>
      IAM -> EUI_SERVICES: <b> Returns success response </b>
      alt if checkMsisdn retruns error    
         EUI_SERVICES -> IAM:     <b> Invoke authenticate api</b>
         IAM -> EUI_SERVICES: <b> Returns success response </b>
         note right of EUI_PROFILE:  \n if it's success, \nwill return msisdn_already exists error \n 
         EUI_SERVICES -> EUI_PROFILE: <b> Returns error response
         EUI_PROFILE -> USR:         <b>Page level error message displayed.</b>
      else will execute steps 4 to 11 
      end
end
@enduml