Skip to content

Commit f4e437f

Browse files
committed
add .all property to Fields
1 parent 0ea7a2a commit f4e437f

2 files changed

Lines changed: 139 additions & 0 deletions

File tree

Sources/TwitterAPIKit/APIv2/FieldsV2.swift

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,29 @@ public enum TwitterTweetFieldsV2: TwitterAPIv2RequestParameter, Hashable {
7474
return other
7575
}
7676
}
77+
78+
public static let all: Set<Self> = [
79+
.attachments,
80+
.authorID,
81+
.contextAnnotations,
82+
.conversationID,
83+
.createdAt,
84+
.entities,
85+
.geo,
86+
.id,
87+
.inReplyToUserID,
88+
.lang,
89+
.nonPublicMetrics,
90+
.publicMetrics,
91+
.organicMetrics,
92+
.promotedMetrics,
93+
.possiblySensitive,
94+
.referencedTweets,
95+
.replySettings,
96+
.source,
97+
.text,
98+
.withheld,
99+
]
77100
}
78101

79102
extension Set where Element == TwitterTweetFieldsV2 {
@@ -134,6 +157,23 @@ public enum TwitterUserFieldsV2: TwitterAPIv2RequestParameter, Hashable {
134157
return other
135158
}
136159
}
160+
161+
public static let all: Set<Self> = [
162+
.createdAt,
163+
.description,
164+
.entities,
165+
.id,
166+
.location,
167+
.name,
168+
.pinnedTweetID,
169+
.profileImageUrl,
170+
.protected,
171+
.publicMetrics,
172+
.url,
173+
.username,
174+
.verified,
175+
.withheld,
176+
]
137177
}
138178

139179
extension Set where Element == TwitterUserFieldsV2 {
@@ -177,6 +217,17 @@ public enum TwitterPlaceFieldsV2: TwitterAPIv2RequestParameter, Hashable {
177217
return other
178218
}
179219
}
220+
221+
public static let all: Set<Self> = [
222+
.containedWithin,
223+
.country,
224+
.countryCode,
225+
.fullName,
226+
.geo,
227+
.id,
228+
.name,
229+
.placeType,
230+
]
180231
}
181232

182233
extension Set where Element == TwitterPlaceFieldsV2 {
@@ -210,6 +261,14 @@ public enum TwitterPollFieldsV2: TwitterAPIv2RequestParameter, Hashable {
210261
return other
211262
}
212263
}
264+
265+
public static let all: Set<Self> = [
266+
.durationMinutes,
267+
.endDatetime,
268+
.id,
269+
.options,
270+
.votingStatus,
271+
]
213272
}
214273

215274
extension Set where Element == TwitterPollFieldsV2 {
@@ -251,6 +310,21 @@ public enum TwitterMediaFieldsV2: TwitterAPIv2RequestParameter, Hashable {
251310
case .other(let string): return string
252311
}
253312
}
313+
314+
public static let all: Set<Self> = [
315+
.durationMs,
316+
.height,
317+
.mediaKey,
318+
.previewImageUrl,
319+
.type,
320+
.url,
321+
.width,
322+
.publicMetrics,
323+
.nonPublicMetrics,
324+
.organicMetrics,
325+
.promotedMetrics,
326+
.altText,
327+
]
254328
}
255329

256330
extension Set where Element == TwitterMediaFieldsV2 {
@@ -285,6 +359,17 @@ public enum TwitterListFieldsV2: TwitterAPIv2RequestParameter, Hashable {
285359
case .other(let string): return string
286360
}
287361
}
362+
363+
public static let all: Set<Self> = [
364+
.createdAt,
365+
.followerCount,
366+
.memberCount,
367+
.private,
368+
.description,
369+
.id,
370+
.name,
371+
.ownerID,
372+
]
288373
}
289374

290375
extension Set where Element == TwitterListFieldsV2 {
@@ -333,6 +418,24 @@ public enum TwitterSpaceFieldsV2: TwitterAPIv2RequestParameter, Hashable {
333418
case .other(let string): return string
334419
}
335420
}
421+
422+
public static let all: Set<Self> = [
423+
.hostIDs,
424+
.createdAt,
425+
.creatorID,
426+
.lang,
427+
.invitedUserIDs,
428+
.participantCount,
429+
.speakerIDs,
430+
.startedAt,
431+
.endedAt,
432+
.subscriberCount,
433+
.topicIDs,
434+
.title,
435+
.updatedAt,
436+
.scheduledStart,
437+
.isTicketed,
438+
]
336439
}
337440

338441
extension Set where Element == TwitterSpaceFieldsV2 {
@@ -357,6 +460,12 @@ public enum TwitterTopicFieldsV2: TwitterAPIv2RequestParameter, Hashable {
357460
case .other(let string): return string
358461
}
359462
}
463+
464+
public static let all: Set<Self> = [
465+
.id,
466+
.name,
467+
.description,
468+
]
360469
}
361470

362471
extension Set where Element == TwitterTopicFieldsV2 {

Tests/TwitterAPIKitTests/APIv2/FieldsV2Tests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class FieldsV2Tests: XCTestCase {
4242
)
4343
}
4444

45+
func testTwitterTweetFieldsV2All() throws {
46+
XCTAssertEqual(TwitterTweetFieldsV2.all.count, 20)
47+
}
48+
4549
func testTwitterUserFieldsV2() throws {
4650
let allCases: [TwitterUserFieldsV2] = [
4751
.createdAt,
@@ -68,6 +72,10 @@ class FieldsV2Tests: XCTestCase {
6872
)
6973
}
7074

75+
func testTwitterUserFieldsV2All() throws {
76+
XCTAssertEqual(TwitterUserFieldsV2.all.count, 14)
77+
}
78+
7179
func testTwitterPlaceFieldsV2() throws {
7280
let allCases: [TwitterPlaceFieldsV2] = [
7381
.containedWithin,
@@ -88,6 +96,10 @@ class FieldsV2Tests: XCTestCase {
8896
)
8997
}
9098

99+
func testTwitterPlaceFieldsV2All() throws {
100+
XCTAssertEqual(TwitterPlaceFieldsV2.all.count, 8)
101+
}
102+
91103
func testTwitterPollFieldsV2() throws {
92104
let allCases: [TwitterPollFieldsV2] = [
93105
.durationMinutes,
@@ -104,6 +116,9 @@ class FieldsV2Tests: XCTestCase {
104116
"duration_minutes,end_datetime,id,options,voting_status,~~"
105117
)
106118
}
119+
func testTwitterPollFieldsV2All() throws {
120+
XCTAssertEqual(TwitterPollFieldsV2.all.count, 5)
121+
}
107122

108123
func testTwitterMediaFieldsV2() throws {
109124
let allCases: [TwitterMediaFieldsV2] = [
@@ -133,6 +148,10 @@ class FieldsV2Tests: XCTestCase {
133148
)
134149
}
135150

151+
func testTwitterMediaFieldsV2All() throws {
152+
XCTAssertEqual(TwitterMediaFieldsV2.all.count, 12)
153+
}
154+
136155
func testTwitterListFieldsV2() throws {
137156
let allCases: [TwitterListFieldsV2] = [
138157
.createdAt,
@@ -153,6 +172,9 @@ class FieldsV2Tests: XCTestCase {
153172
"created_at,description,follower_count,id,member_count,name,owner_id,private,~"
154173
)
155174
}
175+
func testTwitterListFieldsV2All() throws {
176+
XCTAssertEqual(TwitterListFieldsV2.all.count, 8)
177+
}
156178

157179
func testTwitterSpaceFieldsV2() throws {
158180
let allCases: [TwitterSpaceFieldsV2] = [
@@ -182,6 +204,10 @@ class FieldsV2Tests: XCTestCase {
182204
)
183205
}
184206

207+
func testTwitterSpaceFieldsV2All() throws {
208+
XCTAssertEqual(TwitterSpaceFieldsV2.all.count, 15)
209+
}
210+
185211
func testTwitterTopicFieldsV2() throws {
186212
let allCases: [TwitterTopicFieldsV2] = [
187213
.id,
@@ -197,4 +223,8 @@ class FieldsV2Tests: XCTestCase {
197223
"description,id,name,~"
198224
)
199225
}
226+
227+
func testTwitterTopicFieldsV2All() throws {
228+
XCTAssertEqual(TwitterTopicFieldsV2.all.count, 3)
229+
}
200230
}

0 commit comments

Comments
 (0)