package com.kingdee.eas.custom.integration.apimgt.sync;

import java.util.Objects;

/**
 * API 接口端点扫描结果。
 */
public class ApiEndpoint {

    private String apiPath;
    private String httpMethod;
    private String apiName;
    private String apiDesc;
    private boolean isAuthRequired;
    private boolean isSkipCallLog;

    public ApiEndpoint() {
    }

    public ApiEndpoint(String apiPath, String httpMethod, String apiName, String apiDesc,
                       boolean isAuthRequired, boolean isSkipCallLog) {
        this.apiPath = apiPath;
        this.httpMethod = httpMethod;
        this.apiName = apiName;
        this.apiDesc = apiDesc;
        this.isAuthRequired = isAuthRequired;
        this.isSkipCallLog = isSkipCallLog;
    }

    public String getApiPath() {
        return apiPath;
    }

    public void setApiPath(String apiPath) {
        this.apiPath = apiPath;
    }

    public String getHttpMethod() {
        return httpMethod;
    }

    public void setHttpMethod(String httpMethod) {
        this.httpMethod = httpMethod;
    }

    public String getApiName() {
        return apiName;
    }

    public void setApiName(String apiName) {
        this.apiName = apiName;
    }

    public String getApiDesc() {
        return apiDesc;
    }

    public void setApiDesc(String apiDesc) {
        this.apiDesc = apiDesc;
    }

    public boolean isAuthRequired() {
        return isAuthRequired;
    }

    public void setAuthRequired(boolean authRequired) {
        isAuthRequired = authRequired;
    }

    public boolean isSkipCallLog() {
        return isSkipCallLog;
    }

    public void setSkipCallLog(boolean skipCallLog) {
        isSkipCallLog = skipCallLog;
    }

    public String buildKey() {
        return apiPath + "#" + httpMethod;
    }

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

    @Override
    public int hashCode() {
        return Objects.hash(apiPath, httpMethod);
    }

    @Override
    public String toString() {
        return httpMethod + " " + apiPath + " [auth=" + isAuthRequired + "]";
    }
}
