-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdraws.ts
More file actions
263 lines (205 loc) · 5.54 KB
/
Copy pathdraws.ts
File metadata and controls
263 lines (205 loc) · 5.54 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// SPDX-FileCopyrightText: 2026 Xquik contributors
//
// SPDX-License-Identifier: Apache-2.0
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
/**
* Giveaway draws from tweet replies
*/
export class Draws extends APIResource {
/**
* Get draw details
*
* @example
* ```ts
* const draw = await client.draws.retrieve(
* 'f4bd00a2-7b4e-4e59-8e1b-72e2c9f12345',
* );
* ```
*/
retrieve(id: string, options?: RequestOptions): APIPromise<DrawRetrieveResponse> {
return this._client.get(path`/draws/${id}`, options);
}
/**
* List draws
*
* @example
* ```ts
* const draws = await client.draws.list();
* ```
*/
list(
query: DrawListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<DrawListResponse> {
return this._client.get('/draws', { query, ...options });
}
/**
* Export draw data
*
* @example
* ```ts
* const response = await client.draws.export(
* 'f4bd00a2-7b4e-4e59-8e1b-72e2c9f12345',
* { format: 'csv' },
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
export(id: string, query: DrawExportParams, options?: RequestOptions): APIPromise<Response> {
return this._client.get(path`/draws/${id}/export`, {
query,
...options,
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
__binaryResponse: true,
});
}
/**
* Runs a giveaway draw from a source tweet. The draw first checks that the usage
* balance can inspect the source tweet and at least 1 candidate. Available balance
* caps how many replies and retweeters can be inspected before filters and winner
* selection run.
*
* @example
* ```ts
* const response = await client.draws.run({
* tweetUrl: 'https://x.com/elonmusk/status/1234567890',
* mustRetweet: true,
* winnerCount: 3,
* });
* ```
*/
run(body: DrawRunParams, options?: RequestOptions): APIPromise<DrawRunResponse> {
return this._client.post('/draws', { body, ...options });
}
}
/**
* Full giveaway draw with tweet metrics, entries, and timing.
*/
export interface DrawDetail {
/**
* Draw public ID.
*/
id: string;
createdAt: string;
status: string;
totalEntries: number;
tweetAuthorUsername: string;
tweetId: string;
tweetLikeCount: number;
tweetQuoteCount: number;
tweetReplyCount: number;
tweetRetweetCount: number;
tweetText: string;
tweetUrl: string;
validEntries: number;
drawnAt?: string;
}
/**
* Giveaway draw summary with entry counts and status.
*/
export interface DrawListItem {
/**
* Draw public ID for detail responses.
*/
id: string;
createdAt: string;
status: string;
totalEntries: number;
tweetUrl: string;
validEntries: number;
drawnAt?: string;
}
/**
* Giveaway draw winner with position and backup flag.
*/
export interface Winner {
authorUsername: string;
isBackup: boolean;
position: number;
tweetId: string;
}
export interface DrawRetrieveResponse {
/**
* Full giveaway draw with tweet metrics, entries, and timing.
*/
draw: DrawDetail;
winners: Array<Winner>;
}
export interface DrawListResponse {
draws: Array<DrawListItem>;
hasMore: boolean;
nextCursor?: string;
}
export interface DrawRunResponse {
id: string;
/**
* Candidate entries inspected for this draw. This may
* be lower than the source tweet's full reply count.
*/
totalEntries: number;
tweetId: string;
/**
* Entries from the inspected candidate set that passed all filters. This is not
* necessarily every valid reply on the source tweet when the available balance limits inspection.
*/
validEntries: number;
winners: Array<Winner>;
}
export interface DrawListParams {
/**
* Previous nextCursor.
*/
cursor?: string;
/**
* Maximum number of items to return (1-100, default 50). For paid per-result
* endpoints, the returned count may be lower when available usage balance cannot cover
* the requested page. If zero paid results are affordable, the endpoint returns
* 402 insufficient_credits.
*/
limit?: number;
}
export interface DrawExportParams {
/**
* Export output format. PDF entry exports include up to 10,000 rows. Other entry
* formats include up to 100,000 rows.
*/
format: 'csv' | 'json' | 'md' | 'md-document' | 'pdf' | 'txt' | 'xlsx';
/**
* Export winners or all entries
*/
type?: 'winners' | 'entries';
}
export interface DrawRunParams {
tweetUrl: string;
backupCount?: number;
filterAccountAgeDays?: number;
filterLanguage?: string;
filterMinFollowers?: number;
mustFollowUsername?: string;
mustRetweet?: boolean;
requiredHashtags?: Array<string>;
requiredKeywords?: Array<string>;
requiredMentions?: Array<string>;
uniqueAuthorsOnly?: boolean;
winnerCount?: number;
}
export declare namespace Draws {
export {
type DrawDetail as DrawDetail,
type DrawListItem as DrawListItem,
type Winner as Winner,
type DrawRetrieveResponse as DrawRetrieveResponse,
type DrawListResponse as DrawListResponse,
type DrawRunResponse as DrawRunResponse,
type DrawListParams as DrawListParams,
type DrawExportParams as DrawExportParams,
type DrawRunParams as DrawRunParams,
};
}