Skip to content
Merged
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta20"
github "hyperwallet/hyperwallet-ios-sdk" "1.0.1"
github "hyperwallet/hyperwallet-ios-insight" "1.0.0-beta08"
39 changes: 32 additions & 7 deletions TransferMethod/Sources/SelectTransferMethodTypePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,22 +302,47 @@ final class SelectTransferMethodTypePresenter {

private func loadSelectedCountry(_ countries: [HyperwalletCountry],
with userCountry: String?) {
var defaultCurrencyCode: String?
if let userCountry = userCountry, countries.contains(where: { $0.value == userCountry }) {
selectedCountry = userCountry
} else if let country = countries.first, let countryValue = country.value {
selectedCountry = countryValue
}
if !selectedCountry.isEmpty{
Comment thread
grmeyer-hw-dev marked this conversation as resolved.
Outdated
if let country = countries.first(where: { $0.code == selectedCountry }) {
defaultCurrencyCode = country.defaultCurrencyCode
}
}
}

private func loadCurrency(_ keys: HyperwalletTransferMethodConfigurationKey?) {
guard let firstCurrency = keys?.currencies(from: selectedCountry)?.first,
let currencyCode = firstCurrency.code else {
view?.showAlert(message: String(format: "no_currency_available_error_message".localized(), selectedCountry))
return
guard let countries = keys?.countries(),
Comment thread
grmeyer-hw-dev marked this conversation as resolved.
let country = countries.first(where: { $0.code == selectedCountry }) else {
// Handle the case when country is not found
let errorMessage = String(format: "no_country_found_error_message".localized(), selectedCountry ?? "Unknown Country")
Comment thread
grmeyer-hw-dev marked this conversation as resolved.
Outdated
view?.showAlert(message: errorMessage)
return
}
// Check if the country has a defaultCurrencyCode
if let defaultCurrencyCode = country.defaultCurrencyCode {
// If the defaultCurrencyCode exists, use it
Comment thread
grmeyer-hw-dev marked this conversation as resolved.
Outdated
selectedCurrency = defaultCurrencyCode
} else {
// If the defaultCurrencyCode is nil, fall back to the first currency in the currencyList
if let firstCurrency = keys?.currencies(from: selectedCountry)?.first,
let currencyCode = firstCurrency.code {
selectedCurrency = currencyCode
} else {
// Show an alert if no currency is found
let errorMessage = String(format: "no_currency_available_error_message".localized(), selectedCountry ?? "Unknown Country")
Comment thread
grmeyer-hw-dev marked this conversation as resolved.
Outdated
view?.showAlert(message: errorMessage)
return
}
}

// Reload the view with the updated currency data
view?.reloadCountryCurrencyData()
}
selectedCurrency = currencyCode
view?.reloadCountryCurrencyData()
}

private func loadTransferMethodTypesFeesAndProcessingTimes(
_ transferMethodTypes: [HyperwalletTransferMethodType]?) {
Expand Down