/*
 * Michelin North America Order-to-Cash APIs
 * These APIs will help you to do business transactions with Michelin.  <br><br><b>Authentication details:</b><br> <br><u>Option A:</u> OAuth2 Client Credentials (recommended) <br><u>Option B:</u> API Key + Basic Authentication (not recommended) <br><br>To request your access, please contact your representative. <br><br>Our services are based on the EDIWHEEL standards. <br>You can find more information on the <a href=\"https://www.ediwheel.com/\" target=\"_blank\">EDIWHEEL website</a>. 
 *
 * The version of the OpenAPI document: 1.0.1
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.michelin.adk.amn.o2c;

import com.michelin.adk.amn.ApiCallback;
import com.michelin.adk.amn.ApiClient;
import com.michelin.adk.amn.ApiException;
import com.michelin.adk.amn.ApiResponse;
import com.michelin.adk.amn.Configuration;
import com.michelin.adk.amn.Pair;
import com.michelin.adk.amn.ProgressRequestBody;
import com.michelin.adk.amn.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.michelin.adk.amn.o2c.model.EDIWheelC10DesadvRequest;
import com.michelin.adk.amn.o2c.model.EDIWheelC10DesadvResponse;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AsnApi {
    private ApiClient localVarApiClient;
    private int localHostIndex;
    private String localCustomBaseUrl;

    public AsnApi() {
        this(Configuration.getDefaultApiClient());
    }

    public AsnApi(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return localVarApiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public int getHostIndex() {
        return localHostIndex;
    }

    public void setHostIndex(int hostIndex) {
        this.localHostIndex = hostIndex;
    }

    public String getCustomBaseUrl() {
        return localCustomBaseUrl;
    }

    public void setCustomBaseUrl(String customBaseUrl) {
        this.localCustomBaseUrl = customBaseUrl;
    }

    /**
     * Build call for desadvAmnC10DesadvPost
     * @param edIWheelC10DesadvRequest  (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Delivery query responsed </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Authentication information is missing or invalid </td><td>  * WWW_Authenticate -  <br>  </td></tr>
     </table>
     */
    public okhttp3.Call desadvAmnC10DesadvPostCall(EDIWheelC10DesadvRequest edIWheelC10DesadvRequest, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = edIWheelC10DesadvRequest;

        // create path and map variables
        String localVarPath = "/desadv/amn/C1_0/desadv";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        String[] localVarAuthNames = new String[] { "oAuth2ClientCredentials", "apikey", "basicAuth" };
        return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call desadvAmnC10DesadvPostValidateBeforeCall(EDIWheelC10DesadvRequest edIWheelC10DesadvRequest, final ApiCallback _callback) throws ApiException {
        // verify the required parameter 'edIWheelC10DesadvRequest' is set
        if (edIWheelC10DesadvRequest == null) {
            throw new ApiException("Missing the required parameter 'edIWheelC10DesadvRequest' when calling desadvAmnC10DesadvPost(Async)");
        }

        return desadvAmnC10DesadvPostCall(edIWheelC10DesadvRequest, _callback);

    }

    /**
     * Get Advanced Shipping Notice
     * Get Advanced Shipping Notice
     * @param edIWheelC10DesadvRequest  (required)
     * @return EDIWheelC10DesadvResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Delivery query responsed </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Authentication information is missing or invalid </td><td>  * WWW_Authenticate -  <br>  </td></tr>
     </table>
     */
    public EDIWheelC10DesadvResponse desadvAmnC10DesadvPost(EDIWheelC10DesadvRequest edIWheelC10DesadvRequest) throws ApiException {
        ApiResponse<EDIWheelC10DesadvResponse> localVarResp = desadvAmnC10DesadvPostWithHttpInfo(edIWheelC10DesadvRequest);
        return localVarResp.getData();
    }

    /**
     * Get Advanced Shipping Notice
     * Get Advanced Shipping Notice
     * @param edIWheelC10DesadvRequest  (required)
     * @return ApiResponse&lt;EDIWheelC10DesadvResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Delivery query responsed </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Authentication information is missing or invalid </td><td>  * WWW_Authenticate -  <br>  </td></tr>
     </table>
     */
    public ApiResponse<EDIWheelC10DesadvResponse> desadvAmnC10DesadvPostWithHttpInfo(EDIWheelC10DesadvRequest edIWheelC10DesadvRequest) throws ApiException {
        okhttp3.Call localVarCall = desadvAmnC10DesadvPostValidateBeforeCall(edIWheelC10DesadvRequest, null);
        Type localVarReturnType = new TypeToken<EDIWheelC10DesadvResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get Advanced Shipping Notice (asynchronously)
     * Get Advanced Shipping Notice
     * @param edIWheelC10DesadvRequest  (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Delivery query responsed </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Authentication information is missing or invalid </td><td>  * WWW_Authenticate -  <br>  </td></tr>
     </table>
     */
    public okhttp3.Call desadvAmnC10DesadvPostAsync(EDIWheelC10DesadvRequest edIWheelC10DesadvRequest, final ApiCallback<EDIWheelC10DesadvResponse> _callback) throws ApiException {

        okhttp3.Call localVarCall = desadvAmnC10DesadvPostValidateBeforeCall(edIWheelC10DesadvRequest, _callback);
        Type localVarReturnType = new TypeToken<EDIWheelC10DesadvResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
