1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
Files
stackexchange-dnscontrol/vendor/github.com/vultr/govultr/account.go
Patrick Gaskin 44a7ba5711 Switch to official Vultr API library (#529)
* vultr: Switched to official API library (closes #528)

* vultr: Renamed vultr.VultrApi to vultr.Provider

* vendor: Updated govultr
2019-07-15 10:31:55 -04:00

46 lines
1.0 KiB
Go

package govultr
import (
"context"
"net/http"
)
// AccountService is the interface to interact with Accounts endpoint on the Vultr API
// Link: https://www.vultr.com/api/#account
type AccountService interface {
GetInfo(ctx context.Context) (*Account, error)
}
// AccountServiceHandler handles interaction with the account methods for the Vultr API
type AccountServiceHandler struct {
client *Client
}
// Account represents a Vultr account
type Account struct {
Balance string `json:"balance"`
PendingCharges string `json:"pending_charges"`
LastPaymentDate string `json:"last_payment_date"`
LastPaymentAmount string `json:"last_payment_amount"`
}
// GetInfo Vultr account info
func (a *AccountServiceHandler) GetInfo(ctx context.Context) (*Account, error) {
uri := "/v1/account/info"
req, err := a.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
}
account := new(Account)
err = a.client.DoWithContext(ctx, req, account)
if err != nil {
return nil, err
}
return account, nil
}