// Code generated by openapi-nexus. DO NOT EDIT.
//
// Enum Representation API — 1.0.0
// This API demonstrates all 4 kinds of enum representation types: Externally Tagged, Internally Tagged, Adjacently Tagged, and Untagged
package com.example.sdk.apis;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.example.sdk.models.*;
import com.example.sdk.runtime.ApiClient;
import com.example.sdk.runtime.ApiException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import okhttp3.Request;
import okhttp3.Response;
/**
* HandleAdjacentlyTaggedResponse carries the response from handleAdjacentlyTagged.
*/
public class HandleAdjacentlyTaggedResponse {
private final int statusCode;
private final Response raw;
private final AdjacentlyTaggedEnum status200;
public HandleAdjacentlyTaggedResponse(int statusCode, Response raw,
AdjacentlyTaggedEnum status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public AdjacentlyTaggedEnum getStatus200() {
return this.status200;
}
}
/**
* HandleExternallyTaggedResponse carries the response from handleExternallyTagged.
*/
public class HandleExternallyTaggedResponse {
private final int statusCode;
private final Response raw;
private final ExternallyTaggedEnum status200;
public HandleExternallyTaggedResponse(int statusCode, Response raw,
ExternallyTaggedEnum status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public ExternallyTaggedEnum getStatus200() {
return this.status200;
}
}
/**
* HandleInternallyTaggedResponse carries the response from handleInternallyTagged.
*/
public class HandleInternallyTaggedResponse {
private final int statusCode;
private final Response raw;
private final InternallyTaggedEnum status200;
public HandleInternallyTaggedResponse(int statusCode, Response raw,
InternallyTaggedEnum status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public InternallyTaggedEnum getStatus200() {
return this.status200;
}
}
/**
* HandleMixedResponse carries the response from handleMixed.
*/
public class HandleMixedResponse {
private final int statusCode;
private final Response raw;
private final MixedEnum status200;
public HandleMixedResponse(int statusCode, Response raw, MixedEnum status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public MixedEnum getStatus200() {
return this.status200;
}
}
/**
* HandleUntaggedResponse carries the response from handleUntagged.
*/
public class HandleUntaggedResponse {
private final int statusCode;
private final Response raw;
private final UntaggedEnum status200;
public HandleUntaggedResponse(int statusCode, Response raw, UntaggedEnum status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public UntaggedEnum getStatus200() {
return this.status200;
}
}
/**
* EnumReprApi groups operations under the enum-repr tag.
*/
public class EnumReprApi {
private final ApiClient client;
private final Gson gson = new Gson();
public EnumReprApi(ApiClient client) {
this.client = client;
}
/**
* Handle adjacently tagged enum
*/
public HandleAdjacentlyTaggedResponse handleAdjacentlyTagged(AdjacentlyTaggedEnum body) throws IOException {
String path = "/adjacently-tagged";
String jsonBody = gson.toJson(body);
Request request = client.newRequest("POST", path, null, jsonBody);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
AdjacentlyTaggedEnum status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<AdjacentlyTaggedEnum>() {}.getType());
}
return new HandleAdjacentlyTaggedResponse(response.code(), response, status200);
}
/**
* Handle externally tagged enum
*/
public HandleExternallyTaggedResponse handleExternallyTagged(ExternallyTaggedEnum body) throws IOException {
String path = "/externally-tagged";
String jsonBody = gson.toJson(body);
Request request = client.newRequest("POST", path, null, jsonBody);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
ExternallyTaggedEnum status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<ExternallyTaggedEnum>() {}.getType());
}
return new HandleExternallyTaggedResponse(response.code(), response, status200);
}
/**
* Handle internally tagged enum
*/
public HandleInternallyTaggedResponse handleInternallyTagged(InternallyTaggedEnum body) throws IOException {
String path = "/internally-tagged";
String jsonBody = gson.toJson(body);
Request request = client.newRequest("POST", path, null, jsonBody);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
InternallyTaggedEnum status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<InternallyTaggedEnum>() {}.getType());
}
return new HandleInternallyTaggedResponse(response.code(), response, status200);
}
/**
* Handle mixed enum (unit variants SimpleA, SimpleB and tuple variants VariantA(VariantA), VariantB(VariantB))
*/
public HandleMixedResponse handleMixed(MixedEnum body) throws IOException {
String path = "/mixed";
String jsonBody = gson.toJson(body);
Request request = client.newRequest("POST", path, null, jsonBody);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
MixedEnum status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<MixedEnum>() {}.getType());
}
return new HandleMixedResponse(response.code(), response, status200);
}
/**
* Handle untagged enum
*/
public HandleUntaggedResponse handleUntagged(UntaggedEnum body) throws IOException {
String path = "/untagged";
String jsonBody = gson.toJson(body);
Request request = client.newRequest("POST", path, null, jsonBody);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
UntaggedEnum status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<UntaggedEnum>() {}.getType());
}
return new HandleUntaggedResponse(response.code(), response, status200);
}
}