import { Inject, Injectable, } from '@angular/core'; import { HttpHeaders, } from '@angular/common/http'; import { BrandSettingsInterface, } from './../../../models/index'; import { CurrentEnvironmentService, } from './../index'; @Injectable() export class ApiKeyHeaderGenerationService { constructor( @Inject('brandSettings') private _brandSettings: BrandSettingsInterface, private _currentEnvironmentService: CurrentEnvironmentService, ) {} public getProductRequestHeaders() { return new HttpHeaders({ Authorization: `ApiKey ${this._getPublishableKey()}`, }); } private _getPublishableKey() { return this._currentEnvironmentService.isProduction() ? this._brandSettings.publishableKey : this._brandSettings.testPublishableKey; } }