@spartacus/core
Version:
Spartacus - the core framework
115 lines (114 loc) • 4.54 kB
TypeScript
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { AuthService } from '../../auth/user-auth/facade/auth.service';
import { UserIdService } from '../../auth/user-auth/facade/user-id.service';
import { Consent, ConsentTemplate } from '../../model/consent.model';
import { StateWithProcess } from '../../process/store/process-state';
import { StateWithUser } from '../store/user-state';
import * as i0 from "@angular/core";
export declare class UserConsentService {
protected store: Store<StateWithUser | StateWithProcess<void>>;
protected authService: AuthService;
protected userIdService: UserIdService;
constructor(store: Store<StateWithUser | StateWithProcess<void>>, authService: AuthService, userIdService: UserIdService);
/**
* Retrieves all consents.
*/
loadConsents(): void;
/**
* Returns all consent templates. If `loadIfMissing` parameter is set to `true`, the method triggers the load if consent templates.
* @param loadIfMissing is set to `true`, the method will load templates if those are not already present. The default value is `false`.
*/
getConsents(loadIfMissing?: boolean): Observable<ConsentTemplate[]>;
/**
* Returns the consents loading flag
*/
getConsentsResultLoading(): Observable<boolean>;
/**
* Returns the consents success flag
*/
getConsentsResultSuccess(): Observable<boolean>;
/**
* Returns the consents error flag
*/
getConsentsResultError(): Observable<boolean>;
/**
* Resets the processing state for consent retrieval
*/
resetConsentsProcessState(): void;
/**
* Returns the registered consent for the given template ID.
*
* As a side-effect, the method will call `getConsents(true)` to load the templates if those are not present.
*
* @param templateId a template ID by which to filter the registered templates.
*/
getConsent(templateId: string): Observable<Consent>;
/**
* Returns `true` if the consent is truthy and if `consentWithdrawnDate` doesn't exist.
* Otherwise, `false` is returned.
*
* @param consent to check
*/
isConsentGiven(consent: Consent): boolean;
/**
* Returns `true` if the consent is either falsy or if `consentWithdrawnDate` is present.
* Otherwise, `false` is returned.
*
* @param consent to check
*/
isConsentWithdrawn(consent: Consent): boolean;
/**
* Give consent for specified consent template ID and version.
* @param consentTemplateId a template ID for which to give a consent
* @param consentTemplateVersion a template version for which to give a consent
*/
giveConsent(consentTemplateId: string, consentTemplateVersion: number): void;
/**
* Returns the give consent process loading flag
*/
getGiveConsentResultLoading(): Observable<boolean>;
/**
* Returns the give consent process success flag
*/
getGiveConsentResultSuccess(): Observable<boolean>;
/**
* Returns the give consent process error flag
*/
getGiveConsentResultError(): Observable<boolean>;
/**
* Resents the give consent process flags
*/
resetGiveConsentProcessState(): void;
/**
* Withdraw consent for the given `consentCode`
* @param consentCode for which to withdraw the consent
*/
withdrawConsent(consentCode: string): void;
/**
* Returns the withdraw consent process loading flag
*/
getWithdrawConsentResultLoading(): Observable<boolean>;
/**
* Returns the withdraw consent process success flag
*/
getWithdrawConsentResultSuccess(): Observable<boolean>;
/**
* Returns the withdraw consent process error flag
*/
getWithdrawConsentResultError(): Observable<boolean>;
/**
* Resets the process flags for withdraw consent
*/
resetWithdrawConsentProcessState(): void;
/**
* Filters the provided `templateList`' templates by hiding the template IDs specified in `hideTemplateIds`.
* If the `hideTemplateIds` is empty, the provided `templateList` is returned.
*
* @param templateList a list of consent templates to filter
* @param hideTemplateIds template IDs to hide
*/
filterConsentTemplates(templateList: ConsentTemplate[], hideTemplateIds?: string[]): ConsentTemplate[];
static ɵfac: i0.ɵɵFactoryDeclaration<UserConsentService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<UserConsentService>;
}