39 lines
950 B
Go
39 lines
950 B
Go
package playtogo
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
type NameServer struct {
|
|
Name string `json:"name"`
|
|
IP string `json:"ip"`
|
|
IPv6 string `json:"ip6"`
|
|
SeqNR int `json:"seq_nr"`
|
|
}
|
|
|
|
type Domain struct {
|
|
ID int `json:"id"`
|
|
Status string `json:"status"`
|
|
FullName string `json:"full_name"`
|
|
DisplayName string `json:"display_name"`
|
|
DomainName string `json:"domain_name"`
|
|
DomainExtention string `json:"domain_extention"`
|
|
DomainServers []NameServer `json:"name_servers"`
|
|
}
|
|
|
|
func (c *Client) GetDomains(ctx context.Context) ([]Domain, error) {
|
|
var response ApiResponse[[]Domain]
|
|
path := "/api/domains/my"
|
|
|
|
if err := c.do(ctx, http.MethodGet, path, nil, &response); err != nil {
|
|
return nil, fmt.Errorf("get subscription: %w", err)
|
|
}
|
|
|
|
if !response.Success {
|
|
return nil, fmt.Errorf("api error: %v", response.Error)
|
|
}
|
|
|
|
return response.Data, nil
|
|
}
|