package com.writeoff.common.api;

import com.writeoff.common.web.RequestIdContext;
import java.time.Instant;
import java.util.Map;

public class ApiErrorResponse {
    private int code;
    private String message;
    private Map<String, String> errors;
    private String requestId;
    private String timestamp;

    public ApiErrorResponse(int code, String message, Map<String, String> errors, String requestId, String timestamp) {
        this.code = code;
        this.message = message;
        this.errors = errors;
        this.requestId = requestId;
        this.timestamp = timestamp;
    }

    public static ApiErrorResponse of(int code, String message, Map<String, String> errors) {
        return new ApiErrorResponse(code, message, errors, RequestIdContext.get(), Instant.now().toString());
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Map<String, String> getErrors() {
        return errors;
    }

    public String getRequestId() {
        return requestId;
    }

    public String getTimestamp() {
        return timestamp;
    }
}
