openapi-nexus 0.1.4

OpenAPI 3.x multi-language code generator
Documentation
// Code generated by openapi-nexus. DO NOT EDIT.
//
// Reserved Word Fields Test — 1.0.0
// Test case for object properties that collide with language reserved words

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;

/**
 * GetItemsResponse carries the response from getItems.
 */
public class GetItemsResponse {
    private final int statusCode;
    private final Response raw;
    private final Item status200;

    public GetItemsResponse(int statusCode, Response raw, Item status200) {
        this.statusCode = statusCode;
        this.raw = raw;
        this.status200 = status200;
    }

    public int getStatusCode() {
        return this.statusCode;
    }

    public Response getRaw() {
        return this.raw;
    }

    public Item getStatus200() {
        return this.status200;
    }
}

/**
 * ItemsApi groups operations under the items tag.
 */
public class ItemsApi {
    private final ApiClient client;
    private final Gson gson = new Gson();

    public ItemsApi(ApiClient client) {
        this.client = client;
    }

    /**
     * Get items
     */
    public GetItemsResponse getItems() throws IOException {
        String path = "/items";
        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";
        Item status200 = null;
        if (response.code() == 200) {
            status200 = gson.fromJson(responseBody, new TypeToken<Item>() {}.getType());
        }
        return new GetItemsResponse(response.code(), response, status200);
    }
}