ouisys-engine 3.0.1 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +4 -8
- package/.eslintrc.js +1 -1
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -1
- package/.prettierignore +2 -1
- package/.vscode/settings.json +1 -1
- package/README.md +2 -4
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.js +76 -76
- package/dist/common-types/AppThunk.d.ts +11 -12
- package/dist/common-types/IOptInFlowName.d.ts +1 -1
- package/dist/common-types/ITracker.js +1 -2
- package/dist/common-types/RemoteDataState.d.ts +4 -4
- package/dist/common-types/RemoteDataState.js +17 -17
- package/dist/flows/click2smsFlow.d.ts +2 -2
- package/dist/flows/moFlow.d.ts +2 -2
- package/dist/flows/moRedirFlow.d.ts +2 -2
- package/dist/flows/oneClickFlow.d.ts +2 -2
- package/dist/flows/pinFlow.d.ts +2 -2
- package/dist/flows/pinFlow.js +2 -0
- package/dist/flows/strategy.d.ts +8 -8
- package/dist/flows/ussdFlow.d.ts +2 -2
- package/dist/ips/tryGetIPRangeName.d.ts +1 -1
- package/dist/ips/tryGetIPRangeName.js +7 -5
- package/dist/jest.config.js +1 -1
- package/dist/pacman/index.d.ts +2 -2
- package/dist/pacman/index.js +41 -41
- package/dist/pacman/queryString.js +11 -9
- package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +19 -19
- package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +1 -1
- package/dist/reducers/click2smsFlow/index.d.ts +2 -2
- package/dist/reducers/click2smsFlow/index.js +24 -24
- package/dist/reducers/click2smsFlow/utils.d.ts +1 -1
- package/dist/reducers/click2smsFlow/utils.js +30 -30
- package/dist/reducers/moFlow/IMoConstants.d.ts +1 -1
- package/dist/reducers/moFlow/MoTypes.d.ts +13 -13
- package/dist/reducers/moFlow/index.d.ts +3 -3
- package/dist/reducers/moFlow/index.js +27 -27
- package/dist/reducers/moFlow/utils.d.ts +1 -2
- package/dist/reducers/moFlow/utils.js +28 -26
- package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +1 -1
- package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +13 -13
- package/dist/reducers/moRedirFlow/index.d.ts +3 -3
- package/dist/reducers/moRedirFlow/index.js +27 -27
- package/dist/reducers/moRedirFlow/utils.d.ts +1 -1
- package/dist/reducers/moRedirFlow/utils.js +17 -17
- package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +1 -1
- package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +10 -10
- package/dist/reducers/oneClickFlow/index.d.ts +3 -3
- package/dist/reducers/oneClickFlow/index.js +75 -68
- package/dist/reducers/oneClickFlow/utils.d.ts +2 -2
- package/dist/reducers/oneClickFlow/utils.js +70 -69
- package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
- package/dist/reducers/pinFlow/PinTypes.d.ts +24 -23
- package/dist/reducers/pinFlow/index.d.ts +3 -3
- package/dist/reducers/pinFlow/index.js +76 -76
- package/dist/reducers/pinFlow/utils.d.ts +1 -1
- package/dist/reducers/pinFlow/utils.js +61 -65
- package/dist/reducers/strategy/IStategyActionContants.d.ts +1 -1
- package/dist/reducers/strategy/StrategyTypes.d.ts +56 -56
- package/dist/reducers/strategy/index.d.ts +2 -2
- package/dist/reducers/strategy/index.js +99 -99
- package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +3 -2
- package/dist/reducers/strategy/strategies/ask_mobile_number.js +132 -74
- package/dist/reducers/strategy/strategies/ask_operator.d.ts +2 -2
- package/dist/reducers/strategy/strategies/ask_operator.js +64 -68
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +2 -2
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +97 -97
- package/dist/reducers/strategy/strategies/header_enrichment.d.ts +2 -2
- package/dist/reducers/strategy/strategies/header_enrichment.js +116 -120
- package/dist/reducers/strategy/utils.d.ts +3 -3
- package/dist/reducers/strategy/utils.js +115 -111
- package/dist/reducers/ussdFlow/IUssdConstants.d.ts +1 -1
- package/dist/reducers/ussdFlow/UssdTypes.d.ts +13 -13
- package/dist/reducers/ussdFlow/index.d.ts +3 -3
- package/dist/reducers/ussdFlow/index.js +27 -27
- package/dist/reducers/ussdFlow/utils.d.ts +1 -2
- package/dist/reducers/ussdFlow/utils.js +19 -17
- package/dist/store/index.d.ts +8 -8
- package/dist/store/index.js +87 -83
- package/dist/store/reducers.d.ts +7 -7
- package/dist/store/reducers.js +4 -4
- package/dist/utilities/handleSubmitNumber.d.ts +7 -3
- package/dist/utilities/handleSubmitNumber.js +15 -18
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +13 -11
- package/dist/utilities/loadScriptInnerHtml.js +0 -1
- package/index.html +21 -28
- package/mockData/config.json +1 -1
- package/package.json +23 -15
- package/setupJest.js +1 -1
- package/tsconfig.json +2 -2
- package/dist/api/click2sms.js +0 -357
- package/dist/api/mo.js +0 -274
- package/dist/api/moRedir.js +0 -186
- package/dist/api/oneClick.js +0 -366
- package/dist/api/pin.js +0 -493
- package/dist/api/strategies.js +0 -704
- package/dist/api/ussd.js +0 -1
- package/dist/app/store.js +0 -35
- package/dist/features/strategies/categories/askMobileNumber.js +0 -395
- package/dist/features/strategies/categories/askOperator.js +0 -311
- package/dist/features/strategies/categories/detectOperatorByIp.js +0 -606
- package/dist/features/strategies/categories/headerEnrichment.js +0 -670
- package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +0 -12
- package/dist/features/strategies/categories/typings/identifySliceTypes.js +0 -22
- package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +0 -22
- package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +0 -21
- package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +0 -13
- package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +0 -13
- package/dist/features/strategies/click2smsFlowSlice.js +0 -172
- package/dist/features/strategies/identifySlice.js +0 -455
- package/dist/features/strategies/moFlowSlice.js +0 -196
- package/dist/features/strategies/moRedirFlowSlice.js +0 -190
- package/dist/features/strategies/oneClickFlowSlice.js +0 -277
- package/dist/features/strategies/pinFlowSlice.js +0 -313
- package/dist/features/strategies/ussdFlowSlice.js +0 -1
- package/dist/flows/tpayHeFlow.d.ts +0 -7
- package/dist/flows/tpayHeFlow.js +0 -23
- package/dist/mockServer/browser.js +0 -48
- package/dist/mockServer/handlers.js +0 -22
- package/dist/mockServer/server.js +0 -48
- package/dist/reducers/tpayHeFlow/ITpayHeConstants.d.ts +0 -2
- package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
- package/dist/reducers/tpayHeFlow/TpayHeTypes.d.ts +0 -114
- package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
- package/dist/reducers/tpayHeFlow/index.d.ts +0 -7
- package/dist/reducers/tpayHeFlow/index.js +0 -331
- package/dist/reducers/tpayHeFlow/utils.d.ts +0 -20
- package/dist/reducers/tpayHeFlow/utils.js +0 -510
- package/dist/test/setup.js +0 -24
- package/dist/test/test-utils.js +0 -51
- package/prettier.config.js +0 -7
- package/src/@types/react-tracker.d.ts +0 -16
- package/src/@types/redux-cli-logger.d.ts +0 -1
- package/src/@types/tiny-async-pool.d.ts +0 -3
- package/src/@types/window.d.ts +0 -74
- package/src/api/index.ts +0 -225
- package/src/common-types/AppThunk.ts +0 -19
- package/src/common-types/Either.ts +0 -3
- package/src/common-types/IError.ts +0 -5
- package/src/common-types/IOptInFlowName.ts +0 -1
- package/src/common-types/ITracker.ts +0 -10
- package/src/common-types/IVisitor.ts +0 -16
- package/src/common-types/RemoteDataState.ts +0 -88
- package/src/flows/click2smsFlow.ts +0 -18
- package/src/flows/moFlow.ts +0 -20
- package/src/flows/moRedirFlow.ts +0 -20
- package/src/flows/oneClickFlow.ts +0 -20
- package/src/flows/pinFlow.ts +0 -25
- package/src/flows/strategy.ts +0 -51
- package/src/flows/ussdFlow.ts +0 -20
- package/src/index.ts +0 -3
- package/src/ips/tryGetIPRangeName.ts +0 -22
- package/src/jest.config.js +0 -194
- package/src/pacman/index.ts +0 -71
- package/src/pacman/queryString.ts +0 -24
- package/src/reducers/click2smsFlow/Click2smsTypes.ts +0 -93
- package/src/reducers/click2smsFlow/IClick2smsConstants.ts +0 -4
- package/src/reducers/click2smsFlow/index.ts +0 -105
- package/src/reducers/click2smsFlow/utils.ts +0 -126
- package/src/reducers/moFlow/IMoConstants.ts +0 -7
- package/src/reducers/moFlow/MoTypes.ts +0 -125
- package/src/reducers/moFlow/index.ts +0 -150
- package/src/reducers/moFlow/utils.ts +0 -135
- package/src/reducers/moRedirFlow/IMoRedirConstants.ts +0 -7
- package/src/reducers/moRedirFlow/MoRedirTypes.ts +0 -99
- package/src/reducers/moRedirFlow/index.ts +0 -137
- package/src/reducers/moRedirFlow/utils.ts +0 -78
- package/src/reducers/oneClickFlow/IOneClickConstants.ts +0 -3
- package/src/reducers/oneClickFlow/OneClickTypes.ts +0 -108
- package/src/reducers/oneClickFlow/index.ts +0 -268
- package/src/reducers/oneClickFlow/utils.ts +0 -217
- package/src/reducers/pinFlow/IPinConstants.ts +0 -9
- package/src/reducers/pinFlow/PinTypes.ts +0 -189
- package/src/reducers/pinFlow/index.ts +0 -331
- package/src/reducers/pinFlow/utils.ts +0 -232
- package/src/reducers/strategy/IStategyActionContants.ts +0 -17
- package/src/reducers/strategy/StrategyTypes.ts +0 -375
- package/src/reducers/strategy/index.ts +0 -321
- package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -316
- package/src/reducers/strategy/strategies/ask_operator.ts +0 -195
- package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -414
- package/src/reducers/strategy/strategies/header_enrichment.ts +0 -489
- package/src/reducers/strategy/utils.ts +0 -357
- package/src/reducers/ussdFlow/IUssdConstants.ts +0 -7
- package/src/reducers/ussdFlow/UssdTypes.ts +0 -112
- package/src/reducers/ussdFlow/index.ts +0 -146
- package/src/reducers/ussdFlow/utils.ts +0 -88
- package/src/store/index.ts +0 -150
- package/src/store/reducers.ts +0 -37
- package/src/utilities/handleSubmitNumber.ts +0 -65
- package/src/utilities/index.ts +0 -114
- package/src/utilities/loadScriptInnerHtml.ts +0 -14
- package/src/utilities/loadScriptSrc.ts +0 -26
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
2
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
3
|
-
|
|
4
|
-
export type IMoFlowCurrentState =
|
|
5
|
-
| {
|
|
6
|
-
type: "MSISDNEntry";
|
|
7
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type MSISDNEntryErrorTypes =
|
|
11
|
-
| "AlreadySubscribed"
|
|
12
|
-
| "UnknownError"
|
|
13
|
-
| "InvalidMSISDN"
|
|
14
|
-
| "UnexpectedState";
|
|
15
|
-
export type MSISDNEntryFailure = {
|
|
16
|
-
errorType: MSISDNEntryErrorTypes;
|
|
17
|
-
error: any;
|
|
18
|
-
productUrl?:string;
|
|
19
|
-
};
|
|
20
|
-
export type MSISDNEntrySuccess = IKeywordShortcode
|
|
21
|
-
type ACompType =
|
|
22
|
-
React.ComponentType<{ children: React.ReactNode } & React.HTMLAttributes<HTMLAnchorElement> & { keyword?: string, shortcode?: string }>
|
|
23
|
-
|
|
24
|
-
export type IMsisnSubmitActionPayload = {
|
|
25
|
-
type:"MSISDNEntry";
|
|
26
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export interface IMoFlowReducerState {
|
|
32
|
-
currentState:IMoFlowCurrentState
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export type IConfig = {
|
|
37
|
-
offer?: number,
|
|
38
|
-
slug?: string;
|
|
39
|
-
country?: string;
|
|
40
|
-
host?:string;
|
|
41
|
-
device?: "smart" | "feature";
|
|
42
|
-
operators?: string[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type IKeywordShortcode = {
|
|
46
|
-
keyword : string,
|
|
47
|
-
shortcode : string,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type IMSISDNSubmissionResult = {
|
|
51
|
-
success: true
|
|
52
|
-
rockman_id: string,
|
|
53
|
-
keyword: string,
|
|
54
|
-
shortcode: string,
|
|
55
|
-
} | {
|
|
56
|
-
success: false,
|
|
57
|
-
rockman_id: string,
|
|
58
|
-
message: string,
|
|
59
|
-
product_url?:string,
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type ICheckSubscriptionResult = {
|
|
63
|
-
success: false;
|
|
64
|
-
rockman_id: string;
|
|
65
|
-
message: string;
|
|
66
|
-
} | {
|
|
67
|
-
success: true;
|
|
68
|
-
msisdn: string;
|
|
69
|
-
product_url?: string;
|
|
70
|
-
rockman_id: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export type IBackToStartPayload = {
|
|
76
|
-
type: "MSISDNEntry";
|
|
77
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type IMoActions =
|
|
81
|
-
{
|
|
82
|
-
type: "MO_MSISDN_SUBMIT";
|
|
83
|
-
payload:IMsisnSubmitActionPayload;
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
|
87
|
-
{
|
|
88
|
-
type: "MO_MSISDN_SUBMIT_ERROR";
|
|
89
|
-
payload:IMsisdnSubmitErrorPayload;
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
|
93
|
-
{
|
|
94
|
-
type: "MO_BACK_TO_START";
|
|
95
|
-
payload:IBackToStartPayload;
|
|
96
|
-
}
|
|
97
|
-
|
|
|
98
|
-
{
|
|
99
|
-
type:"MOCK_MO_FLOW_STATE";
|
|
100
|
-
payload:IMoFlowCurrentState;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type IMsisdnSubmitErrorPayload = {
|
|
104
|
-
type:"MSISDNEntry";
|
|
105
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export type IMoFlowActionMaps = {
|
|
110
|
-
submitMSISDNAction:(msisdn:string)=>AppThunk;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export type IMockMoFlowStates = "msisdn-entry-success-state" | "msisdn-entry-failure-state"
|
|
114
|
-
|
|
115
|
-
export type IGoogleReCaptcha = {
|
|
116
|
-
site_key: string;
|
|
117
|
-
secret_key: string;
|
|
118
|
-
domains: string;
|
|
119
|
-
success: true;
|
|
120
|
-
} | {
|
|
121
|
-
message: string;
|
|
122
|
-
success: false;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
// LIBRARIES
|
|
2
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
3
|
-
|
|
4
|
-
import { MSISDNEntryFailure, MSISDNEntryErrorTypes, IMoFlowReducerState, MSISDNEntrySuccess, IMsisnSubmitActionPayload, IBackToStartPayload, IMsisdnSubmitErrorPayload, IMoActions, IMoFlowActionMaps, IMockMoFlowStates } from "./MoTypes";
|
|
5
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
6
|
-
import submitMSISDN, { checkSubscription, mockedMSISDNEntrySuccess, mockedMSISDNEntryFailure } from "./utils";
|
|
7
|
-
import { genericHandler, tracker } from "../strategy";
|
|
8
|
-
|
|
9
|
-
//ACTION CREATORS
|
|
10
|
-
export function submitMSISDNAction(msisdn:string, extraParams?:{[key: string]: string}):AppThunk{
|
|
11
|
-
return async (dispatch, store)=>{
|
|
12
|
-
const {currentState} = store().strategy
|
|
13
|
-
if(currentState.type === "MO"){
|
|
14
|
-
const config = currentState.result.config;
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
|
|
18
|
-
dispatch({
|
|
19
|
-
type: "MO_MSISDN_SUBMIT",
|
|
20
|
-
payload:{
|
|
21
|
-
type:"MSISDNEntry",
|
|
22
|
-
result: RDS.Loading()
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
tracker.advancedInFlow('tallyman.v1-mo', 'msisdn-submitted', { msisdn })
|
|
26
|
-
|
|
27
|
-
const keywordAndShortcode = await submitMSISDN(
|
|
28
|
-
window,
|
|
29
|
-
config,
|
|
30
|
-
msisdn,
|
|
31
|
-
extraParams
|
|
32
|
-
);
|
|
33
|
-
tracker.advancedInFlow('tallyman.v1-mo', 'msisdn-submission-success', { msisdn })
|
|
34
|
-
|
|
35
|
-
dispatch({
|
|
36
|
-
type: "MO_MSISDN_SUBMIT",
|
|
37
|
-
payload:{
|
|
38
|
-
type:"MSISDNEntry",
|
|
39
|
-
result: RDS.Success<MSISDNEntryFailure, MSISDNEntrySuccess>({...keywordAndShortcode})
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
try{
|
|
44
|
-
checkSubscription(window, config)
|
|
45
|
-
.then((product_url)=>{
|
|
46
|
-
|
|
47
|
-
tracker.advancedInFlow('tallyman.v1-mo', 'sale', { msisdn });
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
window.location.href = product_url
|
|
50
|
-
}, 1000);
|
|
51
|
-
})
|
|
52
|
-
}catch(err){
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
} catch (ex) {
|
|
56
|
-
console.warn(ex)
|
|
57
|
-
const errorType: MSISDNEntryErrorTypes =
|
|
58
|
-
"AlreadySubscribed" === ex.type
|
|
59
|
-
? "AlreadySubscribed"
|
|
60
|
-
: "InvalidMSISDN" == ex.type
|
|
61
|
-
? "InvalidMSISDN"
|
|
62
|
-
: "UnknownError";
|
|
63
|
-
tracker.recedeInFlow('tallyman.v1-mo', 'msisdn-submission-failure', { msisdn, errorType: errorType || 'UnknownError' })
|
|
64
|
-
|
|
65
|
-
dispatch({
|
|
66
|
-
type: "MO_MSISDN_SUBMIT_ERROR",
|
|
67
|
-
payload:{
|
|
68
|
-
type:"MSISDNEntry",
|
|
69
|
-
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
70
|
-
errorType: errorType,
|
|
71
|
-
error: ex,
|
|
72
|
-
productUrl: ex.productUrl
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}else{
|
|
78
|
-
dispatch({
|
|
79
|
-
type: "MO_MSISDN_SUBMIT_ERROR",
|
|
80
|
-
payload:{
|
|
81
|
-
type:"MSISDNEntry",
|
|
82
|
-
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
83
|
-
errorType: "UnexpectedState",
|
|
84
|
-
error: null
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
throw "Unexpected state"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
export function backToStart(){
|
|
95
|
-
return {
|
|
96
|
-
type:"MO_BACK_TO_START",
|
|
97
|
-
payload:{
|
|
98
|
-
type: "MSISDNEntry",
|
|
99
|
-
result: RDS.NothingYet<MSISDNEntryFailure, MSISDNEntrySuccess>()
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
export function mockMoFlow(mockState:IMockMoFlowStates):AppThunk {
|
|
106
|
-
return (dispatch)=>{
|
|
107
|
-
if(mockState !== undefined){
|
|
108
|
-
switch (mockState) {
|
|
109
|
-
case "msisdn-entry-failure-state":
|
|
110
|
-
return dispatch({
|
|
111
|
-
type:"MOCK_MO_FLOW_STATE",
|
|
112
|
-
payload:mockedMSISDNEntryFailure.currentState
|
|
113
|
-
})
|
|
114
|
-
case "msisdn-entry-success-state":
|
|
115
|
-
return dispatch({
|
|
116
|
-
type:"MOCK_MO_FLOW_STATE",
|
|
117
|
-
payload:mockedMSISDNEntrySuccess.currentState
|
|
118
|
-
})
|
|
119
|
-
default:
|
|
120
|
-
throw "Mock Flow not supported";
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const initialState:IMoFlowReducerState = {
|
|
127
|
-
currentState:{
|
|
128
|
-
type: "MSISDNEntry",
|
|
129
|
-
result: RDS.NothingYet<MSISDNEntryFailure, MSISDNEntrySuccess>()
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const MoFlowActionMaps:IMoFlowActionMaps = {
|
|
134
|
-
submitMSISDNAction:submitMSISDNAction
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export default function MoFlowReducer(state = initialState, action:IMoActions) {
|
|
138
|
-
switch (action.type) {
|
|
139
|
-
case "MO_MSISDN_SUBMIT":
|
|
140
|
-
return genericHandler<IMoFlowReducerState, IMsisnSubmitActionPayload>(state, action.payload)
|
|
141
|
-
case "MO_BACK_TO_START":
|
|
142
|
-
return genericHandler<IMoFlowReducerState, IBackToStartPayload>(state, action.payload)
|
|
143
|
-
case "MO_MSISDN_SUBMIT_ERROR":
|
|
144
|
-
return genericHandler<IMoFlowReducerState, IMsisdnSubmitErrorPayload>(state, action.payload)
|
|
145
|
-
case "MOCK_MO_FLOW_STATE":
|
|
146
|
-
return genericHandler<IMoFlowReducerState, any>(state, action.payload)
|
|
147
|
-
default:
|
|
148
|
-
return state;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { IConfig, IMSISDNSubmissionResult, ICheckSubscriptionResult, IMoFlowReducerState, MSISDNEntryFailure, MSISDNEntrySuccess, IGoogleReCaptcha } from "./MoTypes";
|
|
2
|
-
import IError from "../../common-types/IError";
|
|
3
|
-
import { IKeywordShortcode } from "./MoTypes";
|
|
4
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
5
|
-
import loadScriptInnerHtml from "../../utilities/loadScriptInnerHtml";
|
|
6
|
-
import loadScriptSrc from "../../utilities/loadScriptSrc";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const wait = (ms: number) =>
|
|
10
|
-
//@ts-ignore
|
|
11
|
-
new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
12
|
-
|
|
13
|
-
const loop = async <I extends {}, R extends {}>(
|
|
14
|
-
f: () => Promise<R>,
|
|
15
|
-
max: number,
|
|
16
|
-
stop: (r: R) => boolean,
|
|
17
|
-
i: number
|
|
18
|
-
): Promise<R> => {
|
|
19
|
-
const r = await f();
|
|
20
|
-
if (stop(r) || i >= max) {
|
|
21
|
-
return r;
|
|
22
|
-
} else {
|
|
23
|
-
await wait(1000);
|
|
24
|
-
return loop(f, max, stop, i + 1);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const getConfig = ():IConfig=>{
|
|
30
|
-
try {
|
|
31
|
-
const configs:IConfig = require("../../../../../config.json");
|
|
32
|
-
return configs;
|
|
33
|
-
} catch (ex) {
|
|
34
|
-
throw "config.json not found";
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export default async function submitMSISDN(window: Window, maybeConfig: IConfig, internationalMSISDN: string, extraParams?: {[key: string]: string}): Promise<IKeywordShortcode> {
|
|
42
|
-
const config: IConfig = {offer:window.pac_analytics.visitor.offer, ...(maybeConfig||{})}
|
|
43
|
-
return submitMSISDNWithConfig(window, config, internationalMSISDN, extraParams)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const getGoogleReCaptchaConfig = async ({ slug, country, device, host }:IConfig):Promise<IGoogleReCaptcha>=>{
|
|
47
|
-
const domain = window.location.hostname;
|
|
48
|
-
const result: IGoogleReCaptcha = await window.tallymanApi.getGoogleCaptcha(host, country, slug, device, domain);
|
|
49
|
-
if(result.success === true){
|
|
50
|
-
const srcUrl = `https://www.google.com/recaptcha/api.js?render=${result.site_key}`;
|
|
51
|
-
loadScriptSrc({url:srcUrl, key: result.site_key, isRecaptcha: true});
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function submitMSISDNWithConfig(window: Window, config: IConfig, internationalMSISDN: string, extraParams?: { [key: string]: string }): Promise<IKeywordShortcode> {
|
|
57
|
-
|
|
58
|
-
const { slug, country, device, offer, host } = config
|
|
59
|
-
const search = window.location.search.substr(1) || ''
|
|
60
|
-
const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
|
|
61
|
-
const msisdn = internationalMSISDN.match(/\d+/gi).join('')
|
|
62
|
-
const rockmanId = window.pac_analytics.visitor.rockmanId;
|
|
63
|
-
|
|
64
|
-
const result: IMSISDNSubmissionResult = await window.tallymanApi.triggerMessage(host, slug, country, msisdn, device, offer, rockmanId, search, extraParamsQs)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (false === result.success) {
|
|
68
|
-
const type = result.message == 'ALREADY SUBSCRIBED' ? "AlreadySubscribed" : "InvalidMSISDN";
|
|
69
|
-
const error = new Error(`${type}:\n${result.message}`) as IError & {type:string; productUrl:string;}
|
|
70
|
-
error['type'] = type;
|
|
71
|
-
error['productUrl'] = result.product_url ? result.product_url : "";
|
|
72
|
-
|
|
73
|
-
console.error(error)
|
|
74
|
-
throw error
|
|
75
|
-
} else {
|
|
76
|
-
return result
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export async function checkSubscription(window: Window, maybeConfig: IConfig): Promise<string> {
|
|
83
|
-
const config: IConfig = {offer:window.pac_analytics.visitor.offer, ...(maybeConfig||{})}
|
|
84
|
-
|
|
85
|
-
const { host } = config
|
|
86
|
-
|
|
87
|
-
const rockmanId = window.pac_analytics.visitor.rockmanId
|
|
88
|
-
const check : () => Promise<ICheckSubscriptionResult> = () => window.tallymanApi.checkSubscriptionByRockmanIdOnly(host, rockmanId)
|
|
89
|
-
|
|
90
|
-
const checkResult: ICheckSubscriptionResult = await loop(
|
|
91
|
-
check,
|
|
92
|
-
60,
|
|
93
|
-
r => r.success,
|
|
94
|
-
0
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
if(true === checkResult.success) {
|
|
98
|
-
window.location.href = checkResult.product_url;
|
|
99
|
-
return checkResult.product_url || null
|
|
100
|
-
} else {
|
|
101
|
-
const error = new Error(`${"SubscriptionFailed"}:\n${checkResult.message}`) as IError & {type:string}
|
|
102
|
-
error['type'] = "SubscriptionFailed";
|
|
103
|
-
throw error
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
export const formatSMSLink = (keywordAndShortcode : IKeywordShortcode) =>
|
|
109
|
-
//@ts-ignore
|
|
110
|
-
(!!window.pac_analytics.visitor["x-requested-with"] && window.pac_analytics.visitor["x-requested-with"] !== null && window.pac_analytics.visitor["x-requested-with"].indexOf("com.facebook") !== -1)
|
|
111
|
-
?
|
|
112
|
-
`sms://${keywordAndShortcode.shortcode}?body=${keywordAndShortcode.keyword}`
|
|
113
|
-
:
|
|
114
|
-
(typeof navigator != "undefined" && (/iPhone/i.test(navigator.userAgent) || /Mac OS/i.test(navigator.userAgent)))
|
|
115
|
-
? `sms:${keywordAndShortcode.shortcode}&body=${keywordAndShortcode.keyword}`
|
|
116
|
-
: `sms:${keywordAndShortcode.shortcode}?body=${keywordAndShortcode.keyword}`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
export const mockedMSISDNEntrySuccess : IMoFlowReducerState = {
|
|
120
|
-
currentState:{
|
|
121
|
-
type: "MSISDNEntry",
|
|
122
|
-
result: RDS.Success<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
123
|
-
keyword: 'TEST OK',
|
|
124
|
-
shortcode: '666'
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
export const mockedMSISDNEntryFailure : IMoFlowReducerState = {
|
|
131
|
-
currentState:{
|
|
132
|
-
type: "MSISDNEntry",
|
|
133
|
-
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({ errorType: "InvalidMSISDN", error: "Invalid Mobile Number" })
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
2
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
3
|
-
|
|
4
|
-
export type IMoRedirFlowCurrentState =
|
|
5
|
-
| {
|
|
6
|
-
type: "MSISDNEntry";
|
|
7
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type MSISDNEntryErrorTypes =
|
|
11
|
-
| "AlreadySubscribed"
|
|
12
|
-
| "UnknownError"
|
|
13
|
-
| "InvalidMSISDN"
|
|
14
|
-
| "UnexpectedState";
|
|
15
|
-
export type MSISDNEntryFailure = {
|
|
16
|
-
errorType: MSISDNEntryErrorTypes;
|
|
17
|
-
error: any;
|
|
18
|
-
productUrl?:string;
|
|
19
|
-
};
|
|
20
|
-
export type MSISDNEntrySuccess = {href: string}
|
|
21
|
-
type ACompType =
|
|
22
|
-
React.ComponentType<{ children: React.ReactNode } & React.HTMLAttributes<HTMLAnchorElement> & { keyword?: string, shortcode?: string }>
|
|
23
|
-
|
|
24
|
-
export type IMsisnSubmitActionPayload = {
|
|
25
|
-
type:"MSISDNEntry";
|
|
26
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export interface IMoRedirFlowReducerState {
|
|
32
|
-
currentState:IMoRedirFlowCurrentState
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//import { getConfig, ConfigDetails} from "./config"
|
|
36
|
-
|
|
37
|
-
export type IConfig = {
|
|
38
|
-
offer?: number,
|
|
39
|
-
slug?: string;
|
|
40
|
-
country?: string;
|
|
41
|
-
host?:string;
|
|
42
|
-
device?: "smart" | "feature";
|
|
43
|
-
operators?: string[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export type IMSISDNSubmissionResult = {
|
|
48
|
-
success: true;
|
|
49
|
-
rockman_id: string;
|
|
50
|
-
redirect_url: string;
|
|
51
|
-
} | {
|
|
52
|
-
success: false;
|
|
53
|
-
rockman_id: string;
|
|
54
|
-
message: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export type IBackToStartPayload = {
|
|
61
|
-
type: "MSISDNEntry";
|
|
62
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type IMoRedirActions = {
|
|
66
|
-
type: "MO_REDIR_MSISDN_SUBMIT";
|
|
67
|
-
payload:IMsisnSubmitActionPayload;
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
|
71
|
-
{
|
|
72
|
-
type: "MO_REDIR_MSISDN_SUBMIT_ERROR";
|
|
73
|
-
payload:IMsisdnSubmitErrorPayload;
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
|
77
|
-
{
|
|
78
|
-
type: "MO_REDIR_BACK_TO_START";
|
|
79
|
-
payload:IBackToStartPayload;
|
|
80
|
-
}
|
|
81
|
-
|
|
|
82
|
-
{
|
|
83
|
-
type:"MOCK_MO_REDIR_FLOW_STATE";
|
|
84
|
-
payload:IMoRedirFlowCurrentState;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export type IMsisdnSubmitErrorPayload = {
|
|
89
|
-
type:"MSISDNEntry",
|
|
90
|
-
result: RDS.RemoteDataState<MSISDNEntryFailure, MSISDNEntrySuccess>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
export type IMoRedirFlowActionMaps = {
|
|
95
|
-
submitMSISDNAction:(internationalMSISDN:string,bupperMSISDN?:string, rockman_id?:string)=>AppThunk;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export type IMockMoRedirFlowStates = "msisdn-entry-success-state" | "msisdn-entry-failure-state"
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// LIBRARIES
|
|
2
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
3
|
-
|
|
4
|
-
import { MSISDNEntryFailure, MSISDNEntryErrorTypes, IMoRedirFlowReducerState, MSISDNEntrySuccess, IMsisnSubmitActionPayload, IBackToStartPayload, IMsisdnSubmitErrorPayload, IMoRedirActions, IMoRedirFlowActionMaps, IMockMoRedirFlowStates } from "./MoRedirTypes";
|
|
5
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
6
|
-
import submitMSISDN, { mockedMSISDNEntryFailure, mockedMSISDNEntrySuccess } from "./utils";
|
|
7
|
-
import { genericHandler, tracker } from "../strategy";
|
|
8
|
-
|
|
9
|
-
//ACTION CREATORS
|
|
10
|
-
export function submitMSISDNAction(msisdn:string):AppThunk{
|
|
11
|
-
return async (dispatch, store)=>{
|
|
12
|
-
const {currentState} = store().strategy
|
|
13
|
-
if(currentState.type === "MO_REDIR"){
|
|
14
|
-
|
|
15
|
-
const config = currentState.result.config;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
dispatch({
|
|
20
|
-
type: "MO_REDIR_MSISDN_SUBMIT",
|
|
21
|
-
payload:{
|
|
22
|
-
type:"MSISDNEntry",
|
|
23
|
-
result: RDS.Loading()
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
tracker.advancedInFlow('tallyman.v1-mo-redir', 'msisdn-submitted', { msisdn })
|
|
27
|
-
|
|
28
|
-
const href = await submitMSISDN(
|
|
29
|
-
window,
|
|
30
|
-
config,
|
|
31
|
-
msisdn
|
|
32
|
-
);
|
|
33
|
-
tracker.advancedInFlow('tallyman.v1-mo-redir', 'msisdn-submission-success', { msisdn })
|
|
34
|
-
dispatch({
|
|
35
|
-
type: "MO_REDIR_MSISDN_SUBMIT",
|
|
36
|
-
payload:{
|
|
37
|
-
type:"MSISDNEntry",
|
|
38
|
-
result: RDS.Success<MSISDNEntryFailure, MSISDNEntrySuccess>({href})
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
} catch (ex) {
|
|
42
|
-
console.warn(ex)
|
|
43
|
-
const errorType: MSISDNEntryErrorTypes =
|
|
44
|
-
"SEAlreadySubscribed" === ex.type
|
|
45
|
-
? "AlreadySubscribed"
|
|
46
|
-
: "SEInvalidMSISDN" == ex.type
|
|
47
|
-
? "InvalidMSISDN"
|
|
48
|
-
: "UnknownError";
|
|
49
|
-
tracker.recedeInFlow('tallyman.v1-mo-redir', 'msisdn-submission-failure', { msisdn, errorType: errorType || 'UnknownError' })
|
|
50
|
-
|
|
51
|
-
dispatch({
|
|
52
|
-
type: "MO_REDIR_MSISDN_SUBMIT_ERROR",
|
|
53
|
-
payload:{
|
|
54
|
-
type:"MSISDNEntry",
|
|
55
|
-
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
56
|
-
errorType: errorType,
|
|
57
|
-
error: ex,
|
|
58
|
-
productUrl: ex.productUrl
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}else{
|
|
65
|
-
tracker.recedeInFlow('tallyman.v1-mo-redir', 'msisdn-submission-failure', { msisdn, errorType: 'UnknownError' })
|
|
66
|
-
dispatch({
|
|
67
|
-
type: "MO_REDIR_MSISDN_SUBMIT_ERROR",
|
|
68
|
-
payload:{
|
|
69
|
-
type:"MSISDNEntry",
|
|
70
|
-
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
71
|
-
errorType: "UnexpectedState",
|
|
72
|
-
error:null
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
throw "Unexpected state"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export function backToStart(){
|
|
83
|
-
return {
|
|
84
|
-
type:"MO_REDIR_BACK_TO_START",
|
|
85
|
-
payload:{
|
|
86
|
-
type: "MSISDNEntry",
|
|
87
|
-
result: RDS.NothingYet<MSISDNEntryFailure, MSISDNEntrySuccess>()
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function mockMoRedirFlow(mockState:IMockMoRedirFlowStates):AppThunk {
|
|
93
|
-
return (dispatch)=>{
|
|
94
|
-
if(mockState !== undefined){
|
|
95
|
-
switch (mockState) {
|
|
96
|
-
case "msisdn-entry-failure-state":
|
|
97
|
-
return dispatch({
|
|
98
|
-
type:"MOCK_MO_REDIR_FLOW_STATE",
|
|
99
|
-
payload:mockedMSISDNEntryFailure.currentState
|
|
100
|
-
})
|
|
101
|
-
case "msisdn-entry-success-state":
|
|
102
|
-
return dispatch({
|
|
103
|
-
type:"MOCK_MO_REDIR_FLOW_STATE",
|
|
104
|
-
payload:mockedMSISDNEntrySuccess.currentState
|
|
105
|
-
})
|
|
106
|
-
default:
|
|
107
|
-
throw "Mock Flow not supported";
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const initialState:IMoRedirFlowReducerState = {
|
|
114
|
-
currentState:{
|
|
115
|
-
type: "MSISDNEntry",
|
|
116
|
-
result: RDS.NothingYet<MSISDNEntryFailure, MSISDNEntrySuccess>()
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export const MoRedirFlowActionMaps:IMoRedirFlowActionMaps = {
|
|
121
|
-
submitMSISDNAction:submitMSISDNAction
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export default function MoRedirFlowReducer(state = initialState, action:IMoRedirActions) {
|
|
125
|
-
switch (action.type) {
|
|
126
|
-
case "MO_REDIR_MSISDN_SUBMIT":
|
|
127
|
-
return genericHandler<IMoRedirFlowReducerState, IMsisnSubmitActionPayload>(state, action.payload)
|
|
128
|
-
case "MO_REDIR_BACK_TO_START":
|
|
129
|
-
return genericHandler<IMoRedirFlowReducerState, IBackToStartPayload>(state, action.payload)
|
|
130
|
-
case "MO_REDIR_MSISDN_SUBMIT_ERROR":
|
|
131
|
-
return genericHandler<IMoRedirFlowReducerState, IMsisdnSubmitErrorPayload>(state, action.payload)
|
|
132
|
-
case "MOCK_MO_REDIR_FLOW_STATE":
|
|
133
|
-
return genericHandler<IMoRedirFlowReducerState, any>(state, action.payload)
|
|
134
|
-
default:
|
|
135
|
-
return state;
|
|
136
|
-
}
|
|
137
|
-
}
|