/* tslint:disable */
/* eslint-disable */
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';

import { BaseService } from '../base-service';
import { ApiConfiguration } from '../api-configuration';
import { StrictHttpResponse } from '../strict-http-response';
import { RequestBuilder } from '../request-builder';

import { CommentCreateReq } from '../models/comment-create-req';
import { CommentCreateRsp } from '../models/comment-create-rsp';
import { CommentDeleteRsp } from '../models/comment-delete-rsp';
import { CommentListRsp } from '../models/comment-list-rsp';
import { CommentLookupRsp } from '../models/comment-lookup-rsp';
import { HandlerListRsp } from '../models/handler-list-rsp';
import { ModuleListRsp } from '../models/module-list-rsp';
import { PackageCreateReq } from '../models/package-create-req';
import { PackageCreateRsp } from '../models/package-create-rsp';
import { PackageDeleteRsp } from '../models/package-delete-rsp';
import { PackageListRsp } from '../models/package-list-rsp';
import { PackageLookupRsp } from '../models/package-lookup-rsp';
import { PackageModulesRsp } from '../models/package-modules-rsp';
import { PackageUpdateReq } from '../models/package-update-req';
import { PackageUpdateRsp } from '../models/package-update-rsp';

@Injectable({ providedIn: 'root' })
export class PkgdashService extends BaseService {
  constructor(config: ApiConfiguration, http: HttpClient) {
    super(config, http);
  }

  /** Path part for operation `commentLookup()` */
  static readonly CommentLookupPath = '/v1/comments/{id}';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `commentLookup()` instead.
   *
   * This method doesn't expect any request body.
   */
  commentLookup$Response(
    params: {
      id: number;
      package?: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<CommentLookupRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.CommentLookupPath, 'get');
    if (params) {
      rb.path('id', params.id, {});
      rb.query('package', params.package, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<CommentLookupRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `commentLookup$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  commentLookup(
    params: {
      id: number;
      package?: number;
    },
    context?: HttpContext
  ): Observable<CommentLookupRsp> {
    return this.commentLookup$Response(params, context).pipe(
      map((r: StrictHttpResponse<CommentLookupRsp>): CommentLookupRsp => r.body)
    );
  }

  /** Path part for operation `moduleList()` */
  static readonly ModuleListPath = '/v1/modules';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `moduleList()` instead.
   *
   * This method doesn't expect any request body.
   */
  moduleList$Response(
    params?: {
      package?: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<ModuleListRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.ModuleListPath, 'get');
    if (params) {
      rb.query('package', params.package, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<ModuleListRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `moduleList$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  moduleList(
    params?: {
      package?: number;
    },
    context?: HttpContext
  ): Observable<ModuleListRsp> {
    return this.moduleList$Response(params, context).pipe(
      map((r: StrictHttpResponse<ModuleListRsp>): ModuleListRsp => r.body)
    );
  }

  /** Path part for operation `packageList()` */
  static readonly PackageListPath = '/v1/packages';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `packageList()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageList$Response(
    params?: {
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<PackageListRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.PackageListPath, 'get');
    if (params) {
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<PackageListRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `packageList$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageList(
    params?: {
    },
    context?: HttpContext
  ): Observable<PackageListRsp> {
    return this.packageList$Response(params, context).pipe(
      map((r: StrictHttpResponse<PackageListRsp>): PackageListRsp => r.body)
    );
  }

  /** Path part for operation `packageCreate()` */
  static readonly PackageCreatePath = '/v1/packages';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `packageCreate()` instead.
   *
   * This method sends `application/json` and handles request body of type `application/json`.
   */
  packageCreate$Response(
    params: {
      body: PackageCreateReq
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<PackageCreateRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.PackageCreatePath, 'post');
    if (params) {
      rb.body(params.body, 'application/json');
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<PackageCreateRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `packageCreate$Response()` instead.
   *
   * This method sends `application/json` and handles request body of type `application/json`.
   */
  packageCreate(
    params: {
      body: PackageCreateReq
    },
    context?: HttpContext
  ): Observable<PackageCreateRsp> {
    return this.packageCreate$Response(params, context).pipe(
      map((r: StrictHttpResponse<PackageCreateRsp>): PackageCreateRsp => r.body)
    );
  }

  /** Path part for operation `packageLookup()` */
  static readonly PackageLookupPath = '/v1/packages/{id}';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `packageLookup()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageLookup$Response(
    params: {
      id: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<PackageLookupRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.PackageLookupPath, 'get');
    if (params) {
      rb.path('id', params.id, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<PackageLookupRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `packageLookup$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageLookup(
    params: {
      id: number;
    },
    context?: HttpContext
  ): Observable<PackageLookupRsp> {
    return this.packageLookup$Response(params, context).pipe(
      map((r: StrictHttpResponse<PackageLookupRsp>): PackageLookupRsp => r.body)
    );
  }

  /** Path part for operation `packageUpdate()` */
  static readonly PackageUpdatePath = '/v1/packages/{id}';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `packageUpdate()` instead.
   *
   * This method sends `application/json` and handles request body of type `application/json`.
   */
  packageUpdate$Response(
    params: {
      id: number;
      body: PackageUpdateReq
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<PackageUpdateRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.PackageUpdatePath, 'put');
    if (params) {
      rb.path('id', params.id, {});
      rb.body(params.body, 'application/json');
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<PackageUpdateRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `packageUpdate$Response()` instead.
   *
   * This method sends `application/json` and handles request body of type `application/json`.
   */
  packageUpdate(
    params: {
      id: number;
      body: PackageUpdateReq
    },
    context?: HttpContext
  ): Observable<PackageUpdateRsp> {
    return this.packageUpdate$Response(params, context).pipe(
      map((r: StrictHttpResponse<PackageUpdateRsp>): PackageUpdateRsp => r.body)
    );
  }

  /** Path part for operation `packageDelete()` */
  static readonly PackageDeletePath = '/v1/packages/{id}';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `packageDelete()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageDelete$Response(
    params: {
      id: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<PackageDeleteRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.PackageDeletePath, 'delete');
    if (params) {
      rb.path('id', params.id, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<PackageDeleteRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `packageDelete$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageDelete(
    params: {
      id: number;
    },
    context?: HttpContext
  ): Observable<PackageDeleteRsp> {
    return this.packageDelete$Response(params, context).pipe(
      map((r: StrictHttpResponse<PackageDeleteRsp>): PackageDeleteRsp => r.body)
    );
  }

  /** Path part for operation `commentDelete()` */
  static readonly CommentDeletePath = '/v1/packages/{package_id}/comments/{id}';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `commentDelete()` instead.
   *
   * This method doesn't expect any request body.
   */
  commentDelete$Response(
    params: {
      package_id: number;
      id: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<CommentDeleteRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.CommentDeletePath, 'delete');
    if (params) {
      rb.path('package_id', params.package_id, {});
      rb.path('id', params.id, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<CommentDeleteRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `commentDelete$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  commentDelete(
    params: {
      package_id: number;
      id: number;
    },
    context?: HttpContext
  ): Observable<CommentDeleteRsp> {
    return this.commentDelete$Response(params, context).pipe(
      map((r: StrictHttpResponse<CommentDeleteRsp>): CommentDeleteRsp => r.body)
    );
  }

  /** Path part for operation `commentList()` */
  static readonly CommentListPath = '/v1/packages/{package}/comments';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `commentList()` instead.
   *
   * This method doesn't expect any request body.
   */
  commentList$Response(
    params: {
      package: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<CommentListRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.CommentListPath, 'get');
    if (params) {
      rb.path('package', params.package, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<CommentListRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `commentList$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  commentList(
    params: {
      package: number;
    },
    context?: HttpContext
  ): Observable<CommentListRsp> {
    return this.commentList$Response(params, context).pipe(
      map((r: StrictHttpResponse<CommentListRsp>): CommentListRsp => r.body)
    );
  }

  /** Path part for operation `commentCreate()` */
  static readonly CommentCreatePath = '/v1/packages/{package}/comments';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `commentCreate()` instead.
   *
   * This method sends `application/json` and handles request body of type `application/json`.
   */
  commentCreate$Response(
    params: {
      package: string;
      body: CommentCreateReq
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<CommentCreateRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.CommentCreatePath, 'post');
    if (params) {
      rb.path('package', params.package, {});
      rb.body(params.body, 'application/json');
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<CommentCreateRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `commentCreate$Response()` instead.
   *
   * This method sends `application/json` and handles request body of type `application/json`.
   */
  commentCreate(
    params: {
      package: string;
      body: CommentCreateReq
    },
    context?: HttpContext
  ): Observable<CommentCreateRsp> {
    return this.commentCreate$Response(params, context).pipe(
      map((r: StrictHttpResponse<CommentCreateRsp>): CommentCreateRsp => r.body)
    );
  }

  /** Path part for operation `handlerList()` */
  static readonly HandlerListPath = '/v1/packages/{package}/handlers';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `handlerList()` instead.
   *
   * This method doesn't expect any request body.
   */
  handlerList$Response(
    params: {
      package: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<HandlerListRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.HandlerListPath, 'get');
    if (params) {
      rb.path('package', params.package, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<HandlerListRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `handlerList$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  handlerList(
    params: {
      package: number;
    },
    context?: HttpContext
  ): Observable<HandlerListRsp> {
    return this.handlerList$Response(params, context).pipe(
      map((r: StrictHttpResponse<HandlerListRsp>): HandlerListRsp => r.body)
    );
  }

  /** Path part for operation `packageModules()` */
  static readonly PackageModulesPath = '/v1/packages/{package}/modules';

  /**
   * This method provides access to the full `HttpResponse`, allowing access to response headers.
   * To access only the response body, use `packageModules()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageModules$Response(
    params: {
      package: number;
    },
    context?: HttpContext
  ): Observable<StrictHttpResponse<PackageModulesRsp>> {
    const rb = new RequestBuilder(this.rootUrl, PkgdashService.PackageModulesPath, 'get');
    if (params) {
      rb.path('package', params.package, {});
    }

    return this.http.request(
      rb.build({ responseType: 'json', accept: 'application/json', context })
    ).pipe(
      filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
      map((r: HttpResponse<any>) => {
        return r as StrictHttpResponse<PackageModulesRsp>;
      })
    );
  }

  /**
   * This method provides access only to the response body.
   * To access the full response (for headers, for example), `packageModules$Response()` instead.
   *
   * This method doesn't expect any request body.
   */
  packageModules(
    params: {
      package: number;
    },
    context?: HttpContext
  ): Observable<PackageModulesRsp> {
    return this.packageModules$Response(params, context).pipe(
      map((r: StrictHttpResponse<PackageModulesRsp>): PackageModulesRsp => r.body)
    );
  }

}
