27 lines
469 B
Go
27 lines
469 B
Go
package sms77api
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
)
|
|
|
|
type BalanceResource resource
|
|
|
|
func (api *BalanceResource) Get() (*float64, error) {
|
|
return api.GetContext(context.Background())
|
|
}
|
|
|
|
func (api *BalanceResource) GetContext(ctx context.Context) (*float64, error) {
|
|
res, err := api.client.request(ctx, "balance", "GET", nil)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
float, err := strconv.ParseFloat(res, 64)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &float, nil
|
|
}
|