Skip to content

Commit

Permalink
Converting swift version 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajtaneja86 committed Sep 29, 2017
1 parent 452b769 commit 5bb3a6d
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 102 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0
Binary file modified AcceptSDK-Framework/AcceptSDK.framework/AcceptSDK
Binary file not shown.
30 changes: 21 additions & 9 deletions AcceptSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,17 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Ramamurthy, Rakesh Ramamurthy";
TargetAttributes = {
A0070CD61D38AE0A008BD8D4 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
A0070CE01D38AE0A008BD8D4 = {
CreatedOnToolsVersion = 7.3;
DevelopmentTeam = 8WQ4DJVQC2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
A0070D1C1D38B017008BD8D4 = {
CreatedOnToolsVersion = 7.3;
Expand Down Expand Up @@ -562,14 +562,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -613,14 +619,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -670,7 +682,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386";
};
name = Debug;
Expand All @@ -695,7 +707,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.visa.com.AcceptSDK;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386";
};
name = Release;
Expand All @@ -709,7 +721,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.visa.com.AcceptSDKTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -722,7 +734,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.visa.com.AcceptSDKTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -734,7 +746,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.2;
VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386";
};
name = Debug;
Expand All @@ -747,7 +759,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.2;
VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386";
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions AcceptSDK/AcceptSDKHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ open class AcceptSDKHandler : NSObject {
super.init()
}

public init?(environment: AcceptSDKEnvironment) {
@objc public init?(environment: AcceptSDKEnvironment) {
super.init()

let settings = AcceptSDKSettings.sharedInstance
settings.acceptSDKEnvironment = environment.rawValue
}

open func getTokenWithRequest(_ inRequest: AcceptSDKRequest, successHandler:@escaping (AcceptSDKTokenResponse)->(),failureHandler:@escaping (AcceptSDKErrorResponse)->()) {
@objc open func getTokenWithRequest(_ inRequest: AcceptSDKRequest, successHandler:@escaping (AcceptSDKTokenResponse)->(),failureHandler:@escaping (AcceptSDKErrorResponse)->()) {

inRequest.validate({ (isSuccess) -> () in
let sdkInternal = AcceptSDKInternal()
Expand Down
6 changes: 3 additions & 3 deletions AcceptSDK/AcceptSDKSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import Foundation

open class AcceptSDKSettings : NSObject {

static let sharedInstance = AcceptSDKSettings()
@objc static let sharedInstance = AcceptSDKSettings()

var acceptSDKEnvironment : String?
@objc var acceptSDKEnvironment : String?

static func setAcceptSDKEnvironment(_ environment: String) {
@objc static func setAcceptSDKEnvironment(_ environment: String) {
sharedInstance.acceptSDKEnvironment = environment;
}
}
2 changes: 1 addition & 1 deletion AcceptSDK/Network/AccepSDKtHttp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class HTTP: NSObject, URLSessionDelegate {
}

extension NSMutableURLRequest {
func setBodyContent(_ contentStr: String?) {
@objc func setBodyContent(_ contentStr: String?) {
self.httpBody = contentStr!.data(using: String.Encoding.utf8)
}
}
8 changes: 4 additions & 4 deletions AcceptSDK/Request/AcceptSDKPaymentRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import Foundation

open class AcceptSDKRequest: NSObject {
open var merchantAuthentication:MerchantAuthenticaton = MerchantAuthenticaton()
open var securePaymentContainerRequest:SecurePaymentContainerRequest = SecurePaymentContainerRequest()
let clientId = "accept-sdk-ios-1.0.0"
@objc open var merchantAuthentication:MerchantAuthenticaton = MerchantAuthenticaton()
@objc open var securePaymentContainerRequest:SecurePaymentContainerRequest = SecurePaymentContainerRequest()
@objc let clientId = "accept-sdk-ios-1.0.0"

func validate(_ successHandler:@escaping (_ isSuccess:Bool)->(),failureHandler:@escaping (_ withResponse:AcceptSDKErrorResponse)->()) {
@objc func validate(_ successHandler:@escaping (_ isSuccess:Bool)->(),failureHandler:@escaping (_ withResponse:AcceptSDKErrorResponse)->()) {
self.merchantAuthentication.validate({_ in
self.securePaymentContainerRequest.validate(successHandler, failureHandler: failureHandler)
}, failureHandler: failureHandler)
Expand Down
20 changes: 10 additions & 10 deletions AcceptSDK/Request/FingerPrint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ fileprivate func > <T : Comparable>(lhs: T?, rhs: T?) -> Bool {


open class FingerPrint: NSObject {
open var fingerPrintHashValue:String = String()
open var sequence:String = String()
open var timestamp:String = String()
open var currencyCode:String?
open var amount:String = String()
@objc open var fingerPrintHashValue:String = String()
@objc open var sequence:String = String()
@objc open var timestamp:String = String()
@objc open var currencyCode:String?
@objc open var amount:String = String()

public init?(inHashValue: String, inSequence: String, inTimestamp: String, inCurrencyCode: String?, inAmount: String?) {
@objc public init?(inHashValue: String, inSequence: String, inTimestamp: String, inCurrencyCode: String?, inAmount: String?) {
// guard inHashValue.characters.count > 0 else {return nil}
// guard inTimestamp.characters.count > 0 else {return nil}

Expand All @@ -50,7 +50,7 @@ open class FingerPrint: NSObject {
}
}

func validate(_ successHandler:(_ isSuccess:Bool)->(),failureHandler:(_ withResponse:AcceptSDKErrorResponse)->()) {
@objc func validate(_ successHandler:(_ isSuccess:Bool)->(),failureHandler:(_ withResponse:AcceptSDKErrorResponse)->()) {

if self.fingerPrintHashValue.isEmpty == false {
if isValidTimestamp() {
Expand All @@ -71,7 +71,7 @@ open class FingerPrint: NSObject {
}
}

func isValidTimestamp() -> Bool {
@objc func isValidTimestamp() -> Bool {
var isValid = false

if ((self.timestamp.characters.count > 0) && AcceptSDKStringValidator.isAlphanumeric(self.timestamp) == false) && (AcceptSDKStringValidator.isStringIsNegativeNumber(self.timestamp) == false) && (AcceptSDKStringValidator.isStringContainsDecimalCharacter(self.timestamp) == false) {
Expand All @@ -81,7 +81,7 @@ open class FingerPrint: NSObject {
return isValid
}

func isValidAmount() -> Bool {
@objc func isValidAmount() -> Bool {
var isValid = false

/*
Expand All @@ -103,7 +103,7 @@ open class FingerPrint: NSObject {
}


func getSDKErrorResponse(_ withCode: String, message:String) -> AcceptSDKErrorResponse {
@objc func getSDKErrorResponse(_ withCode: String, message:String) -> AcceptSDKErrorResponse {
let message = Message(inErrorCode: withCode, inErrorMessage: message)
return AcceptSDKErrorResponse(withMessage: message)
}
Expand Down
18 changes: 9 additions & 9 deletions AcceptSDK/Request/MerchantAuthenticaton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Foundation


open class MerchantAuthenticaton: NSObject {
open var name = String()
open var fingerPrint: FingerPrint?
open var clientKey: String?
open var mobileDeviceId:String?
@objc open var name = String()
@objc open var fingerPrint: FingerPrint?
@objc open var clientKey: String?
@objc open var mobileDeviceId:String?

func validate(_ successHandler:@escaping (_ isSuccess:Bool)->(),failureHandler:@escaping (_ withResponse:AcceptSDKErrorResponse)->()) {
@objc func validate(_ successHandler:@escaping (_ isSuccess:Bool)->(),failureHandler:@escaping (_ withResponse:AcceptSDKErrorResponse)->()) {

if ((self.clientKey?.isEmpty) == nil && self.fingerPrint == nil) {
failureHandler(self.getSDKErrorResponse("E_WC_18", message: "Client key is required."))
Expand All @@ -42,7 +42,7 @@ open class MerchantAuthenticaton: NSObject {
}
}

func validateOptionalFileds(_ inName: String?, inDeviceId: String?) -> AcceptSDKErrorResponse? {
@objc func validateOptionalFileds(_ inName: String?, inDeviceId: String?) -> AcceptSDKErrorResponse? {

var errorResponse:AcceptSDKErrorResponse?

Expand All @@ -63,7 +63,7 @@ open class MerchantAuthenticaton: NSObject {
return errorResponse
}

func isValidName(_ inName:String) -> Bool {
@objc func isValidName(_ inName:String) -> Bool {
var isValid = false

if inName.characters.count >= 1 && inName.characters.count <= 25 {
Expand All @@ -73,7 +73,7 @@ open class MerchantAuthenticaton: NSObject {
return isValid
}

func isValidMobileDeviceId(_ inValidMobileDeviceId:String) -> Bool {
@objc func isValidMobileDeviceId(_ inValidMobileDeviceId:String) -> Bool {
var isValid = false

if inValidMobileDeviceId.characters.count >= 1 && inValidMobileDeviceId.characters.count <= 60 {
Expand All @@ -83,7 +83,7 @@ open class MerchantAuthenticaton: NSObject {
return isValid
}

func getSDKErrorResponse(_ withCode: String, message:String) -> AcceptSDKErrorResponse {
@objc func getSDKErrorResponse(_ withCode: String, message:String) -> AcceptSDKErrorResponse {
let message = Message(inErrorCode: withCode, inErrorMessage: message)
return AcceptSDKErrorResponse(withMessage: message)
}
Expand Down
Loading

0 comments on commit 5bb3a6d

Please sign in to comment.