File

src/app/shared/widgets/widgetframe/widgetframe.service.ts

Description

Service to provide common json request methods with AuthHttp

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

constructor(authHttp: HttpClient)
Parameters :
Name Type Optional
authHttp HttpClient no

Methods

deleteData
deleteData(inputurl: , body: null)

DELETE with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error. Should be replaced by using deletes without body, since it does not conform with RFC standard

Parameters :
Name Type Optional Default value Description
inputurl no

Url to json

body null no null

json Payload

Returns : Observable<any>

Observable of json response

getData
getData(inputurl: , options?: any)

GET with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.

Parameters :
Name Type Optional Description
inputurl no

Url to json resource

options any yes
Returns : Observable<any>

Observable of json response

getDataWithResponseType
getDataWithResponseType(inputurl: , resType: )

GET with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.

Parameters :
Name Optional Description
inputurl no

Url to json resource

resType no

the response type

Returns : Observable<any>

Observable of json response

patchData
patchData(inputurl: , body: )

PATCH with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.

Parameters :
Name Optional Description
inputurl no

Url to json

body no

json Payload

Returns : Observable<any>

Observable of json response

postData
postData(inputurl: , body: , options?: any)

POST with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.

Parameters :
Name Type Optional Description
inputurl no

Url to json

body no

json Payload

options any yes
Returns : Observable<any>

Observable of json response

putData
putData(inputurl: string, body: any, options?: any)

PUT with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.

Parameters :
Name Type Optional Description
inputurl string no

Url to json

body any no
options any yes
Returns : Observable<any>

Observable of json response

Properties

Public authHttp
authHttp: HttpClient
Type : HttpClient
import { tap } from "rxjs/operators";
import { Injectable } from "@angular/core";
import { NEVER, Observable } from "rxjs";
import { HttpClient } from "@angular/common/http";
import { ProgressbarService } from "../../components/progressbar/progressbar.service";

/**
 * Service to provide common json request methods with AuthHttp
 *
 */
@Injectable()
export class WidgetframeService {
  constructor(public authHttp: HttpClient) {}

  /**
   * GET with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.
   * @param inputurl  Url to json resource
   * @returns  Observable of json response
   */
  getData(inputurl, options?: any): Observable<any> {
    if (!inputurl) {
      console.error("Inputurl can not be null");
      return NEVER;
    }
    return this.authHttp.get(inputurl, options);
  }

  /**
   * GET with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.
   * @param inputurl  Url to json resource
   * @param resType the response type
   * @returns  Observable of json response
   */
  getDataWithResponseType(inputurl, resType): Observable<any> {
    if (!inputurl) {
      console.error("Inputurl can not be null");
      return NEVER;
    }
    const options = {
      responseType: resType,
    };
    return this.authHttp.get(inputurl, options as any);
  }

  /**
   * PUT with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.
   * @param inputurl  Url to json
   * @returns  Observable of json response
   */
  putData(inputurl: string, body: any, options?: any): Observable<any> {
    if (!inputurl) {
      console.error("Inputurl can not be null");
      return NEVER;
    }
    return this.authHttp.put(inputurl, body, options);
  }
  /**
   * POST with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.
   * @param inputurl  Url to json
   * @param body  json Payload
   * @returns  Observable of json response
   */
  postData(inputurl, body, options?: any): Observable<any> {
    if (!inputurl) {
      console.error("Inputurl can not be null");
      return NEVER;
    }
    return this.authHttp.post(inputurl, body, options);
  }

  /**
   * DELETE with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error. Should be replaced by using deletes without body,
   * since it does not conform with RFC standard
   * @param inputurl  Url to json
   * @param body  json Payload
   * @returns  Observable of json response
   */
  deleteData(inputurl, body = null): Observable<any> {
    if (!inputurl) {
      console.error("Inputurl can not be null");
      return NEVER;
    }
    const options = {
      headers: [],
      body,
    };
    return this.authHttp.delete(inputurl, options as any);
  }

  /**
   * PATCH with AuthHttp. Starts Progressbar before start and and stops Progressbar on finish and error.
   * @param inputurl  Url to json
   * @param body  json Payload
   * @returns  Observable of json response
   */
  patchData(inputurl, body): Observable<any> {
    return this.authHttp.patch(inputurl, body);
  }
}

results matching ""

    No results matching ""