/*
 * File: src/main/java/purchase/utility/ApiResponseStructure.java
 * Description: This class defines a generic structure for API responses in the ERP system.
 * It encapsulates the response data along with meta-information, including status, HTTP code, and a timestamp.
 * The structure aims to standardize API responses, making it easier to manage error handling and provide consistent
 * output across different endpoints.
 */

package com.nebula.erp.purchase.utility;

import lombok.Getter;
import lombok.Setter;
import java.time.Instant;

@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, Instant.now().toString());
        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;
        }
    }
}