private fun getCountryData() {viewModelScope.launch(Dispatchers.IO) {inputStreamForCountriesJSONObject = CountriesRegistrationFormat.instance.getCountriesRegistrationFormat() selectedCountriesJSONObject = inputStreamForCountriesJSONObject!!.optJSONArray(LocaleUtils.instance.localeCountry) for (i in 0 until selectedCountriesJSONObject!!.length()) { val selectedCountryAttributes = selectedCountriesJSONObject!!.optJSONObject(i) val keyAttribute = selectedCountryAttributes!!.optString("name") val keyAttributeRequired = selectedCountryAttributes.optBoolean("required") when (keyAttribute) { "PROVINCE" -> { } "STATE" -> { _uiState.value = uiState.value.copy( addressFields = _uiState.value.addressFields.copy( selectedState = _uiState.value.addressFields.selectedState.copy( isRequired = keyAttributeRequired ) ) ) } "POSTAL_CODE" -> { } "ZIP_CODE" -> { _uiState.value = uiState.value.copy( addressFields = uiState.value.addressFields.copy( zipcode = uiState.value.addressFields.zipcode.copy( isRequired = keyAttributeRequired ) ) ) } "STREET1" -> { _uiState.value = uiState.value.copy( addressFields = uiState.value.addressFields.copy( address1 = uiState.value.addressFields.address1.copy( isRequired = keyAttributeRequired ) ) ) } "STREET2" -> { _uiState.value = uiState.value.copy( addressFields = uiState.value.addressFields.copy( address2 = uiState.value.addressFields.address2.copy( isRequired = keyAttributeRequired ) ) ) } "STREET3" -> { _uiState.value = uiState.value.copy( addressFields = _uiState.value.addressFields.copy( address3 = _uiState.value.addressFields.address3.copy( isRequired = keyAttributeRequired ) ) ) } "STREET4" -> { } "MUNICIPALITY" -> { //Ying confirmed no Latin for Municipality in AN and API call } "CITY" -> { _uiState.value = uiState.value.copy( addressFields = _uiState.value.addressFields.copy( city = _uiState.value.addressFields.city.copy( isRequired = keyAttributeRequired ) ) ) } "STATE_TEXT" -> { } "COUNTRY" -> { _uiState.value = uiState.value.copy( addressFields = _uiState.value.addressFields.copy( selectedCountry = _uiState.value.addressFields.selectedCountry.copy( isRequired = keyAttributeRequired ) ) ) } } } } }
implementation for taking the fields required for the Company information Form