// Package httpapi contains HTTP API handler stubs for the Pangolin v1 API.
// All endpoints return HTTP 501 with a structured bilingual error body until
// real business logic is wired in (tasks #2-#8).
package httpapi

import (
	"encoding/json"
	"net/http"

	openapi_types "github.com/oapi-codegen/runtime/types"

	"github.com/wangjia/pangolin/server/api/gen"
)

// notImplError is the fixed JSON error body returned by every 501 stub.
// Intentionally hand-written here (not from internal/apierr) so that this
// package stays free of dependencies on task-1f which runs in parallel.
var notImplError = struct {
	Code      string `json:"code"`
	MessageZH string `json:"message_zh"`
	MessageEn string `json:"message_en"`
}{
	Code:      "NOT_IMPLEMENTED",
	MessageZH: "接口尚未实现",
	MessageEn: "Not implemented yet",
}

// writeNotImpl writes a 501 Not Implemented response with the structured error body.
func writeNotImpl(w http.ResponseWriter) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	w.WriteHeader(http.StatusNotImplemented)
	_ = json.NewEncoder(w).Encode(notImplError)
}

// UnimplementedServer satisfies gen.ServerInterface and returns 501 for every
// endpoint. Individual methods should be replaced as each module is implemented.
type UnimplementedServer struct{}

// Compile-time assertion: UnimplementedServer must satisfy ServerInterface.
var _ gen.ServerInterface = (*UnimplementedServer)(nil)

// ── Auth ─────────────────────────────────────────────────────────────────────

func (s *UnimplementedServer) SendVerificationCode(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) Register(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) Login(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) RefreshToken(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

// ── Account ──────────────────────────────────────────────────────────────────

func (s *UnimplementedServer) GetMe(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) ListDevices(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) DeleteDevice(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
	writeNotImpl(w)
}

// ── Commerce ─────────────────────────────────────────────────────────────────

func (s *UnimplementedServer) RedeemCode(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) AdsUnlock(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) ListPlans(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}

// ── Nodes ────────────────────────────────────────────────────────────────────

func (s *UnimplementedServer) ListNodes(w http.ResponseWriter, r *http.Request, params gen.ListNodesParams) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) ConnectNode(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) DisconnectNode(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
	writeNotImpl(w)
}

// ── Usage & Notices ──────────────────────────────────────────────────────────

func (s *UnimplementedServer) GetUsage(w http.ResponseWriter, r *http.Request, params gen.GetUsageParams) {
	writeNotImpl(w)
}

func (s *UnimplementedServer) ListNotices(w http.ResponseWriter, r *http.Request) {
	writeNotImpl(w)
}
