Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
injectNewHosts(serviceTemplateURL: string, completionSelection: any): Promise {
const postURL = new Path(serviceTemplateURL)
.append('injector')
.append('replace')
.toString();
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
}),
observe: 'response'
};
this.logger.log('[deployment-completion.service][injectNewHosts][request-url]', JSON.stringify(postURL));
// Todo See how to implement observe: 'response' application-management.service line 166
// @ts-ignore
return this.http.post>(postURL, completionSelection, httpOptions)
.toPromise()
.then(response => {
const injectedserviceTemplateURL = response.headers.get('Location') as string;
this.logger.log('[deployment-completion.service][injectNewHosts][response-location]', response.headers.get('Location'));
return injectedserviceTemplateURL;
});
}
describe('TokenService', () => {
let injector: TestBed;
let service: TokenService;
let httpMock: HttpTestingController;
let apiUrl = environment.apiUrl;
let HttpResponseMock: HttpResponse = {
body: null,
type: null,
clone:null,
status: 200,
statusText: null,
url: null,
ok: true,
headers: new HttpHeaders({ 'authorization': 'bearer token' })
};
beforeEach(() => {
TestBed.configureTestingModule({
providers: [TokenService],
imports: [ HttpClientTestingModule ]
});
injector = getTestBed();
service = injector.get(TokenService);
httpMock = injector.get(HttpTestingController);
});
afterEach(() => {
httpMock.verify();
});
save(settings: GlobalSettings): Observable {
const httpOptions = {
method: 'PUT',
headers: new HttpHeaders({
'Content-Type': 'application/json',
}),
};
return this.http_.put(this.endpoint_, settings, httpOptions);
}
uploadReferentials(collection: string, file: any) {
let header = new HttpHeaders();
header = header.set('Content-Type', 'application/octet-stream').set('X-Filename', file.name);
if ('ontologies'==collection){
header = header.set('Force-Update', 'true');
}
return this.resourcesService.post(collection, header, file, 'text');
}
private _getHeaders(path?: string, method?: HttpMethod, internalClient: boolean = true, internalView: boolean = true, emailRecipients: string = "",
additionalParams?: any): HttpHeaders {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json');
headers = headers.set('Accept', 'application/json');
headers = headers.set('x-ms-internal-client', String(internalClient));
headers = headers.set('x-ms-internal-view', String(internalView));
if (environment.adal.enabled){
headers = headers.set('Authorization', `Bearer ${this._adalService.userInfo.token}`)
}
if (this.GeomasterServiceAddress)
headers = headers.set("x-ms-geomaster-hostname", this.GeomasterServiceAddress);
if (emailRecipients !== "") {
headers = headers.set('x-ms-emailRecipients', emailRecipients);
}
limitations under the License.
*/
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { QuoteBs } from '../common/quoteBs';
import { QuoteCb } from '../common/quoteCb';
import { QuoteIb } from '../common/quoteIb';
import { Utils } from './utils';
import { OrderbookBs } from '../common/orderbookBs';
@Injectable({providedIn: 'root'})
export class BitstampService {
private _reqOptionsArgs = { headers: new HttpHeaders().set( 'Content-Type', 'application/json' ) };
private readonly _bitstamp = '/bitstamp';
BTCEUR = 'btceur';
ETHEUR = 'etheur';
LTCEUR = 'ltceur';
XRPEUR = 'xrpeur';
BTCUSD = 'btcusd';
ETHUSD = 'ethusd';
LTCUSD = 'ltcusd';
XRPUSD = 'xrpusd';
private _utils = new Utils();
constructor(private http: HttpClient) {
}
getCurrentQuote(currencypair: string): Observable {
return this.http.get(this._bitstamp+'/'+currencypair+'/current', this._reqOptionsArgs).pipe(catchError(this._utils.handleError('getCurrentQuote')));
get(url: string, options: HttpOptions = {}): Observable {
return this.http.get(`${this.BASE_URL}${url}`, {
headers: new HttpHeaders(options.headers),
params: new HttpParams({ fromObject: options.query }),
});
}
return new Promise((resolve, reject) => {
const authHeader = new HttpHeaders({
'X-Application-Origin': 'TOA-WebApp-1819',
'Content-Type': 'application/json'
});
this.http.get(this.baseURL + url, { headers: authHeader }).subscribe((data: any[]) => {
resolve(data);
}, (err: any) => {
reject(err);
});
});
}
pisAuthUsingGETResponse(params: PSUPISService.PisAuthUsingGETParams): __Observable<__StrictHttpResponse> {
let __params = this.newParams();
let __headers = new HttpHeaders();
let __body: any = null;
if (params.redirectId != null) __params = __params.set('redirectId', params.redirectId.toString());
if (params.encryptedPaymentId != null) __params = __params.set('encryptedPaymentId', params.encryptedPaymentId.toString());
let req = new HttpRequest(
'GET',
this.rootUrl + `/pis/auth`,
__body,
{
headers: __headers,
params: __params,
responseType: 'json'
});
return this.http.request(req).pipe(
__filter(_r => _r instanceof HttpResponse),
__map((_r) => {
private getRequestOptions(options: RequestOptions) {
const requestOptions: any = {};
requestOptions.headers = new HttpHeaders();
if (options.requestType === RequestTypes.Json) {
requestOptions.headers = requestOptions.headers.append('Content-Type', 'application/json');
}
return requestOptions;
}