forked from mironal/TwitterAPIKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldsV2.swift
More file actions
484 lines (445 loc) · 11.4 KB
/
FieldsV2.swift
File metadata and controls
484 lines (445 loc) · 11.4 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
import Foundation
// https://developer.twitter.com/en/docs/twitter-api/fields
/// tweet.fields
public enum TwitterTweetFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case attachments
case authorID
case contextAnnotations
case conversationID
case createdAt
case entities
case geo
case id
case inReplyToUserID
case lang
case nonPublicMetrics
case publicMetrics
case organicMetrics
case promotedMetrics
case possiblySensitive
case referencedTweets
case replySettings
case source
case text
case withheld
case other(String)
public var stringValue: String {
switch self {
case .attachments:
return "attachments"
case .authorID:
return "author_id"
case .contextAnnotations:
return "context_annotations"
case .conversationID:
return "conversation_id"
case .createdAt:
return "created_at"
case .entities:
return "entities"
case .geo:
return "geo"
case .id:
return "id"
case .inReplyToUserID:
return "in_reply_to_user_id"
case .lang:
return "lang"
case .nonPublicMetrics:
return "non_public_metrics"
case .publicMetrics:
return "public_metrics"
case .organicMetrics:
return "organic_metrics"
case .promotedMetrics:
return "promoted_metrics"
case .possiblySensitive:
return "possibly_sensitive"
case .referencedTweets:
return "referenced_tweets"
case .replySettings:
return "reply_settings"
case .source:
return "source"
case .text:
return "text"
case .withheld:
return "withheld"
case .other(let other):
return other
}
}
public static let all: Set<Self> = [
.attachments,
.authorID,
.contextAnnotations,
.conversationID,
.createdAt,
.entities,
.geo,
.id,
.inReplyToUserID,
.lang,
.nonPublicMetrics,
.publicMetrics,
.organicMetrics,
.promotedMetrics,
.possiblySensitive,
.referencedTweets,
.replySettings,
.source,
.text,
.withheld,
]
}
extension Set where Element == TwitterTweetFieldsV2 {
func bind(param: inout [String: Any]) {
param["tweet.fields"] = commaSeparatedString
}
}
/// user.fields
public enum TwitterUserFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case createdAt
case description
case entities
case id
case location
case name
case pinnedTweetID
case profileImageUrl
case protected
case publicMetrics
case url
case username
case verified
case withheld
case other(String)
public var stringValue: String {
switch self {
case .createdAt:
return "created_at"
case .description:
return "description"
case .entities:
return "entities"
case .id:
return "id"
case .location:
return "location"
case .name:
return "name"
case .pinnedTweetID:
return "pinned_tweet_id"
case .profileImageUrl:
return "profile_image_url"
case .protected:
return "protected"
case .publicMetrics:
return "public_metrics"
case .url:
return "url"
case .username:
return "username"
case .verified:
return "verified"
case .withheld:
return "withheld"
case .other(let other):
return other
}
}
public static let all: Set<Self> = [
.createdAt,
.description,
.entities,
.id,
.location,
.name,
.pinnedTweetID,
.profileImageUrl,
.protected,
.publicMetrics,
.url,
.username,
.verified,
.withheld,
]
}
extension Set where Element == TwitterUserFieldsV2 {
func bind(param: inout [String: Any]) {
param["user.fields"] = commaSeparatedString
}
}
/// place.fields
public enum TwitterPlaceFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case containedWithin
case country
case countryCode
case fullName
case geo
case id
case name
case placeType
case other(String)
public var stringValue: String {
switch self {
case .containedWithin:
return "contained_within"
case .country:
return "country"
case .countryCode:
return "country_code"
case .fullName:
return "full_name"
case .geo:
return "geo"
case .id:
return "id"
case .name:
return "name"
case .placeType:
return "place_type"
case .other(let other):
return other
}
}
public static let all: Set<Self> = [
.containedWithin,
.country,
.countryCode,
.fullName,
.geo,
.id,
.name,
.placeType,
]
}
extension Set where Element == TwitterPlaceFieldsV2 {
func bind(param: inout [String: Any]) {
param["place.fields"] = commaSeparatedString
}
}
/// poll.fields
public enum TwitterPollFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case durationMinutes
case endDatetime
case id
case options
case votingStatus
case other(String)
public var stringValue: String {
switch self {
case .durationMinutes:
return "duration_minutes"
case .endDatetime:
return "end_datetime"
case .id:
return "id"
case .options:
return "options"
case .votingStatus:
return "voting_status"
case .other(let other):
return other
}
}
public static let all: Set<Self> = [
.durationMinutes,
.endDatetime,
.id,
.options,
.votingStatus,
]
}
extension Set where Element == TwitterPollFieldsV2 {
func bind(param: inout [String: Any]) {
param["poll.fields"] = commaSeparatedString
}
}
/// media.fields
public enum TwitterMediaFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case durationMs
case height
case mediaKey
case previewImageUrl
case type
case url
case width
case publicMetrics
case nonPublicMetrics
case organicMetrics
case promotedMetrics
case altText
case variants
case other(String)
public var stringValue: String {
switch self {
case .durationMs: return "duration_ms"
case .height: return "height"
case .mediaKey: return "media_key"
case .previewImageUrl: return "preview_image_url"
case .type: return "type"
case .url: return "url"
case .width: return "width"
case .publicMetrics: return "public_metrics"
case .nonPublicMetrics: return "non_public_metrics"
case .organicMetrics: return "organic_metrics"
case .promotedMetrics: return "promoted_metrics"
case .altText: return "alt_text"
case .variants: return "variants"
case .other(let string): return string
}
}
public static let all: Set<Self> = [
.durationMs,
.height,
.mediaKey,
.previewImageUrl,
.type,
.url,
.width,
.publicMetrics,
.nonPublicMetrics,
.organicMetrics,
.promotedMetrics,
.altText,
.variants,
]
}
extension Set where Element == TwitterMediaFieldsV2 {
func bind(param: inout [String: Any]) {
param["media.fields"] = commaSeparatedString
}
}
/// list.fields
public enum TwitterListFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case createdAt
case followerCount
case memberCount
case `private`
case description
case id
case name
case ownerID
case other(String)
public var stringValue: String {
switch self {
case .createdAt: return "created_at"
case .followerCount: return "follower_count"
case .memberCount: return "member_count"
case .private: return "private"
case .description: return "description"
case .id: return "id"
case .name: return "name"
case .ownerID: return "owner_id"
case .other(let string): return string
}
}
public static let all: Set<Self> = [
.createdAt,
.followerCount,
.memberCount,
.private,
.description,
.id,
.name,
.ownerID,
]
}
extension Set where Element == TwitterListFieldsV2 {
func bind(param: inout [String: Any]) {
param["list.fields"] = commaSeparatedString
}
}
/// space.fields
public enum TwitterSpaceFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case id
case state
case hostIDs
case createdAt
case creatorID
case lang
case invitedUserIDs
case participantCount
case speakerIDs
case startedAt
case endedAt
case subscriberCount
case topicIDs
case title
case updatedAt
case scheduledStart
case isTicketed
case other(String)
public var stringValue: String {
switch self {
case .id: return "id"
case .state: return "state"
case .hostIDs: return "host_ids"
case .createdAt: return "created_at"
case .creatorID: return "creator_id"
case .lang: return "lang"
case .invitedUserIDs: return "invited_user_ids"
case .participantCount: return "participant_count"
case .speakerIDs: return "speaker_ids"
case .startedAt: return "started_at"
case .endedAt: return "ended_at"
case .subscriberCount: return "subscriber_count"
case .topicIDs: return "topic_ids"
case .title: return "title"
case .updatedAt: return "updated_at"
case .scheduledStart: return "scheduled_start"
case .isTicketed: return "is_ticketed"
case .other(let string): return string
}
}
public static let all: Set<Self> = [
.id,
.state,
.hostIDs,
.createdAt,
.creatorID,
.lang,
.invitedUserIDs,
.participantCount,
.speakerIDs,
.startedAt,
.endedAt,
.subscriberCount,
.topicIDs,
.title,
.updatedAt,
.scheduledStart,
.isTicketed,
]
}
extension Set where Element == TwitterSpaceFieldsV2 {
func bind(param: inout [String: Any]) {
param["space.fields"] = commaSeparatedString
}
}
/// topic.fields
public enum TwitterTopicFieldsV2: TwitterAPIv2RequestParameter, Hashable {
case id
case name
case description
case other(String)
public var stringValue: String {
switch self {
case .id: return "id"
case .name: return "name"
case .description: return "description"
case .other(let string): return string
}
}
public static let all: Set<Self> = [
.id,
.name,
.description,
]
}
extension Set where Element == TwitterTopicFieldsV2 {
func bind(param: inout [String: Any]) {
param["topic.fields"] = commaSeparatedString
}
}