// Path: api/src/main/java/hirez/api/object/interfaces/ReturnedMessage.java
// public interface ReturnedMessage {
//     @JsonProperty("ret_msg")
//     String getReturnedMessage();
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import hirez.api.object.*;
import hirez.api.object.interfaces.ReturnedMessage;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Single;
import lombok.Getter;
import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
    final <T> Single<T> get(Class<T> type, String url) {
        return Single.<T>create(sink ->
                httpClient.newCall(new Request.Builder().get()
                        .header("User-Agent", configuration.getUserAgent())
                        .url(url).build()).enqueue(new Callback() {
                    @Override
                    public void onFailure(@NotNull Call call, @NotNull IOException e) {
                        sink.onError(e);
                    }

                    @Override
                    public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
                        sink.onSuccess(buildResponse(response, type));
                    }
                }))
                .doOnEvent((success, error) -> {
                    if (Objects.nonNull(success)) {
                        LOGGER.debug("[SUCCESS] " + url + " -> " + success);
                    }
                    if (Objects.nonNull(error)) {
                        LOGGER.error("[ERROR] " + url, error);
                    }
                })
                .doOnSubscribe(d -> LOGGER.debug("[SUBSCRIBE] \"" + url + "\""))
                .doOnDispose(() -> LOGGER.debug("[DISPOSE] \"" + url + "\""))
                .doOnTerminate(() -> LOGGER.warn("[TERMINATE] \"" + url + "\""));
    }

    protected final <T> Single<T> call(Class<T> type, String method, String... argv) {
        return get(type, configuration.createUrl(method, argv)).flatMap(r -> Single.create(sink -> {
// Path: api/src/main/java/hirez/api/object/interfaces/ReturnedMessage.java
// public interface ReturnedMessage {
//     @JsonProperty("ret_msg")
//     String getReturnedMessage();
// }


// Path: api/src/main/java/hirez/api/Endpoint.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import hirez.api.object.*;
import hirez.api.object.interfaces.ReturnedMessage;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Single;
import lombok.Getter;
import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;

    final <T> Single<T> get(Class<T> type, String url) {
        return Single.<T>create(sink ->
                httpClient.newCall(new Request.Builder().get()
                        .header("User-Agent", configuration.getUserAgent())
                        .url(url).build()).enqueue(new Callback() {
                    @Override
                    public void onFailure(@NotNull Call call, @NotNull IOException e) {
                        sink.onError(e);
                    }

                    @Override
                    public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
                        sink.onSuccess(buildResponse(response, type));
                    }
                }))
                .doOnEvent((success, error) -> {
                    if (Objects.nonNull(success)) {
                        LOGGER.debug("[SUCCESS] " + url + " -> " + success);
                    }
                    if (Objects.nonNull(error)) {
                        LOGGER.error("[ERROR] " + url, error);
                    }
                })
                .doOnSubscribe(d -> LOGGER.debug("[SUBSCRIBE] \"" + url + "\""))
                .doOnDispose(() -> LOGGER.debug("[DISPOSE] \"" + url + "\""))
                .doOnTerminate(() -> LOGGER.warn("[TERMINATE] \"" + url + "\""));
    }

    protected final <T> Single<T> call(Class<T> type, String method, String... argv) {
        return get(type, configuration.createUrl(method, argv)).flatMap(r -> Single.create(sink -> {
            ReturnedMessage rm = null;