Skip to content

Commit

Permalink
Merge pull request #70 from spring-media/PA-4740
Browse files Browse the repository at this point in the history
feat PA-4740: add ensureUserHasOptin
  • Loading branch information
bwagneras committed Sep 17, 2024
2 parents ceba57a + 6172be6 commit bc749b0
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 168 deletions.
12 changes: 10 additions & 2 deletions dist/ps-web-apis.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ function whoamiV1() {
function utilsV1() {
return requirePackage("utils:v1");
}
function waitingRoomV1() {
return requireApi("waiting_room:v1");
}
function abV1() {
return requirePackage("ab:v1");
}
function CligV1() {
return requirePackage("ppclig:v1");
}
Expand All @@ -87,9 +93,11 @@ function CligV2() {
var provideApi = provide;
var requireApi = requirePackage;

exports.whoamiV1 = whoamiV1;
exports.utilsV1 = utilsV1;
exports.waitingRoomV1 = waitingRoomV1;
exports.abV1 = abV1;
exports.CligV1 = CligV1;
exports.CligV2 = CligV2;
exports.provideApi = provideApi;
exports.requireApi = requireApi;
exports.utilsV1 = utilsV1;
exports.whoamiV1 = whoamiV1;
66 changes: 66 additions & 0 deletions dist/ps-web-apis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ export interface WhoamiUserInfo {
export interface PurchaseData {
entitlements: [string];
}
export interface UserDataRequestResult {
success: boolean;
reason?: "userNotLoggedIn" | "generalError" | "userAborted";
}
export declare type FetchOptions = RequestInit & {
timeout?: number;
};
export declare type WaitingRoomQueueDefault = "";
export declare type WaitingRoomQueue = WaitingRoomQueueDefault | "auth" | "checkout";
/**
* Custom fetch interface which includes the possibility to customize timeouts for fetch requests
*/
export declare type Fetch = (input: RequestInfo, init?: FetchOptions) => Promise<Response>;
export declare type GetRosettaEnvByKey = (key: string) => string | undefined;
export declare type WaitForCapacity = (queue: WaitingRoomQueue) => Promise<void>;
export declare type RegisterIframeMessageListener = (eventtype: string, listener: (event: any, iframe: HTMLIFrameElement) => void) => void;
export interface WhoamiV1 {
/**
* will assert valid not outdated session before fetch will be done. backend credentials will be added automatically
Expand All @@ -31,13 +40,51 @@ export interface WhoamiV1 {
* gives information if the user is currently a C1 User. These are users which are not logged in from
* sso/mypass perspective. These users are originated from the apps and have potentially in app purchases.
* If this method resolves to true isLogged in will resolve to false.
* @deprecated there is not replacement for the client planned
*/
isC1User(): boolean;
/**
* gives information if the user is currently a Plenigo User. These are users which are not logged in from
* sso/mypass perspective. These users are originated from the apps and have potentially in app purchases.
* If this method resolves to true isLogged in will resolve to false.
*/
isPlenigoUser(): boolean;
/**
* will assert valid not outdated session before promise is resolved
* an error is resolved if session is invalid and not refeshable (= user logged out)
*/
ensureUserHasAuthorization(): Promise<void>;
/**
* Ensures that the user has provided both a first name and a last name.
* If the user has not provided these details, the function will prompt the user
* to enter them. Depending on the `skippable` parameter, the user may be allowed
* to skip this step.
*
* @param skippable - If true, the user can choose to skip providing their first name
* and last name.
* @param title - Optional. A custom title for the prompt that asks for the user's
* first name and last name. If not set default will be used.
* @param text - Optional. A custom text or message to display in the prompt. If not
* set default will be used.
*
* @returns A promise that resolves to an object indicating whether the user provided
* the required information (`success: true`) or not, along with a `reason` if applicable.
* Possible reasons include "userNotLoggedIn", "error", or "userAborted".
*/
ensureUserHasFirstNameAndLastName(skippable: boolean, title?: string, text?: string): Promise<UserDataRequestResult>;
/**
* Ensures that the user has opted in to a specific data collection or processing activity.
* If the user has not opted in, the function will prompt the user to do so.
*
* @param optIn - A string representing the specific opt-in name.
* This could be the new Marketing_AS_2024 or any other opt-in,
* which are present in agreement.
*
* @returns A promise that resolves to an object indicating whether the user opted in
* successfully (`success: true`) or not, along with a `reason` if applicable.
* Possible reasons include "userNotLoggedIn", "generalError", or "userAborted".
*/
ensureUserHasOptin(optIn: string): Promise<UserDataRequestResult>;
/**
* will start login-process (e.g. go to sso-login)
*/
Expand Down Expand Up @@ -66,12 +113,18 @@ export interface WhoamiV1 {
/**
* will request customer pseudo id for currently logged user from consent backend
* @param clientId The string identifier of the client for which the customer id is requested.
* @deprecated there is not replacement for the client planned
*/
getCustomerId(clientId: string): Promise<string>;
/**
* will provide unsafe purchase data
*/
getUnsafePurchaseData(): Promise<PurchaseData>;
/**
* will provide users registration date if available otherwise returns null.
* Registration date in unix timestamp.
*/
getUnsafeRegistrationDate(): Promise<null | number>;
/**
* will provide jaId for logged in users, otherwise
* @throws error
Expand All @@ -80,6 +133,17 @@ export interface WhoamiV1 {
}
export interface UtilsV1 {
fetchWithTimeout: Fetch;
getRosettaEnvByKey: GetRosettaEnvByKey;
registerIframeMessageListener: RegisterIframeMessageListener;
}
export interface AbV1 {
userInTestGroupForFeature: (key: string) => {
canSeeFeature: boolean;
testGroup: "A" | "B";
};
}
export interface WaitingRoomV1 {
waitForCapacity: WaitForCapacity;
}
export declare type ILayer = "privacy" | "reject";
export declare type IApp = "offerpage" | "checkout" | "cancellation";
Expand Down Expand Up @@ -110,6 +174,8 @@ export declare type ICligV2 = (app: IApp) => Promise<{
}>;
export declare function whoamiV1(): Promise<WhoamiV1>;
export declare function utilsV1(): Promise<UtilsV1>;
export declare function waitingRoomV1(): Promise<WaitingRoomV1>;
export declare function abV1(): Promise<AbV1>;
export declare function CligV1(): Promise<ICligV1>;
export declare function CligV2(): Promise<ICligV2>;
export declare const provideApi: typeof provide;
Expand Down
8 changes: 7 additions & 1 deletion dist/ps-web-apis.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ function whoamiV1() {
function utilsV1() {
return requirePackage("utils:v1");
}
function waitingRoomV1() {
return requireApi("waiting_room:v1");
}
function abV1() {
return requirePackage("ab:v1");
}
function CligV1() {
return requirePackage("ppclig:v1");
}
Expand All @@ -83,4 +89,4 @@ function CligV2() {
var provideApi = provide;
var requireApi = requirePackage;

export { CligV1, CligV2, provideApi, requireApi, utilsV1, whoamiV1 };
export { whoamiV1, utilsV1, waitingRoomV1, abV1, CligV1, CligV2, provideApi, requireApi };
Loading

0 comments on commit bc749b0

Please sign in to comment.