#include "auth_types.h"
#include <strings.h>  // strcasecmp

const char *auth_mode_to_str(auth_mode_t mode) {
    switch (mode) {
        case AUTH_MODE_OPEN:        return "open";
        case AUTH_MODE_LOCAL_RFID:  return "local";
        case AUTH_MODE_OCPP_RFID:   return "ocpp";
        default:                    return "open";
    }
}

bool auth_mode_from_str(const char *s, auth_mode_t *out) {
    if (!s || !out) return false;
    if (!strcasecmp(s, "open"))  { *out = AUTH_MODE_OPEN;        return true; }
    if (!strcasecmp(s, "local")) { *out = AUTH_MODE_LOCAL_RFID;  return true; }
    if (!strcasecmp(s, "ocpp"))  { *out = AUTH_MODE_OCPP_RFID;   return true; }
    return false;
}
