Skip to content

Commit

Permalink
UI SDK Release 1.0.0-beta16 (#321)
Browse files Browse the repository at this point in the history
Release 1.0.0-beta16
  • Loading branch information
aparthibanpaypal authored Jul 6, 2021
1 parent 102417a commit 0517d52
Show file tree
Hide file tree
Showing 94 changed files with 2,350 additions and 541 deletions.
3 changes: 2 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ disabled_rules: # rule identifiers to exclude from running
- empty_xctest_method
- inclusive_language
- trailing_whitespace
- override_in_extension

type_name:
max_length: # warning and error
warning: 60
Expand Down Expand Up @@ -43,7 +45,6 @@ opt_in_rules: # some rules are only opt-in
- multiline_literal_brackets
- multiline_parameters
- operator_usage_whitespace
- override_in_extension
- pattern_matching_keywords
- redundant_nil_coalescing
- redundant_type_annotation
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode12.2
osx_image: xcode12.4
os: osx
branches:
only:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Changelog
=========
[1.0.0-beta16](https://github.com/hyperwallet/hyperwallet-ios-ui-sdk/releases/tag/1.0.0-beta16)
-------------------
- Fixed currency formatting issues
- Fixed add transfer method qraphQL calls
- Fixed memory leaks
- Fixed no fee display issue


[1.0.0-beta15](https://github.com/hyperwallet/hyperwallet-ios-ui-sdk/releases/tag/1.0.0-beta15)
-------------------
Expand Down
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta13"
github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta14"
github "hyperwallet/hyperwallet-ios-insight" "1.0.0-beta04"

Original file line number Diff line number Diff line change
Expand Up @@ -16,139 +16,139 @@
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@testable import Transfer
@testable import Common
import XCTest

class TransferAmountCurrencyFormatterTests: XCTestCase {
class CurrencyFormatterTests: XCTestCase {
// swiftlint:disable function_body_length
func testFormatStringAmount() {
let cases = [
("Albania Currency", "1000000", "ALL", "1,000,000"),
("Argentina Currency", "1000000", "ARS", "1,000,000.00"),
("Armenia Currency", "1000000", "AMD", "1,000,000.00"),
("Albania Currency", "1000000", "ALL", "1 000 000,00"),
("Argentina Currency", "1000000", "ARS", "1.000.000,00"),
("Armenia Currency", "1000000", "AMD", "1 000 000,00"),
("Australia Currency", "1000000", "AUD", "1,000,000.00"),
("Bangladesh Currency", "1000000", "BDT", "1,000,000.00"),
("Brazil Currency", "1000000", "BRL", "1,000,000.00"),
("Bulgaria Currency", "1000000", "BGN", "1,000,000.00"),
("Cambodia Currency", "1000000", "KHR", "1,000,000.00"),
("Bangladesh Currency", "1000000", "BDT", "10,00,000.00"),
("Brazil Currency", "1000000", "BRL", "1.000.000,00"),
("Bulgaria Currency", "1000000", "BGN", "1000000,00"),
("Cambodia Currency", "1000000", "KHR", "1.000.000,00"),
("Canada Currency", "1000000", "CAD", "1,000,000.00"),
("Chile Currency", "1000000", "CLP", "1,000,000"),
("Chile Currency", "1000000", "CLP", "1.000.000"),
("China Currency", "1000000", "CNY", "1,000,000.00"),
("Colombia Currency", "1000000", "COP", "1,000,000"),
("Croatia Currency", "1000000", "HRK", "1,000,000.00"),
("Czech Republic Currency", "1000000", "CZK", "1,000,000.00"),
("Denmark Currency", "1000000", "DKK", "1,000,000.00"),
("Colombia Currency", "1000000", "COP", "1.000.000,00"),
("Croatia Currency", "1000000", "HRK", "1.000.000,00"),
("Czech Republic Currency", "1000000", "CZK", "1 000 000,00"),
("Denmark Currency", "1000000", "DKK", "1.000.000,00"),
("Egypt Currency", "1000000", "EGP", "1,000,000.00"),
("Austria Currency", "1000000", "EUR", "1,000,000.00"),
("Austria Currency", "1000000", "EUR", "1.000.000,00"),
("Hong Kong Currency", "1000000", "HKD", "1,000,000.00"),
("Hungary Currency", "1000000", "HUF", "1,000,000.00"),
("India Currency", "1000000", "INR", "1,000,000.00"),
("Indonesia Currency", "1000000", "IDR", "1,000,000"),
("Hungary Currency", "1000000", "HUF", "1 000 000,00"),
("India Currency", "1000000", "INR", "10,00,000.00"),
("Indonesia Currency", "1000000", "IDR", "1.000.000"),
("Jamaica Currency", "1000000", "JMD", "1,000,000.00"),
("Japan Currency", "1000000", "JPY", "1,000,000"),
("Jordan Currency", "1000000", "JOD", "1,000,000.00"),
("Kazakhstan Currency", "1000000", "KZT", "1,000,000.00"),
("Kazakhstan Currency", "1000000", "KZT", "1 000 000,00"),
("Kenya Currency", "1000000", "KES", "1,000,000.00"),
("Laos Currency", "1000000", "LAK", "1,000,000"),
("Laos Currency", "1000000", "LAK", "1.000.000,00"),
("Malaysia Currency", "1000000", "MYR", "1,000,000.00"),
("Mexico Currency", "1000000", "MXN", "1,000,000.00"),
("Morocco Currency", "1000000", "MAD", "1,000,000.00"),
("Israel Currency", "1000000", "ILS", "1,000,000.00"),
("Morocco Currency", "1000000", "MAD", "1 000 000,00"),
("Israel Currency", "1000000", "ILS", "1,000,000.00"),
("Taiwan Currency", "1000000", "TWD", "1,000,000"),
("Turkey Currency", "1000000", "TRY", "1,000,000.00"),
("Turkey Currency", "1000000", "TRY", "1.000.000,00"),
("New Zealand Currency", "1000000", "NZD", "1,000,000.00"),
("Nigeria Currency", "1000000", "NGN", "1,000,000.00"),
("Norway Currency", "1000000", "NOK", "1,000,000.00"),
("Pakistan Currency", "1000000", "PKR", "1,000,000"),
("Norway Currency", "1000000", "NOK", "1 000 000,00"),
("Pakistan Currency", "1000000", "PKR", "1,000,000.00"),
("Peru Currency", "1000000", "PEN", "1,000,000.00"),
("Philippines Currency", "1000000", "PHP", "1,000,000.00"),
("Poland Currency", "1000000", "PLN", "1,000,000.00"),
("Poland Currency", "1000000", "PLN", "1 000 000,00"),
("Isle of Man Currency", "1000000", "GBP", "1,000,000.00"),
("Romania Currency", "1000000", "RON", "1,000,000.00"),
("Russia Currency", "1000000", "RUB", "1,000,000.00"),
("Serbia Currency", "1000000", "RSD", "1,000,000"),
("Romania Currency", "1000000", "RON", "1.000.000,00"),
("Russia Currency", "1000000", "RUB", "1 000 000,00"),
("Serbia Currency", "1000000", "RSD", "1.000.000,00"),
("Singapore Currency", "1000000", "SGD", "1,000,000.00"),
("South Africa Currency", "1000000", "ZAR", "1,000,000.00"),
("South Africa Currency", "1000000", "ZAR", "1 000 000,00"),
("South Korea Currency", "1000000", "KRW", "1,000,000"),
("Sri Lanka Currency", "1000000", "LKR", "1,000,000.00"),
("Sweden Currency", "1000000", "SEK", "1,000,000.00"),
("Switzerland Currency", "1000000", "CHF", "1,000,000.00"),
("Sri Lanka Currency", "1000000", "LKR", "10,00,000.00"),
("Sweden Currency", "1000000", "SEK", "1 000 000,00"),
("Switzerland Currency", "1000000", "CHF", "1'000'000.00"),
("Thailand Currency", "1000000", "THB", "1,000,000.00"),
("Tunisia Currency", "1000000", "TND", "1,000,000.000"),
("Tunisia Currency", "1000000", "TND", "1.000.000,000"),
("United Arab Emirates Currency", "1000000", "AED", "1,000,000.00"),
("Uganda Currency", "1000000", "UGX", "1,000,000"),
("United States Currency", "1000000", "USD", "1,000,000.00"),
("Vietnam Currency", "1000000", "VND", "1,000,000")
("Vietnam Currency", "1000000", "VND", "1.000.000,00")
]
cases.forEach {
XCTAssertEqual(TransferAmountCurrencyFormatter.formatStringAmount($1, with: $2),
XCTAssertEqual(CurrencyFormatter.formatStringAmount($1, with: $2),
$3,
"\($0) test case - currency should be equal to \($3)")
"\($0) \($2) test case - currency should be equal to \($3)")
}
}

func testFormatDoubleAmount() {
let cases = [
("Albania Currency", "1000000", "ALL", "1,000,000"),
("Argentina Currency", "1000000", "ARS", "1,000,000.00"),
("Armenia Currency", "1000000", "AMD", "1,000,000.00"),
("Albania Currency", "1000000", "ALL", "1 000 000,00"),
("Argentina Currency", "1000000", "ARS", "1.000.000,00"),
("Armenia Currency", "1000000", "AMD", "1 000 000,00"),
("Australia Currency", "1000000", "AUD", "1,000,000.00"),
("Bangladesh Currency", "1000000", "BDT", "1,000,000.00"),
("Brazil Currency", "1000000", "BRL", "1,000,000.00"),
("Bulgaria Currency", "1000000", "BGN", "1,000,000.00"),
("Cambodia Currency", "1000000", "KHR", "1,000,000.00"),
("Bangladesh Currency", "1000000", "BDT", "10,00,000.00"),
("Brazil Currency", "1000000", "BRL", "1.000.000,00"),
("Bulgaria Currency", "1000000", "BGN", "1000000,00"),
("Cambodia Currency", "1000000", "KHR", "1.000.000,00"),
("Canada Currency", "1000000", "CAD", "1,000,000.00"),
("Chile Currency", "1000000", "CLP", "1,000,000"),
("Chile Currency", "1000000", "CLP", "1.000.000"),
("China Currency", "1000000", "CNY", "1,000,000.00"),
("Colombia Currency", "1000000", "COP", "1,000,000"),
("Croatia Currency", "1000000", "HRK", "1,000,000.00"),
("Czech Republic Currency", "1000000", "CZK", "1,000,000.00"),
("Denmark Currency", "1000000", "DKK", "1,000,000.00"),
("Colombia Currency", "1000000", "COP", "1.000.000,00"),
("Croatia Currency", "1000000", "HRK", "1.000.000,00"),
("Czech Republic Currency", "1000000", "CZK", "1 000 000,00"),
("Denmark Currency", "1000000", "DKK", "1.000.000,00"),
("Egypt Currency", "1000000", "EGP", "1,000,000.00"),
("Austria Currency", "1000000", "EUR", "1,000,000.00"),
("Austria Currency", "1000000", "EUR", "1.000.000,00"),
("Hong Kong Currency", "1000000", "HKD", "1,000,000.00"),
("Hungary Currency", "1000000", "HUF", "1,000,000.00"),
("India Currency", "1000000", "INR", "1,000,000.00"),
("Indonesia Currency", "1000000", "IDR", "1,000,000"),
("Hungary Currency", "1000000", "HUF", "1 000 000,00"),
("India Currency", "1000000", "INR", "10,00,000.00"),
("Indonesia Currency", "1000000", "IDR", "1.000.000"),
("Jamaica Currency", "1000000", "JMD", "1,000,000.00"),
("Japan Currency", "1000000", "JPY", "1,000,000"),
("Jordan Currency", "1000000", "JOD", "1,000,000.00"),
("Kazakhstan Currency", "1000000", "KZT", "1,000,000.00"),
("Kazakhstan Currency", "1000000", "KZT", "1 000 000,00"),
("Kenya Currency", "1000000", "KES", "1,000,000.00"),
("Laos Currency", "1000000", "LAK", "1,000,000"),
("Laos Currency", "1000000", "LAK", "1.000.000,00"),
("Malaysia Currency", "1000000", "MYR", "1,000,000.00"),
("Mexico Currency", "1000000", "MXN", "1,000,000.00"),
("Morocco Currency", "1000000", "MAD", "1,000,000.00"),
("Israel Currency", "1000000", "ILS", "1,000,000.00"),
("Morocco Currency", "1000000", "MAD", "1 000 000,00"),
("Israel Currency", "1000000", "ILS", "1,000,000.00"),
("Taiwan Currency", "1000000", "TWD", "1,000,000"),
("Turkey Currency", "1000000", "TRY", "1,000,000.00"),
("Turkey Currency", "1000000", "TRY", "1.000.000,00"),
("New Zealand Currency", "1000000", "NZD", "1,000,000.00"),
("Nigeria Currency", "1000000", "NGN", "1,000,000.00"),
("Norway Currency", "1000000", "NOK", "1,000,000.00"),
("Pakistan Currency", "1000000", "PKR", "1,000,000"),
("Norway Currency", "1000000", "NOK", "1 000 000,00"),
("Pakistan Currency", "1000000", "PKR", "1,000,000.00"),
("Peru Currency", "1000000", "PEN", "1,000,000.00"),
("Philippines Currency", "1000000", "PHP", "1,000,000.00"),
("Poland Currency", "1000000", "PLN", "1,000,000.00"),
("Poland Currency", "1000000", "PLN", "1 000 000,00"),
("Isle of Man Currency", "1000000", "GBP", "1,000,000.00"),
("Romania Currency", "1000000", "RON", "1,000,000.00"),
("Russia Currency", "1000000", "RUB", "1,000,000.00"),
("Serbia Currency", "1000000", "RSD", "1,000,000"),
("Romania Currency", "1000000", "RON", "1.000.000,00"),
("Russia Currency", "1000000", "RUB", "1 000 000,00"),
("Serbia Currency", "1000000", "RSD", "1.000.000,00"),
("Singapore Currency", "1000000", "SGD", "1,000,000.00"),
("South Africa Currency", "1000000", "ZAR", "1,000,000.00"),
("South Africa Currency", "1000000", "ZAR", "1 000 000,00"),
("South Korea Currency", "1000000", "KRW", "1,000,000"),
("Sri Lanka Currency", "1000000", "LKR", "1,000,000.00"),
("Sweden Currency", "1000000", "SEK", "1,000,000.00"),
("Switzerland Currency", "1000000", "CHF", "1,000,000.00"),
("Sri Lanka Currency", "1000000", "LKR", "10,00,000.00"),
("Sweden Currency", "1000000", "SEK", "1 000 000,00"),
("Switzerland Currency", "1000000", "CHF", "1'000'000.00"),
("Thailand Currency", "1000000", "THB", "1,000,000.00"),
("Tunisia Currency", "1000000", "TND", "1,000,000.000"),
("Tunisia Currency", "1000000", "TND", "1.000.000,000"),
("United Arab Emirates Currency", "1000000", "AED", "1,000,000.00"),
("Uganda Currency", "1000000", "UGX", "1,000,000"),
("United States Currency", "1000000", "USD", "1,000,000.00"),
("Vietnam Currency", "1000000", "VND", "1,000,000")
("Vietnam Currency", "1000000", "VND", "1.000.000,00")
]
cases.forEach {
let doubleAmount = NSString(string: $1).doubleValue
XCTAssertEqual(TransferAmountCurrencyFormatter.formatDoubleAmount(doubleAmount, with: $2),
XCTAssertEqual(CurrencyFormatter.formatDoubleAmount(doubleAmount, with: $2),
$3,
"\($0) test case - currency should be equal to \($3)")
}
Expand Down Expand Up @@ -214,7 +214,7 @@ class TransferAmountCurrencyFormatterTests: XCTestCase {
("Vietnam Currency", "1000000", "VND", 10000.0)
]
cases.forEach {
XCTAssertEqual(TransferAmountCurrencyFormatter.getDecimalAmount(amount: $1, currencyCode: $2),
XCTAssertEqual(CurrencyFormatter.getDecimalAmount(amount: $1, currencyCode: $2),
$3,
"\($0) test case - currency should be equal to \($3)")
}
Expand Down
35 changes: 30 additions & 5 deletions Common/Sources/Extensions/HyperwalletFee.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public extension HyperwalletFee {
case percent(_ percentFee: HyperwalletFee)
/// Mixed fee
case mixed(_ percentFee: HyperwalletFee, _ flatFee: HyperwalletFee)
/// No Fee
case noFee

func feeDescription() -> String {
switch self {
Expand All @@ -59,19 +61,32 @@ public extension HyperwalletFee {

case let .mixed(percentFee, flatFee):
return mixedFeeDescription(percentFee, flatFee)

case .noFee:
return noFeeDescription()
}
}

private func noFeeDescription() -> String {
return "no_fee".localized()
}

private func flatFeeDescription(_ flatFee: HyperwalletFee) -> String {
guard let flatFeeValue = flatFee.value?.formatAmountToDouble(), flatFeeValue > 0
else { return FeeTypes.noFee.feeDescription() }
var description = ""
let feeFormat = "fee_flat_formatter".localized()
if let currencySymbol = currencySymbol(currency: flatFee.currency), let flatValue = flatFee.value {
description = String(format: feeFormat.localized(), currencySymbol, flatValue)
} else {
description = FeeTypes.noFee.feeDescription()
}
return description
}

private func percentFeeDescription(_ percentFee: HyperwalletFee) -> String {
guard let percentFeeValue = percentFee.value?.formatAmountToDouble(), percentFeeValue > 0
else { return FeeTypes.noFee.feeDescription() }
var description = ""
var feeFormat = ""
let value = percentFee.value
Expand All @@ -95,6 +110,8 @@ public extension HyperwalletFee {
if let value = value {
feeFormat = "fee_percent_no_min_and_max_formatter".localized()
description = String(format: feeFormat, value)
} else {
description = FeeTypes.noFee.feeDescription()
}
}
return description
Expand All @@ -108,6 +125,15 @@ public extension HyperwalletFee {
let min = percentFee.minimum
let max = percentFee.maximum
let currency = flatFee.currency

if (flatValue == nil && percentValue == nil) ||
( flatValue?.formatAmountToDouble() == 0 && percentValue?.formatAmountToDouble() == 0) {
return FeeTypes.noFee.feeDescription()
} else if flatValue == nil || flatValue?.formatAmountToDouble() == 0 {
return percentFeeDescription(percentFee)
} else if percentValue == nil || percentValue?.formatAmountToDouble() == 0 {
return flatFeeDescription(flatFee)
}

if let min = min, let max = max, let flatValue = flatValue,
let percentValue = percentValue, let currencySymbol = currencySymbol(currency: currency) {
Expand Down Expand Up @@ -136,11 +162,10 @@ public extension HyperwalletFee {
}

private func currencySymbol(currency: String?) -> String? {
if let currency = currency {
let locale = NSLocale(localeIdentifier: currency)
return locale.displayName(forKey: .currencySymbol, value: currency)
}
return nil
guard let currency = currency,
let currencySymbol = CurrencyFormatter.getCurrency(for: currency)?.symbol
else { return nil }
return currencySymbol
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ public extension HyperwalletTransferMethodType {
let attributedText = NSMutableAttributedString()
// Fees
if let fees = self.fees?.nodes {
attributedText.append(value: HyperwalletFee.format(fees: fees), font: font, color: color)
attributedText.append(value: HyperwalletFee.format(fees: fees),
font: font,
color: color)
} else {
attributedText.append(value: HyperwalletFee.FeeTypes.noFee.feeDescription(),
font: font,
color: color)
}

// Processing Time
Expand Down
Loading

0 comments on commit 0517d52

Please sign in to comment.