private fun proceedToAccountCreationApiCall(): JSONObject { val userParams = JSONObject() val createParams = JSONObject() val supplierParams = JSONObject() val addressParams = JSONObject() val touArr = JSONArray() userParams.putOpt("userId", uiState.value.userName.value) userParams.putOpt("password", uiState.value.password.value) userParams.putOpt("firstName",uiState.value.firstName.value) userParams.putOpt("lastName",uiState.value.lastName.value) userParams.putOpt("language",Resources.getSystem().configuration.locale.language) userParams.putOpt("email",uiState.value.email.value) userParams.putOpt("businessRole", uiState.value.selectedBusinessRole) if (uiState.value.selectedBusinessRole == "OTHER") { userParams.putOpt("businessRoleOtherValue", uiState.value.selectedOtherBusinessRole) } createParams.putOpt("user", userParams) addressParams.putOpt("street1", uiState.value.addressFields.address1.value?:"") addressParams.putOpt("street2", uiState.value.addressFields.address2.value?:"") addressParams.putOpt("street3", uiState.value.addressFields.address3.value?:"") addressParams.putOpt("city", uiState.value.addressFields.city.value?:"") addressParams.putOpt("state", uiState.value.addressFields.address1.value?:"") addressParams.putOpt("isoStateCode", uiState.value.selectedStateAbb?:"") addressParams.putOpt("postalCode", uiState.value.addressFields.zipcode.value?:"") addressParams.putOpt("isoCountryCode",uiState.value.addressFields.selectedIso2Code?:"") supplierParams.putOpt("name", uiState.value.companyName.value) supplierParams.putOpt("accountType", "LIGHT") supplierParams.putOpt("routingEmail", uiState.value.email.value) supplierParams.putOpt("address", addressParams) createParams.putOpt("supplier", supplierParams) createParams.putOpt("source", "MOBILE") touArr.put("TOU_UNIFIED") touArr.put("SYSTEM_PRIVACY_STATEMENT") createParams.putOpt("documentTypes", touArr) return createParams } private fun proceedToContactAdminEmailConfirmationScreen() { viewModelScope.launch(Dispatchers.IO) { navigationEvent.emit(RegistrationNavigationEvent.OpenContactAdminEmailConfirmationScreen) } }
This function creates the param required for account creation and makes the api call for the account creation. Based on the response received from the API call it navigates the UI flow further.