// Code generated by openapi-nexus. DO NOT EDIT.
//
// Additional Properties API — 1.0.0
// API demonstrating OpenAPI additionalProperties with multiple levels of structs (RootLevel -> MiddleLevel -> LeafValue), each with HashMap fields.
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;
/**
* PostLeafResponse carries the response from postLeaf.
*/
public class PostLeafResponse {
private final int statusCode;
private final Response raw;
private final LeafValue status200;
public PostLeafResponse(int statusCode, Response raw, LeafValue status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public LeafValue getStatus200() {
return this.status200;
}
}
/**
* PostMiddleResponse carries the response from postMiddle.
*/
public class PostMiddleResponse {
private final int statusCode;
private final Response raw;
private final MiddleLevel status200;
public PostMiddleResponse(int statusCode, Response raw, MiddleLevel status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public MiddleLevel getStatus200() {
return this.status200;
}
}
/**
* PostRootResponse carries the response from postRoot.
*/
public class PostRootResponse {
private final int statusCode;
private final Response raw;
private final RootLevel status200;
public PostRootResponse(int statusCode, Response raw, RootLevel status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public RootLevel getStatus200() {
return this.status200;
}
}
/**
* AdditionalPropertiesApi groups operations under the additional-properties tag.
*/
public class AdditionalPropertiesApi {
private final ApiClient client;
private final Gson gson = new Gson();
public AdditionalPropertiesApi(ApiClient client) {
this.client = client;
}
/**
* Echo leaf payload (attributes map).
*/
public PostLeafResponse postLeaf(LeafValue body) throws IOException {
String path = "/leaf";
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";
LeafValue status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<LeafValue>() {}.getType());
}
return new PostLeafResponse(response.code(), response, status200);
}
/**
* Echo middle-level payload (nested + extra maps).
*/
public PostMiddleResponse postMiddle(MiddleLevel body) throws IOException {
String path = "/middle";
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";
MiddleLevel status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<MiddleLevel>() {}.getType());
}
return new PostMiddleResponse(response.code(), response, status200);
}
/**
* Echo root payload (all three levels with additional-properties-style maps).
*/
public PostRootResponse postRoot(RootLevel body) throws IOException {
String path = "/root";
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";
RootLevel status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<RootLevel>() {}.getType());
}
return new PostRootResponse(response.code(), response, status200);
}
}