This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct LoginRequestCommand: Command { | |
| let id: String | |
| let password: String | |
| var completion: CallResponse<User> | |
| init(_ id: String, password: String, completion: CallResponse<User>) { | |
| self.id = id | |
| self.password = password | |
| self.completion = completion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct LoginDetailsValidator: Command { | |
| let email: String | |
| let password: String | |
| init(_ email: String, _ pass: String){ | |
| self.email = email | |
| password = pass | |
| } | |
| // confirming to the protocol | |
| func execute() throws { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LoginViewController: UIViewController { | |
| @IBOutlet weak var emailTextFeild: UITextField! | |
| @IBOutlet weak var passwordTextFeild: UITextField! | |
| @IBAction func userDidTapLogin(_ sender: UIButton) { | |
| // validate user inputs | |
| guard let email = emailTextFeild.text, !email.isEmpty else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: A UIKit based Playground for presenting user interface | |
| import UIKit | |
| import PlaygroundSupport | |
| var usernameTextfield = UITextField() | |
| var userPasswordTextfield = UITextField() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| post_install do |installer| | |
| #setting all pods to 4.1 | |
| installer.pods_project.targets.each do |target| | |
| target.build_configurations.each do |config| | |
| config.build_settings['SWIFT_VERSION'] = '4.1' | |
| end | |
| end | |
| #some libs uses the old version 4 only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SearchViewController: UIViewController, UISearchBarDelegate { | |
| // We keep track of the pending work item as a property | |
| private var pendingRequestWorkItem: DispatchWorkItem? | |
| func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { | |
| // Cancel the currently pending item | |
| pendingRequestWorkItem?.cancel() | |
| // Wrap our request in a work item | |
| let requestWorkItem = DispatchWorkItem { [weak self] in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func ShowPayfort(controller: PayFortController, with order: ScanOrder, token sdkToken: String) { | |
| let user = UserManager.shared.currentUserInfo | |
| let request = NSMutableDictionary() | |
| // Payfort api :Remember - Before sending the amount value of any transaction | |
| // you have to multiply the value with the currency decimal code according to ISO code 3. | |
| let updatedAmount: Float = Float(order.orderTotalSar! * 100) | |
| request.setValue(updatedAmount, forKey: "amount") | |
| request.setValue("PURCHASE", forKey: "command")//PURCHASE - AUTHORIZATION | |
| request.setValue("SAR", forKey: "currency") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func proceedPayfort(with order: ScanOrder) { | |
| guard let payFortController = PayFortController(enviroment: KPayFortEnviromentSandBox) else { return } | |
| PayFortCredintials.development(udid: payFortController.getUDID()!).send(PayfortResponse.self) { (results) in | |
| switch results { | |
| case .success(let key): | |
| if let token = key.sdkToken { | |
| self.ShowPayfort(controller: payFortController, with: order, token: token) | |
| }else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Encryption { | |
| static func sha256Hex(string: String) -> String? { | |
| guard let messageData = string.data(using: String.Encoding.utf8) else { return nil } | |
| var digestData = Data(count: Int(CC_SHA256_DIGEST_LENGTH)) | |
| _ = digestData.withUnsafeMutableBytes {digestBytes in | |
| messageData.withUnsafeBytes {messageBytes in | |
| CC_SHA256(messageBytes, CC_LONG(messageData.count), digestBytes) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum PayFortCredintials { | |
| case development(udid: String) | |
| case production(udid: String) | |
| var merchantId: String { | |
| switch self { | |
| case .development: | |
| return "dfadf23" | |
| default: | |
| return "dsafq34r" |