HealthService.swift
1.77 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
//
// HealthService.swift
// hippo-watch Watch App
//
// Created by shihao on 2025/7/8.
//
import Foundation
class HealthService {
private let apiClient = APIClient.shared
func getActivityTarget() async throws -> ActivityTarget {
return try await apiClient.request(HealthEndpoint.getActivityTarget)
}
func getHealthData(type: HealthType) async throws -> WatchHRVData {
return try await apiClient.request(HealthEndpoint.getHealthData(type: type))
}
func getMyData() async throws -> HFriendTodayData {
return try await apiClient.request(HealthEndpoint.getTodayData(isFriend: false))
}
func getFriendData() async throws -> HFriendTodayData {
return try await apiClient.request(HealthEndpoint.getTodayData(isFriend: true))
}
func upload(data: [String: Any]) async throws -> LatestHRV {
return try await apiClient.request(HealthEndpoint.upload(data: data))
}
func uploadBatch(data: [[String: Any]]) async throws -> EmptyResponse {
return try await apiClient.request(HealthEndpoint.uploadBatch(data: data))
}
func uploadSleep(data: [[String: Any]]) async throws -> EmptyResponse {
return try await apiClient.request(HealthEndpoint.uploadSleep(data: data))
}
func uploadActivityTarget(data: [String: Any]) async throws -> EmptyResponse {
return try await apiClient.request(HealthEndpoint.uploadActivityTarget(data: data))
}
func getUploadTimes() async throws -> WatchHealthUploadTimeList {
return try await apiClient.request(HealthEndpoint.getUploadTimes)
}
func uploadPulse(pulseType: PulseType) async throws -> EmptyResponse {
return try await apiClient.request(HealthEndpoint.uploadPulse(pulseType: pulseType))
}
}