up
This commit is contained in:
@@ -109,24 +109,33 @@ type HostingerDNSRecord struct {
|
||||
Priority int `json:"priority,omitempty"`
|
||||
}
|
||||
|
||||
// HostingerOrder representa una orden de facturación.
|
||||
type HostingerOrder struct {
|
||||
ID int `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Total float64 `json:"total"`
|
||||
Currency string `json:"currency"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
// HostingerSubscription representa una suscripción de facturación.
|
||||
type HostingerSubscription struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
BillingPeriod int `json:"billing_period"`
|
||||
BillingPeriodUnit string `json:"billing_period_unit"`
|
||||
CurrencyCode string `json:"currency_code"`
|
||||
TotalPrice int `json:"total_price"`
|
||||
RenewalPrice int `json:"renewal_price"`
|
||||
IsAutoRenewed bool `json:"is_auto_renewed"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
NextBillingAt string `json:"next_billing_at"`
|
||||
}
|
||||
|
||||
// HostingerHosting representa una cuenta de hosting.
|
||||
type HostingerHosting struct {
|
||||
ID int `json:"id"`
|
||||
Domain string `json:"domain"`
|
||||
Plan string `json:"plan"`
|
||||
State string `json:"state"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
DiskUsed int64 `json:"disk_used"`
|
||||
DiskLimit int64 `json:"disk_limit"`
|
||||
Domain string `json:"domain"`
|
||||
VhostType string `json:"vhost_type"`
|
||||
IsEnabled bool `json:"is_enabled"`
|
||||
Username string `json:"username"`
|
||||
ClientID int `json:"client_id"`
|
||||
OrderID int `json:"order_id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
RootDirectory string `json:"root_directory"`
|
||||
ParentDomain string `json:"parent_domain"`
|
||||
}
|
||||
|
||||
// ─── Métodos de la API ───────────────────────────────────────────────────────
|
||||
@@ -188,21 +197,21 @@ func (c *HostingerClient) GetDNSRecords(domain string) ([]HostingerDNSRecord, er
|
||||
return []HostingerDNSRecord{}, nil
|
||||
}
|
||||
|
||||
// GetOrders obtiene las órdenes de facturación.
|
||||
func (c *HostingerClient) GetOrders() ([]HostingerOrder, error) {
|
||||
body, err := c.getRaw(context.Background(), "/billing/v1/orders")
|
||||
// GetOrders obtiene las suscripciones de facturación.
|
||||
func (c *HostingerClient) GetOrders() ([]HostingerSubscription, error) {
|
||||
body, err := c.getRaw(context.Background(), "/billing/v1/subscriptions")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var wrapped struct {
|
||||
Data []HostingerOrder `json:"data"`
|
||||
Data []HostingerSubscription `json:"data"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &wrapped); err == nil && wrapped.Data != nil {
|
||||
return wrapped.Data, nil
|
||||
}
|
||||
var arr []HostingerOrder
|
||||
var arr []HostingerSubscription
|
||||
if err := json.Unmarshal(body, &arr); err != nil {
|
||||
return nil, fmt.Errorf("hostinger: no se pudo interpretar respuesta orders: %w", err)
|
||||
return nil, fmt.Errorf("hostinger: no se pudo interpretar respuesta subscriptions: %w", err)
|
||||
}
|
||||
return arr, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user