package com.r11.tools.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpMethod;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * Pojo class for Event entity
 * @author Rafał Żukowicz
 * @author Mikołaj Widła
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@RedisHash("mockHistory")
public class RequestHistory implements Comparable<RequestHistory>, Serializable {

    @Id
    private String id;
    @DateTimeFormat(pattern = "yyyy-MM-ddTHH:mm:ss")
    private LocalDateTime dateTimeStamp;
    @Indexed
    private String clientUUID;
    @Indexed
    private Integer messageID;
    private Map<String,String> headers;
    private HttpMethod httpMethod;
    private String requestBody;

    @Override
    public int compareTo(RequestHistory o) {
        return this.getDateTimeStamp().compareTo(o.getDateTimeStamp()) * -1;
    }
}
