Files
bc-netts-energy/internal/netts/models.go
2025-11-03 19:26:48 +08:00

88 lines
3.2 KiB
Go

package netts
// APIResponse represents Netts standard API response envelope.
type APIResponse[T any] struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data T `json:"data"`
}
// AnalyzeUSDTRequest describes the payload for /apiv2/usdt/analyze.
type AnalyzeUSDTRequest struct {
Sender string `json:"sender"`
Receiver string `json:"receiver"`
Amount string `json:"amount"`
}
// AnalyzeUSDTData contains analysis details for USDT transfer.
type AnalyzeUSDTData struct {
TransferDetails TransferDetails `json:"transfer_details"`
}
// TransferDetails describes recommended resources for a transfer.
type TransferDetails struct {
SenderAddress string `json:"sender_address"`
ReceiverAddress string `json:"receiver_address"`
USDTAmount string `json:"usdt_amount"`
RecommendedEnergy int `json:"recommended_energy"`
EnergyNeeded int `json:"energy_needed"`
BandwidthNeeded int `json:"bandwidth_needed"`
CostBreakdown CostBreakdown `json:"cost_breakdown"`
SavingsAnalysis SavingsAnalysis `json:"savings_analysis"`
HasSufficientUSDT *bool `json:"has_usdt,omitempty"`
RecommendedReserve int `json:"recommended_energy_reserve,omitempty"`
}
// CostBreakdown details TRX costs.
type CostBreakdown struct {
EnergyCost string `json:"energy_cost"`
BandwidthCost string `json:"bandwidth_cost"`
TotalCostTRX string `json:"total_cost_trx"`
}
// SavingsAnalysis summarises cost savings.
type SavingsAnalysis struct {
VsDirectBurn string `json:"vs_direct_burn"`
VsStaking string `json:"vs_staking"`
SavingsPercentage float64 `json:"savings_percentage"`
}
// AddressStatus represents Host Mode status for an address.
type AddressStatus struct {
Address string `json:"address"`
Mode string `json:"mode"`
Status string `json:"status"`
CyclesOrdered int `json:"cycles_ordered"`
CycleSet int `json:"cycle_set"`
CyclesCompleted int `json:"cycles_completed"`
CyclesRemaining int `json:"cycles_remaining"`
OpenOrders int `json:"open_orders"`
NextDelegationTime int64 `json:"next_delegation_time"`
ExpiryTime int64 `json:"expiry_time"`
BalanceAfter float64 `json:"balance_after"`
}
// AddAddressResult captures response from /time/add.
type AddAddressResult struct {
Address string `json:"address"`
CallbackURL string `json:"callback_url,omitempty"`
Timestamp string `json:"timestamp"`
}
// OrderResult captures order summary from /time/order.
type OrderResult struct {
Address string `json:"address"`
CyclesPurchased int `json:"cycles_purchased"`
TotalCycles int `json:"total_cycles"`
PreviousCycles int `json:"previous_cycles"`
TotalCost float64 `json:"total_cost"`
PricePerCycle float64 `json:"price_per_cycle"`
OrderID string `json:"order_id"`
TransactionHash string `json:"transaction_hash"`
PaymentMethod string `json:"payment_method"`
BalanceAfter float64 `json:"balance_after"`
NextDelegation int64 `json:"next_delegation_time"`
ExpiryTime int64 `json:"expiry_time"`
Status string `json:"status"`
}