2024. 2. 22. 21:52ใExperiences/Competition
2024 Google Solution Challenge
https://github.com/GDSC-Wetox/Wetox-iOS
๋งค์ผ๋งค์ผ ๊ฐ๋ฐ๋ก ๋ถํ์ฐ๋ ์ค์ ๋๋ค. . ๐ฉ๐๐ฅ
๋๋์ด ์๋ฒ API ์ฐ๋์ ์๋ฃํ๋ต๋๋ค!! ๊บ์ธ
๋จ์ ๊ฒ์ ๋ฐํ ์์ ์ค๋น ๋ฟ .
์ ๋ง ๋คํธ์ํฌ ์ฐ๋ ์ฝ๋ ์ง๋ ๊ธฐ๊ณ๊ฐ ๋์์ด์ . .
์ ์ถ ๋๋ด๊ณ , MVVM ๋ฆฌํฉํ ๋ง๋ ๊ผฌ์ฅ ํด์ผ์ง
๋ฆฌ์กํธ ์ฝ๋๋ ์ ๋๋ก ๊ณต๋ถํ๊ณ ๋ค์ ์ง๊ณ ์ถ์ด์
# ์๋๋ฐญ ํ๋ ๐ฑ
# ๋๋ค์ ์ค๋ณต ๊ฒ์ฌ API
# ์น๊ตฌ ์์ฒญ ๋ฐ ์๋ฝ API
# AI ์์ฑ ํ๋กํ ๊ฐ์ ธ์ค๊ธฐ API
์ด ์น๊ตฌ ๊ตฌํํ๋๋ฐ ๊ฝค๋ ๊ณ ๋ฏผํ์ ๐ค
์๋ฒ์์ ๋ณด๋ด๋ ๊ฐ์ด URL ์ฃผ์๋ JSON์ด ์๋๋ผ,
PNG ๋ฐ์ดํฐ๋ฅผ ๊ทธ๋๋ก ์๋๋ฐ, ์ด๊ฑธ ๋ฐ์์ฌ ๋,
Observable์ response ๊ฐ์ฒด๋ฅผ ์ ์ธํด์ ๋ฐ๋๊ฒ ์๋๋ผ
Data ๋ฐ๋ก ๋ฐ์์ค๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํด์ผ ํ์ด์
public class RegisterAPI {
static let registerProvider = MoyaProvider<RegisterService>(plugins: [MoyaLoggerPlugin()])
static func postNicknameValidRequest(nickname: NicknameValidRequest) -> Observable<NicknameValidResponse> {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .formatted(DateFormatter().mapDateFormat())
return registerProvider.rx.request(.postNicknameValidRequest(nickname: nickname))
.map(NicknameValidResponse.self, using: decoder)
.asObservable()
.catch { error in
if let moyaError = error as? MoyaError {
switch moyaError {
case .statusCode(let response):
print("HTTP Status Code: \(response.statusCode)")
case .jsonMapping(let response):
print("JSON Mapping Error for Response: \(response)")
default:
print("Other MoyaError: \(moyaError.localizedDescription)")
}
}
return Observable.error(error)
}
}
static func getAIProfileImage() -> Observable<Data> {
return registerProvider.rx.request(.getAIImage)
.map { response -> Data in
return response.data
}
.asObservable()
.catch { error in
if let moyaError = error as? MoyaError {
switch moyaError {
case .statusCode(let response):
print("HTTP Status Code: \(response.statusCode)")
default:
print("Other MoyaError: \(moyaError.localizedDescription)")
}
}
return Observable.error(error)
}
}
}
๋ญ๊ฐ. . ๋ func ์ ์ฐจ์ด๊ฐ ๋๊ปด์ง์ง์ . . ๐ฉ๐
๊ธฐ๊ณ์ ์ฝ๋ฉํ๋ค๊ฐ ํ ๋ฐ ์ฃผ์ถคํ๋ ํํธ
ํ ๋ ๋ฒ ๊ตฌํํด๋๋ฉด ๋ค๋ฅธ์ ๋ค์ ์๋ก ๊ตฌ์กฐ๊ฐ ์ท๋น์ท๋น ํ๊ฑฐ๋ฑ์
๋ง๊ฐ๊น์ง ํ์ดํ ํ !!
'Experiences > Competition' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[2024 GDSC] Google Solution Challenge Certification (0) | 2024.04.11 |
---|---|
2024 Google Solution Challenge ํฅ์คํ (0) | 2023.12.27 |
2024 Google Solution Challenge ์ฐธ๊ฐ (1) | 2023.12.22 |
2022 ์ฐ์ฃผ์ ํ์ฌ๋ ์์ธก AI ๊ฒฝ์ง๋ํ ํ์ (0) | 2022.10.10 |
2022 ์ํํธ์จ์ด์ตํฉ๋ํ ๊ณต๋ชจ์ ์์ (0) | 2022.08.27 |