HealthService.swift 1.77 KB
//
//  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))
    }
}