package FikoYTCevapCls

import FikoYTHata "server/sistem/fikoyt_ctx/fikoyt_hata"

// HTTP Durum Kodlarına Karşılık Gelen Mesajlar
var durumMesajlari = map[int]string{
	// 1xx: Bilgilendirme
	100: "Continue",
	101: "Switching Protocols",
	102: "Processing",
	103: "Early Hints",

	// 2xx: Başarı
	200: "OK",
	201: "Created",
	202: "Accepted",
	203: "Non-Authoritative Information",
	204: "No Content",
	205: "Reset Content",
	206: "Partial Content",
	207: "Multi-Status",
	208: "Already Reported",
	226: "IM Used",

	// 3xx: Yönlendirme
	300: "Multiple Choices",
	301: "Moved Permanently",
	302: "Found",
	303: "See Other",
	304: "Not Modified",
	305: "Use Proxy",
	307: "Temporary Redirect",
	308: "Permanent Redirect",

	// 4xx: İstemci Hataları
	400: "Bad Request",
	401: "Unauthorized",
	402: "Payment Required",
	403: "Forbidden",
	404: "Not Found",
	405: "Method Not Allowed",
	406: "Not Acceptable",
	407: "Proxy Authentication Required",
	408: "Request Timeout",
	409: "Conflict",
	410: "Gone",
	411: "Length Required",
	412: "Precondition Failed",
	413: "Payload Too Large",
	414: "URI Too Long",
	415: "Unsupported Media Type",
	416: "Range Not Satisfiable",
	417: "Expectation Failed",
	418: "I'm a teapot",
	422: "Unprocessable Entity",
	429: "Too Many Requests",

	// 5xx: Sunucu Hataları
	500: "Internal Server Error",
	501: "Not Implemented",
	502: "Bad Gateway",
	503: "Service Unavailable",
	504: "Gateway Timeout",
	505: "HTTP Version Not Supported",

	// Üyelik Sistemi için Ek Kodlar
	460: "Email Not Verified",       // Kullanıcının e-posta doğrulaması eksik
	461: "Invalid Activation Token", // Aktivasyon kodu hatalı
	462: "User Already Exists",      // Kullanıcı zaten kayıtlı
	463: "User Not Found",           // Kullanıcı bulunamadı
	464: "Password Reset Required",  // Şifre sıfırlama gerekli
	465: "Invalid Credentials",      // Hatalı kullanıcı adı veya şifre
	466: "Account Disabled",         // Hesap devre dışı bırakılmış
	467: "Account Not Activated",    // Hesap aktive edilmemiş
	468: "Password Expired",         // Şifre kullanım süresi dolmuş
	469: "Session Expired",          // Oturum süresi dolmuş

	// WebSocket için Ek Kodlar
	470: "WebSocket Connection Failed",       // Bağlantı kurulamadı
	471: "WebSocket Handshake Failed",        // Handshake başarısız
	472: "WebSocket Unauthorized",            // Yetkilendirme hatası
	473: "WebSocket Protocol Error",          // Protokol ihlali
	474: "WebSocket Message Too Large",       // Mesaj boyutu çok büyük
	475: "WebSocket Unsupported Data",        // Desteklenmeyen veri türü
	476: "WebSocket Close Normal",            // Normal kapatma (kod 1000)
	477: "WebSocket Close Going Away",        // Sunucu veya istemci bağlantıdan ayrılıyor (kod 1001)
	478: "WebSocket Close Protocol Error",    // Protokol hatası (kod 1002)
	479: "WebSocket Close Unsupported",       // Desteklenmeyen veri türü (kod 1003)
	480: "WebSocket Close No Status",         // Durum kodu belirtilmedi (kod 1005)
	481: "WebSocket Close Abnormal",          // Anormal bağlantı kapanışı (kod 1006)
	482: "WebSocket Close Invalid Data",      // Geçersiz veri (kod 1007)
	483: "WebSocket Close Policy Violation",  // Politika ihlali (kod 1008)
	484: "WebSocket Close Too Large",         // Mesaj çok büyük (kod 1009)
	485: "WebSocket Close Extension Missing", // Gerekli eklenti eksik (kod 1010)
	486: "WebSocket Close Server Error",      // Sunucu hatası (kod 1011)
	487: "WebSocket Close TLS Error",         // TLS bağlantı hatası (kod 1015)

	// API ve Token Yönetimi
	490: "Invalid API Key",
	491: "Expired API Key",
	492: "Invalid Session Token",
	493: "Expired Session Token",
	494: "Insufficient Permissions",
	495: "CSRF Token Missing",
	496: "CSRF Token Invalid",

	499: "FikoYT Durum",
	// Framework veya Özel Kodlar
	600: "Database Connection Error",
	601: "Invalid API Version",
	602: "Service Deprecated",
	603: "Session Timeout",
	604: "Invalid WebSocket Frame",
	605: "Server Maintenance Mode",
}

// Status koduna uygun mesaj döndürür, bilinmeyen kodlar için varsayılan mesaj
func DurumMesajiAl(code *int) string {
	if code == nil {
		return "Durum Bilinmiyor"
	} else if msg, exists := durumMesajlari[*code]; exists {
		return msg
	}
	return "Durum Bilinmiyor"
}

// Custom Response Struct
type FikoYTCevap struct {
	Durum FikoYTDurum `json:"durum"`
	Sonuc interface{} `json:"sonuc"`
}

func (f *FikoYTCevap) AyarlaDurumKodu(durum int) {
	f.Durum.Kodu = &durum
}

//
type FikoYTDurum struct {
	Kodu       *int                       `json:"kodu"`
	Tamamlandi bool                       `json:"tamamlandi"`
	Mesaj      string                     `json:"mesaj"`
	Hata       bool                       `json:"hata"`
	Hatalar    FikoYTHata.ArrayFikoYTHata `json:"hatalar"`
}
