All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.qytera.qtaf.testrail.utils.APIClient Maven / Gradle / Ivy

There is a newer version: 0.2.23
Show newest version
// Generated by delombok at Tue Jun 25 12:09:13 UTC 2024
package de.qytera.qtaf.testrail.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * The client class for communicating with TestRail's API.
 */
public class APIClient {
    private String user;
    private String password;
    private String url;

    /**
     * Create a new TestRail client.
     *
     * @param baseUrl the TestRail URL
     */
    public APIClient(String baseUrl) {
        if (baseUrl == null) {
            throw new IllegalArgumentException("TestRail base URL is null, please set the value in your configuration file");
        }
        if (!baseUrl.endsWith("/")) {
            baseUrl += "/";
        }
        this.url = baseUrl + "index.php?/api/v2/";
    }

    /**
     * Get the authorization header value.
     *
     * @return the header value
     */
    public String getAuthorizationHeader() {
        return "Basic %s".formatted(new String(Base64.getEncoder().encode((user + ":" + password).getBytes(StandardCharsets.UTF_8))));
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public String getUser() {
        return this.user;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public String getPassword() {
        return this.password;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public String getUrl() {
        return this.url;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public void setUser(final String user) {
        this.user = user;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public void setPassword(final String password) {
        this.password = password;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public void setUrl(final String url) {
        this.url = url;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public boolean equals(final java.lang.Object o) {
        if (o == this) return true;
        if (!(o instanceof APIClient)) return false;
        final APIClient other = (APIClient) o;
        if (!other.canEqual((java.lang.Object) this)) return false;
        final java.lang.Object this$user = this.getUser();
        final java.lang.Object other$user = other.getUser();
        if (this$user == null ? other$user != null : !this$user.equals(other$user)) return false;
        final java.lang.Object this$password = this.getPassword();
        final java.lang.Object other$password = other.getPassword();
        if (this$password == null ? other$password != null : !this$password.equals(other$password)) return false;
        final java.lang.Object this$url = this.getUrl();
        final java.lang.Object other$url = other.getUrl();
        if (this$url == null ? other$url != null : !this$url.equals(other$url)) return false;
        return true;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    protected boolean canEqual(final java.lang.Object other) {
        return other instanceof APIClient;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final java.lang.Object $user = this.getUser();
        result = result * PRIME + ($user == null ? 43 : $user.hashCode());
        final java.lang.Object $password = this.getPassword();
        result = result * PRIME + ($password == null ? 43 : $password.hashCode());
        final java.lang.Object $url = this.getUrl();
        result = result * PRIME + ($url == null ? 43 : $url.hashCode());
        return result;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public java.lang.String toString() {
        return "APIClient(user=" + this.getUser() + ", password=" + this.getPassword() + ", url=" + this.getUrl() + ")";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy