Skip to content

Commit 70745d2

Browse files
authored
Merge pull request #1 from amarofashion/include-swiftlint
Include swiftlint
2 parents a33ef0e + b9f4a3f commit 70745d2

26 files changed

+424
-431
lines changed

.swiftlint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
line_length: 160
2+
excluded:
3+
- Carthage
4+
- Alamofire
5+
- Frameworks
6+
- yotpoKitTests/
7+
- yotpoUsageExampleTests/
8+
- yotpoUsageExampleUITests/
9+
10+
disabled_rules:
11+
- trailing_whitespace
12+
13+
identifier_name:
14+
excluded:
15+
- id

Review.swift

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,45 @@ import Foundation
1010

1111
public struct Review {
1212

13-
public var content : String = ""
14-
public var title : String = ""
15-
public var createdAt : Date = Date()
16-
public var sourceReviewId : String = ""
17-
public var customFields : String = ""
18-
public var productId : Int = 0
19-
public var id : Int = 0
20-
public var score : Int = 0
21-
public var votesUp : Int = 0
22-
public var votesDown : Int = 0
23-
public var verifiedBuyer : Bool = false
24-
public var user : UserReview = UserReview()
13+
public var content: String = ""
14+
public var title: String = ""
15+
public var createdAt: Date = Date()
16+
public var sourceReviewId: String = ""
17+
public var customFields: String = ""
18+
public var productId: Int = 0
19+
public var id: Int = 0
20+
public var score: Int = 0
21+
public var votesUp: Int = 0
22+
public var votesDown: Int = 0
23+
public var verifiedBuyer: Bool = false
24+
public var user: UserReview = UserReview()
2525

2626
public init() {}
2727

28-
public init(titleReview: String, contentReview: String, dateCreated: Date, productID: Int, scoreReview: Int, userReview: UserReview, voteUp: Int, voteDown: Int) {
29-
content = contentReview
30-
title = titleReview
31-
createdAt = dateCreated
32-
productId = productID
33-
score = scoreReview
34-
user = userReview
35-
votesUp = voteUp
36-
votesDown = voteDown
28+
public init(titleReview: String, contentReview: String, dateCreated: Date, productID: Int, scoreReview: Int,
29+
userReview: UserReview, voteUp: Int, voteDown: Int) {
30+
content = contentReview
31+
title = titleReview
32+
createdAt = dateCreated
33+
productId = productID
34+
score = scoreReview
35+
user = userReview
36+
votesUp = voteUp
37+
votesDown = voteDown
3738
}
3839

39-
public init(dic:[String: AnyObject]) {
40-
content = dic["content"] as? String ?? ""
41-
title = dic["title"] as? String ?? ""
42-
43-
sourceReviewId = dic["source_review_id"] as? String ?? ""
44-
customFields = dic["custom_fields"] as? String ?? ""
45-
productId = dic["product_id"] as? Int ?? 0
46-
id = dic["id"] as? Int ?? 0
47-
score = dic["score"] as? Int ?? 0
48-
votesUp = dic["votes_up"] as? Int ?? 0
49-
votesDown = dic["votes_down"] as? Int ?? 0
50-
verifiedBuyer = dic["verified_buyer"] as? Bool ?? false
51-
user = createUser(dic: dic["user"] as? [String : AnyObject] ?? [:])
40+
public init(dic: [String: AnyObject]) {
41+
content = dic["content"] as? String ?? ""
42+
title = dic["title"] as? String ?? ""
43+
sourceReviewId = dic["source_review_id"] as? String ?? ""
44+
customFields = dic["custom_fields"] as? String ?? ""
45+
productId = dic["product_id"] as? Int ?? 0
46+
id = dic["id"] as? Int ?? 0
47+
score = dic["score"] as? Int ?? 0
48+
votesUp = dic["votes_up"] as? Int ?? 0
49+
votesDown = dic["votes_down"] as? Int ?? 0
50+
verifiedBuyer = dic["verified_buyer"] as? Bool ?? false
51+
user = createUser(dic: dic["user"] as? [String: AnyObject] ?? [:])
5252

5353
let dateFormatter = DateFormatter()
5454
dateFormatter.dateFormat = "yyyy-MM-ddEHH:mm:ssz"
@@ -58,8 +58,7 @@ public struct Review {
5858
}
5959
}
6060

61-
internal func createUser(dic: [String:AnyObject])->UserReview {
61+
internal func createUser(dic: [String: AnyObject]) -> UserReview {
6262
return UserReview(dic: dic)
6363
}
64-
6564
}

yotpoKit.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@
339339
FB7575DB1E9D08CC00D1E844 /* Frameworks */,
340340
FB7575DC1E9D08CC00D1E844 /* Headers */,
341341
FB7575DD1E9D08CC00D1E844 /* Resources */,
342+
FB25C0071F3394DE009F517B /* ShellScript */,
342343
);
343344
buildRules = (
344345
);
@@ -524,6 +525,22 @@
524525
};
525526
/* End PBXResourcesBuildPhase section */
526527

528+
/* Begin PBXShellScriptBuildPhase section */
529+
FB25C0071F3394DE009F517B /* ShellScript */ = {
530+
isa = PBXShellScriptBuildPhase;
531+
buildActionMask = 2147483647;
532+
files = (
533+
);
534+
inputPaths = (
535+
);
536+
outputPaths = (
537+
);
538+
runOnlyForDeploymentPostprocessing = 0;
539+
shellPath = /bin/sh;
540+
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
541+
};
542+
/* End PBXShellScriptBuildPhase section */
543+
527544
/* Begin PBXSourcesBuildPhase section */
528545
FB7575DA1E9D08CC00D1E844 /* Sources */ = {
529546
isa = PBXSourcesBuildPhase;

yotpoKit/APIYotpo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import Foundation
1212
open class APIYotpo {
1313

1414
fileprivate let appKey: String
15-
fileprivate let clientSecret:String
15+
fileprivate let clientSecret: String
1616

17-
public init(appK:String, clientS:String) {
17+
public init(appK: String, clientS: String) {
1818
appKey = appK
1919
clientSecret = clientS
2020
}

yotpoKit/Answer.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
import Foundation
1010

1111
public struct Answer {
12-
public var content : String = ""
13-
public var createdAt : String = ""
14-
public var id : Int = 0
15-
public var votesUp : Int = 0
16-
public var votedDown : Int = 0
17-
public var storeOwnerComment : Bool = false
18-
public var answerer : Asker = Asker()
12+
public var content: String = ""
13+
public var createdAt: String = ""
14+
public var id: Int = 0
15+
public var votesUp: Int = 0
16+
public var votedDown: Int = 0
17+
public var storeOwnerComment: Bool = false
18+
public var answerer: Asker = Asker()
1919

2020
public init() {}
2121

22-
public init(dic:[String:AnyObject]) {
23-
content = dic["content"] as? String ?? ""
24-
createdAt = dic["created_at"] as? String ?? ""
25-
id = dic["id"] as? Int ?? 0
26-
votesUp = dic["votes_up"] as? Int ?? 0
27-
votedDown = dic["votes_down"] as? Int ?? 0
28-
storeOwnerComment = dic["store_owner_comment"] as? Bool ?? false
29-
answerer = createAnswerer(dic: dic["answerer"] as? [String : AnyObject] ?? [:])
22+
public init(dic: [String: AnyObject]) {
23+
content = dic["content"] as? String ?? ""
24+
createdAt = dic["created_at"] as? String ?? ""
25+
id = dic["id"] as? Int ?? 0
26+
votesUp = dic["votes_up"] as? Int ?? 0
27+
votedDown = dic["votes_down"] as? Int ?? 0
28+
storeOwnerComment = dic["store_owner_comment"] as? Bool ?? false
29+
answerer = createAnswerer(dic: dic["answerer"] as? [String: AnyObject] ?? [:])
3030
}
3131

32-
internal func createAnswerer(dic: [String:AnyObject])->Asker {
32+
internal func createAnswerer(dic: [String: AnyObject]) -> Asker {
3333
return Asker(dic: dic)
3434
}
3535
}

yotpoKit/Asker.swift

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,30 @@
99
import Foundation
1010

1111
public struct Asker {
12-
public var displayName : String = ""
13-
public var socialImage : String = ""
14-
public var slug : String = ""
15-
public var bio : String = ""
16-
public var userId : Int = 0
17-
public var score : Int = 0
18-
public var badges : [BadgeObject] = []
19-
public var isSocialConnected : Bool = false
12+
public var displayName: String = ""
13+
public var socialImage: String = ""
14+
public var slug: String = ""
15+
public var bio: String = ""
16+
public var userId: Int = 0
17+
public var score: Int = 0
18+
public var badges: [BadgeObject] = []
19+
public var isSocialConnected: Bool = false
2020

2121
public init() {}
2222

23-
public init(dic:[String:AnyObject]) {
24-
displayName = dic["display_name"] as? String ?? ""
25-
socialImage = dic["social_image"] as? String ?? ""
26-
slug = dic["slug"] as? String ?? ""
27-
bio = dic["bio"] as? String ?? ""
28-
userId = dic["id"] as? Int ?? 0
29-
score = dic["score"] as? Int ?? 0
30-
isSocialConnected = dic["is_social_connected"] as? Bool ?? false
31-
badges = createBadges(fromArray: dic["badges"] as? [[String : AnyObject]] ?? [])
23+
public init(dic: [String: AnyObject]) {
24+
displayName = dic["display_name"] as? String ?? ""
25+
socialImage = dic["social_image"] as? String ?? ""
26+
slug = dic["slug"] as? String ?? ""
27+
bio = dic["bio"] as? String ?? ""
28+
userId = dic["id"] as? Int ?? 0
29+
score = dic["score"] as? Int ?? 0
30+
isSocialConnected = dic["is_social_connected"] as? Bool ?? false
31+
badges = createBadges(fromArray: dic["badges"] as? [[String: AnyObject]] ?? [])
3232
}
3333

34-
35-
internal func createBadges(fromArray array: [[String:AnyObject]])->[BadgeObject] {
36-
var myBadges:[BadgeObject] = []
34+
internal func createBadges(fromArray array: [[String: AnyObject]]) -> [BadgeObject] {
35+
var myBadges: [BadgeObject] = []
3736
myBadges = array.map({ (badgeDict) in
3837
return BadgeObject(dic: badgeDict)
3938
})

yotpoKit/BadgeObject.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import Foundation
1111
import Foundation
1212

1313
public struct BadgeObject {
14-
public var id : Int = 0
15-
public var name : String = ""
16-
public var description : String = ""
17-
public var image100 : String = ""
18-
public var image300 : String = ""
14+
public var id: Int = 0
15+
public var name: String = ""
16+
public var description: String = ""
17+
public var image100: String = ""
18+
public var image300: String = ""
1919

20-
public init(dic:[String:AnyObject]) {
21-
id = dic["id"] as? Int ?? 0
22-
name = dic["name"] as? String ?? ""
23-
description = dic["description"] as? String ?? ""
24-
image100 = dic["image_100"] as? String ?? ""
25-
image300 = dic["image_300"] as? String ?? ""
20+
public init(dic: [String: AnyObject]) {
21+
id = dic["id"] as? Int ?? 0
22+
name = dic["name"] as? String ?? ""
23+
description = dic["description"] as? String ?? ""
24+
image100 = dic["image_100"] as? String ?? ""
25+
image300 = dic["image_300"] as? String ?? ""
2626
}
2727
}

yotpoKit/BottomLine.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ import Foundation
1010

1111
public struct BottomLine {
1212

13-
public var customFieldsBottomline : String = ""
14-
public var totalReview : Int = 0
15-
public var averageScore : Float = 0.0
16-
public var starDistribution : StarDistribution = StarDistribution()
13+
public var customFieldsBottomline: String = ""
14+
public var totalReview: Int = 0
15+
public var averageScore: Float = 0.0
16+
public var starDistribution: StarDistribution = StarDistribution()
1717

18-
public init(){}
18+
public init() {}
1919

20-
public init(dic:[String:AnyObject]) {
21-
customFieldsBottomline = dic["custom_fields_bottomline"] as? String ?? ""
22-
totalReview = dic["total_review"] as? Int ?? 0
20+
public init(dic: [String: AnyObject]) {
21+
customFieldsBottomline = dic["custom_fields_bottomline"] as? String ?? ""
22+
totalReview = dic["total_review"] as? Int ?? 0
2323
if totalReview == 0 {
24-
totalReview = dic["total_reviews"] as? Int ?? 0
24+
totalReview = dic["total_reviews"] as? Int ?? 0
2525
}
26-
averageScore = dic["average_score"] as? Float ?? 0.0
27-
starDistribution = createStarDistribution(dic: dic["star_distribution"] as? [String : AnyObject] ?? [:])
26+
averageScore = dic["average_score"] as? Float ?? 0.0
27+
starDistribution = createStarDistribution(dic: dic["star_distribution"] as? [String: AnyObject] ?? [:])
2828
}
2929

30-
internal func createStarDistribution(dic: [String:AnyObject])->StarDistribution {
30+
internal func createStarDistribution(dic: [String: AnyObject]) -> StarDistribution {
3131
return StarDistribution(dic: dic)
3232
}
3333
}

yotpoKit/EndPoint.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
import Alamofire
1111

1212
struct Endpoint {
13-
typealias EndPointType = (URI: String, method: Alamofire.HTTPMethod)
13+
typealias EndPointType = (URI: String, method: Alamofire.HTTPMethod)
1414

1515
}
1616

@@ -19,31 +19,31 @@ extension Endpoint {
1919
struct MyReview {
2020
static let saveReview: EndPointType = ("https://api.yotpo.com/v1/widget/reviews", .post)
2121

22-
func getReviews(productId:String, appKey:String, perPage:Int)->EndPointType {
22+
func getReviews(productId: String, appKey: String, perPage: Int) -> EndPointType {
2323
return ("https://api.yotpo.com/v1/widget/\(appKey)/products/\(productId)/reviews.json?per_page=\(perPage)", .get)
2424
}
2525

26-
func getReviewsPage(productId:String, appKey:String, perPage:Int, page:Int)->EndPointType {
26+
func getReviewsPage(productId: String, appKey: String, perPage: Int, page: Int) -> EndPointType {
2727
return ("https://api.yotpo.com/v1/widget/\(appKey)/products/\(productId)/reviews.json?per_page=\(perPage)&page=\(page)", .get)
2828
}
2929

30-
func getResume(productId:String, appKey:String)->EndPointType {
30+
func getResume(productId: String, appKey: String) -> EndPointType {
3131
return ("https://api.yotpo.com/products/\(appKey)/\(productId)/bottomline", .get)
3232
}
3333

34-
func getReview(reviewId:String)->EndPointType {
34+
func getReview(reviewId: String) -> EndPointType {
3535
return ("https://api.yotpo.com/reviews/\(reviewId)", .get)
3636
}
3737

38-
func saveVote(reviewId:String,vote: VoteType)->EndPointType {
38+
func saveVote(reviewId: String, vote: VoteType) -> EndPointType {
3939
switch vote {
4040
case .like:
4141
return ("https://api.yotpo.com/reviews/\(reviewId)/vote/up", .get)
4242
case .unlike:
4343
return ("https://api.yotpo.com/reviews/\(reviewId)/vote/down", .get)
4444
}
4545
}
46-
func removeVoteReview(reviewId:String,vote: VoteType)->EndPointType {
46+
func removeVoteReview(reviewId: String, vote: VoteType) -> EndPointType {
4747
switch vote {
4848
case .like:
4949
return ("https://api.yotpo.com/reviews/\(reviewId)/vote/up/true", .get)
@@ -59,19 +59,19 @@ extension Endpoint {
5959
struct MyQuestion {
6060
static let saveQuestion: EndPointType = ("https://api.yotpo.com/questions/send_confirmation_mail", .post)
6161

62-
func getQuestions(productId:String, appKey:String)->EndPointType {
62+
func getQuestions(productId: String, appKey: String) -> EndPointType {
6363
return ("https://api.yotpo.com/products/\(appKey)/\(productId)/questions", .get)
6464
}
6565

66-
func getQuestionPage(productId:String, appKey:String, token:String, page:Int)->EndPointType {
66+
func getQuestionPage(productId: String, appKey: String, token: String, page: Int) -> EndPointType {
6767
return ("https://api.yotpo.com/products/\(appKey)/\(productId)/questions?utoken=\(token)&page=\(page)", .get)
6868
}
6969

70-
func getQuestionResume(productId:String, appKey:String)->EndPointType {
70+
func getQuestionResume(productId: String, appKey: String) -> EndPointType {
7171
return ("https://api.yotpo.com/products/\(appKey)/\(productId)/qna_bottomline", .get)
7272
}
7373

74-
func saveVoteQuestion(questionId:String,vote: VoteType)->EndPointType {
74+
func saveVoteQuestion(questionId: String, vote: VoteType) -> EndPointType {
7575
switch vote {
7676
case .like:
7777
return ("https://api.yotpo.com/answers/\(questionId)/vote/up", .get)
@@ -80,7 +80,7 @@ extension Endpoint {
8080
}
8181
}
8282

83-
func removeVoteQuestion(questionId:String,vote: VoteType)->EndPointType {
83+
func removeVoteQuestion(questionId: String, vote: VoteType) -> EndPointType {
8484
switch vote {
8585
case .like:
8686
return ("https://api.yotpo.com/answers/\(questionId)/vote/up/true", .get)

0 commit comments

Comments
 (0)