package com.eactive.httpmockserver.client.entity;

import com.eactive.httpmockserver.server.entity.Server;
import com.eactive.httpmockserver.user.entity.StaffUser;

import javax.persistence.*;
import java.util.Objects;


@Entity
@Table(name = "API_REQUEST_INFO")
public class ApiRequestInfo {

    @Id
    private String id; //uuid

    @ManyToOne
    @JoinColumn(name = "SERVER_ID")
    private Server server;

    @ManyToOne
    @JoinColumn(name = "USER_ID")
    private StaffUser owner;

    private String name;

    private String method;

    private String path;

    @Lob
    private String headers;

    @Lob
    private String queryParams;

    @Lob
    private String variables;

    @Lob
    private String requestBody;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Server getServer() {
        return server;
    }

    public void setServer(Server server) {
        this.server = server;
    }

    public StaffUser getOwner() {
        return owner;
    }

    public void setOwner(StaffUser owner) {
        this.owner = owner;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getHeaders() {
        return headers;
    }

    public void setHeaders(String headers) {
        this.headers = headers;
    }

    public String getQueryParams() {
        return queryParams;
    }

    public void setQueryParams(String queryParams) {
        this.queryParams = queryParams;
    }

    public String getVariables() {
        return variables;
    }

    public void setVariables(String variables) {
        this.variables = variables;
    }

    public String getRequestBody() {
        return requestBody;
    }

    public void setRequestBody(String requestBody) {
        this.requestBody = requestBody;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ApiRequestInfo that = (ApiRequestInfo) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, server, owner, method, path, headers, queryParams, requestBody);
    }

}
