forked from habbes/ussd-menu-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
121 lines (82 loc) · 2.86 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/// <reference types="node" />
// Type definitions for ussd-menu-builder 1.0.0
// Project: ussd-menu-builder
// Definitions by: Jason Schapiro <[email protected]>
import { EventEmitter } from "events";
export = UssdMenu;
declare class UssdState {
constructor(menu: UssdMenu);
defaultNext?: string;
menu: UssdMenu;
name: string;
run(): void;
val: string;
}
declare class UssdMenu extends EventEmitter {
constructor(opts?: UssdMenu.UssdMenuOptions);
session: any;
provider: UssdMenu.UssdMenuProvider;
args: UssdMenu.UssdGatewayArgs;
states: Array<UssdState>;
result: string;
val: string;
callOnResult(): void;
con(text: string): void;
end(text: string): void;
getRoute(args: UssdMenu.UssdGatewayArgs | UssdMenu.HubtelArgs): Promise<string>;
go(state: string): void;
goStart(): void;
mapArgs(args: UssdMenu.UssdGatewayArgs | UssdMenu.HubtelArgs): UssdMenu.UssdGatewayArgs;
onResult?(result: string | UssdMenu.HubtelResponse): void;
resolveRoute(route: string, callback: Function): void;
run(args: UssdMenu.UssdGatewayArgs, onResult?: Function): void;
runState(state: UssdState): void;
sessionConfig(config: UssdMenu.UssdSessionConfig): void;
startState(options: UssdMenu.UssdStateOptions): void;
state(name: string, options: UssdMenu.UssdStateOptions): UssdMenu;
testLinkRule(rule: string, val: string): boolean;
static START_STATE: string;
}
/*~ If you want to expose types from your module as well, you can
*~ place them in this block.
*/
declare namespace UssdMenu {
interface NextState {
[state: string]: Function | string;
}
interface UssdGatewayArgs {
text: string;
phoneNumber: string;
sessionId: string;
serviceCode: string;
}
interface HubtelResponse {
Type: 'Response' | 'Release';
Message: string;
}
interface HubtelArgs {
Mobile: string;
SessionId: string;
ServiceCode: string;
Type: 'Initiation' | 'Response' | 'Release' | 'Timeout';
Message: string;
Operator: 'Tigo' | 'Airtel' | 'MTN' | 'Vodafone' | 'Safaricom';
Sequence: number;
ClientState?: any;
}
type UssdMenuProvider = 'africasTalking' | 'hubtel';
interface UssdMenuOptions {
provider?: UssdMenuProvider;
}
interface UssdStateOptions {
run(): void;
next?: NextState;
defaultNext?: string;
}
interface UssdSessionConfig {
start(sessionId: string, callback?: Function): (Promise<any> | void);
end(sessionId: string, callback?: Function): (Promise<any> | void);
get(sessionId: string, key: string, callback?: Function): (Promise<any> | void);
set(sessionId: string, key: string, value: any, callback?: Function): (Promise<any> | void);
}
}