// Code generated by openapi-nexus. DO NOT EDIT.
//
// Test API with Server Objects — 1.0.0
// This is a test API specification that includes various server configurations
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;
/**
* GetAllUsersResponse carries the response from getAllUsers.
*/
public class GetAllUsersResponse {
private final int statusCode;
private final Response raw;
private final List<GetAllUsersResponse200Item> status200;
public GetAllUsersResponse(int statusCode, Response raw,
List<GetAllUsersResponse200Item> status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public List<GetAllUsersResponse200Item> getStatus200() {
return this.status200;
}
}
/**
* GetUserByIdResponse carries the response from getUserById.
*/
public class GetUserByIdResponse {
private final int statusCode;
private final Response raw;
private final GetUserByIdResponse200 status200;
private final GetUserByIdResponse404 status404;
public GetUserByIdResponse(int statusCode, Response raw, GetUserByIdResponse200 status200,
GetUserByIdResponse404 status404) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
this.status404 = status404;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public GetUserByIdResponse200 getStatus200() {
return this.status200;
}
public GetUserByIdResponse404 getStatus404() {
return this.status404;
}
}
/**
* DefaultApi groups operations under the default tag.
*/
public class DefaultApi {
private final ApiClient client;
private final Gson gson = new Gson();
public DefaultApi(ApiClient client) {
this.client = client;
}
/**
* Get all users
*/
public GetAllUsersResponse getAllUsers() throws IOException {
String path = "/users";
Request request = client.newRequest("GET", path, null, null);
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";
List<GetAllUsersResponse200Item> status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<List<GetAllUsersResponse200Item>>() {}.getType());
}
return new GetAllUsersResponse(response.code(), response, status200);
}
/**
* Get user by ID
*/
public GetUserByIdResponse getUserById(long id) throws IOException {
String path = "/users/{id}".replace("{id}", String.valueOf(id));
Request request = client.newRequest("GET", path, null, null);
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";
GetUserByIdResponse200 status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<GetUserByIdResponse200>() {}.getType());
}
GetUserByIdResponse404 status404 = null;
if (response.code() == 404) {
status404 = gson.fromJson(responseBody, new TypeToken<GetUserByIdResponse404>() {}.getType());
}
return new GetUserByIdResponse(response.code(), response, status200, status404);
}
}