File size: 3,128 Bytes
4c34106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/*
 * This file is part of WPPConnect.
 *
 * WPPConnect is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WPPConnect is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with WPPConnect.  If not, see <https://www.gnu.org/licenses/>.
 */
import { StreamInfo, StreamMode } from '@wppconnect/wa-js/dist/whatsapp/enums';
import { CreateConfig } from '../../config/create-config';
import { SessionToken } from '../../token-store';
import { StatusFind } from './enum';

/**
 * A callback will be received, informing the status of the qrcode
 */
export type CatchQRCallback = (
  qrCode: string,
  asciiQR: string,
  attempt: number,
  urlCode?: string
) => void;

/**
 * A callback will be received, informing the customer's status
 */
export type StatusFindCallback = (
  status: StatusFind | keyof typeof StatusFind,
  session: string
) => void;

/**
 * A callback will be received, informing data as percentage and loading screen message
 */
export type LoadingScreenCallback = (percent: number, message: string) => void;

/**
 * A callback will be received, informing the stream mode has changed
 */
export type OnStreamModeCallback = (mode: StreamMode) => void;

/**
 * A callback will be received, informing the stream info has changed
 */
export type OnStreamInfoCallback = (info: StreamInfo) => void;

/**
 * A callback will be received, informing a code to you connect
 */
export type LinkByCodeCallback = (code: string) => void;

export interface CreateOptions extends CreateConfig {
  /**
   * You must pass a string type parameter, this parameter will be the name of the client's session. If the parameter is not passed, the section name will be "session".
   */
  session?: string;
  /**
   * A callback will be received, informing the status of the qrcode
   */
  catchQR?: CatchQRCallback;

  /**
   * A callback will be received, informing a code to you connect
   */
  catchLinkCode?: LinkByCodeCallback;

  /**
   * A callback will be received, informing the customer's status
   */
  statusFind?: StatusFindCallback;

  /**
   * A callback will be received, informing data as percentage and loading screen message
   */
  onLoadingScreen?: LoadingScreenCallback;

  /**
   * A callback will be received, informing the stream mode has changed
   */
  onStreamModeChanged?: OnStreamModeCallback;
  /**
   * A callback will be received, informing the stream info has changed
   */
  onStreamInfoChanged?: OnStreamInfoCallback;
  /**
   * Pass the session token information you can receive this token with the await client.getSessionTokenBrowser () function
   * @deprecated in favor of `sessionToken`
   */
  browserSessionToken?: SessionToken;
}