/*
 * File: src/main/java/reports/utility/ApiResponseStructure.java
 * Description: This class represents a standardized structure for API responses.
 * It encapsulates the status of the response, metadata about the response,
 * and the actual data returned by the API. This structure helps in maintaining
 * consistency across API responses and provides essential information to clients.
*/

package com.nebula.erp.reports.utility;

import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Getter
@Setter
public class ApiResponseStructure<T> {
    private String status;
    private Meta meta;
    private T data;

    // Updated constructor to accept dynamic status code
    public ApiResponseStructure(String status, int code, String details, T data) {
        this.status = status;
        this.meta = new Meta(code, details, LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
        this.data = data;
    }

    // Inner class for Meta information
    @Getter
    @Setter
    public static class Meta {
        private int code;
        private String details;
        private String timestamp;

        public Meta(int code, String details, String timestamp) {
            this.code = code;
            this.details = details;
            this.timestamp = timestamp;
        }
    }
}