playttm 0.0.1

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/dist/lib.d.ts ADDED
@@ -0,0 +1,192 @@
1
+ export interface TTMConfig {
2
+ cookies?: string;
3
+ headers?: Record<string, string>;
4
+ userAgent?: string;
5
+ timeout?: number;
6
+ endpoint?: string;
7
+ onProgress?: (step: string, message: string, data?: any) => void;
8
+ }
9
+ export interface RoundInfo {
10
+ id: string;
11
+ label: string;
12
+ date: string;
13
+ time: string;
14
+ url: string;
15
+ query: string;
16
+ isDisabled: boolean;
17
+ }
18
+ export interface ZoneItem {
19
+ id: string;
20
+ value: string;
21
+ available: number;
22
+ page: "fixed.php" | "festival.php" | string;
23
+ isAvailable: boolean;
24
+ }
25
+ export interface SeatItem {
26
+ id: string;
27
+ seat: string;
28
+ seatk: string;
29
+ price?: string;
30
+ }
31
+ export interface Attendee {
32
+ fullname: string;
33
+ email?: string;
34
+ phone?: string;
35
+ firstname?: string;
36
+ lastname?: string;
37
+ options?: string;
38
+ }
39
+ export interface QuickBookOptions {
40
+ eventUrl: string;
41
+ roundIndex?: number;
42
+ roundId?: string;
43
+ zoneId: string;
44
+ ticketCount?: number;
45
+ seatSelection?: "random" | "first" | SeatItem[] | string[];
46
+ attendees?: Attendee[];
47
+ deliveryType?: string;
48
+ payType?: string;
49
+ paymentDelayMs?: number;
50
+ printQR?: boolean;
51
+ onProgress?: (step: string, message: string, data?: any) => void;
52
+ }
53
+ export interface QuickBookResult {
54
+ success: boolean;
55
+ orderId: string;
56
+ amount: string;
57
+ qrRawCode?: string;
58
+ qrData: any;
59
+ summary: {
60
+ performance?: string;
61
+ showDate?: string;
62
+ showTime?: string;
63
+ venue?: string;
64
+ zone?: string;
65
+ ticketCount: number;
66
+ totalAmount: string;
67
+ seats?: string[];
68
+ };
69
+ rawPayload?: any;
70
+ displayQR: (title?: string) => void;
71
+ }
72
+ export declare class ThaiTicketMajor {
73
+ private client;
74
+ private jar;
75
+ private endpoint;
76
+ private defaultHeaders;
77
+ private onProgressCallback?;
78
+ constructor(config?: TTMConfig);
79
+ private emitProgress;
80
+ /**
81
+ * Step 1: ดึงรอบการแสดงทั้งหมดจากหน้าหลักคอนเสิร์ต
82
+ */
83
+ getRounds(eventUrl: string): Promise<RoundInfo[]>;
84
+ /**
85
+ * Step 2: ตรวจสอบและยอมรับเงื่อนไขการซื้อบัตร
86
+ */
87
+ verifyCheckCondition(query: string): Promise<{
88
+ result: boolean;
89
+ message: string;
90
+ query: string;
91
+ }>;
92
+ /**
93
+ * Step 3: ดึงข้อมูลโซน, Token (k, tk) และรอบการแสดง
94
+ */
95
+ getZones(query: string): Promise<{
96
+ k: string;
97
+ tk: string;
98
+ query: string;
99
+ rounds: {
100
+ id: string;
101
+ label: string;
102
+ }[];
103
+ rawInputs: Record<string, string>;
104
+ }>;
105
+ /**
106
+ * Step 4: ตรวจสอบสถานะที่นั่งว่างของแต่ละโซน
107
+ */
108
+ getZoneAvailability(roundId: string, tk: string, k: string, query: string): Promise<ZoneItem[]>;
109
+ /**
110
+ * Step 5 (Fixed): ดึงผังที่นั่งว่างและ form payload
111
+ */
112
+ getFixedSeats(k: string, zone: string, roundId: string): Promise<{
113
+ seats: SeatItem[];
114
+ form: Record<string, string>;
115
+ }>;
116
+ /**
117
+ * Step 6 (Fixed): Validate ที่นั่งทีละที่นั่งตามลำดับ
118
+ */
119
+ validateFixedSeats(k: string, zone: string, payload: Record<string, any>, chkSeats: SeatItem[], bookType?: string): Promise<{
120
+ result: boolean;
121
+ status: number;
122
+ message: string;
123
+ }>;
124
+ /**
125
+ * Step 7 (Fixed): จองที่นั่ง Fixed
126
+ */
127
+ bookFixedSeats(k: string, payload: Record<string, any>, seats: SeatItem[]): Promise<{
128
+ data: any;
129
+ nextPayload: URLSearchParams;
130
+ }>;
131
+ /**
132
+ * Step 5 (Festival): ดึงข้อมูลหน้าบัตรยืน
133
+ */
134
+ getFestival(k: string, tk: string, query: string, zone: string, roundId: string): Promise<Record<string, string>>;
135
+ /**
136
+ * Step 6 (Festival): Validate บัตรยืน
137
+ */
138
+ validateFestivalSeats(k: string, payload: Record<string, any>, ticketCount: number): Promise<any>;
139
+ /**
140
+ * Step 7 (Festival): จองบัตรยืน
141
+ */
142
+ bookFestivalSeats(k: string, payload: Record<string, any>, ticketCount: number): Promise<any>;
143
+ /**
144
+ * Step 8 (Enroll): ดึง Form ลงทะเบียนผู้เข้าชม
145
+ */
146
+ enroll(k: string, zone: string, roundId: string, payload: URLSearchParams | string): Promise<Record<string, string>>;
147
+ /**
148
+ * Step 9 (Enroll Process): ส่งข้อมูลผู้เข้าชม
149
+ */
150
+ enrollProcess(k: string, payload: Record<string, any>, attendees: Attendee[]): Promise<{
151
+ data: any;
152
+ nextPayload: URLSearchParams;
153
+ }>;
154
+ /**
155
+ * Step 10: ดึงข้อมูลหน้าสรุปการชำระเงินและที่อยู่จัดส่ง
156
+ */
157
+ getPaymentDetails(k: string, formData: URLSearchParams | Record<string, any>, zone: string, roundId: string, delayMs?: number): Promise<Record<string, string>>;
158
+ /**
159
+ * Step 11: คำนวณยอดเงินรวมสุทธิและยืนยันคำสั่งซื้อ
160
+ */
161
+ confirmPayment(k: string, payload: Record<string, string>, deliver?: string, payType?: string): Promise<Record<string, string>>;
162
+ /**
163
+ * Step 12: ดึง payload เข้ารหัสสำหรับ KBank
164
+ */
165
+ orderEncKBankQR(k: string, payCfmData: Record<string, string>): Promise<Record<string, string>>;
166
+ /**
167
+ * Step 13: เรียก getkbankqr.php
168
+ */
169
+ getKBankQR(orderEncData: Record<string, string>): Promise<any>;
170
+ /**
171
+ * Step 14: ทำรายการ payment_kbankqr.php เพื่อดึง Order ID และ API Key
172
+ */
173
+ paymentKBankQR(orderEncData: Record<string, string>, kbankPayload: Record<string, any>): Promise<{
174
+ orderId: string;
175
+ apiKey: string;
176
+ }>;
177
+ /**
178
+ * Step 15: ยิงตรง Kasikorn Bank Gateway เพื่อสร้าง ThaiQR Code
179
+ */
180
+ generateThaiQR(orderId: string, apiKey: string, amount: string | number): Promise<any>;
181
+ /**
182
+ * ทำการจองแบบครบวงจร (End-to-End) ตั้งแต่เลือกรอบจนได้ QR Code
183
+ */
184
+ quickBook(options: QuickBookOptions): Promise<QuickBookResult>;
185
+ /**
186
+ * แสดงผล QR Code บนหน้าจอ Terminal / Console เพื่อให้สแกนได้ทันที
187
+ */
188
+ static displayQRCode(qrString: string, title?: string): void;
189
+ displayQRCode(qrString: string, title?: string): void;
190
+ }
191
+ export declare const displayQRCode: typeof ThaiTicketMajor.displayQRCode;
192
+ export default ThaiTicketMajor;