HealthEndpoint.swift
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// HealthEndpoint.swift
// hippo-watch Watch App
//
// Created by shihao on 2025/7/8.
//
import Foundation
enum HealthEndpoint: APIEndpoint {
case getTodayStatusInfo
case getLatestHRV
case upload(data: [String: Any])
case uploadPulse(pulseType: PulseType)
var path: String {
switch self {
case .getTodayStatusInfo:
return "/client/doublefeel/health/info_today/"
case .getLatestHRV:
return "/client/doublefeel/health/lastest_hrv/"
case .upload:
return "/client/doublefeel/health/data_upload/common/"
case .uploadPulse:
return "/client/doublefeel/health/pulse/"
}
}
var method: HTTPMethod {
switch self {
case .getTodayStatusInfo:
return .get
case .getLatestHRV:
return .get
case .upload:
return .post
case .uploadPulse:
return .post
}
}
var parameters: [String: Any]? {
switch self {
case .getTodayStatusInfo:
return ["is_other": 1]
case .getLatestHRV:
return nil
case .upload(let data):
return ["data_list": [data]]
case .uploadPulse(let pulseType):
return ["pulse_type": pulseType.rawValue]
}
}
var encoding: ParameterEncoding {
switch self {
case .getTodayStatusInfo:
return .url
case .getLatestHRV:
return .url
case .upload:
return .json
case .uploadPulse:
return .json
}
}
}