Skip to content

Commit

Permalink
Merge pull request #8 from amarofashion/dev
Browse files Browse the repository at this point in the history
Migrate code to Swift 5 and Alamofire to veersion > 5.0
  • Loading branch information
diegolechado authored Mar 25, 2021
2 parents f05ba2d + f3730c7 commit 4e6215d
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 235 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" "4.9.1"
github "Alamofire/Alamofire"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" "747c8db8d57b68d5e35275f10c92d55f982adbd4"
github "Alamofire/Alamofire" "5.4.1"
131 changes: 12 additions & 119 deletions yotpoKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
FB43131A1EA522B0008A4B37 /* BadgeObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB4313191EA522B0008A4B37 /* BadgeObject.swift */; };
FB45C6701EC3723900D50CAA /* QuestionExhibition.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB45C66F1EC3723900D50CAA /* QuestionExhibition.swift */; };
FB66AA0D1EC243780039CF8B /* Yotpo.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB66AA0C1EC243780039CF8B /* Yotpo.swift */; };
FB7575E91E9D08CC00D1E844 /* yotpoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB7575DF1E9D08CC00D1E844 /* yotpoKit.framework */; };
FB7575EE1E9D08CC00D1E844 /* yotpoKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB7575ED1E9D08CC00D1E844 /* yotpoKitTests.swift */; };
FB7575F01E9D08CC00D1E844 /* yotpoKit.h in Headers */ = {isa = PBXBuildFile; fileRef = FB7575E21E9D08CC00D1E844 /* yotpoKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
FB83BD6E1E9D229700FE4971 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB83BD6D1E9D229700FE4971 /* Alamofire.framework */; };
FB83BD731E9D22C300FE4971 /* Review.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB83BD721E9D22C300FE4971 /* Review.swift */; };
Expand Down Expand Up @@ -45,13 +43,6 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
FB7575EA1E9D08CC00D1E844 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FB7575D61E9D08CC00D1E844 /* Project object */;
proxyType = 1;
remoteGlobalIDString = FB7575DE1E9D08CC00D1E844;
remoteInfo = yotpoKit;
};
FB92FBA91E9E646A00D9B127 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FB7575D61E9D08CC00D1E844 /* Project object */;
Expand Down Expand Up @@ -86,9 +77,6 @@
FB7575DF1E9D08CC00D1E844 /* yotpoKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = yotpoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FB7575E21E9D08CC00D1E844 /* yotpoKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = yotpoKit.h; sourceTree = "<group>"; };
FB7575E31E9D08CC00D1E844 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FB7575E81E9D08CC00D1E844 /* yotpoKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = yotpoKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
FB7575ED1E9D08CC00D1E844 /* yotpoKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = yotpoKitTests.swift; sourceTree = "<group>"; };
FB7575EF1E9D08CC00D1E844 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FB83BD6D1E9D229700FE4971 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Alamofire.framework; path = Carthage/Build/iOS/Alamofire.framework; sourceTree = "<group>"; };
FB83BD701E9D22A400FE4971 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Alamofire.framework; path = Carthage/Build/iOS/Alamofire.framework; sourceTree = "<group>"; };
FB83BD721E9D22C300FE4971 /* Review.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Review.swift; path = ../Review.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -127,14 +115,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
FB7575E51E9D08CC00D1E844 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FB7575E91E9D08CC00D1E844 /* yotpoKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FB92FB921E9E646A00D9B127 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -171,7 +151,6 @@
isa = PBXGroup;
children = (
FB7575E11E9D08CC00D1E844 /* yotpoKit */,
FB7575EC1E9D08CC00D1E844 /* yotpoKitTests */,
FB92FB961E9E646A00D9B127 /* yotpoUsageExample */,
FB92FBAB1E9E646A00D9B127 /* yotpoUsageExampleTests */,
FB7575E01E9D08CC00D1E844 /* Products */,
Expand All @@ -183,7 +162,6 @@
isa = PBXGroup;
children = (
FB7575DF1E9D08CC00D1E844 /* yotpoKit.framework */,
FB7575E81E9D08CC00D1E844 /* yotpoKitTests.xctest */,
FB92FB951E9E646A00D9B127 /* yotpoUsageExample.app */,
FB92FBA81E9E646A00D9B127 /* yotpoUsageExampleTests.xctest */,
);
Expand All @@ -202,15 +180,6 @@
path = yotpoKit;
sourceTree = "<group>";
};
FB7575EC1E9D08CC00D1E844 /* yotpoKitTests */ = {
isa = PBXGroup;
children = (
FB7575ED1E9D08CC00D1E844 /* yotpoKitTests.swift */,
FB7575EF1E9D08CC00D1E844 /* Info.plist */,
);
path = yotpoKitTests;
sourceTree = "<group>";
};
FB83BD6C1E9D229700FE4971 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -321,24 +290,6 @@
productReference = FB7575DF1E9D08CC00D1E844 /* yotpoKit.framework */;
productType = "com.apple.product-type.framework";
};
FB7575E71E9D08CC00D1E844 /* yotpoKitTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = FB7575F61E9D08CC00D1E844 /* Build configuration list for PBXNativeTarget "yotpoKitTests" */;
buildPhases = (
FB7575E41E9D08CC00D1E844 /* Sources */,
FB7575E51E9D08CC00D1E844 /* Frameworks */,
FB7575E61E9D08CC00D1E844 /* Resources */,
);
buildRules = (
);
dependencies = (
FB7575EB1E9D08CC00D1E844 /* PBXTargetDependency */,
);
name = yotpoKitTests;
productName = yotpoKitTests;
productReference = FB7575E81E9D08CC00D1E844 /* yotpoKitTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
FB92FB941E9E646A00D9B127 /* yotpoUsageExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = FB92FBC01E9E646A00D9B127 /* Build configuration list for PBXNativeTarget "yotpoUsageExample" */;
Expand Down Expand Up @@ -388,24 +339,19 @@
FB7575DE1E9D08CC00D1E844 = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = PFQ8633X58;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
FB7575E71E9D08CC00D1E844 = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = PFQ8633X58;
LastSwiftMigration = 1240;
ProvisioningStyle = Automatic;
};
FB92FB941E9E646A00D9B127 = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = PFQ8633X58;
LastSwiftMigration = 0910;
LastSwiftMigration = 1240;
ProvisioningStyle = Automatic;
};
FB92FBA71E9E646A00D9B127 = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = PFQ8633X58;
LastSwiftMigration = 0910;
LastSwiftMigration = 1240;
ProvisioningStyle = Automatic;
TestTargetID = FB92FB941E9E646A00D9B127;
};
Expand All @@ -416,6 +362,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand All @@ -425,7 +372,6 @@
projectRoot = "";
targets = (
FB7575DE1E9D08CC00D1E844 /* yotpoKit */,
FB7575E71E9D08CC00D1E844 /* yotpoKitTests */,
FB92FB941E9E646A00D9B127 /* yotpoUsageExample */,
FB92FBA71E9E646A00D9B127 /* yotpoUsageExampleTests */,
);
Expand All @@ -440,13 +386,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
FB7575E61E9D08CC00D1E844 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
FB92FB931E9E646A00D9B127 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -512,14 +451,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
FB7575E41E9D08CC00D1E844 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FB7575EE1E9D08CC00D1E844 /* yotpoKitTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FB92FB911E9E646A00D9B127 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -540,11 +471,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
FB7575EB1E9D08CC00D1E844 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = FB7575DE1E9D08CC00D1E844 /* yotpoKit */;
targetProxy = FB7575EA1E9D08CC00D1E844 /* PBXContainerItemProxy */;
};
FB92FBAA1E9E646A00D9B127 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = FB92FB941E9E646A00D9B127 /* yotpoUsageExample */;
Expand Down Expand Up @@ -711,7 +637,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -738,33 +664,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
FB7575F71E9D08CC00D1E844 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = PFQ8633X58;
INFOPLIST_FILE = yotpoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = amaro.yotpoKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
FB7575F81E9D08CC00D1E844 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = PFQ8633X58;
INFOPLIST_FILE = yotpoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = amaro.yotpoKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -782,7 +682,8 @@
PRODUCT_BUNDLE_IDENTIFIER = amaro.yotpoUsageExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
VALIDATE_WORKSPACE = YES;
};
name = Debug;
};
Expand All @@ -800,7 +701,8 @@
PRODUCT_BUNDLE_IDENTIFIER = amaro.yotpoUsageExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
VALIDATE_WORKSPACE = YES;
};
name = Release;
};
Expand All @@ -815,7 +717,7 @@
PRODUCT_BUNDLE_IDENTIFIER = amaro.yotpoUsageExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yotpoUsageExample.app/yotpoUsageExample";
};
name = Debug;
Expand All @@ -831,7 +733,7 @@
PRODUCT_BUNDLE_IDENTIFIER = amaro.yotpoUsageExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yotpoUsageExample.app/yotpoUsageExample";
};
name = Release;
Expand All @@ -857,15 +759,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FB7575F61E9D08CC00D1E844 /* Build configuration list for PBXNativeTarget "yotpoKitTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FB7575F71E9D08CC00D1E844 /* Debug */,
FB7575F81E9D08CC00D1E844 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FB92FBC01E9E646A00D9B127 /* Build configuration list for PBXNativeTarget "yotpoUsageExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
2 changes: 0 additions & 2 deletions yotpoKit/BadgeObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import Foundation

import Foundation

public struct BadgeObject {
public var id: Int = 0
public var name: String = ""
Expand Down
40 changes: 21 additions & 19 deletions yotpoKit/MyQuestion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ open class MyQuestion: RequestYotpo {
public typealias CompletionDefault = (_ code: Int, _ msg: String) -> Void
public typealias CompletionQuestion = (_ code: Int, _ title: String, _ msg: String) -> Void
public typealias CompleteNextPageQuestions = (_ msg: String, _ newQuestions: [Question], _ productQuestio: ProductQuestion) -> Void
public typealias CompletionWithQuestionsAndExhibition = (_ code: Int, _ msg: String, _ productQuestion: ProductQuestion, _ questionsExhibition: [QuestionExhibition]) -> Void
public typealias CompletionWithQuestionsAndExhibition = (_ code: Int, _ msg: String,
_ productQuestion: ProductQuestion,
_ questionsExhibition: [QuestionExhibition]) -> Void

open func getQuestions(productId: String, completion: @escaping CompletionWithProductQuestions) {
let endPoint = Endpoint.MyQuestion().getQuestions(productId: productId, appKey: appKey)

Alamofire.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
AF.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
switch response.result {
case .success:
guard let JSON = response.result.value as? [String: AnyObject] else {
case .success(let data):
guard let JSON = data as? [String: AnyObject] else {
completion(GetMessage.ParsingError.code, GetMessage.ParsingError.msg, nil)
return
}
Expand All @@ -47,10 +49,10 @@ open class MyQuestion: RequestYotpo {
open func getQuestionPerPage(productId: String, page: Int, completion: @escaping CompletionWithQuestions) {
let endPoint = Endpoint.MyQuestion().getQuestionPage(productId: productId, appKey: appKey, token: tokenId, page: page)

Alamofire.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
AF.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
switch response.result {
case .success:
guard let JSON = response.result.value as? [String: AnyObject],
case .success(let data):
guard let JSON = data as? [String: AnyObject],
let message = JSON["status"]?["message"] as? String else {
completion(GetMessage.ParsingError.code, GetMessage.ParsingError.msg, [])
return
Expand All @@ -74,10 +76,10 @@ open class MyQuestion: RequestYotpo {
open func getQuestionResume(productId: String, completion: @escaping CompletionWithProductQuestions) {
let endPoint = Endpoint.MyQuestion().getQuestionResume(productId: productId, appKey: appKey)

Alamofire.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
AF.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
switch response.result {
case .success:
guard let JSON = response.result.value as? [String: AnyObject],
case .success(let data):
guard let JSON = data as? [String: AnyObject],
let code = JSON["status"]?["code"] as? Int,
let message = JSON["status"]?["message"] as? String else {
completion(GetMessage.ParsingError.code, GetMessage.ParsingError.msg, nil)
Expand Down Expand Up @@ -105,10 +107,10 @@ open class MyQuestion: RequestYotpo {

open func saveVoteQuestion(questionId: String, voteType: VoteType, completion: @escaping CompletionDefault) {
let endPoint = Endpoint.MyQuestion().saveVoteQuestion(questionId: questionId, vote: voteType)
Alamofire.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
AF.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
switch response.result {
case .success:
guard let JSON = response.result.value as? [String: AnyObject],
case .success(let data):
guard let JSON = data as? [String: AnyObject],
let code = JSON["status"]?["code"] as? Int,
let message = JSON["status"]?["message"] as? String,
JSON["response"] as? [String: AnyObject] != nil else {
Expand All @@ -126,10 +128,10 @@ open class MyQuestion: RequestYotpo {
open func removeVoteQuestion(questionId: String, voteType: VoteType, completion: @escaping CompletionDefault) {
let endPoint = Endpoint.MyQuestion().removeVoteQuestion(questionId: questionId, vote: voteType)

Alamofire.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
AF.request(endPoint.URI, method: endPoint.method).responseJSON { (response) in
switch response.result {
case .success:
guard let JSON = response.result.value as? [String: AnyObject],
case .success(let data):
guard let JSON = data as? [String: AnyObject],
let code = JSON["status"]?["code"] as? Int,
let message = JSON["status"]?["message"] as? String,
JSON["response"] as? [String: AnyObject] != nil else {
Expand All @@ -145,11 +147,11 @@ open class MyQuestion: RequestYotpo {

open func saveQuestion(post: Post, completion: @escaping CompletionQuestion) {
let parameter = post.convertToParameterQuestion(appKey: appKey)
Alamofire.request(Endpoint.MyQuestion.saveQuestion.URI, method: Endpoint.MyQuestion.saveQuestion.method,
AF.request(Endpoint.MyQuestion.saveQuestion.URI, method: Endpoint.MyQuestion.saveQuestion.method,
parameters: parameter).responseJSON { (response) in
switch response.result {
case .success:
guard let JSON = response.result.value as? [String: AnyObject],
case .success(let data):
guard let JSON = data as? [String: AnyObject],
let code = JSON["status"]?["code"] as? Int,
JSON["status"]?["message"] as? String != nil,
code == 200 else {
Expand Down
Loading

0 comments on commit 4e6215d

Please sign in to comment.