package errors

import "errors"

type ValidationKeys struct {
	Invalid                   string
	InternalServerError       string
	InvalidJson               string
	Unauthorized              string
	InvalidSubscriptionModel  string
	UserNotFoundWrongPassword string
	JwtGenerationFailed       string
	Duplicate                 string
	InvalidUserID             string
}

type ValidationFields struct {
	General            string
	ParentMemberShipID string
	SubscriptionModel  string
	UserID             string
	Login              string
	Email              string
	User               string
}

var (
	ErrNotFound                = errors.New("not found")
	ErrUserNotFound            = errors.New("user not found")
	ErrInvalidEmail            = errors.New("invalid email")
	ErrInvalidCredentials      = errors.New("invalid credentials: unauthorized")
	ErrAlreadyVerified         = errors.New("user is already verified")
	ErrTokenNotFound           = errors.New("verification token not found")
	ErrTokenNotSet             = errors.New("verification token has not been set")
	ErrNoData                  = errors.New("no data provided")
	ErrNoRowsAffected          = errors.New("no rows affected")
	ErrValueTooLong            = errors.New("cookie value too long")
	ErrInvalidValue            = errors.New("invalid cookie value")
	ErrInvalidSigningAlgorithm = errors.New("invalid signing algorithm")
	ErrValidToken              = errors.New("valid token")
	ErrInvalidUserData         = errors.New("invalid user data")
	ErrDuplicateEntry          = errors.New("duplicate entry; unique constraint failed")
	ErrNotAuthorized           = errors.New("not authorized")
	ValErrParentIDNotSet       = errors.New("Parent Membership ID not provided")
	ValErrParentIDNotFound     = errors.New("Parent Membership ID not found")
	ErrSubscriptionNotFound    = errors.New("Subscription Model not found")
	ErrSubscriptionInUse       = errors.New("This subscription is in active use by existing members.")
	ErrInvalidSubscriptionData = errors.New("Provided subscription data is invalid. Immutable fields where changed.")
)

var Responses = struct {
	Keys   ValidationKeys
	Fields ValidationFields
}{
	Keys: ValidationKeys{
		Invalid:                   "server.validation.invalid",
		InternalServerError:       "server.error.internal_server_error",
		InvalidJson:               "server.error.invalid_json",
		Unauthorized:              "server.error.unauthorized",
		UserNotFoundWrongPassword: "server.validation.user_not_found_or_wrong_password",
		JwtGenerationFailed:       "server.error.jwt_generation_failed",
		Duplicate:                 "server.validation.duplicate",
	},
	Fields: ValidationFields{
		General:            "general",
		ParentMemberShipID: "parent_membership_id",
		SubscriptionModel:  "subscription_model",
		UserID:             "user_id",
		Login:              "login",
		Email:              "email",
		User:               "user",
	},
}
