/* tslint:disable */
import { Injectable } from '@angular/core';
import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http';
import { BaseService as __BaseService } from '../base-service';
import { CrmConfiguration as __Configuration } from '../crm-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 { ResponseArgsOfOptInDTO } from '../models/response-args-of-opt-in-dto';
import { OptInDTO } from '../models/opt-in-dto';
@Injectable({
  providedIn: 'root',
})
class OptInService extends __BaseService {
  static readonly OptInGetOptInPath = '/optin/{optInId}';
  static readonly OptInUpdateOptInPath = '/optin/{optInId}';
  static readonly OptInDeleteOptInPath = '/optin/{optInId}';
  static readonly OptInCreateOptInPath = '/optin';

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

  /**
   * @param optInId undefined
   */
  OptInGetOptInResponse(optInId: number): __Observable<__StrictHttpResponse<ResponseArgsOfOptInDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/optin/${encodeURIComponent(String(optInId))}`,
      __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<ResponseArgsOfOptInDTO>;
      })
    );
  }
  /**
   * @param optInId undefined
   */
  OptInGetOptIn(optInId: number): __Observable<ResponseArgsOfOptInDTO> {
    return this.OptInGetOptInResponse(optInId).pipe(
      __map(_r => _r.body as ResponseArgsOfOptInDTO)
    );
  }

  /**
   * @param params The `OptInService.OptInUpdateOptInParams` containing the following parameters:
   *
   * - `optInId`:
   *
   * - `optIn`:
   */
  OptInUpdateOptInResponse(params: OptInService.OptInUpdateOptInParams): __Observable<__StrictHttpResponse<ResponseArgsOfOptInDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    __body = params.optIn;
    let req = new HttpRequest<any>(
      'PUT',
      this.rootUrl + `/optin/${encodeURIComponent(String(params.optInId))}`,
      __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<ResponseArgsOfOptInDTO>;
      })
    );
  }
  /**
   * @param params The `OptInService.OptInUpdateOptInParams` containing the following parameters:
   *
   * - `optInId`:
   *
   * - `optIn`:
   */
  OptInUpdateOptIn(params: OptInService.OptInUpdateOptInParams): __Observable<ResponseArgsOfOptInDTO> {
    return this.OptInUpdateOptInResponse(params).pipe(
      __map(_r => _r.body as ResponseArgsOfOptInDTO)
    );
  }

  /**
   * @param optInId undefined
   */
  OptInDeleteOptInResponse(optInId: number): __Observable<__StrictHttpResponse<ResponseArgsOfOptInDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    let req = new HttpRequest<any>(
      'DELETE',
      this.rootUrl + `/optin/${encodeURIComponent(String(optInId))}`,
      __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<ResponseArgsOfOptInDTO>;
      })
    );
  }
  /**
   * @param optInId undefined
   */
  OptInDeleteOptIn(optInId: number): __Observable<ResponseArgsOfOptInDTO> {
    return this.OptInDeleteOptInResponse(optInId).pipe(
      __map(_r => _r.body as ResponseArgsOfOptInDTO)
    );
  }

  /**
   * @param optIn undefined
   */
  OptInCreateOptInResponse(optIn: OptInDTO): __Observable<__StrictHttpResponse<ResponseArgsOfOptInDTO>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    __body = optIn;
    let req = new HttpRequest<any>(
      'POST',
      this.rootUrl + `/optin`,
      __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<ResponseArgsOfOptInDTO>;
      })
    );
  }
  /**
   * @param optIn undefined
   */
  OptInCreateOptIn(optIn: OptInDTO): __Observable<ResponseArgsOfOptInDTO> {
    return this.OptInCreateOptInResponse(optIn).pipe(
      __map(_r => _r.body as ResponseArgsOfOptInDTO)
    );
  }
}

module OptInService {

  /**
   * Parameters for OptInUpdateOptIn
   */
  export interface OptInUpdateOptInParams {
    optInId: number;
    optIn: OptInDTO;
  }
}

export { OptInService }
