/*
 * Swagger of Opencellsoft Api
 * @#Introduction
 *
 * The version of the OpenAPI document: 7.3.1-SNAPSHOT
 * Contact: contact@opencellsoft.fr
 *
 * 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 org.openapitools.client.ApiCallback;
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.ApiResponse;
import org.openapitools.client.Configuration;
import org.openapitools.client.Pair;
import org.openapitools.client.ProgressRequestBody;
import org.openapitools.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import org.openapitools.client.model.ModelApiException;
import org.openapitools.client.model.Order;
import org.openapitools.client.model.Orders;

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

public class OrdersApi {
    private ApiClient localVarApiClient;

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

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

    public ApiClient getApiClient() {
        return localVarApiClient;
    }

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

    /**
     * Build call for createOrder
     * @param order order object to be created (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> the created order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createOrderCall(Order order, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = order;

        // create path and map variables
        String localVarPath = "/ordering/orders";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = 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);
        localVarHeaderParams.put("Content-Type", localVarContentType);

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

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

        okhttp3.Call localVarCall = createOrderCall(order, _callback);
        return localVarCall;

    }

    /**
     * Returns the created order
     * Returns the created order
     * @param order order object to be created (required)
     * @return Order
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> the created order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
     </table>
     */
    public Order createOrder(Order order) throws ApiException {
        ApiResponse<Order> localVarResp = createOrderWithHttpInfo(order);
        return localVarResp.getData();
    }

    /**
     * Returns the created order
     * Returns the created order
     * @param order order object to be created (required)
     * @return ApiResponse&lt;Order&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> the created order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Order> createOrderWithHttpInfo(Order order) throws ApiException {
        okhttp3.Call localVarCall = createOrderValidateBeforeCall(order, null);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Returns the created order (asynchronously)
     * Returns the created order
     * @param order order object to be created (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> the created order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createOrderAsync(Order order, final ApiCallback<Order> _callback) throws ApiException {

        okhttp3.Call localVarCall = createOrderValidateBeforeCall(order, _callback);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for deleteOrder
     * @param id id of the order to delete (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the deleted order </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteOrderCall(Long id, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/ordering/orders/{id}"
            .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = 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 = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "auth" };
        return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback);
    }

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

        okhttp3.Call localVarCall = deleteOrderCall(id, _callback);
        return localVarCall;

    }

    /**
     * delete an existing order
     * delete an existing order, and returns the deleted order
     * @param id id of the order to delete (required)
     * @return Order
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the deleted order </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public Order deleteOrder(Long id) throws ApiException {
        ApiResponse<Order> localVarResp = deleteOrderWithHttpInfo(id);
        return localVarResp.getData();
    }

    /**
     * delete an existing order
     * delete an existing order, and returns the deleted order
     * @param id id of the order to delete (required)
     * @return ApiResponse&lt;Order&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the deleted order </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Order> deleteOrderWithHttpInfo(Long id) throws ApiException {
        okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(id, null);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * delete an existing order (asynchronously)
     * delete an existing order, and returns the deleted order
     * @param id id of the order to delete (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the deleted order </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteOrderAsync(Long id, final ApiCallback<Order> _callback) throws ApiException {

        okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(id, _callback);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for deleteOrder1
     * @param id ids of orders to delete (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> the order deletion went ok  </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteOrder1Call(List<Long> id, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/ordering/orders";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (id != null) {
            localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "id", id));
        }

        Map<String, String> localVarHeaderParams = 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 = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "auth" };
        return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call deleteOrder1ValidateBeforeCall(List<Long> id, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteOrder1(Async)");
        }
        

        okhttp3.Call localVarCall = deleteOrder1Call(id, _callback);
        return localVarCall;

    }

    /**
     * delete more than one order
     * delete more than one order
     * @param id ids of orders to delete (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> the order deletion went ok  </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public String deleteOrder1(List<Long> id) throws ApiException {
        ApiResponse<String> localVarResp = deleteOrder1WithHttpInfo(id);
        return localVarResp.getData();
    }

    /**
     * delete more than one order
     * delete more than one order
     * @param id ids of orders to delete (required)
     * @return ApiResponse&lt;String&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> the order deletion went ok  </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<String> deleteOrder1WithHttpInfo(List<Long> id) throws ApiException {
        okhttp3.Call localVarCall = deleteOrder1ValidateBeforeCall(id, null);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * delete more than one order (asynchronously)
     * delete more than one order
     * @param id ids of orders to delete (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> the order deletion went ok  </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteOrder1Async(List<Long> id, final ApiCallback<String> _callback) throws ApiException {

        okhttp3.Call localVarCall = deleteOrder1ValidateBeforeCall(id, _callback);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getOrder
     * @param id id of the order (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the searched order </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular resource is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getOrderCall(Long id, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/ordering/orders/{id}"
            .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = 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 = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "auth" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback);
    }

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

        okhttp3.Call localVarCall = getOrderCall(id, _callback);
        return localVarCall;

    }

    /**
     * Return an order
     * Returns a single order
     * @param id id of the order (required)
     * @return Order
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the searched order </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular resource is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public Order getOrder(Long id) throws ApiException {
        ApiResponse<Order> localVarResp = getOrderWithHttpInfo(id);
        return localVarResp.getData();
    }

    /**
     * Return an order
     * Returns a single order
     * @param id id of the order (required)
     * @return ApiResponse&lt;Order&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the searched order </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular resource is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Order> getOrderWithHttpInfo(Long id) throws ApiException {
        okhttp3.Call localVarCall = getOrderValidateBeforeCall(id, null);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Return an order (asynchronously)
     * Returns a single order
     * @param id id of the order (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the searched order </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular resource is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getOrderAsync(Long id, final ApiCallback<Order> _callback) throws ApiException {

        okhttp3.Call localVarCall = getOrderValidateBeforeCall(id, _callback);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getOrders
     * @param offset  (optional, default to 0l)
     * @param limit  (optional, default to 50l)
     * @param sort  (optional)
     * @param orderBy  (optional)
     * @param filter  (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> list of orders </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back. <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular file is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid parameters supplied </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getOrdersCall(Long offset, Long limit, String sort, String orderBy, String filter, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/ordering/orders";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (offset != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("offset", offset));
        }

        if (limit != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit));
        }

        if (sort != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("sort", sort));
        }

        if (orderBy != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("orderBy", orderBy));
        }

        if (filter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("filter", filter));
        }

        Map<String, String> localVarHeaderParams = 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 = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "auth" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getOrdersValidateBeforeCall(Long offset, Long limit, String sort, String orderBy, String filter, final ApiCallback _callback) throws ApiException {
        

        okhttp3.Call localVarCall = getOrdersCall(offset, limit, sort, orderBy, filter, _callback);
        return localVarCall;

    }

    /**
     * Return a list of orders
     * Returns a list of orders with pagination feature or non integers will simulate API error conditions
     * @param offset  (optional, default to 0l)
     * @param limit  (optional, default to 50l)
     * @param sort  (optional)
     * @param orderBy  (optional)
     * @param filter  (optional)
     * @return Orders
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> list of orders </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back. <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular file is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid parameters supplied </td><td>  -  </td></tr>
     </table>
     */
    public Orders getOrders(Long offset, Long limit, String sort, String orderBy, String filter) throws ApiException {
        ApiResponse<Orders> localVarResp = getOrdersWithHttpInfo(offset, limit, sort, orderBy, filter);
        return localVarResp.getData();
    }

    /**
     * Return a list of orders
     * Returns a list of orders with pagination feature or non integers will simulate API error conditions
     * @param offset  (optional, default to 0l)
     * @param limit  (optional, default to 50l)
     * @param sort  (optional)
     * @param orderBy  (optional)
     * @param filter  (optional)
     * @return ApiResponse&lt;Orders&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> list of orders </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back. <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular file is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid parameters supplied </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Orders> getOrdersWithHttpInfo(Long offset, Long limit, String sort, String orderBy, String filter) throws ApiException {
        okhttp3.Call localVarCall = getOrdersValidateBeforeCall(offset, limit, sort, orderBy, filter, null);
        Type localVarReturnType = new TypeToken<Orders>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Return a list of orders (asynchronously)
     * Returns a list of orders with pagination feature or non integers will simulate API error conditions
     * @param offset  (optional, default to 0l)
     * @param limit  (optional, default to 50l)
     * @param sort  (optional)
     * @param orderBy  (optional)
     * @param filter  (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> list of orders </td><td>  * ETag - a pseudo-unique identifier that represents the version of the data sent back. <br>  </td></tr>
        <tr><td> 304 </td><td> Not Modified, Returned to the client when the cached copy of a particular file is up to date with the server </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid parameters supplied </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getOrdersAsync(Long offset, Long limit, String sort, String orderBy, String filter, final ApiCallback<Orders> _callback) throws ApiException {

        okhttp3.Call localVarCall = getOrdersValidateBeforeCall(offset, limit, sort, orderBy, filter, _callback);
        Type localVarReturnType = new TypeToken<Orders>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for patchOrder
     * @param id id of the order to update (required)
     * @param order order object to be update (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call patchOrderCall(Long id, Order order, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = order;

        // create path and map variables
        String localVarPath = "/ordering/orders/{id}"
            .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = 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);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "auth" };
        return localVarApiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call patchOrderValidateBeforeCall(Long id, Order order, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling patchOrder(Async)");
        }
        
        // verify the required parameter 'order' is set
        if (order == null) {
            throw new ApiException("Missing the required parameter 'order' when calling patchOrder(Async)");
        }
        

        okhttp3.Call localVarCall = patchOrderCall(id, order, _callback);
        return localVarCall;

    }

    /**
     * partially update an existing order
     * update an existing order with a set of changes to apply to the order, and returns the updated order
     * @param id id of the order to update (required)
     * @param order order object to be update (required)
     * @return Order
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public Order patchOrder(Long id, Order order) throws ApiException {
        ApiResponse<Order> localVarResp = patchOrderWithHttpInfo(id, order);
        return localVarResp.getData();
    }

    /**
     * partially update an existing order
     * update an existing order with a set of changes to apply to the order, and returns the updated order
     * @param id id of the order to update (required)
     * @param order order object to be update (required)
     * @return ApiResponse&lt;Order&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Order> patchOrderWithHttpInfo(Long id, Order order) throws ApiException {
        okhttp3.Call localVarCall = patchOrderValidateBeforeCall(id, order, null);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * partially update an existing order (asynchronously)
     * update an existing order with a set of changes to apply to the order, and returns the updated order
     * @param id id of the order to update (required)
     * @param order order object to be update (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call patchOrderAsync(Long id, Order order, final ApiCallback<Order> _callback) throws ApiException {

        okhttp3.Call localVarCall = patchOrderValidateBeforeCall(id, order, _callback);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for updateOrder
     * @param id id of the order to update (required)
     * @param order order object to be update (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call updateOrderCall(Long id, Order order, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = order;

        // create path and map variables
        String localVarPath = "/ordering/orders/{id}"
            .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = 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);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "auth" };
        return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call updateOrderValidateBeforeCall(Long id, Order order, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateOrder(Async)");
        }
        
        // verify the required parameter 'order' is set
        if (order == null) {
            throw new ApiException("Missing the required parameter 'order' when calling updateOrder(Async)");
        }
        

        okhttp3.Call localVarCall = updateOrderCall(id, order, _callback);
        return localVarCall;

    }

    /**
     * update an existing order
     * update an existing order, and returns the updated order
     * @param id id of the order to update (required)
     * @param order order object to be update (required)
     * @return Order
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public Order updateOrder(Long id, Order order) throws ApiException {
        ApiResponse<Order> localVarResp = updateOrderWithHttpInfo(id, order);
        return localVarResp.getData();
    }

    /**
     * update an existing order
     * update an existing order, and returns the updated order
     * @param id id of the order to update (required)
     * @param order order object to be update (required)
     * @return ApiResponse&lt;Order&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Order> updateOrderWithHttpInfo(Long id, Order order) throws ApiException {
        okhttp3.Call localVarCall = updateOrderValidateBeforeCall(id, order, null);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * update an existing order (asynchronously)
     * update an existing order, and returns the updated order
     * @param id id of the order to update (required)
     * @param order order object to be update (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 summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 0 </td><td> the updated order </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Invalid inputs supplied </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> order not found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call updateOrderAsync(Long id, Order order, final ApiCallback<Order> _callback) throws ApiException {

        okhttp3.Call localVarCall = updateOrderValidateBeforeCall(id, order, _callback);
        Type localVarReturnType = new TypeToken<Order>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
