/**
 * OpenAPI Petstore
 * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package org.openapitools.client.api;

import java.util.Objects;
import org.openapitools.client.ApiResponse;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.helidon.common.GenericType;
import io.helidon.common.http.MediaType;
import io.helidon.common.reactive.Single;
import io.helidon.config.Config;
import io.helidon.media.common.MediaSupport;

import io.helidon.media.jackson.JacksonSupport;
import io.helidon.webclient.WebClientRequestBuilder;
import io.helidon.webclient.WebClientResponse;

import org.openapitools.client.ApiClient;

import org.openapitools.client.model.FooGetDefaultResponse;

/**
 * OpenAPI Petstore
 *
 * <p>This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
 */
public class DefaultApiImpl implements DefaultApi {

  private final ApiClient apiClient;

  protected static final GenericType<FooGetDefaultResponse> RESPONSE_TYPE_fooGet = ResponseType.create(FooGetDefaultResponse.class);

  /**
   * Creates a new instance of DefaultApiImpl initialized with the specified {@link ApiClient}.
   *
   */
  public static DefaultApiImpl create(ApiClient apiClient) {
    return new DefaultApiImpl(apiClient);
  }

  protected DefaultApiImpl(ApiClient apiClient) {
    this.apiClient = apiClient;
  }

  @Override
  public ApiResponse<FooGetDefaultResponse> fooGet() {
    WebClientRequestBuilder webClientRequestBuilder = fooGetRequestBuilder();
    return fooGetSubmit(webClientRequestBuilder);
  }

  /**
   * Creates a {@code WebClientRequestBuilder} for the fooGet operation.
   * Optional customization point for subclasses.
   *
   * @return WebClientRequestBuilder for fooGet
   */
  protected WebClientRequestBuilder fooGetRequestBuilder() {
    WebClientRequestBuilder webClientRequestBuilder = apiClient.webClient()
            .method("GET");

    webClientRequestBuilder.path("/foo");
    webClientRequestBuilder.accept(MediaType.APPLICATION_JSON);

    return webClientRequestBuilder;
  }

  /**
   * Initiates the request for the fooGet operation.
   * Optional customization point for subclasses.
   *
   * @param webClientRequestBuilder the request builder to use for submitting the request
   * @return {@code ApiResponse<FooGetDefaultResponse>} for the submitted request
   */
  protected ApiResponse<FooGetDefaultResponse> fooGetSubmit(WebClientRequestBuilder webClientRequestBuilder) {
    Single<WebClientResponse> webClientResponse = webClientRequestBuilder.submit();
    return ApiResponse.create(RESPONSE_TYPE_fooGet, webClientResponse);
  }

}
