package provider

import (
	"context"
	"fmt"

	"apps/backend/internal/module/threads/domain"
)

// UnavailableProvider keeps the service operational when a deployment has not
// configured Threads yet. Every provider operation fails explicitly; it never
// creates a synthetic OAuth account or token.
type UnavailableProvider struct {
	reason string
}

func NewUnavailable(reason string) *UnavailableProvider {
	return &UnavailableProvider{reason: reason}
}

func (p *UnavailableProvider) Name() string { return "unavailable" }

func (p *UnavailableProvider) AuthorizeURL(string, string) string { return "" }

func (p *UnavailableProvider) ExchangeCode(context.Context, string, string) (*domain.TokenPair, error) {
	return nil, fmt.Errorf("Threads OAuth is not configured: %s", p.reason)
}

func (p *UnavailableProvider) Refresh(context.Context, string) (*domain.TokenPair, error) {
	return nil, fmt.Errorf("Threads OAuth is not configured: %s", p.reason)
}

var _ domain.Provider = (*UnavailableProvider)(nil)
