Update hostinger_service.go
This commit is contained in:
@@ -145,20 +145,23 @@ func (c *HostingerClient) GetDomains() ([]HostingerDomain, error) {
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// hostingerDNSZone es la estructura interna de la respuesta de zona DNS.
|
||||
type hostingerDNSZone struct {
|
||||
Records []HostingerDNSRecord `json:"records"`
|
||||
}
|
||||
|
||||
// GetDNSRecords obtiene los registros DNS de un dominio.
|
||||
// Endpoint: GET /dns/v1/zones/{domain} — devuelve un array de zonas con records embebidos.
|
||||
func (c *HostingerClient) GetDNSRecords(domain string) ([]HostingerDNSRecord, error) {
|
||||
var result struct {
|
||||
Data []HostingerDNSRecord `json:"data"`
|
||||
path := fmt.Sprintf("/dns/v1/zones/%s", domain)
|
||||
var zones []hostingerDNSZone
|
||||
if err := c.get(path, &zones); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
path := fmt.Sprintf("/dns/v1/zones/%s/records", domain)
|
||||
if err := c.get(path, &result); err != nil {
|
||||
var arr []HostingerDNSRecord
|
||||
if err2 := c.get(path, &arr); err2 != nil {
|
||||
return nil, err
|
||||
}
|
||||
return arr, nil
|
||||
if len(zones) > 0 {
|
||||
return zones[0].Records, nil
|
||||
}
|
||||
return result.Data, nil
|
||||
return []HostingerDNSRecord{}, nil
|
||||
}
|
||||
|
||||
// GetOrders obtiene las órdenes de facturación.
|
||||
@@ -177,13 +180,14 @@ func (c *HostingerClient) GetOrders() ([]HostingerOrder, error) {
|
||||
}
|
||||
|
||||
// GetHostingAccounts obtiene las cuentas de hosting.
|
||||
// Endpoint: GET /hosting/v1/websites
|
||||
func (c *HostingerClient) GetHostingAccounts() ([]HostingerHosting, error) {
|
||||
var result struct {
|
||||
Data []HostingerHosting `json:"data"`
|
||||
}
|
||||
if err := c.get("/hosting/v1/accounts", &result); err != nil {
|
||||
if err := c.get("/hosting/v1/websites", &result); err != nil {
|
||||
var arr []HostingerHosting
|
||||
if err2 := c.get("/hosting/v1/accounts", &arr); err2 != nil {
|
||||
if err2 := c.get("/hosting/v1/websites", &arr); err2 != nil {
|
||||
return nil, err
|
||||
}
|
||||
return arr, nil
|
||||
|
||||
Reference in New Issue
Block a user