|
| 1 | +import Foundation |
| 2 | + |
| 3 | +/// This endpoint is only available to those users who have been approved for Academic Research access. |
| 4 | +/// https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all |
| 5 | +open class GetTweetsSearchAllRequestV2: TwitterAPIRequest { |
| 6 | + |
| 7 | + public let query: String |
| 8 | + public let endTime: Date? |
| 9 | + public let expansions: Set<TwitterTweetExpansionsV2>? |
| 10 | + public let maxResults: Int? |
| 11 | + public let mediaFields: Set<TwitterMediaFieldsV2>? |
| 12 | + public let nextToken: String? |
| 13 | + public let placeFields: Set<TwitterPlaceFieldsV2>? |
| 14 | + public let pollFields: Set<TwitterPollFieldsV2>? |
| 15 | + public let sinceID: String? |
| 16 | + public let sortOrder: TwitterSearchTweetsSortOrderV2? |
| 17 | + public let startTime: Date? |
| 18 | + public let tweetFields: Set<TwitterTweetFieldsV2>? |
| 19 | + public let untilID: String? |
| 20 | + public let userFields: Set<TwitterUserFieldsV2>? |
| 21 | + |
| 22 | + public var method: HTTPMethod { |
| 23 | + return .get |
| 24 | + } |
| 25 | + |
| 26 | + public var path: String { |
| 27 | + return "/2/tweets/search/all" |
| 28 | + } |
| 29 | + |
| 30 | + open var parameters: [String: Any] { |
| 31 | + var p = [String: Any]() |
| 32 | + p["query"] = query |
| 33 | + endTime?.bind(param: &p, for: "end_time") |
| 34 | + expansions?.bind(param: &p) |
| 35 | + maxResults.map { p["max_results"] = $0 } |
| 36 | + mediaFields?.bind(param: &p) |
| 37 | + nextToken.map { p["next_token"] = $0 } |
| 38 | + placeFields?.bind(param: &p) |
| 39 | + pollFields?.bind(param: &p) |
| 40 | + sinceID.map { p["since_id"] = $0 } |
| 41 | + sortOrder?.bind(param: &p) |
| 42 | + startTime?.bind(param: &p, for: "start_time") |
| 43 | + tweetFields?.bind(param: &p) |
| 44 | + untilID.map { p["until_id"] = $0 } |
| 45 | + userFields?.bind(param: &p) |
| 46 | + return p |
| 47 | + } |
| 48 | + |
| 49 | + public init( |
| 50 | + query: String, |
| 51 | + endTime: Date? = .none, |
| 52 | + expansions: Set<TwitterTweetExpansionsV2>? = .none, |
| 53 | + maxResults: Int? = .none, |
| 54 | + mediaFields: Set<TwitterMediaFieldsV2>? = .none, |
| 55 | + nextToken: String? = .none, |
| 56 | + placeFields: Set<TwitterPlaceFieldsV2>? = .none, |
| 57 | + pollFields: Set<TwitterPollFieldsV2>? = .none, |
| 58 | + sinceID: String? = .none, |
| 59 | + sortOrder: TwitterSearchTweetsSortOrderV2? = .none, |
| 60 | + startTime: Date? = .none, |
| 61 | + tweetFields: Set<TwitterTweetFieldsV2>? = .none, |
| 62 | + untilID: String? = .none, |
| 63 | + userFields: Set<TwitterUserFieldsV2>? = .none |
| 64 | + ) { |
| 65 | + self.query = query |
| 66 | + self.endTime = endTime |
| 67 | + self.expansions = expansions |
| 68 | + self.maxResults = maxResults |
| 69 | + self.mediaFields = mediaFields |
| 70 | + self.nextToken = nextToken |
| 71 | + self.placeFields = placeFields |
| 72 | + self.pollFields = pollFields |
| 73 | + self.sinceID = sinceID |
| 74 | + self.sortOrder = sortOrder |
| 75 | + self.startTime = startTime |
| 76 | + self.tweetFields = tweetFields |
| 77 | + self.untilID = untilID |
| 78 | + self.userFields = userFields |
| 79 | + } |
| 80 | +} |
0 commit comments