MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / updateChannelDeepSeekBalance

Function updateChannelDeepSeekBalance

controller/channel-billing.go:252–279  ·  view source on GitHub ↗
(channel *model.Channel)

Source from the content-addressed store, hash-verified

250}
251
252func updateChannelDeepSeekBalance(channel *model.Channel) (float64, error) {
253 url := "https://api.deepseek.com/user/balance"
254 body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
255 if err != nil {
256 return 0, err
257 }
258 response := DeepSeekUsageResponse{}
259 err = json.Unmarshal(body, &response)
260 if err != nil {
261 return 0, err
262 }
263 index := -1
264 for i, balanceInfo := range response.BalanceInfos {
265 if balanceInfo.Currency == "CNY" {
266 index = i
267 break
268 }
269 }
270 if index == -1 {
271 return 0, errors.New("currency CNY not found")
272 }
273 balance, err := strconv.ParseFloat(response.BalanceInfos[index].TotalBalance, 64)
274 if err != nil {
275 return 0, err
276 }
277 channel.UpdateBalance(balance)
278 return balance, nil
279}
280
281func updateChannelAIGC2DBalance(channel *model.Channel) (float64, error) {
282 url := "https://api.aigc2d.com/dashboard/billing/credit_grants"

Callers 1

updateChannelBalanceFunction · 0.85

Calls 3

GetResponseBodyFunction · 0.85
GetAuthHeaderFunction · 0.85
UpdateBalanceMethod · 0.80

Tested by

no test coverage detected