openapi-nexus 0.1.2

OpenAPI 3.x multi-language code generator
Documentation
// Code generated by openapi-nexus. DO NOT EDIT.
//
// Duplicate Parameter Names Test API — 1.0.0
// Test API with duplicate parameter names across different locations

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;

/**
 * CreateItemWithBodyConflictResponse carries the response from createItemWithBodyConflict.
 */
public class CreateItemWithBodyConflictResponse {
    private final int statusCode;
    private final Response raw;
    private final CreateItemWithBodyConflictResponse200 status200;

    public CreateItemWithBodyConflictResponse(int statusCode, Response raw,
    CreateItemWithBodyConflictResponse200 status200) {
        this.statusCode = statusCode;
        this.raw = raw;
        this.status200 = status200;
    }

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

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

    public CreateItemWithBodyConflictResponse200 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;
    }

    /**
     * Create item with body parameter conflict
     */
    public CreateItemWithBodyConflictResponse createItemWithBodyConflict(String itemId, String body,
    CreateItemWithBodyConflictRequest body2) throws IOException {
        String path = "/items/{itemId}".replace("{itemId}", itemId);
        Map<String, String> query = new HashMap<>();
        if (body != null) {
            query.put("body", body);
        }
        String jsonBody = gson.toJson(body2);
        Request request = client.newRequest("POST", path, query, 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";
        CreateItemWithBodyConflictResponse200 status200 = null;
        if (response.code() == 200) {
            status200 = gson.fromJson(responseBody, new TypeToken<CreateItemWithBodyConflictResponse200>() {}.getType());
        }
        return new CreateItemWithBodyConflictResponse(response.code(), response, status200);
    }
}