(channel *model.Channel)
| 212 | } |
| 213 | |
| 214 | func updateChannelAPI2GPTBalance(channel *model.Channel) (float64, error) { |
| 215 | url := "https://api.api2gpt.com/dashboard/billing/credit_grants" |
| 216 | body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key)) |
| 217 | |
| 218 | if err != nil { |
| 219 | return 0, err |
| 220 | } |
| 221 | response := API2GPTUsageResponse{} |
| 222 | err = json.Unmarshal(body, &response) |
| 223 | if err != nil { |
| 224 | return 0, err |
| 225 | } |
| 226 | channel.UpdateBalance(response.TotalRemaining) |
| 227 | return response.TotalRemaining, nil |
| 228 | } |
| 229 | |
| 230 | func updateChannelSiliconFlowBalance(channel *model.Channel) (float64, error) { |
| 231 | url := "https://api.siliconflow.cn/v1/user/info" |
no test coverage detected