forked from TeamDooRiBon/DooRi-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TeamDooRiBon#149 from Hansangjin98/fix/147-errorFix
[FIX] TeamDooRiBon#147 - ์ฑํฅํ ์คํธ ๊ด๋ จ ์ด์ ํด๊ฒฐ
- Loading branch information
Showing
14 changed files
with
213 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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
20 changes: 20 additions & 0 deletions
20
DooRiBon/DooRiBon/Resources/Colors.xcassets/grayblack2.colorset/Contents.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.212", | ||
"green" : "0.196", | ||
"red" : "0.180" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
22 changes: 22 additions & 0 deletions
22
DooRiBon/DooRiBon/Sources/Main/StyleTest/Models/MainStyleTestDataModel.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// MainStyleTestDataModel.swift | ||
// DooRiBon | ||
// | ||
// Created by ํ์์ง on 2021/07/16. | ||
// | ||
|
||
import Foundation | ||
|
||
struct MainStyleTestResponse: Codable { | ||
let status: Int | ||
let success: Bool | ||
let message: String | ||
let data: MainStyleTestData? | ||
} | ||
|
||
// MARK: - DataClass | ||
struct MainStyleTestData: Codable { | ||
let member, title: String | ||
let tag: [String] | ||
let iOSResultImage, aOSResultImage, thumbnail: String | ||
} |
This file contains 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
This file contains 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
58 changes: 58 additions & 0 deletions
58
DooRiBon/DooRiBon/Sources/Main/StyleTest/Service/MainStyleTestService.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// MainStyleTestService.swift | ||
// DooRiBon | ||
// | ||
// Created by ํ์์ง on 2021/07/16. | ||
// | ||
|
||
import Foundation | ||
import Alamofire | ||
|
||
struct MainStyleTestService{ | ||
static let shared = MainStyleTestService() | ||
|
||
private func makeParameter(score: [Int]) -> Parameters | ||
{ | ||
return ["score" : score] | ||
} | ||
|
||
func getData(score : [Int], completion : @escaping (NetworkResult<Any>) -> Void) | ||
{ | ||
let url: String = APIConstants.styleTestMainURL | ||
let header : HTTPHeaders = NetworkInfo.headerWithToken | ||
let dataRequest = AF.request(url, | ||
method: .post, | ||
parameters: makeParameter(score: score), | ||
encoding: JSONEncoding.default, | ||
headers: header) | ||
dataRequest.responseData { dataResponse in | ||
|
||
dump(dataResponse) | ||
|
||
switch dataResponse.result { | ||
case .success: | ||
guard let statusCode = dataResponse.response?.statusCode else {return} | ||
guard let value = dataResponse.value else {return} | ||
let networkResult = self.judgeStatus(by: statusCode, value) | ||
completion(networkResult) | ||
case .failure: completion(.pathErr) | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult<Any> { | ||
|
||
let decoder = JSONDecoder() | ||
guard let decodedData = try? decoder.decode(MainStyleTestResponse.self, from: data) | ||
else { return .pathErr} | ||
switch statusCode { | ||
|
||
case 200: return .success(decodedData) | ||
case 400: return .requestErr(decodedData) | ||
case 500: return .serverErr | ||
default: return .networkFail | ||
} | ||
} | ||
} |
Oops, something went wrong.