// // FunctionTest.swift // GMERemittanceTests // // Created by InKwon Devik Kim on 09/07/2019. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import XCTest @testable import GME_Remit class FunctionTest: XCTestCase { func testExpireDate() { guard let remindDay = Utility.calculateDDay(registDate: "7/12/2018 4:19:37 PM") else { XCTAssert(false) return } print("remindDay: \(remindDay)") XCTAssert(true) } func testDateFormat() { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "M/d/yyyy h:mm:ss a" dateFormatter.locale = Locale(identifier: "ko_kr") dateFormatter.timeZone = TimeZone(abbreviation: "KST") var dateComponent = DateComponents() dateComponent.year = 1 let resigstDate = "7/11/2019 4:19:37 PM" guard let date = dateFormatter.date(from: resigstDate) else { XCTAssert(false) return } print("Date: \(date)") } func testIDValid() { let extractID = "l.e ibn$iz@55_good-)(*&".extract(regex: "[A-Z0-9a-z._@-]") print("Extract ID: \(extractID)") XCTAssertEqual(extractID, "l.eibniz@55_good-") } func testASCIIAndSpace() { let extractID = "l.e ibn$iz@55_good-)(*&".extract(regex: "[A-Z0-9a-z\\s]") print("Extract ID: \(extractID)") let textField = UITextField() textField.text = "l.e ibn$iz@55_good-)(*&" textField.fitlerBy(type: .alphabetNumberic, isSendAction: true) XCTAssertEqual(extractID, "le ibniz55good") XCTAssertEqual(textField.text ?? "", "le ibniz55good") } func testDynamicFieldMap() { let models = [FieldModel]() let textFields = [ValidationTextField]() let dynamicField = [ "Bank Name": 0, "Branch Name": 1, "Account No.": 2, "Id Type": 3, "ID Number": 4, "First Name": 5, "Middle Name": 6, "Last Name": 7, "Full Name": 8, "First Name in Local": 9, "Middle Name in Local": 10, "Last Name in Local": 11, "Local Name": 12, "Mobile Number": 13, "Province": 14, "State": 15, "City": 16, "Address": 17, "Realation Group": 18, "Transfer Reason": 19 ] models.forEach { property in guard let key = property.fieldName, let tag = dynamicField[key], let textField = textFields.filter({ $0.tag == tag }).first, let isRequire = property.required, let isHidden = isRequire == "H" ? true : false, let min = property.minLength, let max = property.maxLength, let keyboardType = property.keyBoardType else {return} textField.isHidden = isHidden textField.validCondition = { $0.count > min && $0.count < max } switch keyboardType { case "AN": textField.keyboardType = .asciiCapable textField.removeNonASCII() case "N": textField.keyboardType = .numberPad case "ANS": textField.keyboardType = .asciiCapable default: textField.keyboardType = .asciiCapable textField.removeNonASCII() } } } func testDecimalToCurrency() { var amount = "10000" XCTAssert(amount.decimalToCurrency() == "10,000", amount.decimalToCurrency()) amount = "10000.00" XCTAssert(amount.decimalToCurrency() == "10,000", amount.decimalToCurrency()) amount = "11345.00" XCTAssert(amount.decimalToCurrency() == "11,345", amount.decimalToCurrency()) amount = "11345.94" XCTAssert(amount.decimalToCurrency() == "11,345.94", amount.decimalToCurrency()) amount = "0.11" XCTAssert(amount.decimalToCurrency() == "0.11", amount.decimalToCurrency()) amount = "10000" XCTAssert( amount.decimalToCurrency(as: .krw, isFront: true) == "KRW 10,000", amount.decimalToCurrency(as: .krw, isFront: true) ) amount = "10000.00" XCTAssert( amount.decimalToCurrency(as: .krw, isFront: false) == "10,000 KRW", amount.decimalToCurrency(as: .krw, isFront: false) ) amount = "11345.00" XCTAssert( amount.decimalToCurrency(as: .usd, isFront: true) == "USD 11,345", amount.decimalToCurrency(as: .usd, isFront: true) ) amount = "11345.94" XCTAssert( amount.decimalToCurrency(as: .usd, isFront: false) == "11,345.94 USD", amount.decimalToCurrency(as: .usd, isFront: false) ) amount = "0.11" XCTAssert( amount.decimalToCurrency(as: .usd, isFront: true) == "USD 0.11", amount.decimalToCurrency(as: .usd, isFront: true) ) } func testCurrencyToDecimal() { var amount = "10,000" XCTAssert(amount.currencyToDecimal() == "10000", amount.currencyToDecimal()) amount = "10,000.00" XCTAssert(amount.currencyToDecimal() == "10000.00", amount.currencyToDecimal()) amount = "11,345.94" XCTAssert(amount.currencyToDecimal() == "11345.94", amount.currencyToDecimal()) amount = "0.11" XCTAssert(amount.currencyToDecimal() == "0.11", amount.currencyToDecimal()) amount = "KRW 10,000" XCTAssert(amount.currencyToDecimal() == "10000", amount.currencyToDecimal()) amount = "USD 11,345" XCTAssert(amount.currencyToDecimal() == "11345", amount.currencyToDecimal()) amount = "11,345.94 USD" XCTAssert(amount.currencyToDecimal() == "11345.94", amount.currencyToDecimal()) amount = "USD 0.11" XCTAssert(amount.currencyToDecimal() == "0.11", amount.currencyToDecimal()) } func testCreditCard() { XCTAssert(CreditCardType.validate(cardNumber: "5365100675887315") == Optional(.mastercard)) } func testTextClip() { let testJson = """ { "Id" : "", "Extra" : "", "Extra2" : "", "Data" : { "CardListType" : "2", "CountryPriceCode" : [ { "Wireless" : "59", "Country" : "Mongolia", "Code" : "976", "Cable" : "59" }, { "Wireless" : "110", "Country" : "Nepal", "Code" : "977", "Cable" : "110" }, { "Wireless" : "63.8", "Country" : "Vietnam", "Code" : "84", "Cable" : "63.8" }, { "Wireless" : "150", "Country" : "Myanmar", "Code" : "95", "Cable" : "150" }, { "Wireless" : "82.3", "Country" : "Uzbekistan", "Code" : "998", "Cable" : "82.3" }, { "Wireless" : "97", "Country" : "Sri Lanka", "Code" : "94", "Cable" : "97" }, { "Wireless" : "60", "Country" : "Indonesia", "Code" : "62", "Cable" : "60" }, { "Wireless" : "65.2", "Country" : "Pakistan", "Code" : "92", "Cable" : "65.2" }, { "Wireless" : "44", "Country" : "Thailand", "Code" : "66", "Cable" : "44" }, { "Wireless" : "68.2", "Country" : "Cambodia", "Code" : "855", "Cable" : "68.2" }, { "Wireless" : "45", "Country" : "China", "Code" : "86", "Cable" : "45" }, { "Wireless" : "166.7", "Country" : "Philippines", "Code" : "63", "Cable" : "166.7" }, { "Wireless" : "49", "Country" : "Bangladesh", "Code" : "880", "Cable" : "49" }, { "Wireless" : "0", "Country" : "Korea", "Code" : "82", "Cable" : "0" }, { "Wireless" : "325.5", "Country" : "Afghanistan", "Code" : "93", "Cable" : "325.5" }, { "Wireless" : "147", "Country" : "Alaska (U.S.)", "Code" : "1907", "Cable" : "147" }, { "Wireless" : "105", "Country" : "Albania", "Code" : "355", "Cable" : "105" }, { "Wireless" : "189", "Country" : "Algeria", "Code" : "213", "Cable" : "189" }, { "Wireless" : "52.5", "Country" : "Andorra", "Code" : "376", "Cable" : "252" }, { "Wireless" : "94.5", "Country" : "Angola", "Code" : "244", "Cable" : "94.5" }, { "Wireless" : "94.5", "Country" : "Anguilla", "Code" : "1264", "Cable" : "94.5" }, { "Wireless" : "0", "Country" : "Antarctic", "Code" : "6721", "Cable" : "0" }, { "Wireless" : "136.5", "Country" : "Antigua", "Code" : "1268", "Cable" : "136.5" }, { "Wireless" : "126", "Country" : "Antilles (Neth)", "Code" : "599", "Cable" : "126" }, { "Wireless" : "31.5", "Country" : "Argentina", "Code" : "54", "Cable" : "189" }, { "Wireless" : "168", "Country" : "Armenia", "Code" : "374", "Cable" : "168" }, { "Wireless" : "210", "Country" : "Aruba", "Code" : "2978", "Cable" : "210" }, { "Wireless" : "31.5", "Country" : "Australia", "Code" : "61", "Cable" : "147" }, { "Wireless" : "31.5", "Country" : "Austria", "Code" : "43", "Cable" : "147" }, { "Wireless" : "231", "Country" : "Azerbaijan", "Code" : "994", "Cable" : "347" }, { "Wireless" : "52.5", "Country" : "Bahrain", "Code" : "973", "Cable" : "199.5" }, { "Wireless" : "178.5", "Country" : "Barbados", "Code" : "1246", "Cable" : "178.5" }, { "Wireless" : "273", "Country" : "Belarus", "Code" : "375", "Cable" : "273" }, { "Wireless" : "31.5", "Country" : "Belgium", "Code" : "32", "Cable" : "199.5" }, { "Wireless" : "252", "Country" : "Belize", "Code" : "501", "Cable" : "252" }, { "Wireless" : "231", "Country" : "Benin", "Code" : "229", "Cable" : "231" }, { "Wireless" : "31.5", "Country" : "Bermuda", "Code" : "1441", "Cable" : "31.5" }, { "Wireless" : "126", "Country" : "Bolivia", "Code" : "591", "Cable" : "157.5" }, { "Wireless" : "304.5", "Country" : "Bosnia", "Code" : "387", "Cable" : "304.5" }, { "Wireless" : "168", "Country" : "Botswana", "Code" : "267", "Cable" : "168" }, { "Wireless" : "31.5", "Country" : "Brazil", "Code" : "55", "Cable" : "231" }, { "Wireless" : "31.5", "Country" : "Brunei", "Code" : "673", "Cable" : "52.5" }, { "Wireless" : "52.5", "Country" : "Bulgaria", "Code" : "359", "Cable" : "367.5" }, { "Wireless" : "315", "Country" : "Burkina Faso", "Code" : "226", "Cable" : "315" }, { "Wireless" : "189", "Country" : "Burundi", "Code" : "257", "Cable" : "189" }, { "Wireless" : "168", "Country" : "Bhutan", "Code" : "975", "Cable" : "168" }, { "Wireless" : "126", "Country" : "Cameroon", "Code" : "237", "Cable" : "189" }, { "Wireless" : "31.5", "Country" : "Canada", "Code" : "1", "Cable" : "31.5" }, { "Wireless" : "189", "Country" : "Cape Verde", "Code" : "238", "Cable" : "189" }, { "Wireless" : "157.5", "Country" : "Cayman Islands", "Code" : "1345", "Cable" : "157.5" }, { "Wireless" : "178.5", "Country" : "Ceuta", "Code" : "34956", "Cable" : "178.5" }, { "Wireless" : "31.5", "Country" : "Chile", "Code" : "56", "Cable" : "199.5" }, { "Wireless" : "31.5", "Country" : "Colombia", "Code" : "57", "Cable" : "94.5" }, { "Wireless" : "409.5", "Country" : "Comoros", "Code" : "269", "Cable" : "409.5" }, { "Wireless" : "357", "Country" : "Congo", "Code" : "242", "Cable" : "357" }, { "Wireless" : "31.5", "Country" : "Costa Rica", "Code" : "506", "Cable" : "52.5" }, { "Wireless" : "31.5", "Country" : "Croatia", "Code" : "385", "Cable" : "241.5" }, { "Wireless" : "861", "Country" : "Cuba", "Code" : "53", "Cable" : "861" }, { "Wireless" : "31.5", "Country" : "Cypress", "Code" : "357", "Cable" : "52.5" }, { "Wireless" : "31.5", "Country" : "Czech Republic", "Code" : "420", "Cable" : "136.5" }, { "Wireless" : "136.5", "Country" : "Denmark", "Code" : "45", "Cable" : "157.5" }, { "Wireless" : "357", "Country" : "Djibouti", "Code" : "253", "Cable" : "357" }, { "Wireless" : "31.5", "Country" : "Dominica Per", "Code" : "1809", "Cable" : "94.5" }, { "Wireless" : "126", "Country" : "Ecuador", "Code" : "593", "Cable" : "231" }, { "Wireless" : "94.5", "Country" : "Egypt", "Code" : "20", "Cable" : "126" }, { "Wireless" : "210", "Country" : "El Salvador", "Code" : "503", "Cable" : "210" }, { "Wireless" : "31.5", "Country" : "England", "Code" : "44", "Cable" : "294" }, { "Wireless" : "0", "Country" : "Equatorial Guinea", "Code" : "240", "Cable" : "0" }, { "Wireless" : "262.5", "Country" : "Eritrea", "Code" : "291", "Cable" : "262.5" }, { "Wireless" : "31.5", "Country" : "Estonia", "Code" : "372", "Cable" : "1207.5" }, { "Wireless" : "409.5", "Country" : "Ethiopia", "Code" : "251", "Cable" : "409.5" }, { "Wireless" : "220.5", "Country" : "Faroe Islands", "Code" : "298", "Cable" : "220.5" }, { "Wireless" : "283.5", "Country" : "Fiji", "Code" : "679", "Cable" : "283.5" }, { "Wireless" : "84", "Country" : "Finland", "Code" : "358", "Cable" : "52.5" }, { "Wireless" : "31.5", "Country" : "France", "Code" : "33", "Cable" : "126" }, { "Wireless" : "451.5", "Country" : "Gabon", "Code" : "241", "Cable" : "451.5" }, { "Wireless" : "525", "Country" : "Gambia", "Code" : "220", "Cable" : "525" }, { "Wireless" : "136.5", "Country" : "Georgia", "Code" : "995", "Cable" : "136.5" }, { "Wireless" : "31.5", "Country" : "Germany", "Code" : "49", "Cable" : "178.5" }, { "Wireless" : "168", "Country" : "Gibraltar", "Code" : "350", "Cable" : "168" }, { "Wireless" : "31.5", "Country" : "Greece", "Code" : "30", "Cable" : "147" }, { "Wireless" : "630", "Country" : "Greenland", "Code" : "299", "Cable" : "630" }, { "Wireless" : "241.5", "Country" : "Grenada", "Code" : "1473", "Cable" : "241.5" }, { "Wireless" : "157.5", "Country" : "Guam (U.S.)", "Code" : "1671", "Cable" : "157.5" }, { "Wireless" : "157.5", "Country" : "Guatemala", "Code" : "502", "Cable" : "157.5" }, { "Wireless" : "483", "Country" : "Guinea", "Code" : "224", "Cable" : "483" }, { "Wireless" : "378", "Country" : "Guinea-Bissau", "Code" : "245", "Cable" : "378" }, { "Wireless" : "357", "Country" : "Guyana", "Code" : "592", "Cable" : "357" }, { "Wireless" : "31.5", "Country" : "Hawaii (U.S.)", "Code" : "1808", "Cable" : "31.5" }, { "Wireless" : "147", "Country" : "Honduras", "Code" : "504", "Cable" : "147" }, { "Wireless" : "48.1", "Country" : "Hong Kong", "Code" : "852", "Cable" : "48.1" }, { "Wireless" : "31.5", "Country" : "Hungary", "Code" : "36", "Cable" : "105" }, { "Wireless" : "31.5", "Country" : "Iceland", "Code" : "354", "Cable" : "346.5" }, { "Wireless" : "31.5", "Country" : "India", "Code" : "91", "Cable" : "31.5" }, { "Wireless" : "199.5", "Country" : "Iran", "Code" : "98", "Cable" : "199.5" }, { "Wireless" : "84", "Country" : "Iraq", "Code" : "964", "Cable" : "84" }, { "Wireless" : "31.5", "Country" : "Ireland", "Code" : "353", "Cable" : "241.5" }, { "Wireless" : "31.5", "Country" : "Israel", "Code" : "972", "Cable" : "94.5" }, { "Wireless" : "31.5", "Country" : "Italy", "Code" : "39", "Cable" : "189" }, { "Wireless" : "168", "Country" : "Jamaica", "Code" : "1876", "Cable" : "168" }, { "Wireless" : "31.5", "Country" : "Japan", "Code" : "81", "Cable" : "147" }, { "Wireless" : "94.5", "Country" : "Jordan", "Code" : "962", "Cable" : "115.5" }, { "Wireless" : "105", "Country" : "Kazakhstan", "Code" : "7", "Cable" : "105" }, { "Wireless" : "94.5", "Country" : "Kenya", "Code" : "254", "Cable" : "126" }, { "Wireless" : "105", "Country" : "Kyrgyzstan", "Code" : "996", "Cable" : "105" }, { "Wireless" : "94.5", "Country" : "Kuwait", "Code" : "965", "Cable" : "94.5" }, { "Wireless" : "31.5", "Country" : "Laos", "Code" : "856", "Cable" : "31.5" }, { "Wireless" : "1218", "Country" : "Latvia", "Code" : "371", "Cable" : "661.5" }, { "Wireless" : "105", "Country" : "Lebanon", "Code" : "961", "Cable" : "199.5" }, { "Wireless" : "325.5", "Country" : "Lesotho", "Code" : "266", "Cable" : "325.5" }, { "Wireless" : "430.5", "Country" : "Liberia", "Code" : "231", "Cable" : "430.5" }, { "Wireless" : "336", "Country" : "Libya", "Code" : "218", "Cable" : "336" }, { "Wireless" : "588", "Country" : "Liechtenstein", "Code" : "423", "Cable" : "588" }, { "Wireless" : "1039.5", "Country" : "Lithuania", "Code" : "370", "Cable" : "1039.5" }, { "Wireless" : "31.5", "Country" : "Luxembourg", "Code" : "352", "Cable" : "147" }, { "Wireless" : "84", "Country" : "Macau", "Code" : "853", "Cable" : "84" }, { "Wireless" : "378", "Country" : "Macedonia", "Code" : "389", "Cable" : "378" }, { "Wireless" : "430.5", "Country" : "Madagascar", "Code" : "261", "Cable" : "472.5" }, { "Wireless" : "84", "Country" : "Malawi", "Code" : "265", "Cable" : "84" }, { "Wireless" : "31.5", "Country" : "Malaysia", "Code" : "60", "Cable" : "31.5" }, { "Wireless" : "840", "Country" : "Maldives", "Code" : "960", "Cable" : "840" }, { "Wireless" : "294", "Country" : "Mali", "Code" : "223", "Cable" : "294" }, { "Wireless" : "262.5", "Country" : "Marshall Islands", "Code" : "692", "Cable" : "262.5" }, { "Wireless" : "157.5", "Country" : "Martinique", "Code" : "596", "Cable" : "157.5" }, { "Wireless" : "483", "Country" : "Mauritanian", "Code" : "222", "Cable" : "483" }, { "Wireless" : "210", "Country" : "Mauritius", "Code" : "230", "Cable" : "210" }, { "Wireless" : "378", "Country" : "Mayotte", "Code" : "269", "Cable" : "378" }, { "Wireless" : "84", "Country" : "Mexico", "Code" : "52", "Cable" : "199.5" }, { "Wireless" : "210", "Country" : "Micronesia", "Code" : "691", "Cable" : "210" }, { "Wireless" : "147", "Country" : "Moldova", "Code" : "373", "Cable" : "294" }, { "Wireless" : "84", "Country" : "Monaco", "Code" : "377", "Cable" : "346.5" }, { "Wireless" : "294", "Country" : "Morocco", "Code" : "212", "Cable" : "294" }, { "Wireless" : "210", "Country" : "Mozambique", "Code" : "258", "Cable" : "210" }, { "Wireless" : "84", "Country" : "Namibia", "Code" : "264", "Cable" : "84" }, { "Wireless" : "31.5", "Country" : "Netherlands", "Code" : "31", "Cable" : "231" }, { "Wireless" : "210", "Country" : "New Caledonia", "Code" : "687", "Cable" : "210" }, { "Wireless" : "31.5", "Country" : "New Zealand", "Code" : "64", "Cable" : "252" }, { "Wireless" : "147", "Country" : "Nicaragua", "Code" : "505", "Cable" : "241.5" }, { "Wireless" : "252", "Country" : "Niger", "Code" : "227", "Cable" : "252" }, { "Wireless" : "96", "Country" : "Nigeria", "Code" : "234", "Cable" : "96.2" }, { "Wireless" : "735", "Country" : "Niue Island", "Code" : "683", "Cable" : "735" }, { "Wireless" : "241.5", "Country" : "Norfolk Island", "Code" : "672", "Cable" : "241.5" }, { "Wireless" : "31.5", "Country" : "Norway", "Code" : "47", "Cable" : "241.5" }, { "Wireless" : "189", "Country" : "Oman", "Code" : "968", "Cable" : "189" }, { "Wireless" : "367.5", "Country" : "Palau", "Code" : "680", "Cable" : "367.5" }, { "Wireless" : "63", "Country" : "Panama", "Code" : "507", "Cable" : "157.5" }, { "Wireless" : "1050", "Country" : "Papua New Guinea", "Code" : "675", "Cable" : "1050" }, { "Wireless" : "31.5", "Country" : "Paraguay", "Code" : "595", "Cable" : "126" }, { "Wireless" : "31.5", "Country" : "Peru", "Code" : "51", "Cable" : "126" }, { "Wireless" : "31.5", "Country" : "Poland", "Code" : "48", "Cable" : "115.5" }, { "Wireless" : "31.5", "Country" : "Portugal", "Code" : "351", "Cable" : "105" }, { "Wireless" : "31.5", "Country" : "Puerto Rico", "Code" : "1787", "Cable" : "31.5" }, { "Wireless" : "168", "Country" : "Qatar", "Code" : "974", "Cable" : "199.5" }, { "Wireless" : "325.5", "Country" : "Reunion island", "Code" : "262", "Cable" : "325.5" }, { "Wireless" : "31.5", "Country" : "Romania", "Code" : "40", "Cable" : "105" }, { "Wireless" : "52.5", "Country" : "Russia", "Code" : "7", "Cable" : "126" }, { "Wireless" : "147", "Country" : "Rwanda", "Code" : "250", "Cable" : "147" }, { "Wireless" : "31.5", "Country" : "Samoa(American)", "Code" : "685", "Cable" : "31.5" }, { "Wireless" : "1218", "Country" : "San Marino", "Code" : "378549", "Cable" : "1218" }, { "Wireless" : "966", "Country" : "Sao Tome and Principe", "Code" : "23912", "Cable" : "966" }, { "Wireless" : "94.5", "Country" : "Saudi Arabia", "Code" : "966", "Cable" : "147" }, { "Wireless" : "430.5", "Country" : "Senegal", "Code" : "221", "Cable" : "430.5" }, { "Wireless" : "252", "Country" : "Serbia", "Code" : "381", "Cable" : "252" }, { "Wireless" : "588", "Country" : "Seychelles", "Code" : "248", "Cable" : "588" }, { "Wireless" : "462", "Country" : "Sierra Leone", "Code" : "232", "Cable" : "462" }, { "Wireless" : "31.5", "Country" : "Singapore", "Code" : "65", "Cable" : "31.5" }, { "Wireless" : "94.5", "Country" : "Slovakia", "Code" : "421", "Cable" : "94.5" }, { "Wireless" : "31.5", "Country" : "Slovenian", "Code" : "386", "Cable" : "357" }, { "Wireless" : "1050", "Country" : "Solomon Islands", "Code" : "677", "Cable" : "1050" }, { "Wireless" : "567", "Country" : "Somalia", "Code" : "252", "Cable" : "567" }, { "Wireless" : "52.5", "Country" : "South Africa", "Code" : "27", "Cable" : "189" }, { "Wireless" : "31.5", "Country" : "Spain", "Code" : "34", "Cable" : "178.5" }, { "Wireless" : "241.5", "Country" : "St Lucia", "Code" : "1758", "Cable" : "241.5" }, { "Wireless" : "252", "Country" : "St. Vincent and the Grenadines", "Code" : "1784", "Cable" : "252" }, { "Wireless" : "231", "Country" : "Sudan", "Code" : "249", "Cable" : "231" }, { "Wireless" : "136.5", "Country" : "Suriname", "Code" : "597", "Cable" : "199.5" }, { "Wireless" : "136.5", "Country" : "Swaziland", "Code" : "268", "Cable" : "136.5" }, { "Wireless" : "31.5", "Country" : "Sweden", "Code" : "46", "Cable" : "84" }, { "Wireless" : "31.5", "Country" : "Swiss", "Code" : "41", "Cable" : "189" }, { "Wireless" : "178.5", "Country" : "Syria", "Code" : "963", "Cable" : "178.5" }, { "Wireless" : "31.5", "Country" : "Taiwan", "Code" : "886", "Cable" : "105" }, { "Wireless" : "157.5", "Country" : "Tajikistan", "Code" : "992", "Cable" : "157.5" }, { "Wireless" : "252", "Country" : "Tanzania", "Code" : "255", "Cable" : "273" }, { "Wireless" : "346.5", "Country" : "Togo", "Code" : "228", "Cable" : "346.5" }, { "Wireless" : "420", "Country" : "Tonga", "Code" : "676", "Cable" : "420" }, { "Wireless" : "105", "Country" : "Trinidad and Tobago", "Code" : "1868", "Cable" : "105" }, { "Wireless" : "462", "Country" : "Tunisia", "Code" : "216", "Cable" : "462" }, { "Wireless" : "31.5", "Country" : "Turkey", "Code" : "90", "Cable" : "210" }, { "Wireless" : "126", "Country" : "Turkmenistan", "Code" : "993", "Cable" : "126" }, { "Wireless" : "168", "Country" : "Turks and Caicos Islands", "Code" : "1649", "Cable" : "168" }, { "Wireless" : "756", "Country" : "Tuvalu", "Code" : "688", "Cable" : "756" }, { "Wireless" : "199.5", "Country" : "Uganda", "Code" : "256", "Cable" : "199.5" }, { "Wireless" : "157.5", "Country" : "Ukraine", "Code" : "380", "Cable" : "157.5" }, { "Wireless" : "157.5", "Country" : "United Arab Emirates", "Code" : "971", "Cable" : "157.5" }, { "Wireless" : "31.5", "Country" : "United States", "Code" : "1", "Cable" : "31.5" }, { "Wireless" : "63", "Country" : "Uruguay", "Code" : "598", "Cable" : "189" }, { "Wireless" : "556.5", "Country" : "Vanuatu", "Code" : "678", "Cable" : "556.5" }, { "Wireless" : "325.5", "Country" : "Vatican City", "Code" : "396", "Cable" : "325.5" }, { "Wireless" : "31.5", "Country" : "Venezuela", "Code" : "58", "Cable" : "105" }, { "Wireless" : "1207.5", "Country" : "Wallis and Futuna Islands", "Code" : "681", "Cable" : "1207.5" }, { "Wireless" : "168", "Country" : "Yemen", "Code" : "967", "Cable" : "168" }, { "Wireless" : "105", "Country" : "Zambia", "Code" : "260", "Cable" : "105" }, { "Wireless" : "294", "Country" : "Zimbabwe", "Code" : "263", "Cable" : "294" }, { "Wireless" : "220.5", "Country" : "Ghana", "Code" : "233", "Cable" : "220.5" }, { "Wireless" : "84", "Country" : "Nauru", "Code" : "520", "Cable" : "84" }, { "Wireless" : "199.5", "Country" : "Dominica", "Code" : "1767", "Cable" : "199.5" }, { "Wireless" : "682.5", "Country" : "East Timor", "Code" : "670", "Cable" : "682.5" }, { "Wireless" : "31.5", "Country" : "Malta", "Code" : "356", "Cable" : "220.5" }, { "Wireless" : "189", "Country" : "Bahamas", "Code" : "1242", "Cable" : "189" }, { "Wireless" : "231", "Country" : "Chad", "Code" : "235", "Cable" : "231" }, { "Wireless" : "304.5", "Country" : "Central African Republic", "Code" : "236", "Cable" : "304.5" }, { "Wireless" : "1176", "Country" : "Kiribati", "Code" : "686", "Cable" : "1176" }, { "Wireless" : "315", "Country" : "Haiti", "Code" : "509", "Cable" : "315" } ], "CardInfo" : [ { "Promotion_price" : null, "FacePrice" : null, "CardCode" : "MANGO_001", "SubInfo" : null, "CardName" : null } ], "ButtonsGrid" : [ { "Price" : "10000" }, { "Price" : "20000" }, { "Price" : "30000" }, { "Price" : "40000" }, { "Price" : "50000" }, { "Price" : "100000" } ] }, "ErrorCode" : "0", "Msg" : "Success" } """ guard let jsonData = ResponseContainerObject(JSONString: testJson), let json = jsonData.data?.countryPriceCode else { return } json.forEach { print("\(CountryEnum.getCode(from: $0.countryName ?? "")) : \($0.countryName), \($0.countryCode)") } } }