Skip to content

Commit 0b40c17

Browse files
committed
[feat] #121 Version Network API ꡬ성
- μ„œλ²„λ‘œλΆ€ν„° μ•±μŠ€ν† μ–΄μ— μžˆλŠ” μ΅œμ‹  버전을 λ°›μ•„μ˜΄ - κ΅¬ν˜„μš”μ²­ν–ˆλŠ”λ°... 아직 λ―Έμ‚¬μš©μž„
1 parent 99d72a7 commit 0b40c17

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// VersionResponse.swift
3+
// CoreKit
4+
//
5+
// Created by κΉ€λ―Όν˜Έ on 9/10/24.
6+
//
7+
8+
import Foundation
9+
10+
public struct VersionResponse: Decodable {
11+
public let recentVersion: String
12+
}
13+
14+
extension VersionResponse {
15+
static let mock: Self = Self(recentVersion: "1.0.0")
16+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// VersionClient.swift
3+
// CoreKit
4+
//
5+
// Created by κΉ€λ―Όν˜Έ on 9/10/24.
6+
//
7+
8+
import Foundation
9+
10+
import Dependencies
11+
import Moya
12+
13+
// MARK: - Dependency Values
14+
extension DependencyValues {
15+
public var versionClient: VersionClient {
16+
get { self[VersionClient.self] }
17+
set { self[VersionClient.self] = newValue }
18+
}
19+
}
20+
/// μ•ŒλžŒμ— κ΄€λ ¨ν•œ APIλ₯Ό μ²˜λ¦¬ν•˜λŠ” Client
21+
public struct VersionClient {
22+
public var 버전체크: @Sendable () async throws -> VersionResponse
23+
}
24+
25+
extension VersionClient: DependencyKey {
26+
public static let liveValue: Self = {
27+
let nonProvider = MoyaProvider<VersionEndpoint>.buildNonToken()
28+
29+
return Self(
30+
버전체크: {
31+
try await nonProvider.request(.버전체크)
32+
}
33+
)
34+
}()
35+
36+
public static let previewValue: Self = {
37+
Self(
38+
버전체크: { .mock }
39+
)
40+
}()
41+
}
42+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// VersionEndpoint.swift
3+
// CoreKit
4+
//
5+
// Created by κΉ€λ―Όν˜Έ on 9/10/24.
6+
//
7+
8+
import Foundation
9+
import Util
10+
import Moya
11+
12+
/// Version을 μœ„ν•œ Moya Endpoint
13+
public enum VersionEndpoint {
14+
case 버전체크
15+
}
16+
17+
extension VersionEndpoint: TargetType {
18+
public var baseURL: URL {
19+
return Constants.serverURL.appendingPathComponent(Constants.versionPath, conformingTo: .url)
20+
}
21+
22+
public var path: String {
23+
/// ν™•μž₯성을 μœ„ν•΄ switch문으둜 놔둠
24+
switch self {
25+
case .버전체크: return ""
26+
}
27+
}
28+
29+
public var method: Moya.Method {
30+
switch self {
31+
case .버전체크:
32+
return .get
33+
}
34+
}
35+
36+
public var task: Moya.Task {
37+
switch self {
38+
case .버전체크:
39+
return .requestPlain
40+
}
41+
}
42+
43+
public var headers: [String : String]? {
44+
["Content-Type": "application/json"]
45+
}
46+
}

β€ŽProjects/Util/Sources/Constants.swiftβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum Constants {
1515
public static let contentPath: String = "/api/v1/content"
1616
public static let remindPath: String = "api/v1/remind"
1717
public static let alertPath: String = "/api/v1/alert"
18+
public static let versionPath: String = "/api/v1/version"
1819

1920
public static let 곡지사항_μ£Όμ†Œ: URL = URL(string: "https://www.notion.so/POKIT-d97c81534b354cfebe677fbf1fbfe2b2")!
2021
public static let μ„œλΉ„μŠ€_μ΄μš©μ•½κ΄€_μ£Όμ†Œ: URL = URL(string: "https://www.notion.so/3bddcd6fd00043abae6b92a50c39b132?pvs=4")!

0 commit comments

Comments
Β (0)