/* tslint:disable */
import { Injectable } from '@angular/core';
import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http';
import { BaseService as __BaseService } from '../base-service';
import { OmsConfiguration as __Configuration } from '../oms-configuration';
import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response';
import { Observable as __Observable } from 'rxjs';
import { map as __map, filter as __filter } from 'rxjs/operators';

import { ResponseArgsOfIEnumerableOfDisplayOrderDTO } from '../models/response-args-of-ienumerable-of-display-order-dto';
import { ResponseArgsOfSupplierOrderResult } from '../models/response-args-of-supplier-order-result';
import { ReorderData } from '../models/reorder-data';
@Injectable({
  providedIn: 'root',
})
class OrderCheckoutService extends __BaseService {
  static readonly OrderCheckoutCreateOrderPath = '/order/checkout/{checkoutId}';
  static readonly OrderCheckoutCreateOrder2Path = '/order/checkout/{checkoutId}';
  static readonly OrderCheckoutOrderAtSupplierPath = '/order/{orderId}';
  static readonly OrderCheckoutNachbestellenPath = '/wareneingang/offeneposten/reorder';

  constructor(
    config: __Configuration,
    http: HttpClient
  ) {
    super(config, http);
  }

  /**
   * @param params The `OrderCheckoutService.OrderCheckoutCreateOrderParams` containing the following parameters:
   *
   * - `checkoutId`:
   *
   * - `locale`:
   */
  OrderCheckoutCreateOrderResponse(params: OrderCheckoutService.OrderCheckoutCreateOrderParams): __Observable<__StrictHttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    if (params.locale != null) __params = __params.set('locale', params.locale.toString());
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/order/checkout/${params.checkoutId}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>;
      })
    );
  }
  /**
   * @param params The `OrderCheckoutService.OrderCheckoutCreateOrderParams` containing the following parameters:
   *
   * - `checkoutId`:
   *
   * - `locale`:
   */
  OrderCheckoutCreateOrder(params: OrderCheckoutService.OrderCheckoutCreateOrderParams): __Observable<ResponseArgsOfIEnumerableOfDisplayOrderDTO> {
    return this.OrderCheckoutCreateOrderResponse(params).pipe(
      __map(_r => _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO)
    );
  }

  /**
   * @param params The `OrderCheckoutService.OrderCheckoutCreateOrder2Params` containing the following parameters:
   *
   * - `checkoutId`:
   *
   * - `locale`:
   */
  OrderCheckoutCreateOrder2Response(params: OrderCheckoutService.OrderCheckoutCreateOrder2Params): __Observable<__StrictHttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    if (params.locale != null) __params = __params.set('locale', params.locale.toString());
    let req = new HttpRequest<any>(
      'PUT',
      this.rootUrl + `/order/checkout/${params.checkoutId}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>;
      })
    );
  }
  /**
   * @param params The `OrderCheckoutService.OrderCheckoutCreateOrder2Params` containing the following parameters:
   *
   * - `checkoutId`:
   *
   * - `locale`:
   */
  OrderCheckoutCreateOrder2(params: OrderCheckoutService.OrderCheckoutCreateOrder2Params): __Observable<ResponseArgsOfIEnumerableOfDisplayOrderDTO> {
    return this.OrderCheckoutCreateOrder2Response(params).pipe(
      __map(_r => _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO)
    );
  }

  /**
   * @param orderId Bestellung PK
   */
  OrderCheckoutOrderAtSupplierResponse(orderId: number): __Observable<__StrictHttpResponse<ResponseArgsOfSupplierOrderResult>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/order/${orderId}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfSupplierOrderResult>;
      })
    );
  }
  /**
   * @param orderId Bestellung PK
   */
  OrderCheckoutOrderAtSupplier(orderId: number): __Observable<ResponseArgsOfSupplierOrderResult> {
    return this.OrderCheckoutOrderAtSupplierResponse(orderId).pipe(
      __map(_r => _r.body as ResponseArgsOfSupplierOrderResult)
    );
  }

  /**
   * @param data undefined
   */
  OrderCheckoutNachbestellenResponse(data: ReorderData): __Observable<__StrictHttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = data;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/wareneingang/offeneposten/reorder`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>;
      })
    );
  }
  /**
   * @param data undefined
   */
  OrderCheckoutNachbestellen(data: ReorderData): __Observable<ResponseArgsOfIEnumerableOfDisplayOrderDTO> {
    return this.OrderCheckoutNachbestellenResponse(data).pipe(
      __map(_r => _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO)
    );
  }
}

module OrderCheckoutService {

  /**
   * Parameters for OrderCheckoutCreateOrder
   */
  export interface OrderCheckoutCreateOrderParams {
    checkoutId: number;
    locale?: null | string;
  }

  /**
   * Parameters for OrderCheckoutCreateOrder2
   */
  export interface OrderCheckoutCreateOrder2Params {
    checkoutId: number;
    locale?: null | string;
  }
}

export { OrderCheckoutService }
