Update hostinger_service.go
This commit is contained in:
@@ -145,20 +145,23 @@ func (c *HostingerClient) GetDomains() ([]HostingerDomain, error) {
|
|||||||
return result.Data, nil
|
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.
|
// 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) {
|
func (c *HostingerClient) GetDNSRecords(domain string) ([]HostingerDNSRecord, error) {
|
||||||
var result struct {
|
path := fmt.Sprintf("/dns/v1/zones/%s", domain)
|
||||||
Data []HostingerDNSRecord `json:"data"`
|
var zones []hostingerDNSZone
|
||||||
|
if err := c.get(path, &zones); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
path := fmt.Sprintf("/dns/v1/zones/%s/records", domain)
|
if len(zones) > 0 {
|
||||||
if err := c.get(path, &result); err != nil {
|
return zones[0].Records, nil
|
||||||
var arr []HostingerDNSRecord
|
|
||||||
if err2 := c.get(path, &arr); err2 != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return arr, nil
|
|
||||||
}
|
}
|
||||||
return result.Data, nil
|
return []HostingerDNSRecord{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrders obtiene las órdenes de facturación.
|
// GetOrders obtiene las órdenes de facturación.
|
||||||
@@ -177,13 +180,14 @@ func (c *HostingerClient) GetOrders() ([]HostingerOrder, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetHostingAccounts obtiene las cuentas de hosting.
|
// GetHostingAccounts obtiene las cuentas de hosting.
|
||||||
|
// Endpoint: GET /hosting/v1/websites
|
||||||
func (c *HostingerClient) GetHostingAccounts() ([]HostingerHosting, error) {
|
func (c *HostingerClient) GetHostingAccounts() ([]HostingerHosting, error) {
|
||||||
var result struct {
|
var result struct {
|
||||||
Data []HostingerHosting `json:"data"`
|
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
|
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 nil, err
|
||||||
}
|
}
|
||||||
return arr, nil
|
return arr, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user