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

Function updateChannelAIProxyBalance

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

Source from the content-addressed store, hash-verified

192}
193
194func updateChannelAIProxyBalance(channel *model.Channel) (float64, error) {
195 url := "https://aiproxy.io/api/report/getUserOverview"
196 headers := http.Header{}
197 headers.Add("Api-Key", channel.Key)
198 body, err := GetResponseBody("GET", url, channel, headers)
199 if err != nil {
200 return 0, err
201 }
202 response := AIProxyUserOverviewResponse{}
203 err = json.Unmarshal(body, &response)
204 if err != nil {
205 return 0, err
206 }
207 if !response.Success {
208 return 0, fmt.Errorf("code: %d, message: %s", response.ErrorCode, response.Message)
209 }
210 channel.UpdateBalance(response.Data.TotalPoints)
211 return response.Data.TotalPoints, nil
212}
213
214func updateChannelAPI2GPTBalance(channel *model.Channel) (float64, error) {
215 url := "https://api.api2gpt.com/dashboard/billing/credit_grants"

Callers 1

updateChannelBalanceFunction · 0.85

Calls 3

GetResponseBodyFunction · 0.85
AddMethod · 0.80
UpdateBalanceMethod · 0.80

Tested by

no test coverage detected