/*
 * 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.EDIWheelB34InvoiceListRequest;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponse;

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

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

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

    public InvoiceApi(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 invoiceAmnB34InvoicesPost
     * @param edIWheelB34InvoiceListRequest  (optional)
     * @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> Invoices list 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 invoiceAmnB34InvoicesPostCall(EDIWheelB34InvoiceListRequest edIWheelB34InvoiceListRequest, 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 = edIWheelB34InvoiceListRequest;

        // create path and map variables
        String localVarPath = "/invoice/amn/B3_4/invoices";

        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 invoiceAmnB34InvoicesPostValidateBeforeCall(EDIWheelB34InvoiceListRequest edIWheelB34InvoiceListRequest, final ApiCallback _callback) throws ApiException {
        return invoiceAmnB34InvoicesPostCall(edIWheelB34InvoiceListRequest, _callback);

    }

    /**
     * Retrieve invoice and download its PDF format
     * Retrieve invoice and download its PDF format
     * @param edIWheelB34InvoiceListRequest  (optional)
     * @return EDIWheelB34InvoiceListResponse
     * @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> Invoices list 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 EDIWheelB34InvoiceListResponse invoiceAmnB34InvoicesPost(EDIWheelB34InvoiceListRequest edIWheelB34InvoiceListRequest) throws ApiException {
        ApiResponse<EDIWheelB34InvoiceListResponse> localVarResp = invoiceAmnB34InvoicesPostWithHttpInfo(edIWheelB34InvoiceListRequest);
        return localVarResp.getData();
    }

    /**
     * Retrieve invoice and download its PDF format
     * Retrieve invoice and download its PDF format
     * @param edIWheelB34InvoiceListRequest  (optional)
     * @return ApiResponse&lt;EDIWheelB34InvoiceListResponse&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> Invoices list 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<EDIWheelB34InvoiceListResponse> invoiceAmnB34InvoicesPostWithHttpInfo(EDIWheelB34InvoiceListRequest edIWheelB34InvoiceListRequest) throws ApiException {
        okhttp3.Call localVarCall = invoiceAmnB34InvoicesPostValidateBeforeCall(edIWheelB34InvoiceListRequest, null);
        Type localVarReturnType = new TypeToken<EDIWheelB34InvoiceListResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Retrieve invoice and download its PDF format (asynchronously)
     * Retrieve invoice and download its PDF format
     * @param edIWheelB34InvoiceListRequest  (optional)
     * @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> Invoices list 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 invoiceAmnB34InvoicesPostAsync(EDIWheelB34InvoiceListRequest edIWheelB34InvoiceListRequest, final ApiCallback<EDIWheelB34InvoiceListResponse> _callback) throws ApiException {

        okhttp3.Call localVarCall = invoiceAmnB34InvoicesPostValidateBeforeCall(edIWheelB34InvoiceListRequest, _callback);
        Type localVarReturnType = new TypeToken<EDIWheelB34InvoiceListResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
