HealthEndpoint.swift 1.6 KB
//
//  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
        }
    }
}