|
|
|
@ -1,5 +1,5 @@ |
|
|
|
import { HttpClient, HttpRequest } from '@angular/common/http'; |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { Injectable, Inject } from '@angular/core'; |
|
|
|
import { Store } from '@ngxs/store'; |
|
|
|
import { Observable, throwError } from 'rxjs'; |
|
|
|
import { catchError } from 'rxjs/operators'; |
|
|
|
@ -7,12 +7,18 @@ import { RestOccurError } from '../actions/rest.actions'; |
|
|
|
import { Rest } from '../models/rest'; |
|
|
|
import { ConfigState } from '../states/config.state'; |
|
|
|
import { isUndefinedOrEmptyString } from '../utils/common-utils'; |
|
|
|
import { ABP } from '../models/common'; |
|
|
|
import { CORE_OPTIONS } from '../tokens/options.token'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
providedIn: 'root', |
|
|
|
}) |
|
|
|
export class RestService { |
|
|
|
constructor(private http: HttpClient, private store: Store) {} |
|
|
|
constructor( |
|
|
|
@Inject(CORE_OPTIONS) private options: ABP.Root, |
|
|
|
private http: HttpClient, |
|
|
|
private store: Store, |
|
|
|
) {} |
|
|
|
|
|
|
|
private getApiFromStore(apiName: string): string { |
|
|
|
return this.store.selectSnapshot(ConfigState.getApiUrl(apiName)); |
|
|
|
@ -41,7 +47,12 @@ export class RestService { |
|
|
|
params: Object.keys(params).reduce((acc, key) => { |
|
|
|
const value = params[key]; |
|
|
|
|
|
|
|
if (!isUndefinedOrEmptyString(value)) acc[key] = value; |
|
|
|
if ( |
|
|
|
!isUndefinedOrEmptyString(value) && |
|
|
|
(value === null ? this.options.sendNullsAsQueryParam : true) |
|
|
|
) { |
|
|
|
acc[key] = value; |
|
|
|
} |
|
|
|
|
|
|
|
return acc; |
|
|
|
}, {}), |
|
|
|
|