user health no err

This commit is contained in:
boufni95 2024-12-12 18:59:25 +00:00
parent 84b3ef4b9d
commit 93af9969ed
11 changed files with 234 additions and 192 deletions

View file

@ -125,7 +125,7 @@ type Client struct {
UpdateChannelPolicy func(req UpdateChannelPolicyRequest) error
UpdateUserOffer func(req OfferConfig) error
UseInviteLink func(req UseInviteLinkRequest) error
UserHealth func() error
UserHealth func() (*UserHealthState, error)
}
func NewClient(params ClientParams) *Client {
@ -1904,26 +1904,31 @@ func NewClient(params ClientParams) *Client {
}
return nil
},
UserHealth: func() error {
UserHealth: func() (*UserHealthState, error) {
auth, err := params.RetrieveUserAuth()
if err != nil {
return err
return nil, err
}
finalRoute := "/api/user/health"
body := []byte{}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return err
return nil, err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return err
return nil, err
}
if result.Status == "ERROR" {
return fmt.Errorf(result.Reason)
return nil, fmt.Errorf(result.Reason)
}
return nil
res := UserHealthState{}
err = json.Unmarshal(resBody, &res)
if err != nil {
return nil, err
}
return &res, nil
},
}
}

View file

@ -555,6 +555,9 @@ type UsageMetrics struct {
type UseInviteLinkRequest struct {
Invite_token string `json:"invite_token"`
}
type UserHealthState struct {
Downtime_reason string `json:"downtime_reason"`
}
type UserInfo struct {
Balance int64 `json:"balance"`
Bridge_url string `json:"bridge_url"`