diff --git a/.gitignore b/.gitignore index 98c0265f..b50a4f88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -/.build +**/.build/ /Packages /*.xcodeproj xcuserdata/ diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..077df5a1 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,24 @@ +{ + "originHash" : "28646c95ce099a594da4055dd782bd0d0bd7f7e18fcda3479d388d8f54492a59", + "pins" : [ + { + "identity" : "swift-asn1", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-asn1.git", + "state" : { + "revision" : "a54383ada6cecde007d374f58f864e29370ba5c3", + "version" : "1.3.2" + } + }, + { + "identity" : "swift-crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-crypto.git", + "state" : { + "revision" : "e8d6eba1fef23ae5b359c46b03f7d94be2f41fed", + "version" : "3.12.3" + } + } + ], + "version" : 3 +} diff --git a/Package.swift b/Package.swift index 08fd98ca..57ff9d9e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,46 +1,125 @@ -// swift-tools-version:5.5 +// swift-tools-version: 6.1 +// The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription -// Currently, CommonCrypto and CryptoKit are not available under Linux. -// If CommonCrypto is not available, swift-crypto should be used. - -#if canImport(CommonCrypto) - internal let dependencies: [Package.Dependency] = [] - internal let tDependencies: [Target.Dependency] = [] -#else // for Linux - internal let dependencies: [Package.Dependency] = [ - .package(url: "https://github.com/apple/swift-crypto.git", from: "3.8.0") - ] - internal let tDependencies: [Target.Dependency] = [.product(name: "Crypto", package: "swift-crypto")] -#endif - -internal let package = Package( +let package = Package( name: "TwitterAPIKit", platforms: [ - .macOS(.v10_14), - .iOS(.v12), - .tvOS(.v12), - .watchOS(.v6), + .macOS(.v13), + .iOS(.v16), + .tvOS(.v16), + .watchOS(.v9), ], products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "TwitterAPIKit", targets: ["TwitterAPIKit"] ), ], - dependencies: dependencies, + dependencies: [ + .package(url: "https://github.com/apple/swift-crypto.git", from: "3.1.0"), + ], targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "TwitterAPIKit", - dependencies: tDependencies + dependencies: [ + .product(name: "Crypto", package: "swift-crypto"), + ] ), .testTarget( name: "TwitterAPIKitTests", dependencies: ["TwitterAPIKit"] ), + .executableTarget( + name: "GetUserByIdExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetUserByIdExample" + ), + .executableTarget( + name: "GetUsersByIdsExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetUsersByIdsExample" + ), + .executableTarget( + name: "GetUserByUsernameExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetUserByUsernameExample" + ), + .executableTarget( + name: "GetUsersByUsernamesExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetUsersByUsernamesExample" + ), + .executableTarget( + name: "GetAuthenticatedUserExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetAuthenticatedUserExample" + ), + .executableTarget( + name: "RetweetExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/RetweetExample" + ), + .executableTarget( + name: "GetTweetsCountsAllExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetTweetsCountsAllExample" + ), + .executableTarget( + name: "GetTweetsCountsRecentExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetTweetsCountsRecentExample" + ), + .executableTarget( + name: "GetTweetsSearchAllExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetTweetsSearchAllExample" + ), + .executableTarget( + name: "GetTweetsSearchRecentExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetTweetsSearchRecentExample" + ), + .executableTarget( + name: "GetTweetsRetweetedByExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetTweetsRetweetedByExample" + ), + .executableTarget( + name: "DeleteUsersRetweetsExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/DeleteUsersRetweetsExample" + ), + .executableTarget( + name: "GetUserTweetsExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetUserTweetsExample" + ), + .executableTarget( + name: "GetTweetExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/GetTweetExample" + ), + .executableTarget( + name: "PostTweetExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/PostTweetExample" + ), + .executableTarget( + name: "OAuth10aExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/OAuth10aExample" + ), + .executableTarget( + name: "OAuth20Example", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/OAuth20Example" + ), + .executableTarget( + name: "OAuth20RefreshExample", + dependencies: ["TwitterAPIKit"], + path: "Sources/Examples/OAuth20RefreshExample" + ), ] -) +) \ No newline at end of file diff --git a/Sources/Examples/DeleteUsersRetweetsExample/DeleteUsersRetweetsExample.swift b/Sources/Examples/DeleteUsersRetweetsExample/DeleteUsersRetweetsExample.swift new file mode 100644 index 00000000..0930b46e --- /dev/null +++ b/Sources/Examples/DeleteUsersRetweetsExample/DeleteUsersRetweetsExample.swift @@ -0,0 +1,33 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to unretweet a tweet by the authenticated user. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to unretweet a tweet +/// 3. Prints the result +@main +internal struct DeleteUsersRetweetsExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth20( + clientId: ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "", + clientSecret: ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "", + accessToken: ProcessInfo.processInfo.environment["TWITTER_ACCESS_TOKEN"] ?? "", + refreshToken: nil + ) + ) + + let userId = "YOUR_USER_ID" + let tweetId = "YOUR_TWEET_ID" + let request = DeleteUsersRetweetsRequestV2(userId: userId, tweetId: tweetId) + + do { + let response = try await client.send(request) + print("\nšŸ—‘ļø Unretweet result: \(response.data)") + } catch { + print("Error unretweeting: \(error)") + } + } +} diff --git a/Sources/Examples/GetAuthenticatedUserExample/GetAuthenticatedUserExample.swift b/Sources/Examples/GetAuthenticatedUserExample/GetAuthenticatedUserExample.swift new file mode 100644 index 00000000..b8ddeab0 --- /dev/null +++ b/Sources/Examples/GetAuthenticatedUserExample/GetAuthenticatedUserExample.swift @@ -0,0 +1,39 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve the authenticated user's profile information using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to the /2/users/me endpoint to get the current user's profile +/// 3. Includes additional data like the user's pinned tweet +/// 4. Prints the user's name, username, and their pinned tweet (if one exists) +@main +internal struct GetAuthenticatedUserExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + let meRequest = GetUsersMeRequestV2( + expansions: [.pinnedTweetID], + tweetFields: [.createdAt, .text], + userFields: [.name, .username, .profileImageUrl] + ) + + do { + let response = try await client.send(meRequest) + print("Authenticated User: \(response.data.name) (@\(response.data.username))") + if let pinnedTweet = response.includes?.tweets?.first { + print("Pinned Tweet: \(pinnedTweet.text)") + } + } catch { + print("Error retrieving authenticated user: \(error)") + } + } +} diff --git a/Sources/Examples/GetTweetExample/GetTweetExample.swift b/Sources/Examples/GetTweetExample/GetTweetExample.swift new file mode 100644 index 00000000..57481343 --- /dev/null +++ b/Sources/Examples/GetTweetExample/GetTweetExample.swift @@ -0,0 +1,83 @@ +// main.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. + +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve a specific tweet and its associated data using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to fetch a specific tweet by ID +/// 3. Includes expanded data like author information, metrics, and referenced tweets +/// 4. Prints the tweet's content, metrics (retweets, likes, replies, quotes), and author details +@main +public struct GetTweetExample { + /// Entry Point + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + let tweetId = "1931427021776908732" + + await handleRequest(client, tweetId: tweetId) + } + + private static func logResponse(_ response: GetTweetRequestV2.Response) { + print("Successfully retrieved tweet!") + print("Tweet ID: \(response.data.id)") + print("Tweet text: \(response.data.text)") + print("Created at: \(String(describing: response.data.createdAt))") + + if let metrics = response.data.publicMetrics { + print("Metrics:") + print("- Retweets: \(metrics.retweetCount)") + print("- Likes: \(metrics.likeCount)") + print("- Replies: \(metrics.replyCount)") + print("- Quotes: \(metrics.quoteCount)") + } + + if let author = response.includes?.users?.first { + print("\nAuthor:") + print("- Name: \(author.name)") + print("- Username: @\(author.username)") + } + } + + private static func handleRequest(_ client: TwitterAPISession, tweetId: String) async { + do { + let request = GetTweetRequestV2( + id: tweetId, + expansions: [ + .authorID, + .referencedTweetsID, + ], + tweetFields: [ + .createdAt, + .text, + .publicMetrics, + .entities, + ], + userFields: [ + .name, + .username, + .profileImageUrl, + ] + ) + + let response = try await client.send(request) + + logResponse(response) + + } catch { + print("Error retrieving tweet: \(error)") + } + } +} diff --git a/Sources/Examples/GetTweetsCountsAllExample/GetTweetsCountsAllExample.swift b/Sources/Examples/GetTweetsCountsAllExample/GetTweetsCountsAllExample.swift new file mode 100644 index 00000000..aad56336 --- /dev/null +++ b/Sources/Examples/GetTweetsCountsAllExample/GetTweetsCountsAllExample.swift @@ -0,0 +1,44 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve tweet counts from the last 7 days. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to count tweets matching a search query +/// 3. Specifies a time range and granularity for the counts +/// 4. Prints the tweet counts for each time period +/// Note: This endpoint requires Academic Research access. +@main +internal struct GetTweetsCountsAllExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth20( + clientId: ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "", + clientSecret: ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "", + accessToken: ProcessInfo.processInfo.environment["TWITTER_ACCESS_TOKEN"] ?? "", + refreshToken: nil + ) + ) + + let endTime = Date() + + guard let startTime = Calendar.current.date(byAdding: .day, value: -7, to: endTime) else { + throw URLError(.badURL) + } + + let request = GetTweetsCountsAllRequestV2( + query: "Twitter", + endTime: endTime, + granularity: .day, + startTime: startTime + ) + + do { + let response = try await client.send(request) + print("\nšŸ“ˆ Total Tweets: \(response.meta.totalTweetCount) npt: \(response.meta.nextToken ?? "N/A")") + } catch { + print("Error retrieving tweet counts: \(error)") + } + } +} diff --git a/Sources/Examples/GetTweetsCountsRecentExample/GetTweetsCountsRecentExample.swift b/Sources/Examples/GetTweetsCountsRecentExample/GetTweetsCountsRecentExample.swift new file mode 100644 index 00000000..4fefd37b --- /dev/null +++ b/Sources/Examples/GetTweetsCountsRecentExample/GetTweetsCountsRecentExample.swift @@ -0,0 +1,46 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve tweet counts from the last 7 days. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to count tweets matching a search query +/// 3. Specifies a time range and granularity for the counts +/// 4. Prints the tweet counts for each time period +@main +internal struct GetTweetsCountsRecentExample { + /// EntryPoint + public static func main() async throws { + // Initialize the client with your credentials + let client = TwitterAPISession( + authenticationType: .oauth20( + clientId: ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "", + clientSecret: ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "", + accessToken: ProcessInfo.processInfo.environment["TWITTER_ACCESS_TOKEN"] ?? "", + refreshToken: nil + ) + ) + + // Set up the time range (last 24 hours) + let endTime = Date() + guard let startTime = Calendar.current.date(byAdding: .hour, value: -24, to: endTime) else { + throw URLError(.badURL) + } + + // Create the request + let request = GetTweetsCountsRecentRequestV2( + query: "Swift", + endTime: endTime, + granularity: .hour, + startTime: startTime + ) + + do { + let response = try await client.send(request) + + print("\nšŸ“ˆ Total Tweets: \(response.meta.totalTweetCount)") + } catch { + print("Error retrieving tweet counts: \(error)") + } + } +} diff --git a/Sources/Examples/GetTweetsRetweetedByExample/GetTweetsRetweetedByExample.swift b/Sources/Examples/GetTweetsRetweetedByExample/GetTweetsRetweetedByExample.swift new file mode 100644 index 00000000..d95f0bb0 --- /dev/null +++ b/Sources/Examples/GetTweetsRetweetedByExample/GetTweetsRetweetedByExample.swift @@ -0,0 +1,35 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve users who retweeted a specific tweet. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to get users who retweeted a tweet +/// 3. Prints the user information +@main +internal struct GetTweetsRetweetedByExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth20( + clientId: ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "", + clientSecret: ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "", + accessToken: ProcessInfo.processInfo.environment["TWITTER_ACCESS_TOKEN"] ?? "", + refreshToken: nil + ) + ) + + let tweetId = "YOUR_TWEET_ID" + let request = GetTweetsRetweetedByRequestV2(tweetId: tweetId) + + do { + let response = try await client.send(request) + print("\nšŸ” Users who retweeted:") + for user in response.data { + print("@\(user.username) (\(user.name))") + } + } catch { + print("Error retrieving retweeters: \(error)") + } + } +} diff --git a/Sources/Examples/GetTweetsSearchAllExample/GetTweetsSearchAllExample.swift b/Sources/Examples/GetTweetsSearchAllExample/GetTweetsSearchAllExample.swift new file mode 100644 index 00000000..f731528e --- /dev/null +++ b/Sources/Examples/GetTweetsSearchAllExample/GetTweetsSearchAllExample.swift @@ -0,0 +1,46 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to search all tweets using the full-archive search endpoint. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to search tweets matching a query +/// 3. Prints the results +/// Note: This endpoint requires Academic Research access. +@main +internal struct GetTweetsSearchAllExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth20( + clientId: ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "", + clientSecret: ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "", + accessToken: ProcessInfo.processInfo.environment["TWITTER_ACCESS_TOKEN"] ?? "", + refreshToken: nil + ) + ) + + let endTime = Date() + guard let startTime = Calendar.current.date(byAdding: .day, value: -30, to: endTime) else { + throw URLError(.badURL) + } + + let request = GetTweetsSearchAllRequestV2( + query: "TwitterAPIKit", + endTime: endTime, + maxResults: 10, + startTime: startTime + ) + + do { + let response = try await client.send(request) + print("\nšŸ”Ž Search Results:") + for tweet in response.data { + print("\(tweet.id): \(tweet.text)") + } + print("\nMeta: \(response.meta)") + } catch { + print("Error searching tweets: \(error)") + } + } +} diff --git a/Sources/Examples/GetTweetsSearchRecentExample/GetTweetsSearchRecentExample.swift b/Sources/Examples/GetTweetsSearchRecentExample/GetTweetsSearchRecentExample.swift new file mode 100644 index 00000000..94e26bbf --- /dev/null +++ b/Sources/Examples/GetTweetsSearchRecentExample/GetTweetsSearchRecentExample.swift @@ -0,0 +1,38 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to search recent tweets using the recent search endpoint. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to search recent tweets matching a query +/// 3. Prints the results +@main +internal struct GetTweetsSearchRecentExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth20( + clientId: ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "", + clientSecret: ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "", + accessToken: ProcessInfo.processInfo.environment["TWITTER_ACCESS_TOKEN"] ?? "", + refreshToken: nil + ) + ) + + let request = GetTweetsSearchRecentRequestV2( + query: "Swift", + maxResults: 10 + ) + + do { + let response = try await client.send(request) + print("\nšŸ”Ž Recent Search Results:") + for tweet in response.data { + print("\(tweet.id): \(tweet.text)") + } + print("\nMeta: \(response.meta)") + } catch { + print("Error searching recent tweets: \(error)") + } + } +} diff --git a/Sources/Examples/GetUserByIdExample/GetUserByIdExample.swift b/Sources/Examples/GetUserByIdExample/GetUserByIdExample.swift new file mode 100644 index 00000000..9ae96887 --- /dev/null +++ b/Sources/Examples/GetUserByIdExample/GetUserByIdExample.swift @@ -0,0 +1,41 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve a specific user's profile by their Twitter ID using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to fetch a user's profile using their numeric ID +/// 3. Includes expanded data like their pinned tweet +/// 4. Prints the user's name, username, profile image URL, and pinned tweet (if one exists) +@main +internal struct GetUserByIdExample { + /// EntryPoint + public static func main() async throws { + let client = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + let elonMuskID = "44196397" + let userRequest = GetUserRequestV2( + id: elonMuskID, + expansions: [.pinnedTweetID], + tweetFields: [.createdAt, .text], + userFields: [.name, .username, .profileImageUrl] + ) + + do { + let response = try await client.send(userRequest) + print("User: \(response.data.name) (@\(response.data.username)) \(response.data.profileImageUrl ?? "")") + if let pinnedTweet = response.includes?.tweets?.first { + print("Pinned Tweet: \(pinnedTweet.text)") + } + } catch { + print("Error retrieving user: \(error)") + } + } +} diff --git a/Sources/Examples/GetUserByUsernameExample/GetUserByUsernameExample.swift b/Sources/Examples/GetUserByUsernameExample/GetUserByUsernameExample.swift new file mode 100644 index 00000000..751c7396 --- /dev/null +++ b/Sources/Examples/GetUserByUsernameExample/GetUserByUsernameExample.swift @@ -0,0 +1,43 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve a specific user's profile by their Twitter username using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to fetch a user's profile using their @username +/// 3. Includes expanded data like their pinned tweet +/// 4. Prints the user's name, username, and pinned tweet (if one exists) +@main +internal struct GetUserByUsernameExample { + /// EntryPoint + public static func main() async throws { + // Initialize the client with your credentials + let client = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + // Get user by username + let elonMuskUsername = "elonmusk" + let userByUsernameRequest = GetUsersByUsernameRequestV2( + username: elonMuskUsername, + expansions: [.pinnedTweetID], + tweetFields: [.createdAt, .text], + userFields: [.name, .username, .profileImageUrl] + ) + + do { + let response = try await client.send(userByUsernameRequest) + print("User: \(response.data.name) (@\(response.data.username))") + if let pinnedTweet = response.includes?.tweets?.first { + print("Pinned Tweet: \(pinnedTweet.text)") + } + } catch { + print("Error retrieving user: \(error)") + } + } +} diff --git a/Sources/Examples/GetUserTweetsExample/GetUserTweetsExample.swift b/Sources/Examples/GetUserTweetsExample/GetUserTweetsExample.swift new file mode 100644 index 00000000..a690d69f --- /dev/null +++ b/Sources/Examples/GetUserTweetsExample/GetUserTweetsExample.swift @@ -0,0 +1,71 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve a user's recent tweets using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to fetch tweets from a specific user ID +/// 3. Handles pagination through the user's tweet history +/// 4. Prints each tweet's ID, text, creation time, and pagination metadata +/// 5. Includes comprehensive error handling for common API issues +@main +internal struct GetUserTweetsExample { + /// EntryPoint + public static func main() async throws { + // Create the environment with your credentials + let simpleClient = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + // Create request to fetch tweets from your own account + let userId = ProcessInfo.processInfo.environment["TWITTER_USER_ID"] ?? "" + let request = GetUserTweetsRequestV2(userId: userId) + + do { + // Make the request + let response = try await simpleClient.send(request) + + // Print the tweets + print("\nšŸ“± User's Tweets:") + for tweet in response.data { + print("\nTweet ID: \(tweet.id)") + print("Text: \(tweet.text)") + print("Created at: \(tweet.createdAt)") + } + + // Print pagination info + print("\nšŸ“Š Meta Information:") + print("Result count: \(response.meta.resultCount)") + if let nextToken = response.meta.nextToken { + print("Next token: \(nextToken)") + } + + } catch let error as TwitterAPIError { + handleError(error: error) + } catch { + print("āŒ Error fetching tweets: \(error)") + } + } + + private static func handleError(error: TwitterAPIError) { + switch error.errorType { + case .unauthorized: + print("Authentication failed") + case .rateLimit: + print("Rate limit exceeded") + case .forbidden: + print("Access forbidden") + case .notFound: + print("Resource not found") + case .serverError: + print("Twitter API server error") + case .unknown: + print("Unknown error: \(error.localizedDescription)") + } + } +} diff --git a/Sources/Examples/GetUsersByIdsExample/GetUsersByIdsExample.swift b/Sources/Examples/GetUsersByIdsExample/GetUsersByIdsExample.swift new file mode 100644 index 00000000..cb2497ea --- /dev/null +++ b/Sources/Examples/GetUsersByIdsExample/GetUsersByIdsExample.swift @@ -0,0 +1,37 @@ +import Foundation +import TwitterAPIKit + +@main +internal struct GetUsersByIdsExample { + /// EntryPoint + public static func main() async throws { + // Initialize the client with your credentials + let client = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + // Get multiple users by IDs + let elonMuskID = "44196397" + let twitterID = "783214" + let usersRequest = GetUsersRequestV2( + ids: [elonMuskID, twitterID], + expansions: [.pinnedTweetID], + tweetFields: [.createdAt, .text], + userFields: [.name, .username, .profileImageUrl] + ) + + do { + let response = try await client.send(usersRequest) + for user in response.data { + print("User: \(user.name) (@\(user.username))") + } + } catch { + print("Error retrieving users: \(error)") + } + } +} diff --git a/Sources/Examples/GetUsersByUsernamesExample/GetUsersByUsernamesExample.swift b/Sources/Examples/GetUsersByUsernamesExample/GetUsersByUsernamesExample.swift new file mode 100644 index 00000000..570a0b6a --- /dev/null +++ b/Sources/Examples/GetUsersByUsernamesExample/GetUsersByUsernamesExample.swift @@ -0,0 +1,43 @@ +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retrieve multiple users' profiles by their Twitter usernames using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to fetch multiple users' profiles using their @usernames +/// 3. Includes expanded data like their pinned tweets +/// 4. Prints each user's name and username +@main +internal struct GetUsersByUsernamesExample { + /// EntryPoint + public static func main() async throws { + // Initialize the client with your credentials + let client = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + // Get multiple users by usernames + let elonMuskUsername = "elonmusk" + let twitterUsername = "twitter" + let usersByUsernamesRequest = GetUsersByRequestV2( + usernames: [elonMuskUsername, twitterUsername], + expansions: [.pinnedTweetID], + tweetFields: [.createdAt, .text], + userFields: [.name, .username, .profileImageUrl] + ) + + do { + let response = try await client.send(usersByUsernamesRequest) + for user in response.data { + print("User: \(user.name) (@\(user.username))") + } + } catch { + print("Error retrieving users: \(error)") + } + } +} diff --git a/Sources/Examples/OAuth10aExample/OAuth10aExample.swift b/Sources/Examples/OAuth10aExample/OAuth10aExample.swift new file mode 100644 index 00000000..3d875882 --- /dev/null +++ b/Sources/Examples/OAuth10aExample/OAuth10aExample.swift @@ -0,0 +1,190 @@ +// OAuth10aExample.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation +import TwitterAPIKit + +// swiftlint:disable function_body_length + +/// This example demonstrates the OAuth 1.0a authentication flow for Twitter API v1. +/// OAuth 1.0a is used for user authentication, allowing your application to act on behalf of a Twitter user. +/// +/// The flow consists of three main steps: +/// 1. Get a request token - This is a temporary token used to start the OAuth process +/// 2. Get user authorization - The user authorizes your application to access their account +/// 3. Get an access token - Exchange the request token for a permanent access token +/// +/// To run this example: +/// 1. Set your Twitter API credentials as environment variables: +/// export TWITTER_CONSUMER_KEY="your_consumer_key" +/// export TWITTER_CONSUMER_SECRET="your_consumer_secret" +/// 2. Run the example: swift run OAuth10aExample +/// 3. Open the authorization URL in your browser +/// 4. Authorize the application +/// 5. Enter the PIN code from the callback URL +/// +/// The example will then print your access token and secret, which you can use to make authenticated API calls. +@main +internal struct OAuth10aExample { + /// EntryPoint + public static func main() async { + do { + // Get Twitter API credentials from environment variables + let consumerKey = ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "" + let consumerSecret = ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "" + + print("Starting OAuth 1.0a flow...") + print("Using Consumer Key: \(consumerKey)") + + // Step 1: Get request token + // This is a temporary token that will be used to start the OAuth process + // We only need the consumer key and secret for this step + print("\nStep 1: Getting request token...") + let requestToken = try await getRequestToken( + consumerKey: consumerKey, + consumerSecret: consumerSecret + ) + print("Request Token: \(requestToken.oauthToken)") + + // Step 2: Get authorization URL + // This URL will be opened in the user's browser + // The user will authorize your application and get a PIN code + print("\nStep 2: Getting authorization URL...") + if let authURL = getAuthorizationURL( + consumerKey: consumerKey, + consumerSecret: consumerSecret, + requestToken: requestToken.oauthToken + ) { + print("Authorization URL: \(authURL)") + print("\nPlease open this URL in your browser and authorize the application.") + print("After authorization, you'll be redirected to your callback URL with a verifier.") + print("Enter the verifier from the callback URL:") + + // In a real application, you would handle the callback URL and get the verifier + // For this example, we'll read it from console input + guard let verifier = readLine() else { + print("No verifier provided") + return + } + + // Step 3: Get access token + // Exchange the request token and verifier for a permanent access token + // This token can be used to make authenticated API calls + print("\nStep 3: Getting access token...") + let accessToken = try await getAccessToken( + consumerKey: consumerKey, + consumerSecret: consumerSecret, + requestToken: requestToken.oauthToken, + verifier: verifier + ) + + print("\nOAuth 1.0a flow completed successfully!") + print("Access Token: \(accessToken.oauthToken)") + print("Access Token Secret: \(accessToken.oauthTokenSecret)") + if let userID = accessToken.userID { + print("User ID: \(userID)") + } + if let screenName = accessToken.screenName { + print("Screen Name: \(screenName)") + } + } else { + print("Failed to get authorization URL") + } + } catch let error as TwitterAPIError { + print("\nTwitter API Error:") + print("Error: \(error)") + } catch { + print("\nError: \(error)") + } + } + + /// Gets a request token from Twitter's OAuth endpoint. + /// This is the first step in the OAuth 1.0a flow. + /// - Parameters: + /// - consumerKey: Your Twitter API consumer key + /// - consumerSecret: Your Twitter API consumer secret + /// - Returns: A request token that can be used to start the OAuth process + private static func getRequestToken( + consumerKey: String, + consumerSecret: String, + ) async throws -> TwitterOAuthTokenV1 { + // For request token, we only need consumer credentials - NO OAuth tokens + let session = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: consumerKey, + consumerSecret: consumerSecret, + oauthToken: nil, // No OAuth token for request token + oauthTokenSecret: nil // No OAuth token secret for request token + ) + ) + + let oauthAPI = OAuth10aAPI(session: session) + let request = PostOAuthRequestTokenRequestV1(oauthCallback: "oob", xAuthAccessType: "write") + return try await oauthAPI.postOAuthRequestToken(request) + } + + /// Gets the authorization URL that the user needs to visit to authorize your application. + /// This is the second step in the OAuth 1.0a flow. + /// - Parameters: + /// - consumerKey: Your Twitter API consumer key + /// - consumerSecret: Your Twitter API consumer secret + /// - requestToken: The request token obtained from getRequestToken + /// - Returns: The URL that the user needs to visit to authorize your application + private static func getAuthorizationURL( + consumerKey: String, + consumerSecret: String, + requestToken: String + ) -> URL? { + // For authorization URL, we only need consumer credentials + let session = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: consumerKey, + consumerSecret: consumerSecret, + oauthToken: nil, // No OAuth token needed + oauthTokenSecret: nil // No OAuth token secret needed + ) + ) + + let oauthAPI = OAuth10aAPI(session: session) + let request = GetOAuthAuthorizeRequestV1(oauthToken: requestToken) + return oauthAPI.makeOAuthAuthorizeURL(request) + } + + /// Exchanges the request token and verifier for a permanent access token. + /// This is the final step in the OAuth 1.0a flow. + /// - Parameters: + /// - consumerKey: Your Twitter API consumer key + /// - consumerSecret: Your Twitter API consumer secret + /// - requestToken: The request token obtained from getRequestToken + /// - verifier: The verifier obtained from the user's authorization + /// - Returns: A permanent access token that can be used to make authenticated API calls + private static func getAccessToken( + consumerKey: String, + consumerSecret: String, + requestToken: String, + verifier: String + ) async throws -> TwitterOAuthAccessTokenV1 { + // For access token, we need both consumer credentials and request token + let session = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: consumerKey, + consumerSecret: consumerSecret, + oauthToken: requestToken, + oauthTokenSecret: nil // No request token secret needed + ) + ) + + let oauthAPI = OAuth10aAPI(session: session) + let request = PostOAuthAccessTokenRequestV1( + oauthToken: requestToken, + oauthVerifier: verifier + ) + return try await oauthAPI.postOAuthAccessToken(request) + } +} +// swiftlint:enable function_body_length diff --git a/Sources/Examples/OAuth20Example/OAuth20Example.swift b/Sources/Examples/OAuth20Example/OAuth20Example.swift new file mode 100644 index 00000000..56e88ce4 --- /dev/null +++ b/Sources/Examples/OAuth20Example/OAuth20Example.swift @@ -0,0 +1,197 @@ +// OAuth20Example.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Crypto +import Foundation +import TwitterAPIKit + +// swiftlint:disable force_unwrapping function_body_length + +/// This example demonstrates the OAuth 2.0 authentication flow for Twitter API v2. +/// OAuth 2.0 is used for user authentication, allowing your application to act on behalf of a Twitter user. +/// +/// The flow consists of three main steps: +/// 1. Generate a code challenge and verifier for PKCE +/// 2. Get user authorization - The user authorizes your application to access their account +/// 3. Get an access token - Exchange the authorization code for an access token +/// +/// To run this example: +/// 1. Set your Twitter API credentials as environment variables: +/// export TWITTER_CLIENT_ID="your_client_id" +/// export TWITTER_CLIENT_SECRET="your_client_secret" +/// export TWITTER_REDIRECT_URI="your_redirect_uri" +/// 2. Run the example: swift run OAuth20Example +/// 3. Open the authorization URL in your browser +/// 4. Authorize the application +/// 5. Enter the authorization code from the callback URL +/// +/// The example will then print your access token and refresh token, which you can use to make authenticated API calls. +@main +internal struct OAuth20Example { + /// EntryPoint + public static func main() async { + do { + // Get Twitter API credentials from environment variables + let clientId = ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "" + let clientSecret = ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "" + let redirectURI = ProcessInfo.processInfo.environment["TWITTER_REDIRECT_URI"] ?? "" + + print("Starting OAuth 2.0 flow...") + print("Using Client ID: \(clientId)") + + // Step 1: Generate PKCE challenge and verifier + print("\nStep 1: Generating PKCE challenge and verifier...") + let codeVerifier = generateCodeVerifier() + let codeChallenge = codeVerifier + print("Code Verifier: \(codeVerifier)") + print("Code Challenge: \(codeChallenge)") + + // Generate a random state for security + let state = generateRandomState() + print("State: \(state)") + + // Step 2: Get authorization URL + print("\nStep 2: Getting authorization URL...") + if let authURL = getAuthorizationURL( + clientId: clientId, + redirectURI: redirectURI, + codeChallenge: codeChallenge, + state: state + ) { + print("Authorization URL: \(authURL)") + print("\nPlease open this URL in your browser and authorize the application.") + print("Enter the authorization code from the callback URL:") + + // In a real application, you would handle the callback URL and get the code + // For this example, we'll read it from console input + guard let code = readLine() else { + print("No authorization code provided") + return + } + + // Step 3: Get access token + print("\nStep 3: Getting access token...") + let accessToken = try await getAccessToken( + clientId: clientId, + clientSecret: clientSecret, + redirectURI: redirectURI, + code: code, + codeVerifier: codeVerifier + ) + + print("\nOAuth 2.0 flow completed successfully!") + print("Access Token: \(accessToken.accessToken)") + print("Token Type: \(accessToken.tokenType)") + print("Expires In: \(accessToken.expiresIn) seconds") + print("Scope: \(accessToken.scope.joined(separator: " "))") + if let refreshToken = accessToken.refreshToken { + print("Refresh Token: \(refreshToken)") + } + } else { + print("Failed to get authorization URL") + } + } catch let error as TwitterAPIError { + print("\nTwitter API Error:") + print("Error: \(error)") + } catch { + print("\nError: \(error)") + } + } + + /// Generates a random code verifier for PKCE. + /// - Returns: A random string suitable for use as a code verifier + private static func generateCodeVerifier() -> String { + // Generate a very short verifier (8 characters) + let allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + let length = 8 + let verifier = String((0.. String { + let allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + let length = 32 + return String((0.. URL? { + let session = TwitterAPISession( + authenticationType: .oauth20( + clientId: clientId, + clientSecret: "", // Not needed for authorization URL + accessToken: "", // Not needed for authorization URL + refreshToken: nil // Not needed for authorization URL + ) + ) + + let oauthAPI = OAuth20API(session: session) + let request = GetOAuth2AuthorizeRequestV1( + clientID: clientId, + redirectURI: redirectURI, + state: state, + codeChallenge: codeChallenge, + codeChallengeMethod: "plain", + scopes: [.tweetRead] + ) + return oauthAPI.makeOAuth2AuthorizeURL(request) + } + + /// Exchanges the authorization code for an access token. + /// This is the final step in the OAuth 2.0 flow. + /// - Parameters: + /// - clientId: Your Twitter API client ID + /// - clientSecret: Your Twitter API client secret + /// - redirectURI: The URI that Twitter will redirect to after authorization + /// - code: The authorization code obtained from the user's authorization + /// - codeVerifier: The PKCE code verifier + /// - Returns: An access token that can be used to make authenticated API calls + private static func getAccessToken( + clientId: String, + clientSecret: String, + redirectURI: String, + code: String, + codeVerifier: String + ) async throws -> TwitterOAuth2AccessToken { + let session = TwitterAPISession( + authenticationType: .oauth20( + clientId: clientId, + clientSecret: clientSecret, + accessToken: "", // Not needed for token request + refreshToken: nil // Not needed for token request + ) + ) + + let oauthAPI = OAuth20API(session: session) + let request = PostOAuth2AccessTokenRequestV2( + code: code, + clientID: clientId, // Include client ID for public client + redirectURI: redirectURI, + codeVerifier: codeVerifier + ) + return try await oauthAPI.postOAuth2AccessToken(request) + } +} +// swiftlint:enable force_unwrapping function_body_length diff --git a/Sources/Examples/OAuth20RefreshExample/OAuth20RefreshExample.swift b/Sources/Examples/OAuth20RefreshExample/OAuth20RefreshExample.swift new file mode 100644 index 00000000..6dddcd92 --- /dev/null +++ b/Sources/Examples/OAuth20RefreshExample/OAuth20RefreshExample.swift @@ -0,0 +1,88 @@ +// OAuth20RefreshExample.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation +import TwitterAPIKit + +/// This example demonstrates how to refresh an OAuth 2.0 access token using a refresh token. +/// When an access token expires, you can use the refresh token to get a new access token +/// without requiring the user to re-authorize your application. +/// +/// To run this example: +/// 1. Set your Twitter API credentials as environment variables: +/// export TWITTER_CLIENT_ID="your_client_id" +/// export TWITTER_CLIENT_SECRET="your_client_secret" +/// export TWITTER_REFRESH_TOKEN="your_refresh_token" +/// 2. Run the example: swift run OAuth20RefreshExample +/// +/// The example will then print your new access token and refresh token. +@main +internal struct OAuth20RefreshExample { + /// EntryPoint + public static func main() async { + do { + // Get Twitter API credentials from environment variables + let clientId = ProcessInfo.processInfo.environment["TWITTER_CLIENT_ID"] ?? "" + let clientSecret = ProcessInfo.processInfo.environment["TWITTER_CLIENT_SECRET"] ?? "" + let refreshToken = ProcessInfo.processInfo.environment["TWITTER_REFRESH_TOKEN"] ?? "" + + print("Starting OAuth 2.0 token refresh...") + print("Using Client ID: \(clientId)") + + // Refresh the access token + print("\nRefreshing access token...") + let newTokens = try await refreshAccessToken( + clientId: clientId, + clientSecret: clientSecret, + refreshToken: refreshToken + ) + + print("\nToken refresh completed successfully!") + print("New Access Token: \(newTokens.accessToken)") + print("Token Type: \(newTokens.tokenType)") + print("Expires In: \(newTokens.expiresIn) seconds") + print("Scope: \(newTokens.scope.joined(separator: " "))") + if let newRefreshToken = newTokens.refreshToken { + print("New Refresh Token: \(newRefreshToken)") + } + } catch let error as TwitterAPIError { + print("\nTwitter API Error:") + print("Error: \(error)") + } catch { + print("\nError: \(error)") + } + } + + /// Refreshes an expired access token using a refresh token. + /// - Parameters: + /// - clientId: Your Twitter API client ID + /// - clientSecret: Your Twitter API client secret + /// - refreshToken: The refresh token obtained from the initial OAuth 2.0 flow + /// - Returns: A new access token and refresh token + private static func refreshAccessToken( + clientId: String, + clientSecret: String, + refreshToken: String + ) async throws -> TwitterOAuth2AccessToken { + let session = TwitterAPISession( + authenticationType: .oauth20( + clientId: clientId, + clientSecret: clientSecret, + accessToken: "", // Not needed for refresh + refreshToken: nil // Not needed for refresh + ) + ) + + let oauthAPI = OAuth20API(session: session) + let request = PostOAuth2RefreshTokenRequestV2( + refreshToken: refreshToken, + clientID: clientId + ) + return try await oauthAPI.postOAuth2RefreshToken(request) + } +} diff --git a/Sources/Examples/PostTweetExample/PostTweetExample.swift b/Sources/Examples/PostTweetExample/PostTweetExample.swift new file mode 100644 index 00000000..f92400ae --- /dev/null +++ b/Sources/Examples/PostTweetExample/PostTweetExample.swift @@ -0,0 +1,44 @@ +// PostTweetExample.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. + +import Foundation +import TwitterAPIKit + +/// Demonstrates how to post a new tweet using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to create a new tweet with specified text +/// 3. Prints the newly created tweet's ID and content upon success +/// 4. Includes error handling for failed tweet creation +@main +internal struct PostTweetExample { + /// EntryPoint + public static func main() async throws { + // Create the environment with your credentials + let simpleClient = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + // The text of the tweet you want to post + let tweetText = "Hello, Twitter! This is a test tweet from TwitterAPIKit." + + do { + // Create and send the tweet request + let request = PostTweetsRequestV2(text: tweetText) + let response = try await simpleClient.send(request) + + print("Successfully posted tweet!") + print("Tweet ID: \(response.data.id)") + print("Tweet text: \(response.data.text)") + } catch { + print("Error posting tweet: \(error)") + } + } +} diff --git a/Sources/Examples/RetweetExample/RetweetExample.swift b/Sources/Examples/RetweetExample/RetweetExample.swift new file mode 100644 index 00000000..f44d2e77 --- /dev/null +++ b/Sources/Examples/RetweetExample/RetweetExample.swift @@ -0,0 +1,43 @@ +// RetweetExample.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. + +import Foundation +import TwitterAPIKit + +/// Demonstrates how to retweet a specific tweet using Twitter API v2. +/// This example: +/// 1. Creates a Twitter API client using environment variables for authentication +/// 2. Makes a request to retweet a specific tweet using user ID and tweet ID +/// 3. Prints confirmation of the retweet action and its status +/// 4. Includes error handling for failed retweet attempts +@main +internal struct RetweetExample { + /// EntryPoint + public static func main() async throws { + // Create the environment with your credentials + let simpleClient = TwitterAPISession( + authenticationType: .oauth10a( + consumerKey: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_KEY"] ?? "", + consumerSecret: ProcessInfo.processInfo.environment["TWITTER_CONSUMER_SECRET"] ?? "", + oauthToken: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN"] ?? "", + oauthTokenSecret: ProcessInfo.processInfo.environment["TWITTER_OAUTH_TOKEN_SECRET"] ?? "" + ) + ) + + let userId = ProcessInfo.processInfo.environment["TWITTER_USER_ID"] ?? "" + let tweetId = ProcessInfo.processInfo.environment["TWITTER_TWEET_ID"] ?? "" + + do { + // Create and send the retweet request + let request = PostUsersRetweetsRequestV2(userId: userId, tweetId: tweetId) + let response = try await simpleClient.send(request) + + print("Successfully retweeted tweet with ID: \(tweetId)") + print("Retweeted: \(response.data.retweeted)") + } catch { + print("Error retweeting: \(error)") + } + } +} diff --git a/Sources/TwitterAPIKit/APIv1/Account/AccountAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Account/AccountAPIv1.swift deleted file mode 100644 index 6c1e4194..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/AccountAPIv1.swift +++ /dev/null @@ -1,78 +0,0 @@ -// AccountAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class AccountAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/get-account-settings - public func getAccountSetting( - _ request: GetAccountSettingsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/get-account-verify_credentials - public func getAccountVerify( - _ request: GetAccountVerifyCredentialsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-account-remove_profile_banner - public func postRemoveProfileBanner( - _ request: PostAccountRemoveProfileBannerRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-account-settings - public func postAccountSettings( - _ request: PostAccountSettingsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-account-update_profile - public func postAccountProfile( - _ request: PostAccountUpdateProfileRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-account-update_profile_banner - public func postProfileBanner( - _ request: PostAccountUpdateProfileBannerRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-account-update_profile_image - public func postProfileImage( - _ request: PostAccountUpdateProfileImageRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/GetAccountSettingsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/GetAccountSettingsRequestV1.swift deleted file mode 100644 index fa791c33..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/GetAccountSettingsRequestV1.swift +++ /dev/null @@ -1,32 +0,0 @@ -// GetAccountSettingsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/get-account-settings -open class GetAccountSettingsRequestV1: TwitterAPIRequest { - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/account/settings.json" - } - - open var parameters: [String: Any] { - [:] - } - - public init() {} - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/GetAccountVerifyCredentialsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/GetAccountVerifyCredentialsRequestV1.swift deleted file mode 100644 index 96cf97da..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/GetAccountVerifyCredentialsRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetAccountVerifyCredentialsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/get-account-verify_credentials -open class GetAccountVerifyCredentialsRequestV1: TwitterAPIRequest { - public let skipStatus: Bool? - public let includeEmail: Bool? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/account/verify_credentials.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - skipStatus.map { params["skip_status"] = $0 } - includeEmail.map { params["include_email"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - skipStatus: Bool? = .none, - includeEmail: Bool? = .none, - includeEntities: Bool? = .none - ) { - self.skipStatus = skipStatus - self.includeEmail = includeEmail - self.includeEntities = includeEntities - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountRemoveProfileBannerRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountRemoveProfileBannerRequestV1.swift deleted file mode 100644 index 5cd1fda0..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountRemoveProfileBannerRequestV1.swift +++ /dev/null @@ -1,32 +0,0 @@ -// PostAccountRemoveProfileBannerRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-account-remove_profile_banner -open class PostAccountRemoveProfileBannerRequestV1: TwitterAPIRequest { - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/account/remove_profile_banner.json" - } - - open var parameters: [String: Any] { - [:] - } - - public init() {} - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountSettingsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountSettingsRequestV1.swift deleted file mode 100644 index 7e637dd9..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountSettingsRequestV1.swift +++ /dev/null @@ -1,65 +0,0 @@ -// PostAccountSettingsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-account-settings -open class PostAccountSettingsRequestV1: TwitterAPIRequest { - /// two letter ISO 639-1 - public let lang: String? - /// RailsTimeZone - public let timeZone: String? - /// ISO 8601 (00-23) - public let startSleepTime: Int? - /// ISO 8601 (00-23) - public let endSleepTime: Int? - - public let sleepTimeEnabled: Bool? - public let trendLocationWoeid: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/account/settings.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - lang.map { params["lang"] = $0 } - timeZone.map { params["time_zone"] = $0 } - startSleepTime.map { params["start_sleep_time"] = $0 } - endSleepTime.map { params["end_sleep_time"] = $0 } - sleepTimeEnabled.map { params["sleep_time_enabled"] = $0 } - trendLocationWoeid.map { params["trend_location_woeid"] = $0 } - return params - } - - public init( - lang: String? = .none, - timeZone: String? = .none, - startSleepTime: Int? = .none, - endSleepTime: Int? = .none, - sleepTimeEnabled: Bool? = .none, - trendLocationWoeid: String? = .none - ) { - self.lang = lang - self.timeZone = timeZone - self.startSleepTime = startSleepTime - self.endSleepTime = endSleepTime - self.sleepTimeEnabled = sleepTimeEnabled - self.trendLocationWoeid = trendLocationWoeid - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileBannerRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileBannerRequestV1.swift deleted file mode 100644 index cce023c5..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileBannerRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// PostAccountUpdateProfileBannerRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-account-update_profile_banner -open class PostAccountUpdateProfileBannerRequestV1: TwitterAPIRequest { - public let banner: Data - public let width: Int? - public let height: Int? - public let offsetTop: Int? - public let offsetLeft: Int? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/account/update_profile_banner.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["banner"] = banner.base64EncodedString() - width.map { params["width"] = $0 } - height.map { params["height"] = $0 } - offsetTop.map { params["offset_top"] = $0 } - offsetLeft.map { params["offset_left"] = $0 } - return params - } - - public init( - banner: Data, - width: Int? = .none, - height: Int? = .none, - offsetTop: Int? = .none, - offsetLeft: Int? = .none - ) { - self.banner = banner - self.width = width - self.height = height - self.offsetTop = offsetTop - self.offsetLeft = offsetLeft - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileImageRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileImageRequestV1.swift deleted file mode 100644 index 0b1c702c..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileImageRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostAccountUpdateProfileImageRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-account-update_profile_image -open class PostAccountUpdateProfileImageRequestV1: TwitterAPIRequest { - public let image: Data - public let skipStatus: Bool? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/account/update_profile_image.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["image"] = image.base64EncodedString() - skipStatus.map { params["skip_status"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - image: Data, - skipStatus: Bool? = .none, - includeEntities: Bool? = .none - ) { - self.image = image - self.skipStatus = skipStatus - self.includeEntities = includeEntities - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileRequestV1.swift deleted file mode 100644 index 0c463c1d..00000000 --- a/Sources/TwitterAPIKit/APIv1/Account/Requests/PostAccountUpdateProfileRequestV1.swift +++ /dev/null @@ -1,65 +0,0 @@ -// PostAccountUpdateProfileRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-account-update_profile -open class PostAccountUpdateProfileRequestV1: TwitterAPIRequest { - public let url: String? - public let name: String? - public let location: String? - public let skipStatus: Bool? - public let description: String? - public let includeEntities: Bool? - /// ex) F00 , FF0000 - public let profileLinkColor: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/account/update_profile.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - url.map { params["url"] = $0 } - name.map { params["name"] = $0 } - location.map { params["location"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - description.map { params["description"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - profileLinkColor.map { params["profile_link_color"] = $0 } - return params - } - - public init( - url: String? = .none, - name: String? = .none, - location: String? = .none, - skipStatus: Bool? = .none, - description: String? = .none, - includeEntities: Bool? = .none, - profileLinkColor: String? = .none - ) { - self.url = url - self.name = name - self.location = location - self.skipStatus = skipStatus - self.description = description - self.includeEntities = includeEntities - self.profileLinkColor = profileLinkColor - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Application/ApplicationAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Application/ApplicationAPIv1.swift deleted file mode 100644 index 0383f7ba..00000000 --- a/Sources/TwitterAPIKit/APIv1/Application/ApplicationAPIv1.swift +++ /dev/null @@ -1,24 +0,0 @@ -// ApplicationAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class ApplicationAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/ - /// rate-limit-status/api-reference/get-application-rate_limit_status - public func getRateLimit( - _ request: GetApplicationRateLimitStatusRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Application/Requests/GetApplicationRateLimitStatusRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Application/Requests/GetApplicationRateLimitStatusRequestV1.swift deleted file mode 100644 index 6aeeba15..00000000 --- a/Sources/TwitterAPIKit/APIv1/Application/Requests/GetApplicationRateLimitStatusRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetApplicationRateLimitStatusRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/ -/// rate-limit-status/api-reference/get-application-rate_limit_status -open class GetApplicationRateLimitStatusRequestV1: TwitterAPIRequest { - public let resources: [String]? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/application/rate_limit_status.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - resources.map { params["resources"] = $0.joined(separator: ",") } - return params - } - - public init( - resources: [String]? = .none - ) { - self.resources = resources - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/BlockAndMuteAPIv1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/BlockAndMuteAPIv1.swift deleted file mode 100644 index 217b4113..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/BlockAndMuteAPIv1.swift +++ /dev/null @@ -1,96 +0,0 @@ -// BlockAndMuteAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class BlockAndMuteAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/get-blocks-ids - public func getBlockIDs( - _ request: GetBlocksIDsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/get-blocks-list - public func getBlockUsers( - _ request: GetBlocksListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/get-mutes-users-ids - public func getMuteIDs( - _ request: GetMutesUsersIDsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/get-mutes-users-list - public func getMuteUsers( - _ request: GetMutesUsersListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/post-blocks-create - public func postBlockUser( - _ request: PostBlocksCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/post-blocks-destroy - public func postUnblockUser( - _ request: PostBlocksDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/post-mutes-users-create - public func postMuteUser( - _ request: PostMutesUsersCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/post-mutes-users-destroy - public func postUnmuteUser( - _ request: PostMutesUsersDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ - /// api-reference/post-users-report_spam - public func postReportSpam( - _ request: PostUsersReportSpamRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetBlocksIDsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetBlocksIDsRequestV1.swift deleted file mode 100644 index d867745d..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetBlocksIDsRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetBlocksIDsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/get-blocks-ids -open class GetBlocksIDsRequestV1: TwitterAPIRequest { - public let stringifyIDs: Bool? - public let cursor: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/blocks/ids.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - stringifyIDs.map { params["stringify_ids"] = $0 } - cursor.map { params["cursor"] = $0 } - return params - } - - public init( - stringifyIDs: Bool? = .none, - cursor: String? = .none - ) { - self.stringifyIDs = stringifyIDs - self.cursor = cursor - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetBlocksListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetBlocksListRequestV1.swift deleted file mode 100644 index e633c9a7..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetBlocksListRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetBlocksListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/get-blocks-list -open class GetBlocksListRequestV1: TwitterAPIRequest { - public let includeEntities: Bool? - public let skipStatus: Bool? - public let cursor: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/blocks/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - cursor.map { params["cursor"] = $0 } - return params - } - - public init( - includeEntities: Bool? = .none, - skipStatus: Bool? = .none, - cursor: String? = .none - ) { - self.includeEntities = includeEntities - self.skipStatus = skipStatus - self.cursor = cursor - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetMutesUsersIDsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetMutesUsersIDsRequestV1.swift deleted file mode 100644 index c085eae3..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetMutesUsersIDsRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetMutesUsersIDsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/get-mutes-users-ids -open class GetMutesUsersIDsRequestV1: TwitterAPIRequest { - public let stringifyIDs: Bool? - public let cursor: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/mutes/users/ids.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - stringifyIDs.map { params["stringify_ids"] = $0 } - cursor.map { params["cursor"] = $0 } - return params - } - - public init( - stringifyIDs: Bool? = .none, - cursor: String? = .none - ) { - self.stringifyIDs = stringifyIDs - self.cursor = cursor - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetMutesUsersListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetMutesUsersListRequestV1.swift deleted file mode 100644 index 4184b484..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/GetMutesUsersListRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetMutesUsersListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/get-mutes-users-list -open class GetMutesUsersListRequestV1: TwitterAPIRequest { - public let cursor: String? - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/mutes/users/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - cursor.map { params["cursor"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - cursor: String? = .none, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.cursor = cursor - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostBlocksCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostBlocksCreateRequestV1.swift deleted file mode 100644 index e914601d..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostBlocksCreateRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostBlocksCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/post-blocks-create -open class PostBlocksCreateRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/blocks/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.user = user - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostBlocksDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostBlocksDestroyRequestV1.swift deleted file mode 100644 index 50a54659..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostBlocksDestroyRequestV1.swift +++ /dev/null @@ -1,49 +0,0 @@ -// PostBlocksDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/post-blocks-destroy -open class PostBlocksDestroyRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/blocks/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - - user.bind(param: ¶ms) - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.user = user - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostMutesUsersCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostMutesUsersCreateRequestV1.swift deleted file mode 100644 index 88cf3b3d..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostMutesUsersCreateRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostMutesUsersCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/post-mutes-users-create -open class PostMutesUsersCreateRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/mutes/users/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - return params - } - - public init( - user: TwitterUserIdentifierV1 - ) { - self.user = user - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostMutesUsersDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostMutesUsersDestroyRequestV1.swift deleted file mode 100644 index a70529d4..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostMutesUsersDestroyRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostMutesUsersDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/ -/// api-reference/post-mutes-users-destroy -open class PostMutesUsersDestroyRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/mutes/users/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - return params - } - - public init( - user: TwitterUserIdentifierV1 - ) { - self.user = user - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostUsersReportSpamRequestV1.swift b/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostUsersReportSpamRequestV1.swift deleted file mode 100644 index e1d54086..00000000 --- a/Sources/TwitterAPIKit/APIv1/BlockAndMute/Requests/PostUsersReportSpamRequestV1.swift +++ /dev/null @@ -1,34 +0,0 @@ -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// mute-block-report-users/api-reference/post-users-report_spam -open class PostUsersReportSpamRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let performBlock: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/users/report_spam.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - performBlock.map { params["perform_block"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - performBlock: Bool? = .none - ) { - self.user = user - self.performBlock = performBlock - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/CollectionAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Collection/CollectionAPIv1.swift deleted file mode 100644 index 2d43dacf..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/CollectionAPIv1.swift +++ /dev/null @@ -1,105 +0,0 @@ -// CollectionAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class CollectionAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/get-collections-entries - public func getCollectionEntries( - _ request: GetCollectionsEntriesRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/get-collections-list - public func getCollections( - _ request: GetCollectionsListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/get-collections-show - public func getCollection( - _ request: GetCollectionsShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-create - public func postCreateCollection( - _ request: PostCollectionsCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-destroy - public func postDestroyCollection( - _ request: PostCollectionsDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-entries-add - public func postCollectionAddEntry( - _ request: PostCollectionsEntriesAddRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-entries-curate - public func postCollectionCurate( - _ request: PostCollectionsEntriesCurateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-entries-move - public func postCollectionMoveEntry( - _ request: PostCollectionsEntriesMoveRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-entries-remove - public func postCollectionRemoveEntry( - _ request: PostCollectionsEntriesRemoveRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/ - /// api-reference/post-collections-update - public func postCollectionUpdate( - _ request: PostCollectionsUpdateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsEntriesRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsEntriesRequestV1.swift deleted file mode 100644 index 6358b4ee..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsEntriesRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetCollectionsEntriesRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/get-collections-entries -open class GetCollectionsEntriesRequestV1: TwitterAPIRequest { - public let id: String - public let count: Int? - public let maxPosition: String? - public let minPosition: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/collections/entries.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - count.map { params["count"] = $0 } - maxPosition.map { params["max_position"] = $0 } - minPosition.map { params["min_position"] = $0 } - return params - } - - public init( - id: String, - count: Int? = .none, - maxPosition: String? = .none, - minPosition: String? = .none - ) { - self.id = id - self.count = count - self.maxPosition = maxPosition - self.minPosition = minPosition - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsListRequestV1.swift deleted file mode 100644 index 7c1e83c3..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsListRequestV1.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetCollectionsListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/api-reference/get-collections-list -open class GetCollectionsListRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - public let tweetID: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/collections/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - tweetID.map { params["tweet_id"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - tweetID: String? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsShowRequestV1.swift deleted file mode 100644 index 7227d336..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/GetCollectionsShowRequestV1.swift +++ /dev/null @@ -1,38 +0,0 @@ -// GetCollectionsShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/api-reference/get-collections-show -open class GetCollectionsShowRequestV1: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/collections/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - return params - } - - public init( - id: String - ) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsCreateRequestV1.swift deleted file mode 100644 index ae4b6983..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsCreateRequestV1.swift +++ /dev/null @@ -1,62 +0,0 @@ -// PostCollectionsCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-create -open class PostCollectionsCreateRequestV1: TwitterAPIRequest { - public enum TimelineOrder: String { - case curationReverseChron = "curation_reverse_chron" - case tweetChron = "tweet_chron" - case tweetReverseChron = "tweet_reverse_chron" - - public func bind(param: inout [String: Any]) { - param["timeline_order"] = rawValue - } - } - - public let name: String - public let url: String? - public let description: String? - public let timelineOrder: TimelineOrder? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["name"] = name - url.map { params["url"] = $0 } - description.map { params["description"] = $0 } - timelineOrder?.bind(param: ¶ms) - return params - } - - public init( - name: String, - url: String? = .none, - description: String? = .none, - timelineOrder: TimelineOrder? = .none - ) { - self.name = name - self.url = url - self.description = description - self.timelineOrder = timelineOrder - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsDestroyRequestV1.swift deleted file mode 100644 index c8ed255b..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsDestroyRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostCollectionsDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-destroy -open class PostCollectionsDestroyRequestV1: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - return params - } - - public init( - id: String - ) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesAddRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesAddRequestV1.swift deleted file mode 100644 index c79662d1..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesAddRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostCollectionsEntriesAddRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-entries-add -open class PostCollectionsEntriesAddRequestV1: TwitterAPIRequest { - public let id: String - public let tweetID: String - public let above: Bool? - public let relativeTo: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/entries/add.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - params["tweet_id"] = tweetID - above.map { params["above"] = $0 } - relativeTo.map { params["relative_to"] = $0 } - return params - } - - public init( - id: String, - tweetID: String, - above: Bool? = .none, - relativeTo: String? = .none - ) { - self.id = id - self.tweetID = tweetID - self.above = above - self.relativeTo = relativeTo - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesCurateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesCurateRequestV1.swift deleted file mode 100644 index b7d5b8b6..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesCurateRequestV1.swift +++ /dev/null @@ -1,62 +0,0 @@ -// PostCollectionsEntriesCurateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-entries-curate -open class PostCollectionsEntriesCurateRequestV1: TwitterAPIRequest { - public enum Operation { - case add(tweetID: String) - case remove(tweetID: String) - - public var keyValue: [String: String] { - switch self { - case let .add(tweetID): - ["op": "add", "tweet_id": tweetID] - case let .remove(tweetID): - ["op": "remove", "tweet_id": tweetID] - } - } - } - - public let id: String - public let changes: [Operation] - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/entries/curate.json" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - params["changes"] = changes.map(\.keyValue) - return params - } - - public init( - id: String, - changes: [Operation] - ) { - self.id = id - self.changes = changes - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesMoveRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesMoveRequestV1.swift deleted file mode 100644 index 801fa46a..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesMoveRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostCollectionsEntriesMoveRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-entries-move -open class PostCollectionsEntriesMoveRequestV1: TwitterAPIRequest { - public let id: String - public let tweetID: String - public let above: Bool? - public let relativeTo: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/entries/move.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - params["tweet_id"] = tweetID - above.map { params["above"] = $0 } - params["relative_to"] = relativeTo - return params - } - - public init( - id: String, - tweetID: String, - above: Bool? = .none, - relativeTo: String - ) { - self.id = id - self.tweetID = tweetID - self.above = above - self.relativeTo = relativeTo - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesRemoveRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesRemoveRequestV1.swift deleted file mode 100644 index 24844ee0..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsEntriesRemoveRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostCollectionsEntriesRemoveRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-entries-remove -open class PostCollectionsEntriesRemoveRequestV1: TwitterAPIRequest { - public let id: String - public let tweetID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/entries/remove.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - params["tweet_id"] = tweetID - return params - } - - public init( - id: String, - tweetID: String - ) { - self.id = id - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsUpdateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsUpdateRequestV1.swift deleted file mode 100644 index 58121c33..00000000 --- a/Sources/TwitterAPIKit/APIv1/Collection/Requests/PostCollectionsUpdateRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostCollectionsUpdateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// curate-a-collection/api-reference/post-collections-update -open class PostCollectionsUpdateRequestV1: TwitterAPIRequest { - public let id: String - public let url: String? - public let name: String? - public let description: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/collections/update.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - url.map { params["url"] = $0 } - name.map { params["name"] = $0 } - description.map { params["description"] = $0 } - return params - } - - public init( - id: String, - url: String? = .none, - name: String? = .none, - description: String? = .none - ) { - self.id = id - self.url = url - self.name = name - self.description = description - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/DirectMessageAPIv1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/DirectMessageAPIv1.swift deleted file mode 100644 index 93d9a5fa..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/DirectMessageAPIv1.swift +++ /dev/null @@ -1,69 +0,0 @@ -// DirectMessageAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class DirectMessageAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ - /// sending-and-receiving/api-reference/new-event - public func postDirectMessage( - _ request: PostDirectMessageRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ - /// sending-and-receiving/api-reference/delete-message-event - public func deleteDirectMessage( - _ request: DeleteDirectMessageRequestV1 - ) -> TwitterAPISessionDataTask { // 204 - No Content - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ - /// sending-and-receiving/api-reference/get-event - public func getDirectMessage( - _ request: GetDirectMessageRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ - /// sending-and-receiving/api-reference/list-events - public func getDirectMessageList( - _ request: GetDirectMessageListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ - /// typing-indicator-and-read-receipts/api-reference/new-read-receipt - public func postDirectMessageMarkRead( - _ request: PostDirectMessagesMarkReadRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ - /// typing-indicator-and-read-receipts/api-reference/new-typing-indicator - public func postDirectMessageTypingIndicator( - _ request: PostDirectMessagesIndicateTypingRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/DeleteDirectMessageRequestV1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/DeleteDirectMessageRequestV1.swift deleted file mode 100644 index 952ee064..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/DeleteDirectMessageRequestV1.swift +++ /dev/null @@ -1,38 +0,0 @@ -// DeleteDirectMessageRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ -/// sending-and-receiving/api-reference/delete-message-event -open class DeleteDirectMessageRequestV1: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/1.1/direct_messages/events/destroy.json" - } - - open var parameters: [String: Any] { - [ - "id": id, - ] - } - - public init(id: String) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/GetDirectMessageListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/GetDirectMessageListRequestV1.swift deleted file mode 100644 index 10d48ecb..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/GetDirectMessageListRequestV1.swift +++ /dev/null @@ -1,42 +0,0 @@ -// GetDirectMessageListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/list-events -open class GetDirectMessageListRequestV1: TwitterAPIRequest { - /// Max: 50 - public let count: Int? - public let cursor: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/direct_messages/events/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - - return params - } - - public init(count: Int? = .none, cursor: String? = .none) { - self.count = count - self.cursor = cursor - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/GetDirectMessageRequestV1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/GetDirectMessageRequestV1.swift deleted file mode 100644 index b5db0a6f..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/GetDirectMessageRequestV1.swift +++ /dev/null @@ -1,35 +0,0 @@ -// GetDirectMessageRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/get-event - -open class GetDirectMessageRequestV1: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/direct_messages/events/show.json" - } - - open var parameters: [String: Any] { - ["id": id] - } - - public init(id: String) { - self.id = id - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessageRequestV1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessageRequestV1.swift deleted file mode 100644 index 5b08ae70..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessageRequestV1.swift +++ /dev/null @@ -1,156 +0,0 @@ -// PostDirectMessageRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/new-event -open class PostDirectMessageRequestV1: TwitterAPIRequest { - public enum Attachment { - public enum Location { - case coordinate(TwitterCoordinateV1) - case place(String /* Place ID */ ) - } - - case media(String /* Media ID */ ) - - /** - If you attach a Location, it will probably return the following error for unknown reasons. - ``` - { - "errors" : [ - { - "message" : "event.message_create.message_data.attachment: unknown type location", - "code" : 214 - } - ] - } - ``` - */ - case location(Location) - - public var parameter: [String: Any] { - switch self { - case let .media(mediaID): - [ - "type": "media", - "media": ["id": mediaID], - ] - case let .location(.coordinate(coordinate)): - [ - "type": "location", - "location": [ - "type": "shared_coordinate", - "shared_coordinate": [ - "coordinates": [ - "type": "Point", - "coordinates": [coordinate.lat, coordinate.long], - ], - ], - ], - ] - case let .location(.place(placeID)): - [ - "type": "location", - "location": [ - "type": "shared_place", - "shared_place": [ - "place": [ - "id": placeID, - ], - ], - ], - ] - } - } - } - - public struct QuickReplyOption { - public let label: String - public let description: String - public let metadata: String - - public init( - label: String, - description: String, - metadata: String - ) { - self.label = label - self.description = description - self.metadata = metadata - } - - public var parameter: [String: String] { - [ - "label": label, - "description": description, - "metadata": metadata, - ] - } - } - - /// message_create.target.recipient_id - public let targetUserID: String - /// message_create.message_data.text - public let message: String - public let attachment: Attachment? - public let quickReplyOptions: [QuickReplyOption]? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/direct_messages/events/new.json" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var messageData: [String: Any] = [ - "text": message, - ] - - attachment.map { messageData["attachment"] = $0.parameter } - quickReplyOptions.map { - messageData["quick_reply"] = [ - "type": "options", - "options": $0.map(\.parameter), - ] - } - - return [ - "event": [ - "type": "message_create", - "message_create": [ - "target": [ - "recipient_id": targetUserID, - ], - "message_data": messageData, - ], - ], - ] - } - - public init( - targetUserID: String, - message: String, - attachment: Attachment? = .none, - quickReplyOptions: [QuickReplyOption]? = .none - ) { - self.targetUserID = targetUserID - self.message = message - self.attachment = attachment - self.quickReplyOptions = quickReplyOptions - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessagesIndicateTypingRequestV1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessagesIndicateTypingRequestV1.swift deleted file mode 100644 index ad8e779d..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessagesIndicateTypingRequestV1.swift +++ /dev/null @@ -1,38 +0,0 @@ -// PostDirectMessagesIndicateTypingRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ -/// typing-indicator-and-read-receipts/api-reference/new-typing-indicator -open class PostDirectMessagesIndicateTypingRequestV1: TwitterAPIRequest { - public let recipientID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/direct_messages/indicate_typing.json" - } - - open var parameters: [String: Any] { - ["recipient_id": recipientID] - } - - public init( - recipientID: String - ) { - self.recipientID = recipientID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessagesMarkReadRequestV1.swift b/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessagesMarkReadRequestV1.swift deleted file mode 100644 index bb3b982c..00000000 --- a/Sources/TwitterAPIKit/APIv1/DirectMessage/Requests/PostDirectMessagesMarkReadRequestV1.swift +++ /dev/null @@ -1,49 +0,0 @@ -// PostDirectMessagesMarkReadRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/ -/// typing-indicator-and-read-receipts/api-reference/new-read-receipt -open class PostDirectMessagesMarkReadRequestV1: TwitterAPIRequest { - /// Message ID - public let lastReadEventID: String - - /// User ID - public let recipientID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/direct_messages/mark_read.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - - params["last_read_event_id"] = lastReadEventID - params["recipient_id"] = recipientID - - return params - } - - public init( - lastReadEventID: String, - recipientID: String - ) { - self.lastReadEventID = lastReadEventID - self.recipientID = recipientID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Favorite/FavoriteAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Favorite/FavoriteAPIv1.swift deleted file mode 100644 index d21db427..00000000 --- a/Sources/TwitterAPIKit/APIv1/Favorite/FavoriteAPIv1.swift +++ /dev/null @@ -1,36 +0,0 @@ -// FavoriteAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class FavoriteAPIv1: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create - public func postFavorite( - _ request: PostFavoriteRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-destroy - public func postUnFavorite( - _ request: PostUnFavoriteRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list - public func getFavorites( - _ request: GetFavoritesRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Favorite/Requests/GetFavoritesRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Favorite/Requests/GetFavoritesRequestV1.swift deleted file mode 100644 index 6d9f9c32..00000000 --- a/Sources/TwitterAPIKit/APIv1/Favorite/Requests/GetFavoritesRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetFavoritesRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list -open class GetFavoritesRequestV1: TwitterAPIRequest { - public let target: TwitterUserIdentifierV1 - public let count: Int? - public let sinceID: String? - public let maxID: String? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/favorites/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - - target.bind(param: ¶ms) - count.map { params["count"] = $0 } - sinceID.map { params["since_id"] = $0 } - maxID.map { params["max_id"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - - return params - } - - public init( - target: TwitterUserIdentifierV1, - count: Int? = .none, - sinceID: String? = .none, - maxID: String? = .none, - includeEntities: Bool? = .none - ) { - self.target = target - self.count = count - self.sinceID = sinceID - self.maxID = maxID - self.includeEntities = includeEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Favorite/Requests/PostFavoriteRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Favorite/Requests/PostFavoriteRequestV1.swift deleted file mode 100644 index a663527e..00000000 --- a/Sources/TwitterAPIKit/APIv1/Favorite/Requests/PostFavoriteRequestV1.swift +++ /dev/null @@ -1,42 +0,0 @@ -// PostFavoriteRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create -open class PostFavoriteRequestV1: TwitterAPIRequest { - public let id: String - public let includeEntities: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/favorites/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - id: String, - includeEntities: Bool? = .none - ) { - self.id = id - self.includeEntities = includeEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Favorite/Requests/PostUnFavoriteRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Favorite/Requests/PostUnFavoriteRequestV1.swift deleted file mode 100644 index 8fa58265..00000000 --- a/Sources/TwitterAPIKit/APIv1/Favorite/Requests/PostUnFavoriteRequestV1.swift +++ /dev/null @@ -1,42 +0,0 @@ -// PostUnFavoriteRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-destroy -open class PostUnFavoriteRequestV1: TwitterAPIRequest { - public let id: String - public let includeEntities: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/favorites/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - id: String, - includeEntities: Bool? = .none - ) { - self.id = id - self.includeEntities = includeEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/FriendshipsAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/FriendshipsAPIv1.swift deleted file mode 100644 index 87cddba0..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/FriendshipsAPIv1.swift +++ /dev/null @@ -1,123 +0,0 @@ -// FriendshipsAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class FriendshipsAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-followers-ids - public func getFollowerIDs( - _ request: GetFollowersIDsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-followers-list - public func getFollowers( - _ request: GetFollowersListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friends-ids - public func getFriendIDs( - _ request: GetFriendsIDsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friends-list - public func getFriends( - _ request: GetFriendsListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friendships-incoming - public func getFriendshipsIncoming( - _ request: GetFriendshipsIncomingRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friendships-lookup - public func getFriendshipsLookup( - _ request: GetFriendshipsLookupRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friendships-no_retweets-ids - public func getFriendshipsNoRetweetsIDs( - _ request: GetFriendshipsNoRetweetsIDsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friendships-outgoing - public func getFriendshipsOutgoing( - _ request: GetFriendshipsOutgoingRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-friendships-show - public func getFriendships( - _ request: GetFriendshipsShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/post-friendships-create - public func postFollowUser( - _ request: PostFriendshipsCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/post-friendships-destroy - public func postUnfollowUser( - _ request: PostFriendshipsDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/post-friendships-update - public func postFriendshipsUpdate( - _ request: PostFriendshipsUpdateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFollowersIDsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFollowersIDsRequestV1.swift deleted file mode 100644 index 21149197..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFollowersIDsRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetFollowersIDsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-followers-ids -open class GetFollowersIDsRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - public let stringifyIDs: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/followers/ids.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - stringifyIDs.map { params["stringify_ids"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - stringifyIDs: Bool? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - self.stringifyIDs = stringifyIDs - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFollowersListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFollowersListRequestV1.swift deleted file mode 100644 index 2bbb2847..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFollowersListRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetFollowersListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-followers-list -open class GetFollowersListRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - public let skipStatus: Bool? - public let includeUserEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/followers/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - includeUserEntities.map { params["include_user_entities"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - skipStatus: Bool? = .none, - includeUserEntities: Bool? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - self.skipStatus = skipStatus - self.includeUserEntities = includeUserEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendsIDsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendsIDsRequestV1.swift deleted file mode 100644 index 15e6900a..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendsIDsRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetFriendsIDsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friends-ids -open class GetFriendsIDsRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - public let stringifyIDs: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friends/ids.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - stringifyIDs.map { params["stringify_ids"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - stringifyIDs: Bool? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - self.stringifyIDs = stringifyIDs - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendsListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendsListRequestV1.swift deleted file mode 100644 index 880db967..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendsListRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetFriendsListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friends-list -open class GetFriendsListRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - public let skipStatus: Bool? - public let includeUserEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friends/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - includeUserEntities.map { params["include_user_entities"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - skipStatus: Bool? = .none, - includeUserEntities: Bool? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - self.skipStatus = skipStatus - self.includeUserEntities = includeUserEntities - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsIncomingRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsIncomingRequestV1.swift deleted file mode 100644 index 2f499e25..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsIncomingRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetFriendshipsIncomingRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friendships-incoming -open class GetFriendshipsIncomingRequestV1: TwitterAPIRequest { - public let cursor: String? - public let stringifyIDs: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friendships/incoming.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - cursor.map { params["cursor"] = $0 } - stringifyIDs.map { params["stringify_ids"] = $0 } - return params - } - - public init( - cursor: String? = .none, - stringifyIDs: Bool? = .none - ) { - self.cursor = cursor - self.stringifyIDs = stringifyIDs - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsLookupRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsLookupRequestV1.swift deleted file mode 100644 index ee56bc54..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsLookupRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetFriendshipsLookupRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friendships-lookup -open class GetFriendshipsLookupRequestV1: TwitterAPIRequest { - public let users: TwitterUsersIdentifierV1 - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friendships/lookup.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - users.bind(param: ¶ms) - return params - } - - public init( - users: TwitterUsersIdentifierV1 - ) { - self.users = users - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsNoRetweetsIDsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsNoRetweetsIDsRequestV1.swift deleted file mode 100644 index 0c781385..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsNoRetweetsIDsRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetFriendshipsNoRetweetsIDsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friendships-no_retweets-ids -open class GetFriendshipsNoRetweetsIDsRequestV1: TwitterAPIRequest { - public let stringifyIDs: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friendships/no_retweets/ids.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - stringifyIDs.map { params["stringify_ids"] = $0 } - return params - } - - public init( - stringifyIDs: Bool? = .none - ) { - self.stringifyIDs = stringifyIDs - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsOutgoingRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsOutgoingRequestV1.swift deleted file mode 100644 index a97cf208..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsOutgoingRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetFriendshipsOutgoingRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friendships-outgoing -open class GetFriendshipsOutgoingRequestV1: TwitterAPIRequest { - public let cursor: String? - public let stringifyIDs: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friendships/outgoing" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - cursor.map { params["cursor"] = $0 } - stringifyIDs.map { params["stringify_ids"] = $0 } - return params - } - - public init( - cursor: String? = .none, - stringifyIDs: Bool? = .none - ) { - self.cursor = cursor - self.stringifyIDs = stringifyIDs - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsShowRequestV1.swift deleted file mode 100644 index dd9ff46e..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/GetFriendshipsShowRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetFriendshipsShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-friendships-show -open class GetFriendshipsShowRequestV1: TwitterAPIRequest { - public let sourceUser: TwitterUserIdentifierV1 - public let targetUser: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/friendships/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - sourceUser.bind(param: ¶ms, userIDKey: "source_id", screenNameKey: "source_screen_name") - targetUser.bind(param: ¶ms, userIDKey: "target_id", screenNameKey: "target_screen_name") - return params - } - - public init( - sourceUser: TwitterUserIdentifierV1, - targetUser: TwitterUserIdentifierV1 - ) { - self.sourceUser = sourceUser - self.targetUser = targetUser - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsCreateRequestV1.swift deleted file mode 100644 index 52953013..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsCreateRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostFriendshipsCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/post-friendships-create -open class PostFriendshipsCreateRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let follow: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/friendships/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - follow.map { params["follow"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - follow: Bool? = .none - ) { - self.user = user - self.follow = follow - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsDestroyRequestV1.swift deleted file mode 100644 index 8f22aa88..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsDestroyRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostFriendshipsDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/post-friendships-destroy -open class PostFriendshipsDestroyRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/friendships/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - return params - } - - public init( - user: TwitterUserIdentifierV1 - ) { - self.user = user - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsUpdateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsUpdateRequestV1.swift deleted file mode 100644 index 57c9b387..00000000 --- a/Sources/TwitterAPIKit/APIv1/Friendships/Requests/PostFriendshipsUpdateRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostFriendshipsUpdateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/post-friendships-update -open class PostFriendshipsUpdateRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let device: Bool? - public let retweets: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/friendships/update.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - device.map { params["device"] = $0 } - retweets.map { params["retweets"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - device: Bool? = .none, - retweets: Bool? = .none - ) { - self.user = user - self.device = device - self.retweets = retweets - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Geo/GeoAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Geo/GeoAPIv1.swift deleted file mode 100644 index f727d34a..00000000 --- a/Sources/TwitterAPIKit/APIv1/Geo/GeoAPIv1.swift +++ /dev/null @@ -1,42 +0,0 @@ -// GeoAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class GeoAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/geo/ - /// places-near-location/api-reference/get-geo-reverse_geocode - public func getReverseGeocode( - _ request: GetGeoReverseGeocodeRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/geo/ - /// place-information/api-reference/get-geo-id-place_id - public func getGeoPlace( - _ request: GetGeoPlaceIDRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/geo/ - /// places-near-location/api-reference/get-geo-search - public func searchGeo( - _ request: GetGeoSearchRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoPlaceIDRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoPlaceIDRequestV1.swift deleted file mode 100644 index a721c1a6..00000000 --- a/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoPlaceIDRequestV1.swift +++ /dev/null @@ -1,36 +0,0 @@ -// GetGeoPlaceIDRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/geo/place-information/api-reference/get-geo-id-place_id -open class GetGeoPlaceIDRequestV1: TwitterAPIRequest { - public let placeID: String - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/geo/id/\(placeID).json" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - placeID: String - ) { - self.placeID = placeID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoReverseGeocodeRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoReverseGeocodeRequestV1.swift deleted file mode 100644 index 50b415b3..00000000 --- a/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoReverseGeocodeRequestV1.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetGeoReverseGeocodeRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/geo/places-near-location/api-reference/get-geo-reverse_geocode -open class GetGeoReverseGeocodeRequestV1: TwitterAPIRequest { - public let location: TwitterCoordinateV1 - public let accuracy: TwitterAccuracyV1? - public let maxResults: Int? - public let granularity: TwitterGranularityV1? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/geo/reverse_geocode.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - location.bind(param: ¶ms) - accuracy?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - granularity?.bind(param: ¶ms) - return params - } - - public init( - location: TwitterCoordinateV1, - accuracy: TwitterAccuracyV1? = .none, - maxResults: Int? = .none, - granularity: TwitterGranularityV1? = .none - ) { - self.location = location - self.accuracy = accuracy - self.maxResults = maxResults - self.granularity = granularity - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoSearchRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoSearchRequestV1.swift deleted file mode 100644 index a38e136e..00000000 --- a/Sources/TwitterAPIKit/APIv1/Geo/Requests/GetGeoSearchRequestV1.swift +++ /dev/null @@ -1,62 +0,0 @@ -// GetGeoSearchRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/geo/places-near-location/api-reference/get-geo-search -open class GetGeoSearchRequestV1: TwitterAPIRequest { - public enum Location { - case coordinate(TwitterCoordinateV1) - case query(String) - case ip(String) - public func bind(param: inout [String: Any]) { - switch self { - case let .coordinate(twitterCoordinate): - twitterCoordinate.bind(param: ¶m) - case let .query(string): - param["query"] = string - case let .ip(string): - param["ip"] = string - } - } - } - - public let location: Location - public let maxResults: Int? - public let granularity: TwitterGranularityV1? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/geo/search.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - location.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - granularity?.bind(param: ¶ms) - return params - } - - public init( - location: Location, - maxResults: Int? = .none, - granularity: TwitterGranularityV1? = .none - ) { - self.location = location - self.maxResults = maxResults - self.granularity = granularity - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Help/HelpAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Help/HelpAPIv1.swift deleted file mode 100644 index d6530e10..00000000 --- a/Sources/TwitterAPIKit/APIv1/Help/HelpAPIv1.swift +++ /dev/null @@ -1,24 +0,0 @@ -// HelpAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class HelpAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/ - /// supported-languages/api-reference/get-help-languages - public func getSupportedLanguages( - _ request: GetHelpLanguagesRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Help/Requests/GetHelpLanguagesRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Help/Requests/GetHelpLanguagesRequestV1.swift deleted file mode 100644 index 4b5ff4dc..00000000 --- a/Sources/TwitterAPIKit/APIv1/Help/Requests/GetHelpLanguagesRequestV1.swift +++ /dev/null @@ -1,32 +0,0 @@ -// GetHelpLanguagesRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/ -/// supported-languages/api-reference/get-help-languages -open class GetHelpLanguagesRequestV1: TwitterAPIRequest { - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/help/languages.json" - } - - open var parameters: [String: Any] { - [:] - } - - public init() {} - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/ListAPIv1.swift b/Sources/TwitterAPIKit/APIv1/List/ListAPIv1.swift deleted file mode 100644 index 632c3bcd..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/ListAPIv1.swift +++ /dev/null @@ -1,186 +0,0 @@ -// ListAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class ListAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-list - public func getLists( - _ request: GetListsListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-members - public func getListMembers( - _ request: GetListsMembersRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-members-show - public func getListMember( - _ request: GetListsMembersShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-memberships - public func getListMemberships( - _ request: GetListsMembershipsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-ownerships - public func getListOwnerships( - _ request: GetListsOwnershipsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-show - public func getList( - _ request: GetListsShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-statuses - public func getListStatuses( - _ request: GetListsStatusesRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-subscribers - public func getListSubscribers( - _ request: GetListsSubscribersRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-subscribers-show - public func getListSubscriber( - _ request: GetListsSubscribersShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/get-lists-subscriptions - public func getListSubscriptions( - _ request: GetListsSubscriptionsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-create - public func postCreateList( - _ request: PostListsCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-destroy - public func postDestroyList( - _ request: PostListsDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-members-create - public func postAddListMember( - _ request: PostListsMembersCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-members-create_all - public func postAddListMembers( - _ request: PostListsMembersCreateAllRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-members-destroy - public func postRemoveListMember( - _ request: PostListsMembersDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-members-destroy_all - public func postRemoveListMembers( - _ request: PostListsMembersDestroyAllRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-subscribers-create - public func postSubscribeList( - _ request: PostListsSubscribersCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-subscribers-destroy - public func postUnsubscribeList( - _ request: PostListsSubscribersDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// create-manage-lists/api-reference/post-lists-update - public func postUpdateList( - _ request: PostListsUpdateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsListRequestV1.swift deleted file mode 100644 index ede21b7b..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsListRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetListsListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-list -open class GetListsListRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let reverse: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/list.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - reverse.map { params["reverse"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - reverse: Bool? = .none - ) { - self.user = user - self.reverse = reverse - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembersRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembersRequestV1.swift deleted file mode 100644 index 5d2d1b38..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembersRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetListsMembersRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-members -open class GetListsMembersRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let count: Int? - public let cursor: String? - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/members.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - list: TwitterListIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.list = list - self.count = count - self.cursor = cursor - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembersShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembersShowRequestV1.swift deleted file mode 100644 index 4e8ba766..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembersShowRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetListsMembersShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-members-show -open class GetListsMembersShowRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let user: TwitterUserIdentifierV1 - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/members/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - user.bind(param: ¶ms) - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - list: TwitterListIdentifierV1, - user: TwitterUserIdentifierV1, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.list = list - self.user = user - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembershipsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembershipsRequestV1.swift deleted file mode 100644 index 619a5c2e..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsMembershipsRequestV1.swift +++ /dev/null @@ -1,53 +0,0 @@ -// GetListsMembershipsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-memberships -open class GetListsMembershipsRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - public let filterToOwnedLists: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/memberships.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - filterToOwnedLists.map { params["filter_to_owned_lists"] = $0 } - - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - filterToOwnedLists: Bool? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - self.filterToOwnedLists = filterToOwnedLists - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsOwnershipsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsOwnershipsRequestV1.swift deleted file mode 100644 index 84649343..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsOwnershipsRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetListsOwnershipsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-ownerships -open class GetListsOwnershipsRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let cursor: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/ownerships.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsShowRequestV1.swift deleted file mode 100644 index e1ba266e..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsShowRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetListsShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-show -open class GetListsShowRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1 - ) { - self.list = list - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsStatusesRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsStatusesRequestV1.swift deleted file mode 100644 index 6edb1d3d..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsStatusesRequestV1.swift +++ /dev/null @@ -1,60 +0,0 @@ -// GetListsStatusesRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-statuses -open class GetListsStatusesRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let count: Int? - public let sinceID: String? - public let maxID: String? - public let includeEntities: Bool? - public let includeRTs: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/statuses.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - count.map { params["count"] = $0 } - sinceID.map { params["since_id"] = $0 } - maxID.map { params["max_id"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - includeRTs.map { params["include_rts"] = $0 } - return params - } - - public init( - list: TwitterListIdentifierV1, - count: Int? = .none, - sinceID: String? = .none, - maxID: String? = .none, - includeEntities: Bool? = .none, - includeRTs: Bool? = .none - ) { - self.list = list - self.count = count - self.sinceID = sinceID - self.maxID = maxID - self.includeEntities = includeEntities - self.includeRTs = includeRTs - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscribersRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscribersRequestV1.swift deleted file mode 100644 index 592e0e18..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscribersRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetListsSubscribersRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-subscribers -open class GetListsSubscribersRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let count: Int? - public let cursor: String? - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/subscribers.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - list: TwitterListIdentifierV1, - count: Int? = .none, - cursor: String? = .none, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.list = list - self.count = count - self.cursor = cursor - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscribersShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscribersShowRequestV1.swift deleted file mode 100644 index 25cd1d46..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscribersShowRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetListsSubscribersShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-subscribers-show -open class GetListsSubscribersShowRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let user: TwitterUserIdentifierV1 - public let includeEntities: Bool? - public let skipStatus: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/subscribers/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - user.bind(param: ¶ms) - includeEntities.map { params["include_entities"] = $0 } - skipStatus.map { params["skip_status"] = $0 } - return params - } - - public init( - list: TwitterListIdentifierV1, - user: TwitterUserIdentifierV1, - includeEntities: Bool? = .none, - skipStatus: Bool? = .none - ) { - self.list = list - self.user = user - self.includeEntities = includeEntities - self.skipStatus = skipStatus - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscriptionsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscriptionsRequestV1.swift deleted file mode 100644 index 7da560d8..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/GetListsSubscriptionsRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetListsSubscriptionsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/get-lists-subscriptions -open class GetListsSubscriptionsRequestV1: TwitterAPIRequest { - internal let user: TwitterUserIdentifierV1 - internal let count: Int? - internal let cursor: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/lists/subscriptions.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - cursor: String? = .none - ) { - self.user = user - self.count = count - self.cursor = cursor - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsCreateRequestV1.swift deleted file mode 100644 index 79296154..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsCreateRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostListsCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-create -open class PostListsCreateRequestV1: TwitterAPIRequest { - public let name: String - public let mode: TwitterListModeV1? - public let description: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["name"] = name - mode?.bind(param: ¶ms) - description.map { params["description"] = $0 } - return params - } - - public init( - name: String, - mode: TwitterListModeV1? = .none, - description: String? = .none - ) { - self.name = name - self.mode = mode - self.description = description - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsDestroyRequestV1.swift deleted file mode 100644 index 3c5858dc..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsDestroyRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostListsDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-destroy -open class PostListsDestroyRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1 - ) { - self.list = list - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersCreateAllRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersCreateAllRequestV1.swift deleted file mode 100644 index bddaaca3..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersCreateAllRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostListsMembersCreateAllRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-members-create_all -open class PostListsMembersCreateAllRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let users: TwitterUsersIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/members/create_all.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - users.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1, - users: TwitterUsersIdentifierV1 - ) { - self.list = list - self.users = users - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersCreateRequestV1.swift deleted file mode 100644 index 0ae34c73..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersCreateRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostListsMembersCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-members-create -open class PostListsMembersCreateRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let user: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/members/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - user.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1, - user: TwitterUserIdentifierV1 - ) { - self.list = list - self.user = user - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersDestroyAllRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersDestroyAllRequestV1.swift deleted file mode 100644 index eba44b5e..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersDestroyAllRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostListsMembersDestroyAllRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-members-destroy_all -open class PostListsMembersDestroyAllRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let users: TwitterUsersIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/members/destroy_all.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - users.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1, - users: TwitterUsersIdentifierV1 - ) { - self.list = list - self.users = users - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersDestroyRequestV1.swift deleted file mode 100644 index 4d2d1db0..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsMembersDestroyRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostListsMembersDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-members-destroy -open class PostListsMembersDestroyRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let user: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/members/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - user.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1, - user: TwitterUserIdentifierV1 - ) { - self.list = list - self.user = user - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsSubscribersCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsSubscribersCreateRequestV1.swift deleted file mode 100644 index bed9e8d3..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsSubscribersCreateRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostListsSubscribersCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-subscribers-create -open class PostListsSubscribersCreateRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/subscribers/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1 - ) { - self.list = list - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsSubscribersDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsSubscribersDestroyRequestV1.swift deleted file mode 100644 index d54aac51..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsSubscribersDestroyRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostListsSubscribersDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-subscribers-destroy -open class PostListsSubscribersDestroyRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/subscribers/destroy.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - return params - } - - public init( - list: TwitterListIdentifierV1 - ) { - self.list = list - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsUpdateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsUpdateRequestV1.swift deleted file mode 100644 index a5044c30..00000000 --- a/Sources/TwitterAPIKit/APIv1/List/Requests/PostListsUpdateRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostListsUpdateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// create-manage-lists/api-reference/post-lists-update -open class PostListsUpdateRequestV1: TwitterAPIRequest { - public let list: TwitterListIdentifierV1 - public let name: String? - public let mode: TwitterListModeV1? - public let description: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/lists/update.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - list.bind(param: ¶ms) - name.map { params["name"] = $0 } - mode?.bind(param: ¶ms) - description.map { params["description"] = $0 } - return params - } - - public init( - list: TwitterListIdentifierV1, - name: String? = .none, - mode: TwitterListModeV1? = .none, - description: String? = .none - ) { - self.list = list - self.name = name - self.mode = mode - self.description = description - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/MediaAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Media/MediaAPIv1.swift deleted file mode 100644 index f52ddbc5..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/MediaAPIv1.swift +++ /dev/null @@ -1,236 +0,0 @@ -// MediaAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -// swiftlint:disable function_body_length closure_body_length -open class MediaAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/get-media-upload-status - public func getUploadMediaStatus( - _ request: GetUploadMediaStatusRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/post-media-upload-init - public func uploadMediaInit( - _ request: UploadMediaInitRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/post-media-upload-append - public func uploadMediaAppend( - _ request: UploadMediaAppendRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// Utility method for split uploading of large files. - public func uploadMediaAppendSplitChunks( - _ request: UploadMediaAppendRequestV1, - maxBytes: Int = 5_242_880 /* 5MB */ - ) -> [TwitterAPISessionSpecializedTask] { - request.segments(maxBytes: maxBytes) - .map { req in - uploadMediaAppend(req).specialized { _ in - req.mediaID - } - } - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/post-media-upload-finalize - public func uploadMediaFinalize( - _ request: UploadMediaFinalizeRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// Upload media utility method. - /// INIT -> APPEND x n -> FINALIZE -> STATUS x n (If needed) - public func uploadMedia( - _ parameters: UploadMediaRequestParameters, - completionHandler: @escaping ( - TwitterAPIResponse - ) -> Void - ) { - uploadMediaInit( - .init( - totalBytes: parameters.media.count, - mediaType: parameters.mediaType, - mediaCategory: parameters.mediaCategory, - additionalOwners: parameters.additionalOwners - ) - ) - .responseDecodable( - type: TwitterAPIClient.UploadMediaInitResponse.self, - queue: .processQueue - ) - { [weak self] response in - - guard let self else { return } - - let mediaID: String - do { - mediaID = try response.result.get().mediaID - } catch { - completionHandler(response.map(\.mediaID)) - return - } - - uploadMediaAppendSplitChunks( - .init( - mediaID: mediaID, - filename: parameters.filename, - mimeType: parameters.mediaType, - media: parameters.media, - segmentIndex: 0 - ), maxBytes: parameters.uploadChunkSize ?? 5_242_880 - ) - .responseObject(queue: .processQueue) { [weak self] responses in - - guard let self else { return } - - if let error = responses.first(where: \.isError) { - completionHandler(error) - return - } - - uploadMediaFinalize(.init(mediaID: mediaID)) - .responseDecodable( - type: TwitterAPIClient.UploadMediaFinalizeResponse.self, - queue: .processQueue - ) { [weak self] response in - guard let self else { return } - - var finalizeResult: TwitterAPIClient.UploadMediaFinalizeResponse - do { - finalizeResult = try response.result.get() - } catch { - completionHandler(response.map(\.mediaID)) - return - } - - guard let processingInfo = finalizeResult.processingInfo else { - completionHandler(response.map(\.mediaID)) - return - } - - waitMediaProcessing( - mediaID: mediaID, - initialWaitSec: processingInfo.checkAfterSecs ?? 0 - ) { response in - completionHandler(response.map(\.mediaID)) - } - } - } - } - } - - public func waitMediaProcessing( - mediaID: String, - initialWaitSec: Int, - completionHandler: @escaping ( - TwitterAPIResponse - ) -> Void - ) { - DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + .seconds(initialWaitSec)) { [weak self] in - guard let self else { return } - waitMediaProcessing(mediaID: mediaID, completionHandler: completionHandler) - } - } - - public func waitMediaProcessing( - mediaID: String, - completionHandler: @escaping ( - TwitterAPIResponse - ) -> Void - ) { - _ = getUploadMediaStatus(.init(mediaID: mediaID)) - .responseDecodable( - type: TwitterAPIClient.UploadMediaStatusResponse.self, - queue: .processQueue - ) { [weak self] response in - guard let self else { return } - - do { - let success = try response.result.get() - - switch success.state { - case let .pending(checkAfterSecs: sec), - let .inProgress(checkAfterSecs: sec, progressPercent: _): - - waitMediaProcessing( - mediaID: mediaID, - initialWaitSec: sec, - completionHandler: completionHandler - ) - case .succeeded: - completionHandler(response) - case let .failed(error: error): - throw TwitterAPIKitError.uploadMediaFailed(reason: .processingFailed(error: error)) - case .unknown: - throw TwitterAPIKitError.unkonwn( - error: NSError(domain: "TwitterAPIKit", code: 0, userInfo: [:]) - ) - } - } catch let error as TwitterAPIKitError { - completionHandler( - response.flatMap { _ in .failure(error) } - ) - return - } catch { - completionHandler( - response.flatMap { _ in .failure(.unkonwn(error: error)) } - ) - } - } - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/post-media-metadata-create - public func createMediaMetadata( - _ request: PostMediaMetadataCreateRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/ - /// post-media-subtitles-create - public func createSubtitle( - _ request: PostMediaSubtitlesCreateRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/ - /// api-reference/ - /// post-media-subtitles-delete - public func deleteSubtitle( - _ request: PostMediaSubtitlesDeleteRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} -// swiftlint:enable function_body_length closure_body_length diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/GetUploadMediaStatusRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/GetUploadMediaStatusRequestV1.swift deleted file mode 100644 index 652eb185..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/GetUploadMediaStatusRequestV1.swift +++ /dev/null @@ -1,41 +0,0 @@ -// GetUploadMediaStatusRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class GetUploadMediaStatusRequestV1: TwitterAPIRequest { - public let command: String = "STATUS" - public let mediaID: String - - public var method: HTTPMethod { - .get - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var path: String { - "/1.1/media/upload.json" - } - - open var parameters: [String: Any] { - [ - "command": command, - "media_id": mediaID, - ] - } - - public init(mediaID: String) { - self.mediaID = mediaID - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaMetadataCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaMetadataCreateRequestV1.swift deleted file mode 100644 index 99371177..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaMetadataCreateRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostMediaMetadataCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-metadata-create -open class PostMediaMetadataCreateRequestV1: TwitterAPIRequest { - public let mediaID: String - public let altText: String - - public var method: HTTPMethod { - .post - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var bodyContentType: BodyContentType { - .json - } - - public var path: String { - "/1.1/media/metadata/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - - params["media_id"] = mediaID - params["alt_text"] = ["text": altText] - - return params - } - - public init( - mediaID: String, - altText: String - ) { - self.mediaID = mediaID - self.altText = altText - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaSubtitlesCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaSubtitlesCreateRequestV1.swift deleted file mode 100644 index 78d0c115..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaSubtitlesCreateRequestV1.swift +++ /dev/null @@ -1,79 +0,0 @@ -// PostMediaSubtitlesCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-subtitles-create -open class PostMediaSubtitlesCreateRequestV1: TwitterAPIRequest { - public struct Subtitle { - public let mediaID: String - /// The language code should be a BCP47 code (e.g. 'en", "sp") - public let languageCode: String - public let displayName: String - - public init( - mediaID: String, - languageCode: String, - displayName: String - ) { - self.mediaID = mediaID - self.languageCode = languageCode - self.displayName = displayName - } - } - - public let mediaID: String - public let mediaCategory: String - public let subtitles: [Subtitle] - - public var method: HTTPMethod { - .post - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var bodyContentType: BodyContentType { - .json - } - - public var path: String { - "/1.1/media/subtitles/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["media_id"] = mediaID - params["media_category"] = mediaCategory - params["subtitle_info"] = [ - "subtitles": subtitles.map { - [ - "media_id": $0.mediaID, - "language_code": $0.languageCode, - "display_name": $0.displayName, - ] - }, - ] - return params - } - - public init( - mediaID: String, - mediaCategory: String, - subtitles: [Subtitle] - ) { - self.mediaID = mediaID - self.mediaCategory = mediaCategory - self.subtitles = subtitles - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaSubtitlesDeleteRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaSubtitlesDeleteRequestV1.swift deleted file mode 100644 index 8d7776e4..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/PostMediaSubtitlesDeleteRequestV1.swift +++ /dev/null @@ -1,59 +0,0 @@ -// PostMediaSubtitlesDeleteRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-subtitles-delete -open class PostMediaSubtitlesDeleteRequestV1: TwitterAPIRequest { - public let mediaID: String - public let mediaCategory: String - /// //The language code should be a BCP47 code (e.g. 'en", "sp") - public let subtitleLanguageCodes: [String] - - public var method: HTTPMethod { - .post - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var bodyContentType: BodyContentType { - .json - } - - public var path: String { - "/1.1/media/subtitles/delete.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["media_id"] = mediaID - params["media_category"] = mediaCategory - params["subtitle_info"] = [ - "subtitles": subtitleLanguageCodes.map { - ["language_code": $0] - }, - ] - return params - } - - public init( - mediaID: String, - mediaCategory: String, - subtitleLanguageCodes: [String] - ) { - self.mediaID = mediaID - self.mediaCategory = mediaCategory - self.subtitleLanguageCodes = subtitleLanguageCodes - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaAppendRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaAppendRequestV1.swift deleted file mode 100644 index 80fa4a1e..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaAppendRequestV1.swift +++ /dev/null @@ -1,87 +0,0 @@ -// UploadMediaAppendRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-append -open class UploadMediaAppendRequestV1: TwitterAPIRequest { - public let command: String = "APPEND" - public let mediaID: String - - /// media filename - public let filename: String - - /// media mime type - public let mimeType: String - public let media: Data - public let segmentIndex: Int - - public var method: HTTPMethod { - .post - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var path: String { - "/1.1/media/upload.json" - } - - public var bodyContentType: BodyContentType { - .multipartFormData - } - - open var parameters: [String: MultipartFormDataPart] { - return [ - "command": .value(name: "command", value: command), - "media_id": .value(name: "media_id", value: mediaID), - "media": .data(name: "media", value: media, filename: filename, mimeType: mimeType), - "segment_index": .value(name: "segment_index", value: segmentIndex), - ] - } - - public required init( - mediaID: String, - filename: String, - mimeType: String, - media: Data, - segmentIndex: Int = 0 - ) { - self.mediaID = mediaID - self.filename = filename - self.mimeType = mimeType - self.media = media - self.segmentIndex = segmentIndex - } - - open func segments(maxBytes: Int) -> [UploadMediaAppendRequestV1] { - var requests = [Self]() - let totalDataSize = media.count - var currentSegmentIndex = 0 - repeat { - currentSegmentIndex = segmentIndex + requests.count - let start = currentSegmentIndex * maxBytes - let len = min(totalDataSize - start, maxBytes) - let req = Self( - mediaID: mediaID, - filename: filename, - mimeType: mimeType, - media: media.subdata(in: start ..< (start + len)), - segmentIndex: currentSegmentIndex - ) - requests.append(req) - } while ((currentSegmentIndex + 1) * maxBytes) < totalDataSize - - return requests - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaFinalizeRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaFinalizeRequestV1.swift deleted file mode 100644 index 83d738d1..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaFinalizeRequestV1.swift +++ /dev/null @@ -1,42 +0,0 @@ -// UploadMediaFinalizeRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-finalize -open class UploadMediaFinalizeRequestV1: TwitterAPIRequest { - public let command: String = "FINALIZE" - public let mediaID: String - - public var method: HTTPMethod { - .post - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var path: String { - "/1.1/media/upload.json" - } - - open var parameters: [String: Any] { - [ - "command": command, - "media_id": mediaID, - ] - } - - public init(mediaID: String) { - self.mediaID = mediaID - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaInitRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaInitRequestV1.swift deleted file mode 100644 index 142cfcf5..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/Requests/UploadMediaInitRequestV1.swift +++ /dev/null @@ -1,56 +0,0 @@ -// UploadMediaInitRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-init -open class UploadMediaInitRequestV1: TwitterAPIRequest { - public let command: String = "INIT" - public let totalBytes: Int - public let mediaType: String - public let mediaCategory: String? - public let additionalOwners: [String]? - - public var method: HTTPMethod { - .post - } - - public var baseURLType: TwitterBaseURLType { - .upload - } - - public var path: String { - "/1.1/media/upload.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["command"] = command - params["total_bytes"] = totalBytes - params["media_type"] = mediaType - mediaCategory.map { params["media_category"] = $0 } - additionalOwners.map { params["additional_owners"] = $0.joined(separator: ",") } - return params - } - - public init( - totalBytes: Int, - mediaType: String, - mediaCategory: String? = .none, - additionalOwners: [String]? = .none - ) { - self.totalBytes = totalBytes - self.mediaType = mediaType - self.mediaCategory = mediaCategory - self.additionalOwners = additionalOwners - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Media/UploadMediaRequestParameters.swift b/Sources/TwitterAPIKit/APIv1/Media/UploadMediaRequestParameters.swift deleted file mode 100644 index b5102e29..00000000 --- a/Sources/TwitterAPIKit/APIv1/Media/UploadMediaRequestParameters.swift +++ /dev/null @@ -1,137 +0,0 @@ -// UploadMediaRequestParameters.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Parameters for uploading media to Twitter's API. -public struct UploadMediaRequestParameters { - /// The raw media data to upload. - public let media: Data - - /// The MIME type of the media (e.g., "image/jpeg", "video/mp4"). - public let mediaType: String - - /// The filename to use for the uploaded media. - public let filename: String - - /// The category of media being uploaded (e.g., "tweet_image", "tweet_video"). - public let mediaCategory: String? - - /// Additional Twitter user IDs that should have permission to use this media. - public let additionalOwners: [String]? - - /// The size of each chunk when uploading large media files, in bytes. - public let uploadChunkSize: Int? - - /// Creates parameters for a media upload request. - /// - Parameters: - /// - media: The raw media data to upload. - /// - mediaType: The MIME type of the media. - /// - filename: The filename to use (can be any value, e.g., "photo.jpg"). - /// - mediaCategory: The category of media being uploaded (optional). - /// - additionalOwners: Additional user IDs that can use this media (optional). - /// - uploadChunkSize: Size of each chunk for chunked uploads, in bytes (optional). - public init( - media: Data, - mediaType: String, - filename: String, - mediaCategory: String? = .none, - additionalOwners: [String]? = .none, - uploadChunkSize: Int? = .none - ) { - self.media = media - self.mediaType = mediaType - self.mediaCategory = mediaCategory - self.additionalOwners = additionalOwners - self.filename = filename - self.uploadChunkSize = uploadChunkSize - } -} - -public extension TwitterAPIClient { - struct UploadMediaInitResponse: Decodable { - public let mediaID: String - public let expiresAfterSecs: Int - - private enum CodingKeys: String, CodingKey { - case mediaID = "mediaIdString" - case expiresAfterSecs - } - } - - struct UploadMediaVideo: Decodable { - public let videoType: String - } - - struct UploadMediaProcessingInfo: Decodable { - public enum State { - case pending(checkAfterSecs: Int) - case inProgress(checkAfterSecs: Int, progressPercent: Int) - case failed(error: TwitterAPIKitError.UploadMediaError) - case succeeded - - case unknown - } - - public var enumState: State { - if state == "pending", let checkAfterSecs { - return .pending(checkAfterSecs: checkAfterSecs) - } - - if state == "in_progress", let checkAfterSecs, let progressPercent { - return .inProgress(checkAfterSecs: checkAfterSecs, progressPercent: progressPercent) - } - - if state == "failed", let error { - return .failed(error: error) - } - - if state == "succeeded" { - return .succeeded - } - return .unknown - } - - /// pending -> in_progress -> [failed|succeeded] - public let state: String - public let checkAfterSecs: Int? - - /// 0 - 100 % - public let progressPercent: Int? - public let error: TwitterAPIKitError.UploadMediaError? - } - - struct UploadMediaFinalizeResponse: Decodable { - public let mediaID: String - public let size: Int - public let expiresAfterSecs: Int - public let video: UploadMediaVideo? - public let processingInfo: UploadMediaProcessingInfo? - - private enum CodingKeys: String, CodingKey { - case mediaID = "mediaIdString" - case size, expiresAfterSecs, video, processingInfo - } - } - - struct UploadMediaStatusResponse: Decodable { - public var state: UploadMediaProcessingInfo.State { - processingInfo.enumState - } - - public let mediaID: String - public let expiresAfterSecs: Int? - public let video: UploadMediaVideo? - public let processingInfo: UploadMediaProcessingInfo - - private enum CodingKeys: String, CodingKey { - case mediaID = "mediaIdString" - case expiresAfterSecs, video, processingInfo - } - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetersRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetersRequestV1.swift deleted file mode 100644 index 0e32c8bf..00000000 --- a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetersRequestV1.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetRetweetersRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// post-and-engage/api-reference/get-statuses-retweeters-ids -open class GetRetweetersRequestV1: TwitterAPIRequest { - // Status ID - public let tweetID: String - public let count: Int? - public let cursor: String? - public let stringifyIDs: Bool? - - public var method: HTTPMethod { - return .get - } - - public var path: String { - - return "/1.1/statuses/retweeters/ids.json" - } - - open var parameters: [String: Any] { - - var params = [String: Any]() - - params["id"] = tweetID - count.map { params["count"] = $0 } - cursor.map { params["cursor"] = $0 } - stringifyIDs.map { params["stringify_ids"] = $0 } - - return params - } - - public init( - tweetID: String, - count: Int? = .none, - cursor: String? = .none, - stringifyIDs: Bool? = .none - ) { - self.tweetID = tweetID - self.count = count - self.cursor = cursor - self.stringifyIDs = stringifyIDs - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetsOfMeRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetsOfMeRequestV1.swift deleted file mode 100644 index 9df2d928..00000000 --- a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetsOfMeRequestV1.swift +++ /dev/null @@ -1,62 +0,0 @@ -// GetRetweetsOfMeRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ -/// post-and-engage/api-reference/get-statuses-retweets_of_me -open class GetRetweetsOfMeRequestV1: TwitterAPIRequest { - public let count: Int? - public let sinceID: String? - public let maxID: String? - public let trimUser: Bool? - public let includeEntities: Bool? - public let includeUserEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/retweets_of_me.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - - count.map { params["count"] = $0 } - sinceID.map { params["since_id"] = $0 } - maxID.map { params["max_id"] = $0 } - trimUser.map { params["trim_user"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - includeUserEntities.map { params["include_user_entities"] = $0 } - - return params - } - - public init( - count: Int? = .none, - sinceID: String? = .none, - maxID: String? = .none, - trimUser: Bool? = .none, - includeEntities: Bool? = .none, - includeUserEntities: Bool? = .none - ) { - self.count = count - self.sinceID = sinceID - self.maxID = maxID - self.trimUser = trimUser - self.includeEntities = includeEntities - self.includeUserEntities = includeUserEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetsRequestV1.swift deleted file mode 100644 index 0146f100..00000000 --- a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/GetRetweetsRequestV1.swift +++ /dev/null @@ -1,47 +0,0 @@ -// GetRetweetsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweets-id -open class GetRetweetsRequestV1: TwitterAPIRequest { - /// Status ID - public let id: String - /// max: 100 - public let count: Int? - public let trimUser: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/retweets/\(id).json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - count.map { params["count"] = $0 } - trimUser.map { params["trim_user"] = $0 } - return params - } - - public init( - id: String, - count: Int? = .none, - trimUser: Bool? = .none - ) { - self.id = id - self.count = count - self.trimUser = trimUser - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/PostRetweetRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Retweet/Requests/PostRetweetRequestV1.swift deleted file mode 100644 index b8f7ff99..00000000 --- a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/PostRetweetRequestV1.swift +++ /dev/null @@ -1,41 +0,0 @@ -// PostRetweetRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id -open class PostRetweetRequestV1: TwitterAPIRequest { - public let id: String - public let trimUser: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/statuses/retweet/\(id).json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - trimUser.map { params["trim_user"] = $0 } - return params - } - - public init( - id: String, - trimUser: Bool? = .none - ) { - self.id = id - self.trimUser = trimUser - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/PostUnRetweetRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Retweet/Requests/PostUnRetweetRequestV1.swift deleted file mode 100644 index 24fe3dd1..00000000 --- a/Sources/TwitterAPIKit/APIv1/Retweet/Requests/PostUnRetweetRequestV1.swift +++ /dev/null @@ -1,41 +0,0 @@ -// PostUnRetweetRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-unretweet-id -open class PostUnRetweetRequestV1: TwitterAPIRequest { - public let id: String - public let trimUser: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/statuses/unretweet/\(id).json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - trimUser.map { params["trim_user"] = $0 } - return params - } - - public init( - id: String, - trimUser: Bool? = .none - ) { - self.id = id - self.trimUser = trimUser - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Retweet/RetweetAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Retweet/RetweetAPIv1.swift deleted file mode 100644 index a44a2ee7..00000000 --- a/Sources/TwitterAPIKit/APIv1/Retweet/RetweetAPIv1.swift +++ /dev/null @@ -1,60 +0,0 @@ -// RetweetAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class RetweetAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/ - /// api-reference/post-statuses-retweet-id - public func postRetweet( - _ request: PostRetweetRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/ - /// api-reference/post-statuses-unretweet-id - public func postUnRetweet( - _ request: PostUnRetweetRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/ - /// api-reference/get-statuses-retweets-id - public func getRetweets( - _ request: GetRetweetsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/ - /// api-reference/get-statuses-retweets_of_me - public func getRetweetsOfMe( - _ request: GetRetweetsOfMeRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/ - /// api-reference/get-statuses-retweeters-ids - public func getRetweeters( - _ request: GetRetweetersRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Search/Requests/GetSavedSearchesListRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Search/Requests/GetSavedSearchesListRequestV1.swift deleted file mode 100644 index 448c7ef2..00000000 --- a/Sources/TwitterAPIKit/APIv1/Search/Requests/GetSavedSearchesListRequestV1.swift +++ /dev/null @@ -1,32 +0,0 @@ -// GetSavedSearchesListRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/get-saved_searches-list -open class GetSavedSearchesListRequestV1: TwitterAPIRequest { - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/saved_searches/list.json" - } - - open var parameters: [String: Any] { - [:] - } - - public init() {} - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Search/Requests/GetSearchTweetsRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Search/Requests/GetSearchTweetsRequestV1.swift deleted file mode 100644 index b6308ddf..00000000 --- a/Sources/TwitterAPIKit/APIv1/Search/Requests/GetSearchTweetsRequestV1.swift +++ /dev/null @@ -1,80 +0,0 @@ -// GetSearchTweetsRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets -open class GetSearchTweetsRequestV1: TwitterAPIRequest { - public enum ResultType: String { - case mixed - case recent - case popular - } - - public let query: String - public let lang: String? - public let count: Int? - public let until: String? - public let maxID: String? - public let locale: String? - public let geocode: String? - public let sinceID: String? - public let resultType: ResultType? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/search/tweets.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["q"] = query - lang.map { params["lang"] = $0 } - count.map { params["count"] = $0 } - until.map { params["until"] = $0 } - maxID.map { params["max_id"] = $0 } - locale.map { params["locale"] = $0 } - geocode.map { params["geocode"] = $0 } - sinceID.map { params["since_id"] = $0 } - resultType.map { params["result_type"] = $0.rawValue } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - query: String, - lang: String? = .none, - count: Int? = .none, - until: String? = .none, - maxID: String? = .none, - locale: String? = .none, - geocode: String? = .none, - sinceID: String? = .none, - resultType: ResultType? = .none, - includeEntities: Bool? = .none - ) { - self.query = query - self.lang = lang - self.count = count - self.until = until - self.maxID = maxID - self.locale = locale - self.geocode = geocode - self.sinceID = sinceID - self.resultType = resultType - self.includeEntities = includeEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Search/Requests/PostSavedSearchesCreateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Search/Requests/PostSavedSearchesCreateRequestV1.swift deleted file mode 100644 index bcc36a3a..00000000 --- a/Sources/TwitterAPIKit/APIv1/Search/Requests/PostSavedSearchesCreateRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// PostSavedSearchesCreateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-saved_searches-create -open class PostSavedSearchesCreateRequestV1: TwitterAPIRequest { - public let query: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/saved_searches/create.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["query"] = query - return params - } - - public init( - query: String - ) { - self.query = query - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Search/Requests/PostSavedSearchesDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Search/Requests/PostSavedSearchesDestroyRequestV1.swift deleted file mode 100644 index 85c33f0b..00000000 --- a/Sources/TwitterAPIKit/APIv1/Search/Requests/PostSavedSearchesDestroyRequestV1.swift +++ /dev/null @@ -1,38 +0,0 @@ -// PostSavedSearchesDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/post-saved_searches-destroy-id -open class PostSavedSearchesDestroyRequestV1: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/saved_searches/destroy/\(id).json" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String - ) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Search/SearchAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Search/SearchAPIv1.swift deleted file mode 100644 index 2abc04be..00000000 --- a/Sources/TwitterAPIKit/APIv1/Search/SearchAPIv1.swift +++ /dev/null @@ -1,51 +0,0 @@ -// SearchAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class SearchAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/ - /// api-reference/get-search-tweets - public func searchTweets( - _ request: GetSearchTweetsRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/get-saved_searches-list - public func getSavedSearches( - _ request: GetSavedSearchesListRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-saved_searches-create - public func postCreateSavedSearch( - _ request: PostSavedSearchesCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ - /// manage-account-settings/api-reference/post-saved_searches-destroy-id - public func postDestroySavedSearch( - _ request: PostSavedSearchesCreateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesHomeTimelineRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesHomeTimelineRequestV1.swift deleted file mode 100644 index e86ee9a9..00000000 --- a/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesHomeTimelineRequestV1.swift +++ /dev/null @@ -1,60 +0,0 @@ -// GetStatusesHomeTimelineRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/ -/// api-reference/get-statuses-home_timeline -open class GetStatusesHomeTimelineRequestV1: TwitterAPIRequest { - public let count: Int? - public let maxID: String? - public let sinceID: String? - public let trimUser: Bool? - public let excludeReplies: Bool? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/home_timeline.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - count.map { params["count"] = $0 } - maxID.map { params["max_id"] = $0 } - sinceID.map { params["since_id"] = $0 } - trimUser.map { params["trim_user"] = $0 } - excludeReplies.map { params["exclude_replies"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - count: Int? = .none, - maxID: String? = .none, - sinceID: String? = .none, - trimUser: Bool? = .none, - excludeReplies: Bool? = .none, - includeEntities: Bool? = .none - ) { - self.count = count - self.maxID = maxID - self.sinceID = sinceID - self.trimUser = trimUser - self.excludeReplies = excludeReplies - self.includeEntities = includeEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesMentionsTimelineRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesMentionsTimelineRequestV1.swift deleted file mode 100644 index 5e67c716..00000000 --- a/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesMentionsTimelineRequestV1.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetStatusesMentionsTimelineRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-mentions_timeline -open class GetStatusesMentionsTimelineRequestV1: TwitterAPIRequest { - public let count: Int? - public let maxID: String? - public let sinceID: String? - public let trimUser: Bool? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/mentions_timeline.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - count.map { params["count"] = $0 } - maxID.map { params["max_id"] = $0 } - sinceID.map { params["since_id"] = $0 } - trimUser.map { params["trim_user"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - count: Int? = .none, - maxID: String? = .none, - sinceID: String? = .none, - trimUser: Bool? = .none, - includeEntities: Bool? = .none - ) { - self.count = count - self.maxID = maxID - self.sinceID = sinceID - self.trimUser = trimUser - self.includeEntities = includeEntities - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesUserTimelineRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesUserTimelineRequestV1.swift deleted file mode 100644 index 80ab8bee..00000000 --- a/Sources/TwitterAPIKit/APIv1/Timelines/Requests/GetStatusesUserTimelineRequestV1.swift +++ /dev/null @@ -1,62 +0,0 @@ -// GetStatusesUserTimelineRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-user_timeline -open class GetStatusesUserTimelineRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let count: Int? - public let maxID: String? - public let sinceID: String? - public let trimUser: Bool? - public let includeRTs: Bool? - public let excludeReplies: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/user_timeline.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - count.map { params["count"] = $0 } - maxID.map { params["max_id"] = $0 } - sinceID.map { params["since_id"] = $0 } - trimUser.map { params["trim_user"] = $0 } - includeRTs.map { params["include_rts"] = $0 } - excludeReplies.map { params["exclude_replies"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - count: Int? = .none, - maxID: String? = .none, - sinceID: String? = .none, - trimUser: Bool? = .none, - includeRTs: Bool? = .none, - excludeReplies: Bool? = .none - ) { - self.user = user - self.count = count - self.maxID = maxID - self.sinceID = sinceID - self.trimUser = trimUser - self.includeRTs = includeRTs - self.excludeReplies = excludeReplies - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Timelines/TimelineAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Timelines/TimelineAPIv1.swift deleted file mode 100644 index 83cee92c..00000000 --- a/Sources/TwitterAPIKit/APIv1/Timelines/TimelineAPIv1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// TimelineAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/overview -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/ -/// overview -open class TimelineAPIv1: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-home_timeline - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/ - /// api-reference/get-statuses-home_timeline - public func getHomeTimeline( - _ request: GetStatusesHomeTimelineRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/ - /// overview - /// api-reference/get-statuses-mentions_timeline - public func getMentionsTimeline( - _ request: GetStatusesMentionsTimelineRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/ - /// api-reference/get-statuses-user_timeline - public func getUserTimeline( - _ request: GetStatusesUserTimelineRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsAvailableRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsAvailableRequestV1.swift deleted file mode 100644 index edcef8b8..00000000 --- a/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsAvailableRequestV1.swift +++ /dev/null @@ -1,31 +0,0 @@ -// GetTrendsAvailableRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/trends/trends-for-location/ -/// api-reference/get-trends-available -open class GetTrendsAvailableRequestV1: TwitterAPIRequest { - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/trends/available.json" - } - - open var parameters: [String: Any] { - [:] - } - - public init() {} - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsClosestRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsClosestRequestV1.swift deleted file mode 100644 index 633b25d3..00000000 --- a/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsClosestRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetTrendsClosestRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/trends/trends-for-location/ -/// api-reference/get-trends-closest -open class GetTrendsClosestRequestV1: TwitterAPIRequest { - public let location: TwitterCoordinateV1 - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/trends/closest.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - location.bind(param: ¶ms) - return params - } - - public init( - location: TwitterCoordinateV1 - ) { - self.location = location - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsPlaceRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsPlaceRequestV1.swift deleted file mode 100644 index 40e10f8a..00000000 --- a/Sources/TwitterAPIKit/APIv1/Trend/Requests/GetTrendsPlaceRequestV1.swift +++ /dev/null @@ -1,45 +0,0 @@ -// GetTrendsPlaceRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/trends/trends-for-location/api-reference/get-trends-place -open class GetTrendsPlaceRequestV1: TwitterAPIRequest { - /// Where On Earth ID Global - public let woeid: String - - /// exclude hshtags - public let exclude: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/trends/place.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["woeid"] = woeid - exclude.map { params["exclude"] = $0 } - return params - } - - public init( - woeid: String, - exclude: Bool? = .none - ) { - self.woeid = woeid - self.exclude = exclude - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Trend/TrendAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Trend/TrendAPIv1.swift deleted file mode 100644 index 72f5e0d8..00000000 --- a/Sources/TwitterAPIKit/APIv1/Trend/TrendAPIv1.swift +++ /dev/null @@ -1,42 +0,0 @@ -// TrendAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class TrendAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/trends/ - /// trends-for-location/api-reference/get-trends-available - public func getTrendsAvailable( - _ request: GetTrendsAvailableRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/trends/ - /// locations-with-trending-topics/api-reference/get-trends-closest - public func getTrendsClosest( - _ request: GetTrendsClosestRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/trends/ - /// trends-for-location/api-reference/get-trends-place - public func getTrends( - _ request: GetTrendsPlaceRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/GetStatusesLookupRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Tweet/Requests/GetStatusesLookupRequestV1.swift deleted file mode 100644 index 7a44a7fc..00000000 --- a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/GetStatusesLookupRequestV1.swift +++ /dev/null @@ -1,58 +0,0 @@ -// GetStatusesLookupRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-lookup -open class GetStatusesLookupRequestV1: TwitterAPIRequest { - public let ids: [String] - public let map: Bool? - public let trimUser: Bool? - public let includeCardUri: Bool? - public let includeEntities: Bool? - public let includeExtAltText: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/lookup.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = ids.joined(separator: ",") - map.map { params["map"] = $0 } - trimUser.map { params["trim_user"] = $0 } - includeCardUri.map { params["include_card_uri"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - includeExtAltText.map { params["include_ext_alt_text"] = $0 } - return params - } - - public init( - ids: [String], - map: Bool? = .none, - trimUser: Bool? = .none, - includeCardUri: Bool? = .none, - includeEntities: Bool? = .none, - includeExtAltText: Bool? = .none - ) { - self.ids = ids - self.map = map - self.trimUser = trimUser - self.includeCardUri = includeCardUri - self.includeEntities = includeEntities - self.includeExtAltText = includeExtAltText - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/GetStatusesShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Tweet/Requests/GetStatusesShowRequestV1.swift deleted file mode 100644 index 741a8aaa..00000000 --- a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/GetStatusesShowRequestV1.swift +++ /dev/null @@ -1,58 +0,0 @@ -// GetStatusesShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-show-id -open class GetStatusesShowRequestV1: TwitterAPIRequest { - public let id: String - public let trimUser: Bool? - public let includeCardUri: Bool? - public let includeEntities: Bool? - public let includeMyRetweet: Bool? - public let includeExtAltText: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/statuses/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["id"] = id - trimUser.map { params["trim_user"] = $0 } - includeCardUri.map { params["include_card_uri"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - includeMyRetweet.map { params["include_my_retweet"] = $0 } - includeExtAltText.map { params["include_ext_alt_text"] = $0 } - return params - } - - public init( - id: String, - trimUser: Bool? = .none, - includeCardUri: Bool? = .none, - includeEntities: Bool? = .none, - includeMyRetweet: Bool? = .none, - includeExtAltText: Bool? = .none - ) { - self.id = id - self.trimUser = trimUser - self.includeCardUri = includeCardUri - self.includeEntities = includeEntities - self.includeMyRetweet = includeMyRetweet - self.includeExtAltText = includeExtAltText - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/PostStatusesDestroyRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Tweet/Requests/PostStatusesDestroyRequestV1.swift deleted file mode 100644 index a6d670e8..00000000 --- a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/PostStatusesDestroyRequestV1.swift +++ /dev/null @@ -1,41 +0,0 @@ -// PostStatusesDestroyRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-destroy-id -open class PostStatusesDestroyRequestV1: TwitterAPIRequest { - public let id: String - public let trimUser: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/statuses/destroy/\(id).json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - trimUser.map { params["trim_user"] = $0 } - return params - } - - public init( - id: String, - trimUser: Bool? = .none - ) { - self.id = id - self.trimUser = trimUser - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/PostStatusesUpdateRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Tweet/Requests/PostStatusesUpdateRequestV1.swift deleted file mode 100644 index c7734212..00000000 --- a/Sources/TwitterAPIKit/APIv1/Tweet/Requests/PostStatusesUpdateRequestV1.swift +++ /dev/null @@ -1,90 +0,0 @@ -// PostStatusesUpdateRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-update -open class PostStatusesUpdateRequestV1: TwitterAPIRequest { - public let status: String - public let inReplyToStatusID: String? - public let autoPopulateReplyMetadata: Bool? - public let excludeReplyUserIDs: [String]? - public let attachmentUrl: String? - public let mediaIDs: [String]? - public let possiblySensitive: Bool? - public let location: TwitterCoordinateV1? - public let placeID: String? - public let displayCoordinates: Bool? - public let trimUser: Bool? - public let enableDMcommands: Bool? - public let failDMcommands: Bool? - public let cardUri: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/1.1/statuses/update.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["status"] = status - inReplyToStatusID.map { params["in_reply_to_status_id"] = $0 } - autoPopulateReplyMetadata.map { params["auto_populate_reply_metadata"] = $0 } - excludeReplyUserIDs.map { params["exclude_reply_user_ids"] = $0.joined(separator: ",") } - attachmentUrl.map { params["attachment_url"] = $0 } - mediaIDs.map { params["media_ids"] = $0.joined(separator: ",") } - possiblySensitive.map { params["possibly_sensitive"] = $0 } - location?.bind(param: ¶ms) - placeID.map { params["place_id"] = $0 } - displayCoordinates.map { params["display_coordinates"] = $0 } - trimUser.map { params["trim_user"] = $0 } - enableDMcommands.map { params["enable_dmcommands"] = $0 } - failDMcommands.map { params["fail_dmcommands"] = $0 } - cardUri.map { params["card_uri"] = $0 } - return params - } - - public init( - status: String, - inReplyToStatusID: String? = .none, - autoPopulateReplyMetadata: Bool? = .none, - excludeReplyUserIDs: [String]? = .none, - attachmentUrl: String? = .none, - mediaIDs: [String]? = .none, - possiblySensitive: Bool? = .none, - location: TwitterCoordinateV1? = .none, - placeID: String? = .none, - displayCoordinates: Bool? = .none, - trimUser: Bool? = .none, - enableDMcommands: Bool? = .none, - failDMcommands: Bool? = .none, - cardUri: String? = .none - ) { - self.status = status - self.inReplyToStatusID = inReplyToStatusID - self.autoPopulateReplyMetadata = autoPopulateReplyMetadata - self.excludeReplyUserIDs = excludeReplyUserIDs - self.attachmentUrl = attachmentUrl - self.mediaIDs = mediaIDs - self.possiblySensitive = possiblySensitive - self.location = location - self.placeID = placeID - self.displayCoordinates = displayCoordinates - self.trimUser = trimUser - self.enableDMcommands = enableDMcommands - self.failDMcommands = failDMcommands - self.cardUri = cardUri - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Tweet/TweetAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Tweet/TweetAPIv1.swift deleted file mode 100644 index d9d54c11..00000000 --- a/Sources/TwitterAPIKit/APIv1/Tweet/TweetAPIv1.swift +++ /dev/null @@ -1,51 +0,0 @@ -// TweetAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class TweetAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ - /// post-and-engage/api-reference/post-statuses-update - public func postUpdateStatus( - _ request: PostStatusesUpdateRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ - /// post-and-engage/api-reference/post-statuses-destroy-id - public func postDestroyStatus( - _ request: PostStatusesDestroyRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ - /// post-and-engage/api-reference/get-statuses-show-id - public func getShowStatus( - _ request: GetStatusesShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/ - /// post-and-engage/api-reference/get-statuses-lookup - public func getLookupStatuses( - _ request: GetStatusesLookupRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/TwitterAPIv1.swift b/Sources/TwitterAPIKit/APIv1/TwitterAPIv1.swift deleted file mode 100644 index aa1e6605..00000000 --- a/Sources/TwitterAPIKit/APIv1/TwitterAPIv1.swift +++ /dev/null @@ -1,89 +0,0 @@ -// TwitterAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -/// Main class for accessing Twitter API v1.1 endpoints. -/// This class provides access to all Twitter API v1.1 functionality through specialized API clients. -/// Each property represents a group of related API endpoints. -open class TwitterAPIv1: TwitterAPI { - /// API client for managing Twitter account settings and profile information. - public let account: AccountAPIv1 - - /// API client for accessing application-level information and rate limits. - public let application: ApplicationAPIv1 - - /// API client for managing blocked and muted users. - public let blockAndMute: BlockAndMuteAPIv1 - - /// API client for managing Twitter collections (curated groups of tweets). - public let collection: CollectionAPIv1 - - /// API client for sending and receiving direct messages. - public let directMessage: DirectMessageAPIv1 - - /// API client for managing tweet favorites (likes). - public let favorite: FavoriteAPIv1 - - /// API client for managing user relationships (following/followers). - public let friendships: FriendshipsAPIv1 - - /// API client for accessing Twitter's geo-location features. - public let geo: GeoAPIv1 - - /// API client for accessing Twitter platform information and supported features. - public let help: HelpAPIv1 - - /// API client for managing Twitter lists. - public let list: ListAPIv1 - - /// API client for uploading and managing media attachments. - public let media: MediaAPIv1 - - /// API client for managing retweets. - public let retweet: RetweetAPIv1 - - /// API client for searching tweets and managing saved searches. - public let search: SearchAPIv1 - - /// API client for accessing user timelines. - public let timeline: TimelineAPIv1 - - /// API client for accessing trending topics. - public let trend: TrendAPIv1 - - /// API client for creating, deleting, and retrieving tweets. - public let tweet: TweetAPIv1 - - /// API client for managing and retrieving user information. - public let user: UserAPIv1 - - /// Creates a new Twitter API v1.1 client. - /// - Parameter session: The Twitter API session to use for making requests. - public init(session: TwitterAPISession) { - account = .init(session: session) - application = .init(session: session) - blockAndMute = .init(session: session) - collection = .init(session: session) - directMessage = .init(session: session) - favorite = .init(session: session) - friendships = .init(session: session) - geo = .init(session: session) - help = .init(session: session) - list = .init(session: session) - media = .init(session: session) - retweet = .init(session: session) - search = .init(session: session) - timeline = .init(session: session) - trend = .init(session: session) - tweet = .init(session: session) - user = .init(session: session) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/TwitterListIdentifierV1.swift b/Sources/TwitterAPIKit/APIv1/TwitterListIdentifierV1.swift deleted file mode 100644 index f31d8037..00000000 --- a/Sources/TwitterAPIKit/APIv1/TwitterListIdentifierV1.swift +++ /dev/null @@ -1,43 +0,0 @@ -// TwitterListIdentifierV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Represents different ways to identify a Twitter list in API v1.1. -/// Lists can be identified either by their unique ID or by a combination of slug and owner. -public enum TwitterListIdentifierV1 { - /// Identifies a list by its unique numeric ID. - /// - Parameter listID: The unique identifier of the list. - case listID(String) - - /// Identifies a list by its slug (URL-friendly name) and owner. - /// - Parameters: - /// - slug: The URL-friendly name of the list. - /// - owner: The identifier of the list's owner. - case slug(slug: String, owner: TwitterUserIdentifierV1) -} - -public extension TwitterListIdentifierV1 { - /// Binds the list identifier to the request parameters. - /// - Parameters: - /// - param: The parameters dictionary to bind to. - func bind(param: inout [String: Any]) { - switch self { - case let .listID(string): - param["list_id"] = string - case let .slug(slug, owner): - param["slug"] = slug - switch owner { - case let .userID(string): - param["owner_id"] = string - case let .screenName(string): - param["owner_screen_name"] = string - } - } - } -} diff --git a/Sources/TwitterAPIKit/APIv1/TwitterListModeV1.swift b/Sources/TwitterAPIKit/APIv1/TwitterListModeV1.swift deleted file mode 100644 index a7f71cae..00000000 --- a/Sources/TwitterAPIKit/APIv1/TwitterListModeV1.swift +++ /dev/null @@ -1,33 +0,0 @@ -// TwitterListModeV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Represents the visibility mode of a Twitter list in API v1.1. -/// Lists can be either public (visible to all users) or private (visible only to the owner). -public enum TwitterListModeV1 { - /// The list is private and only visible to its owner. - case `private` - - /// The list is publicly visible to all Twitter users. - case `public` -} - -public extension TwitterListModeV1 { - /// Binds the list mode to the request parameters. - /// - Parameters: - /// - param: The parameters dictionary to bind to. - func bind(param: inout [String: Any]) { - switch self { - case .public: - param["mode"] = "public" - case .private: - param["mode"] = "private" - } - } -} diff --git a/Sources/TwitterAPIKit/APIv1/TwitterLocations.swift b/Sources/TwitterAPIKit/APIv1/TwitterLocations.swift deleted file mode 100644 index ccb71a43..00000000 --- a/Sources/TwitterAPIKit/APIv1/TwitterLocations.swift +++ /dev/null @@ -1,72 +0,0 @@ -// TwitterLocations.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// A protocol that represents a location in the Twitter API v1 -public protocol TwitterLocations { - // No Logic Here -} - -/// Represents geographical coordinates in the Twitter API v1 -public struct TwitterCoordinateV1: TwitterLocations { - /// The latitude coordinate - public var lat: Double - /// The longitude coordinate - public var long: Double - - /// Creates a new coordinate with the specified latitude and longitude - public init(lat: Double, long: Double) { - self.lat = lat - self.long = long - } - - /// Binds the coordinate values to the provided parameters dictionary - public func bind(param: inout [String: Any]) { - param["lat"] = lat - param["long"] = long - } -} - -/// Represents accuracy levels for geographical locations -public enum TwitterAccuracyV1: TwitterLocations { - // swiftlint:disable identifier_name - /// Accuracy in feet - case ft(Int) - /// Accuracy in meters - case m(Int) - - /// Binds the accuracy value to the provided parameters dictionary - public func bind(param: inout [String: Any]) { - switch self { - case let .m(int): - param["accuracy"] = "\(int)m" - case let .ft(int): - param["accuracy"] = "\(int)ft" - } - } -} - -// swiftlint:enable identifier_name - -/// Represents the granularity level for geographical locations -public enum TwitterGranularityV1: String { - /// Administrative level granularity - case admin - /// City level granularity - case city - /// Country levelk granularity - case country - /// Neighborhood level granularity - case neighborhood - - /// Binds the granularity value to the provided parameters dictionary - public func bind(param: inout [String: Any]) { - param["granularity"] = rawValue - } -} diff --git a/Sources/TwitterAPIKit/APIv1/TwitterUserIdentifierV1.swift b/Sources/TwitterAPIKit/APIv1/TwitterUserIdentifierV1.swift deleted file mode 100644 index b41e988d..00000000 --- a/Sources/TwitterAPIKit/APIv1/TwitterUserIdentifierV1.swift +++ /dev/null @@ -1,65 +0,0 @@ -// TwitterUserIdentifierV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Represents a way to identify a single Twitter user in the v1.1 API. -public enum TwitterUserIdentifierV1 { - /// Identifies a user by their screen name (username). - /// - Parameter String: The user's screen name without the @ symbol. - case screenName(String) - - /// Identifies a user by their numeric user ID. - /// - Parameter String: The user's unique numeric ID. - case userID(String) -} - -/// Represents a way to identify multiple Twitter users in the v1.1 API. -public enum TwitterUsersIdentifierV1 { - /// Identifies multiple users by their screen names (usernames). - /// - Parameter [String]: An array of screen names without the @ symbol. - case screenNames([String]) - - /// Identifies multiple users by their numeric user IDs. - /// - Parameter [String]: An array of user IDs. - case userIDs([String]) -} - -// MARK: - extensions - -/// Extension to bind user identifier to request parameters -public extension TwitterUserIdentifierV1 { - /// Binds the user identifier to the request parameters - /// - Parameters: - /// - param: The parameters dictionary to bind to - /// - userIDKey: The key to use for the user ID - /// - screenNameKey: The key to use for the screen name - func bind(param: inout [String: Any], userIDKey: String = "user_id", screenNameKey: String = "screen_name") { - switch self { - case let .userID(string): - param[userIDKey] = string - case let .screenName(string): - param[screenNameKey] = string - } - } -} - -/// Extension to bind multiple user identifiers to request parameters -public extension TwitterUsersIdentifierV1 { - /// Binds the multiple user identifiers to the request parameters - /// - Parameters: - /// - param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - switch self { - case let .userIDs(array): - param["user_id"] = array.joined(separator: ",") - case let .screenNames(array): - param["screen_name"] = array.joined(separator: ",") - } - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersLookupRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersLookupRequestV1.swift deleted file mode 100644 index 1468432e..00000000 --- a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersLookupRequestV1.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetUsersLookupRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-users-lookup -open class GetUsersLookupRequestV1: TwitterAPIRequest { - public let users: TwitterUsersIdentifierV1 - public let tweetMode: Bool? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/users/lookup.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - users.bind(param: ¶ms) - tweetMode.map { params["tweet_mode"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - users: TwitterUsersIdentifierV1, - tweetMode: Bool? = .none, - includeEntities: Bool? = .none - ) { - self.users = users - self.tweetMode = tweetMode - self.includeEntities = includeEntities - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersProfileBannerRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersProfileBannerRequestV1.swift deleted file mode 100644 index f8c6b09a..00000000 --- a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersProfileBannerRequestV1.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetUsersProfileBannerRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// manage-account-settings/api-reference/get-users-profile_banner -open class GetUsersProfileBannerRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/users/profile_banner.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - return params - } - - public init( - user: TwitterUserIdentifierV1 - ) { - self.user = user - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersSearchRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersSearchRequestV1.swift deleted file mode 100644 index 06a041e7..00000000 --- a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersSearchRequestV1.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetUsersSearchRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-users-search -open class GetUsersSearchRequestV1: TwitterAPIRequest { - public let query: String - public let page: Int? - public let count: Int? - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/users/search.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["q"] = query - page.map { params["page"] = $0 } - count.map { params["count"] = $0 } - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - query: String, - page: Int? = .none, - count: Int? = .none, - includeEntities: Bool? = .none - ) { - self.query = query - self.page = page - self.count = count - self.includeEntities = includeEntities - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersShowRequestV1.swift b/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersShowRequestV1.swift deleted file mode 100644 index ac65ea30..00000000 --- a/Sources/TwitterAPIKit/APIv1/Users/Requests/GetUsersShowRequestV1.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetUsersShowRequestV1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/ -/// follow-search-get-users/api-reference/get-users-show -open class GetUsersShowRequestV1: TwitterAPIRequest { - public let user: TwitterUserIdentifierV1 - public let includeEntities: Bool? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/1.1/users/show.json" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - user.bind(param: ¶ms) - includeEntities.map { params["include_entities"] = $0 } - return params - } - - public init( - user: TwitterUserIdentifierV1, - includeEntities: Bool? = .none - ) { - self.user = user - self.includeEntities = includeEntities - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv1/Users/UserAPIv1.swift b/Sources/TwitterAPIKit/APIv1/Users/UserAPIv1.swift deleted file mode 100644 index e188212b..00000000 --- a/Sources/TwitterAPIKit/APIv1/Users/UserAPIv1.swift +++ /dev/null @@ -1,51 +0,0 @@ -// UserAPIv1.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class UserAPIv1: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-users-lookup - public func getUsers( - _ request: GetUsersLookupRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-users-show - public func getUser( - _ request: GetUsersShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/ - /// api-reference/get-users-search - public func searchUser( - _ request: GetUsersShowRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/ - /// api-reference/get-users-profile_banner - public func getUserProfileBanner( - _ request: GetUsersProfileBannerRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/BlockAndMuteAPIv2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/BlockAndMuteAPIv2.swift deleted file mode 100644 index 0898ccfe..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/BlockAndMuteAPIv2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// BlockAndMuteAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class BlockAndMuteAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/get-users-blocking - public func getBlockUsers( - _ request: GetUsersBlockingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/post-users-user_id-blocking - public func blockUser( - _ request: PostUsersBlockingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/delete-users-user_id-blocking - public func unblockUser( - _ request: DeleteUsersBlockingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/get-users-muting - public func getMuteUsers( - _ request: GetUsersMutingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/post-users-user_id-muting - public func muteUser( - _ request: PostUsersMutingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/delete-users-user_id-muting - public func unmuteUser( - _ request: DeleteUsersMutingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/DeleteUsersBlockingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/DeleteUsersBlockingRequestV2.swift deleted file mode 100644 index 9178a973..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/DeleteUsersBlockingRequestV2.swift +++ /dev/null @@ -1,39 +0,0 @@ -// DeleteUsersBlockingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/delete-users-user_id-blocking -open class DeleteUsersBlockingRequestV2: TwitterAPIRequest { - public let sourceUserID: String - public let targetUserID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(sourceUserID)/blocking/\(targetUserID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - sourceUserID: String, - targetUserID: String - ) { - self.sourceUserID = sourceUserID - self.targetUserID = targetUserID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/DeleteUsersMutingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/DeleteUsersMutingRequestV2.swift deleted file mode 100644 index 8474a999..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/DeleteUsersMutingRequestV2.swift +++ /dev/null @@ -1,39 +0,0 @@ -// DeleteUsersMutingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/delete-users-user_id-muting -open class DeleteUsersMutingRequestV2: TwitterAPIRequest { - public let sourceUserID: String - public let targetUserID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(sourceUserID)/muting/\(targetUserID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - sourceUserID: String, - targetUserID: String - ) { - self.sourceUserID = sourceUserID - self.targetUserID = targetUserID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/GetUsersBlockingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/GetUsersBlockingRequestV2.swift deleted file mode 100644 index e795d445..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/GetUsersBlockingRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetUsersBlockingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/get-users-blocking -open class GetUsersBlockingRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/blocking" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/GetUsersMutingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/GetUsersMutingRequestV2.swift deleted file mode 100644 index 0dc556f4..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/GetUsersMutingRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetUsersMutingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/get-users-muting -open class GetUsersMutingRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/muting" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/PostUsersBlockingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/PostUsersBlockingRequestV2.swift deleted file mode 100644 index de09ad27..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/PostUsersBlockingRequestV2.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostUsersBlockingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/post-users-user_id-blocking -open class PostUsersBlockingRequestV2: TwitterAPIRequest { - public let id: String - public let targetUserID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/blocking" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["target_user_id"] = targetUserID - return params - } - - public init( - id: String, - targetUserID: String - ) { - self.id = id - self.targetUserID = targetUserID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/PostUsersMutingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/PostUsersMutingRequestV2.swift deleted file mode 100644 index c212a417..00000000 --- a/Sources/TwitterAPIKit/APIv2/BlockAndMute/Requests/PostUsersMutingRequestV2.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostUsersMutingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/post-users-user_id-muting -open class PostUsersMutingRequestV2: TwitterAPIRequest { - public let id: String - public let targetUserID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/muting" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["target_user_id"] = targetUserID - return params - } - - public init( - id: String, - targetUserID: String - ) { - self.id = id - self.targetUserID = targetUserID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Bookmarks/BookmarksAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Bookmarks/BookmarksAPIv2.swift deleted file mode 100644 index fbd94c4e..00000000 --- a/Sources/TwitterAPIKit/APIv2/Bookmarks/BookmarksAPIv2.swift +++ /dev/null @@ -1,42 +0,0 @@ -// BookmarksAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class BookmarksAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/ - /// api-reference/get-users-id-bookmarks - public func getBookmarks( - _ request: GetUsersBookmarksRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/ - /// api-reference/post-users-id-bookmarks - public func createBookmark( - _ request: PostUsersBookmarksRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/ - /// api-reference/delete-users-id-bookmarks-tweet_id - public func deleteBookmark( - _ request: DeleteUsersBookmarksRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/DeleteUsersBookmarksRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/DeleteUsersBookmarksRequestV2.swift deleted file mode 100644 index dac429a4..00000000 --- a/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/DeleteUsersBookmarksRequestV2.swift +++ /dev/null @@ -1,42 +0,0 @@ -// DeleteUsersBookmarksRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/delete-users-id-bookmarks-tweet_id -open class DeleteUsersBookmarksRequestV2: TwitterAPIRequest { - /// The user ID of an authenticated user who you are removing a Bookmark of a Tweet on behalf of. It must match your - /// own user ID or that of an authenticating user, meaning that you must pass the Access Tokens associated with the - /// user ID when authenticating your request. - public let id: String - public let tweetID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(id)/bookmarks/\(tweetID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String, - tweetID: String - ) { - self.id = id - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/GetUsersBookmarksRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/GetUsersBookmarksRequestV2.swift deleted file mode 100644 index 14efc311..00000000 --- a/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/GetUsersBookmarksRequestV2.swift +++ /dev/null @@ -1,70 +0,0 @@ -// GetUsersBookmarksRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/get-users-id-bookmarks -open class GetUsersBookmarksRequestV2: TwitterAPIRequest { - /// User ID of an authenticated user to request bookmarked Tweets for. - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/bookmarks" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/PostUsersBookmarksRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/PostUsersBookmarksRequestV2.swift deleted file mode 100644 index 77886ba5..00000000 --- a/Sources/TwitterAPIKit/APIv2/Bookmarks/Requests/PostUsersBookmarksRequestV2.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostUsersBookmarksRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/post-users-id-bookmarks -open class PostUsersBookmarksRequestV2: TwitterAPIRequest { - /// The user ID who you are bookmarking a Tweet on behalf of. It must match your own user ID or that of an - /// authenticating user, meaning that you must pass the Access Token associated with the user ID when authenticating - /// your request. - public let id: String - public let tweetID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/bookmarks" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["tweet_id"] = tweetID - return params - } - - public init( - id: String, - tweetID: String - ) { - self.id = id - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Compliance/ComplianceAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Compliance/ComplianceAPIv2.swift deleted file mode 100644 index d0199d42..00000000 --- a/Sources/TwitterAPIKit/APIv2/Compliance/ComplianceAPIv2.swift +++ /dev/null @@ -1,42 +0,0 @@ -// ComplianceAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class ComplianceAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/ - /// api-reference/get-compliance-jobs-id - public func getComplianceJob( - _ request: GetComplianceJobRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/ - /// api-reference/get-compliance-jobs - public func getComplianceJobj( - _ request: GetComplianceJobsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/ - /// api-reference/post-compliance-jobs - public func createComplianceJob( - _ request: PostComplianceJobsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Compliance/Requests/GetComplianceJobRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Compliance/Requests/GetComplianceJobRequestV2.swift deleted file mode 100644 index c35630ea..00000000 --- a/Sources/TwitterAPIKit/APIv2/Compliance/Requests/GetComplianceJobRequestV2.swift +++ /dev/null @@ -1,36 +0,0 @@ -// GetComplianceJobRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs-id -open class GetComplianceJobRequestV2: TwitterAPIRequest { - public let id: Int - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/compliance/jobs/\(id)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: Int - ) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Compliance/Requests/GetComplianceJobsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Compliance/Requests/GetComplianceJobsRequestV2.swift deleted file mode 100644 index 8f8cbe83..00000000 --- a/Sources/TwitterAPIKit/APIv2/Compliance/Requests/GetComplianceJobsRequestV2.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetComplianceJobsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs -open class GetComplianceJobsRequestV2: TwitterAPIRequest { - public enum Status: String { - case created - case inProgress = "in_progress" - case failed - case complete - public func bind(param: inout [String: Any]) { - param["status"] = rawValue - } - } - - public let type: TwitterComplianceJobTypeV2 - public let status: Status? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/compliance/jobs" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - type.bind(param: ¶ms) - status?.bind(param: ¶ms) - return params - } - - public init( - type: TwitterComplianceJobTypeV2, - status: Status? = .none - ) { - self.type = type - self.status = status - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Compliance/Requests/PostComplianceJobsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Compliance/Requests/PostComplianceJobsRequestV2.swift deleted file mode 100644 index f73503d4..00000000 --- a/Sources/TwitterAPIKit/APIv2/Compliance/Requests/PostComplianceJobsRequestV2.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostComplianceJobsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/post-compliance-jobs -open class PostComplianceJobsRequestV2: TwitterAPIRequest { - public let type: TwitterComplianceJobTypeV2 - public let name: String? - public let resumable: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/compliance/jobs" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - type.bind(param: ¶ms) - name.map { params["name"] = $0 } - resumable.map { params["resumable"] = $0 } - return params - } - - public init( - type: TwitterComplianceJobTypeV2, - name: String? = .none, - resumable: Bool? = .none - ) { - self.type = type - self.name = name - self.resumable = resumable - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/DirectMessageAPIv2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/DirectMessageAPIv2.swift deleted file mode 100644 index 742d3c62..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/DirectMessageAPIv2.swift +++ /dev/null @@ -1,69 +0,0 @@ -// DirectMessageAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class DirectMessageAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/ - /// api-reference/get-dm_events - public func getDmEvents( - _ request: GetDmEventsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/ - /// api-reference/get-dm_conversations-with-participant_id-dm_events - public func getDmEventsWithParticipantId( - _ request: GetDmConversationsWithParticipantIdDmEventsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/ - /// api-reference/get-dm_conversations-dm_conversation_id-dm_events - public func getDmEventsByConversationsId( - _ request: GetDmConversationsIdDmEventsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/ - /// api-reference/post-dm_conversations-dm_conversation_id-messages - public func postDmConversationById( - _ request: PostDmConversationByIdRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/ - /// api-reference/post-dm_conversations-with-participant_id-messages - public func postDmConversationWithUser( - _ request: PostDmConversationWithUserRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/ - /// api-reference/post-dm_conversations - public func postDmConversation( - _ request: PostDmConversationRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmConversationsIdDmEventsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmConversationsIdDmEventsRequestV2.swift deleted file mode 100644 index c666c1a1..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmConversationsIdDmEventsRequestV2.swift +++ /dev/null @@ -1,79 +0,0 @@ -// GetDmConversationsIdDmEventsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Returns DM Events for a DM Conversation -/// Required OAuth 2.0 scopes: dm.read, tweet.read, users.read -open class GetDmConversationsIdDmEventsRequestV2: TwitterAPIRequest { - /// The DM Conversation ID. - public let id: String - /// The maximum number of results. - public let maxResults: Int? - /// This parameter is used to get a specified 'page' of results. - public let paginationToken: String? - /// The set of event_types to include in the results. - public let eventTypes: Set? - /// A comma separated list of DmEvent fields to display. - public let dmEventFields: Set? - /// A comma separated list of fields to expand. - public let expansions: Set? - /// A comma separated list of Media fields to display. - public let mediaFields: Set? - /// A comma separated list of User fields to display. - public let userFields: Set? - /// A comma separated list of Tweet fields to display. - public let tweetFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/dm_conversations/\(id)/dm_events" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - eventTypes?.bind(param: ¶ms) - dmEventFields?.bind(param: ¶ms) - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - maxResults: Int? = .none, - paginationToken: String? = .none, - eventTypes: Set? = .none, - dmEventFields: Set? = .none, - expansions: Set? = .none, - mediaFields: Set? = .none, - userFields: Set? = .none, - tweetFields: Set? = .none - ) { - self.id = id - self.maxResults = maxResults - self.paginationToken = paginationToken - self.eventTypes = eventTypes - self.dmEventFields = dmEventFields - self.expansions = expansions - self.mediaFields = mediaFields - self.userFields = userFields - self.tweetFields = tweetFields - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmConversationsWithParticipantIdDmEventsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmConversationsWithParticipantIdDmEventsRequestV2.swift deleted file mode 100644 index 261d4a72..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmConversationsWithParticipantIdDmEventsRequestV2.swift +++ /dev/null @@ -1,82 +0,0 @@ -// GetDmConversationsWithParticipantIdDmEventsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -// swiftlint:disable type_name -import Foundation - -/// Returns DM Events for a DM Conversation -/// Required OAuth 2.0 scopes: dm.read, tweet.read, users.read -open class GetDmConversationsWithParticipantIdDmEventsRequestV2: TwitterAPIRequest { - /// The ID of the participant user for the One to One DM conversation. - public let participantID: String - /// The maximum number of results. - public let maxResults: Int? - /// This parameter is used to get a specified 'page' of results. - public let paginationToken: String? - /// The set of event_types to include in the results. - public let eventTypes: Set? - /// A comma separated list of DmEvent fields to display. - public let dmEventFields: Set? - /// A comma separated list of fields to expand. - public let expansions: Set? - /// A comma separated list of Media fields to display. - public let mediaFields: Set? - /// A comma separated list of User fields to display. - public let userFields: Set? - /// A comma separated list of Tweet fields to display. - public let tweetFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/dm_conversations/with/\(participantID)/dm_events" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - eventTypes?.bind(param: ¶ms) - dmEventFields?.bind(param: ¶ms) - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - return params - } - - public init( - participantID: String, - maxResults: Int? = .none, - paginationToken: String? = .none, - eventTypes: Set? = .none, - dmEventFields: Set? = .none, - expansions: Set? = .none, - mediaFields: Set? = .none, - userFields: Set? = .none, - tweetFields: Set? = .none - ) { - self.participantID = participantID - self.maxResults = maxResults - self.paginationToken = paginationToken - self.eventTypes = eventTypes - self.dmEventFields = dmEventFields - self.expansions = expansions - self.mediaFields = mediaFields - self.userFields = userFields - self.tweetFields = tweetFields - } - - deinit { - // De-init Logic Here - } -} - -// swiftlint:enable type_name diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmEventsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmEventsRequestV2.swift deleted file mode 100644 index 4afbdf08..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/GetDmEventsRequestV2.swift +++ /dev/null @@ -1,75 +0,0 @@ -// GetDmEventsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Returns recent DM Events across DM conversations -/// Required OAuth 2.0 scopes: dm.read, tweet.read, users.read -open class GetDmEventsRequestV2: TwitterAPIRequest { - /// The maximum number of results. - public let maxResults: Int? - /// This parameter is used to get a specified 'page' of results. - public let paginationToken: String? - /// The set of event_types to include in the results. - public let eventTypes: Set? - /// A comma separated list of DmEvent fields to display. - public let dmEventFields: Set? - /// A comma separated list of fields to expand. - public let expansions: Set? - /// A comma separated list of Media fields to display. - public let mediaFields: Set? - /// A comma separated list of User fields to display. - public let userFields: Set? - /// A comma separated list of Tweet fields to display. - public let tweetFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/dm_events" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - eventTypes?.bind(param: ¶ms) - dmEventFields?.bind(param: ¶ms) - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - return params - } - - public init( - maxResults: Int? = .none, - paginationToken: String? = .none, - eventTypes: Set? = .none, - dmEventFields: Set? = .none, - expansions: Set? = .none, - mediaFields: Set? = .none, - userFields: Set? = .none, - tweetFields: Set? = .none - ) { - self.maxResults = maxResults - self.paginationToken = paginationToken - self.eventTypes = eventTypes - self.dmEventFields = dmEventFields - self.expansions = expansions - self.mediaFields = mediaFields - self.userFields = userFields - self.tweetFields = tweetFields - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationByIdRequestV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationByIdRequestV2.swift deleted file mode 100644 index 6fdc316d..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationByIdRequestV2.swift +++ /dev/null @@ -1,55 +0,0 @@ -// PostDmConversationByIdRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Creates a new message for a DM Conversation specified by DM Conversation ID -/// Required OAuth 2.0 scopes: dm.write, tweet.read, users.read -open class PostDmConversationByIdRequestV2: TwitterAPIRequest { - /// The DM Conversation ID. - public let dmConversationID: String - /// Attachments to a DM Event. - public let attachments: [String]? - /// Text of the message. - public let text: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/dm_conversations/\(dmConversationID)/messages" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - if let attachments { - params["attachments"] = attachments.map { ["media_id": $0] } - } - text.map { params["text"] = $0 } - return params - } - - public init( - dmConversationID: String, - attachments: [String]? = .none, - text: String? = .none - ) { - self.dmConversationID = dmConversationID - self.attachments = attachments - self.text = text - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationRequestV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationRequestV2.swift deleted file mode 100644 index ea7cec00..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationRequestV2.swift +++ /dev/null @@ -1,68 +0,0 @@ -// PostDmConversationRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Creates a new DM Conversation. -/// Required OAuth 2.0 scopes: dm.write, tweet.read, users.read -open class PostDmConversationRequestV2: TwitterAPIRequest { - /// The conversation type that is being created. - public enum ConversationType: String { - case group = "Group" - } - - /// The conversation type that is being created. - public let conversationType: ConversationType - /// Participants for the DM Conversation. - public let participantIDs: [String] - /// Attachments to a DM Event. - public let attachments: [String]? - /// Text of the message. - public let text: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/dm_conversations" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["conversation_type"] = conversationType.rawValue - params["participant_ids"] = participantIDs - var message = [String: Any]() - text.map { message["text"] = $0 } - if let attachments { - message["attachments"] = attachments.map { ["media_id": $0] } - } - params["message"] = message - return params - } - - public init( - conversationType: ConversationType, - participantIDs: [String], - attachments: [String]? = .none, - text: String? = .none - ) { - self.conversationType = conversationType - self.participantIDs = participantIDs - self.attachments = attachments - self.text = text - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationWithUserRequestV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationWithUserRequestV2.swift deleted file mode 100644 index f41ba434..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/Requests/PostDmConversationWithUserRequestV2.swift +++ /dev/null @@ -1,55 +0,0 @@ -// PostDmConversationWithUserRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Creates a new message for a DM Conversation with a participant user by ID -/// Required OAuth 2.0 scopes: dm.write, tweet.read, users.read -open class PostDmConversationWithUserRequestV2: TwitterAPIRequest { - /// The ID of the recipient user that will receive the DM. - public let participantID: String - /// Attachments to a DM Event. - public let attachments: [String]? - /// Text of the message. - public let text: String? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/dm_conversations/with/\(participantID)/messages" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - if let attachments { - params["attachments"] = attachments.map { ["media_id": $0] } - } - text.map { params["text"] = $0 } - return params - } - - public init( - participantID: String, - attachments: [String]? = .none, - text: String? = .none - ) { - self.participantID = participantID - self.attachments = attachments - self.text = text - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/DirectMessage/TwitterDirectMessageEventTypeV2.swift b/Sources/TwitterAPIKit/APIv2/DirectMessage/TwitterDirectMessageEventTypeV2.swift deleted file mode 100644 index b22525a9..00000000 --- a/Sources/TwitterAPIKit/APIv2/DirectMessage/TwitterDirectMessageEventTypeV2.swift +++ /dev/null @@ -1,28 +0,0 @@ -// TwitterDirectMessageEventTypeV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// The set of event_types to include in the results. -public enum TwitterDirectMessageEventTypeV2: String { - case messageCreate = "MessageCreate" - case participantsJoin = "ParticipantsJoin" - case participantsLeave = "ParticipantsLeave" -} - -extension TwitterDirectMessageEventTypeV2: TwitterAPIv2RequestParameter { - public var stringValue: String { rawValue } -} - -/// Binds the event_types to the request parameters. -public extension Set { - /// Binds the event_types to the request parameters. - func bind(param: inout [String: Any]) { - param["event_types"] = commaSeparatedString - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Friendships/FriendshipsAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Friendships/FriendshipsAPIv2.swift deleted file mode 100644 index 717740e7..00000000 --- a/Sources/TwitterAPIKit/APIv2/Friendships/FriendshipsAPIv2.swift +++ /dev/null @@ -1,51 +0,0 @@ -// FriendshipsAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class FriendshipsAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/users/follows/ - /// api-reference/get-users-id-following - public func getFollowing( - _ request: GetUsersFollowingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/users/follows/ - /// api-reference/get-users-id-followers - public func getFollowers( - _ request: GetUsersFollowersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/users/follows/ - /// api-reference/post-users-source_user_id-following - public func follow( - _ request: PostUsersFollowingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/users/follows/ - /// api-reference/delete-users-source_id-following - public func unfollow( - _ request: DeleteUsersFollowingRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/DeleteUsersFollowingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Friendships/Requests/DeleteUsersFollowingRequestV2.swift deleted file mode 100644 index d3814c98..00000000 --- a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/DeleteUsersFollowingRequestV2.swift +++ /dev/null @@ -1,39 +0,0 @@ -// DeleteUsersFollowingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/delete-users-source_id-following -open class DeleteUsersFollowingRequestV2: TwitterAPIRequest { - public let sourceUserID: String - public let targetUserID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(sourceUserID)/following/\(targetUserID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - sourceUserID: String, - targetUserID: String - ) { - self.sourceUserID = sourceUserID - self.targetUserID = targetUserID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/GetUsersFollowersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Friendships/Requests/GetUsersFollowersRequestV2.swift deleted file mode 100644 index 475acb58..00000000 --- a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/GetUsersFollowersRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetUsersFollowersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-followers -open class GetUsersFollowersRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/followers" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/GetUsersFollowingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Friendships/Requests/GetUsersFollowingRequestV2.swift deleted file mode 100644 index 694cbb3c..00000000 --- a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/GetUsersFollowingRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetUsersFollowingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following -open class GetUsersFollowingRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/following" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/PostUsersFollowingRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Friendships/Requests/PostUsersFollowingRequestV2.swift deleted file mode 100644 index 0c26de1a..00000000 --- a/Sources/TwitterAPIKit/APIv2/Friendships/Requests/PostUsersFollowingRequestV2.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostUsersFollowingRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/post-users-source_user_id-following -open class PostUsersFollowingRequestV2: TwitterAPIRequest { - public let id: String - public let targetUserID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/following" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["target_user_id"] = targetUserID - return params - } - - public init( - id: String, - targetUserID: String - ) { - self.id = id - self.targetUserID = targetUserID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Like/LikeAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Like/LikeAPIv2.swift deleted file mode 100644 index adc21712..00000000 --- a/Sources/TwitterAPIKit/APIv2/Like/LikeAPIv2.swift +++ /dev/null @@ -1,43 +0,0 @@ -// LikeAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class LikeAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-tweets-id-liking_users - public func getLikingUsers( - _ request: GetTweetsLikingUsersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-users-id-liked_tweets - public func getLikedTweets( - _ request: GetUsersLikedTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/post-users-id-likes - public func postLike( - _ request: PostUsersLikesRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/delete-users-id-likes-tweet_id - public func deleteLike( - _ request: DeleteUsersLikesRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Like/Requests/DeleteUsersLikesRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Like/Requests/DeleteUsersLikesRequestV2.swift deleted file mode 100644 index 0c845db3..00000000 --- a/Sources/TwitterAPIKit/APIv2/Like/Requests/DeleteUsersLikesRequestV2.swift +++ /dev/null @@ -1,40 +0,0 @@ -// DeleteUsersLikesRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/delete-users-id-likes-tweet_id -open class DeleteUsersLikesRequestV2: TwitterAPIRequest { - /// user ID - public let id: String - public let tweetID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(id)/likes/\(tweetID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String, - tweetID: String - ) { - self.id = id - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Like/Requests/GetTweetsLikingUsersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Like/Requests/GetTweetsLikingUsersRequestV2.swift deleted file mode 100644 index bb5d026b..00000000 --- a/Sources/TwitterAPIKit/APIv2/Like/Requests/GetTweetsLikingUsersRequestV2.swift +++ /dev/null @@ -1,70 +0,0 @@ -// GetTweetsLikingUsersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-tweets-id-liking_users -open class GetTweetsLikingUsersRequestV2: TwitterAPIRequest { - /// Tweet ID - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/\(id)/liking_users" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Like/Requests/GetUsersLikedTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Like/Requests/GetUsersLikedTweetsRequestV2.swift deleted file mode 100644 index 93bd387a..00000000 --- a/Sources/TwitterAPIKit/APIv2/Like/Requests/GetUsersLikedTweetsRequestV2.swift +++ /dev/null @@ -1,70 +0,0 @@ -// GetUsersLikedTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-users-id-liked_tweets -open class GetUsersLikedTweetsRequestV2: TwitterAPIRequest { - /// User ID - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/liked_tweets" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Like/Requests/PostUsersLikesRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Like/Requests/PostUsersLikesRequestV2.swift deleted file mode 100644 index 7764792c..00000000 --- a/Sources/TwitterAPIKit/APIv2/Like/Requests/PostUsersLikesRequestV2.swift +++ /dev/null @@ -1,46 +0,0 @@ -// PostUsersLikesRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/post-users-id-likes -open class PostUsersLikesRequestV2: TwitterAPIRequest { - /// user ID - public let id: String - public let tweetID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/likes" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["tweet_id"] = tweetID - return params - } - - public init( - id: String, - tweetID: String - ) { - self.id = id - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/ListAPIv2.swift b/Sources/TwitterAPIKit/APIv2/List/ListAPIv2.swift deleted file mode 100644 index d2a77bad..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/ListAPIv2.swift +++ /dev/null @@ -1,168 +0,0 @@ -// ListAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class ListAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/ - /// api-reference/get-lists-id-tweets - public func getListTweets( - _ request: GetListsTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/ - /// api-reference/get-lists-id - public func getList( - _ request: GetListRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/ - /// api-reference/get-users-id-owned_lists - public func getLists( - _ request: GetUsersOwnedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/ - /// api-reference/post-users-id-followed-lists - public func followList( - _ request: PostUsersFollowedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/ - /// api-reference/delete-users-id-followed-lists-list_id - public func unfollowList( - _ request: DeleteUsersFollowedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/ - /// api-reference/get-lists-id-followers - public func listFollowers( - _ request: GetListsFollowersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/ - /// api-reference/get-users-id-followed_lists - public func followedLists( - _ request: GetUsersFollowedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/ - /// api-reference/post-lists-id-members - public func addListMember( - _ request: PostListsMembersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/ - /// api-reference/delete-lists-id-members-user_id - public func removeListMember( - _ request: DeleteListsMembersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/ - /// api-reference/get-users-id-list_memberships - public func getListMemberships( - _ request: GetUsersListMembershipsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/ - /// api-reference/get-lists-id-members - public func getListMembers( - _ request: GetListsMembersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/ - /// api-reference/post-lists - public func createList( - _ request: PostListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/ - /// api-reference/put-lists-id - public func updateList( - _ request: PutListRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/ - /// api-reference/delete-lists-id - public func deleteList( - _ request: DeleteListRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/ - /// api-reference/get-users-id-pinned_lists - public func pinnedList( - _ request: GetUsersPinnedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/ - /// api-reference/post-users-id-pinned-lists - public func pinList( - _ request: PostUsersPinnedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/ - /// api-reference/delete-users-id-pinned-lists-list_id - public func unpinList( - _ request: DeleteUsersPinnedListsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteListRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteListRequestV2.swift deleted file mode 100644 index 361d0ca2..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteListRequestV2.swift +++ /dev/null @@ -1,36 +0,0 @@ -// DeleteListRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/delete-lists-id -open class DeleteListRequestV2: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/lists/\(id)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String - ) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteListsMembersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteListsMembersRequestV2.swift deleted file mode 100644 index 56cf0965..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteListsMembersRequestV2.swift +++ /dev/null @@ -1,39 +0,0 @@ -// DeleteListsMembersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/delete-lists-id-members-user_id -open class DeleteListsMembersRequestV2: TwitterAPIRequest { - public let id: String - public let userID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/lists/\(id)/members/\(userID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String, - userID: String - ) { - self.id = id - self.userID = userID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteUsersFollowedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteUsersFollowedListsRequestV2.swift deleted file mode 100644 index a7609501..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteUsersFollowedListsRequestV2.swift +++ /dev/null @@ -1,41 +0,0 @@ -// DeleteUsersFollowedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/ -/// api-reference/delete-users-id-followed-lists-list_id -open class DeleteUsersFollowedListsRequestV2: TwitterAPIRequest { - public let id: String - public let listID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(id)/followed_lists/\(listID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String, - listID: String - ) { - self.id = id - self.listID = listID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteUsersPinnedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteUsersPinnedListsRequestV2.swift deleted file mode 100644 index 8275a53a..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/DeleteUsersPinnedListsRequestV2.swift +++ /dev/null @@ -1,41 +0,0 @@ -// DeleteUsersPinnedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/ -/// api-reference/delete-users-id-pinned-lists-list_id -open class DeleteUsersPinnedListsRequestV2: TwitterAPIRequest { - public let id: String - public let listID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(id)/pinned_lists/\(listID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String, - listID: String - ) { - self.id = id - self.listID = listID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetListRequestV2.swift deleted file mode 100644 index e04b9386..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListRequestV2.swift +++ /dev/null @@ -1,49 +0,0 @@ -// GetListRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/api-reference/get-lists-id -open class GetListRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let listFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/lists/\(id)" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - listFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - listFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.listFields = listFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsFollowersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsFollowersRequestV2.swift deleted file mode 100644 index 97ad5816..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsFollowersRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetListsFollowersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/get-lists-id-followers -open class GetListsFollowersRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/lists/\(id)/followers" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsMembersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsMembersRequestV2.swift deleted file mode 100644 index 00fe51e0..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsMembersRequestV2.swift +++ /dev/null @@ -1,58 +0,0 @@ -// GetListsMembersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-lists-id-members -open class GetListsMembersRequestV2: TwitterAPIRequest { - /// List ID - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/lists/\(id)/members" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsTweetsRequestV2.swift deleted file mode 100644 index 948c20c2..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetListsTweetsRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetListsTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/api-reference/get-lists-id-tweets -open class GetListsTweetsRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let paginationToken: String? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/lists/\(id)/tweets" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.paginationToken = paginationToken - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersFollowedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersFollowedListsRequestV2.swift deleted file mode 100644 index 32eabbca..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersFollowedListsRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetUsersFollowedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/get-users-id-followed_lists -open class GetUsersFollowedListsRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let listFields: Set? - public let maxResults: Int? - public let paginationToken: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/followed_lists" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - listFields?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - listFields: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.listFields = listFields - self.maxResults = maxResults - self.paginationToken = paginationToken - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersListMembershipsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersListMembershipsRequestV2.swift deleted file mode 100644 index a075da4e..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersListMembershipsRequestV2.swift +++ /dev/null @@ -1,58 +0,0 @@ -// GetUsersListMembershipsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-users-id-list_memberships -open class GetUsersListMembershipsRequestV2: TwitterAPIRequest { - /// User ID - public let id: String - public let expansions: Set? - public let listFields: Set? - public let maxResults: Int? - public let paginationToken: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/list_memberships" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - listFields?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - listFields: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.listFields = listFields - self.maxResults = maxResults - self.paginationToken = paginationToken - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersOwnedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersOwnedListsRequestV2.swift deleted file mode 100644 index e81137ad..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersOwnedListsRequestV2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// GetUsersOwnedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/api-reference/get-users-id-owned_lists -open class GetUsersOwnedListsRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let listFields: Set? - public let maxResults: Int? - public let paginationToken: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/owned_lists" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - listFields?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - paginationToken.map { params["pagination_token"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - listFields: Set? = .none, - maxResults: Int? = .none, - paginationToken: String? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.listFields = listFields - self.maxResults = maxResults - self.paginationToken = paginationToken - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersPinnedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersPinnedListsRequestV2.swift deleted file mode 100644 index 5c0466c4..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/GetUsersPinnedListsRequestV2.swift +++ /dev/null @@ -1,49 +0,0 @@ -// GetUsersPinnedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/api-reference/get-users-id-pinned_lists -open class GetUsersPinnedListsRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let listFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/pinned_lists" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - listFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - listFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.listFields = listFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/PostListsMembersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/PostListsMembersRequestV2.swift deleted file mode 100644 index 6822cb26..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/PostListsMembersRequestV2.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostListsMembersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/post-lists-id-members -open class PostListsMembersRequestV2: TwitterAPIRequest { - public let id: String - public let userID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/lists/\(id)/members" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["user_id"] = userID - return params - } - - public init( - id: String, - userID: String - ) { - self.id = id - self.userID = userID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/PostListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/PostListsRequestV2.swift deleted file mode 100644 index 712c5cb6..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/PostListsRequestV2.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/post-lists -open class PostListsRequestV2: TwitterAPIRequest { - public let name: String - public let description: String? - public let `private`: Bool? - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/lists" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["name"] = name - description.map { params["description"] = $0 } - `private`.map { params["private"] = $0 } - return params - } - - public init( - name: String, - description: String? = .none, - private: Bool? = .none - ) { - self.name = name - self.description = description - self.private = `private` - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/PostUsersFollowedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/PostUsersFollowedListsRequestV2.swift deleted file mode 100644 index 61cbad52..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/PostUsersFollowedListsRequestV2.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostUsersFollowedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/post-users-id-followed-lists -open class PostUsersFollowedListsRequestV2: TwitterAPIRequest { - public let id: String - public let listID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/followed_lists" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["list_id"] = listID - return params - } - - public init( - id: String, - listID: String - ) { - self.id = id - self.listID = listID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/PostUsersPinnedListsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/PostUsersPinnedListsRequestV2.swift deleted file mode 100644 index 731152cd..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/PostUsersPinnedListsRequestV2.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostUsersPinnedListsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/api-reference/post-users-id-pinned-lists -open class PostUsersPinnedListsRequestV2: TwitterAPIRequest { - public let id: String - public let listID: String - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/users/\(id)/pinned_lists" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["list_id"] = listID - return params - } - - public init( - id: String, - listID: String - ) { - self.id = id - self.listID = listID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/List/Requests/PutListRequestV2.swift b/Sources/TwitterAPIKit/APIv2/List/Requests/PutListRequestV2.swift deleted file mode 100644 index 8ac1fd2e..00000000 --- a/Sources/TwitterAPIKit/APIv2/List/Requests/PutListRequestV2.swift +++ /dev/null @@ -1,53 +0,0 @@ -// PutListRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/put-lists-id -open class PutListRequestV2: TwitterAPIRequest { - public let id: String - public let description: String? - public let name: String? - public let `private`: Bool? - - public var method: HTTPMethod { - .put - } - - public var path: String { - "/2/lists/\(id)" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - description.map { params["description"] = $0 } - name.map { params["name"] = $0 } - `private`.map { params["private"] = $0 } - return params - } - - public init( - id: String, - description: String? = .none, - name: String? = .none, - private: Bool? = .none - ) { - self.id = id - self.description = description - self.name = name - self.private = `private` - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Media/Models/TwitterMediaV2.swift b/Sources/TwitterAPIKit/APIv2/Media/Models/TwitterMediaV2.swift new file mode 100644 index 00000000..d9eac059 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Media/Models/TwitterMediaV2.swift @@ -0,0 +1,31 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a media entity in the Twitter API v2 +public struct TwitterMediaV2: Decodable, Sendable { + public let mediaKey: String + public let type: String + public let url: String? + public let durationMs: Int? + public let height: Int? + public let width: Int? + public let previewImageUrl: String? + public let altText: String? + + private enum CodingKeys: String, CodingKey { + case mediaKey = "media_key" + case type + case url + case durationMs = "duration_ms" + case height + case width + case previewImageUrl = "preview_image_url" + case altText = "alt_text" + } +} diff --git a/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/TweetCountGranularityV2.swift b/Sources/TwitterAPIKit/APIv2/Models/TweetCountGranularityV2.swift similarity index 100% rename from Sources/TwitterAPIKit/APIv2/TweetCount/Requests/TweetCountGranularityV2.swift rename to Sources/TwitterAPIKit/APIv2/Models/TweetCountGranularityV2.swift diff --git a/Sources/TwitterAPIKit/APIv2/Models/TweetExclusion.swift b/Sources/TwitterAPIKit/APIv2/Models/TweetExclusion.swift new file mode 100644 index 00000000..73247ede --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Models/TweetExclusion.swift @@ -0,0 +1,32 @@ +// TweetExclusion.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents types of tweets that can be excluded from results +public enum TweetExclusion: TwitterAPIv2RequestParameter, Sendable { + /// Exclude replies from results + case replies + /// Exclude retweets from results + case retweets + + public var stringValue: String { + switch self { + case .replies: "replies" + case .retweets: "retweets" + } + } +} + +/// Extension to bind exclusions to request parameters +public extension Set { + /// Extension to bind exclusions to request parameters + func bind(param: inout [String: Any]) { + param["exclude"] = commaSeparatedString + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Models/TwitterGeoV2.swift b/Sources/TwitterAPIKit/APIv2/Models/TwitterGeoV2.swift new file mode 100644 index 00000000..4eb09665 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Models/TwitterGeoV2.swift @@ -0,0 +1,25 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents geographic information in the Twitter API v2 +public struct TwitterGeoV2: Decodable, Sendable { + public let coordinates: TwitterCoordinatesV2? + public let placeId: String? + + private enum CodingKeys: String, CodingKey { + case coordinates + case placeId = "place_id" + } +} + +/// Represents coordinates in the Twitter API v2 +public struct TwitterCoordinatesV2: Decodable, Sendable { + public let type: String + public let coordinates: [Double] +} diff --git a/Sources/TwitterAPIKit/APIv2/Models/TwitterPublicMetricsV2.swift b/Sources/TwitterAPIKit/APIv2/Models/TwitterPublicMetricsV2.swift new file mode 100644 index 00000000..95add869 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Models/TwitterPublicMetricsV2.swift @@ -0,0 +1,31 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents public metrics for a Twitter entity (Tweet or User) +public struct TwitterPublicMetricsV2: Decodable, Sendable { + public let retweetCount: Int + public let replyCount: Int + public let likeCount: Int + public let quoteCount: Int + public let followersCount: Int? + public let followingCount: Int? + public let tweetCount: Int? + public let listedCount: Int? + + private enum CodingKeys: String, CodingKey { + case retweetCount = "retweet_count" + case replyCount = "reply_count" + case likeCount = "like_count" + case quoteCount = "quote_count" + case followersCount = "followers_count" + case followingCount = "following_count" + case tweetCount = "tweet_count" + case listedCount = "listed_count" + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Models/TwitterReplySettingsV2.swift b/Sources/TwitterAPIKit/APIv2/Models/TwitterReplySettingsV2.swift new file mode 100644 index 00000000..1ac00282 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Models/TwitterReplySettingsV2.swift @@ -0,0 +1,11 @@ +import Foundation + +public enum TwitterReplySettingsV2: String, Decodable, Sendable { + case everyone + case following + case mentionedUsers = "mentioned_users" + + public func bind(param: inout [String: Any]) { + param["reply_settings"] = rawValue + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Models/TwitterSearchTweetsSortOrderV2.swift b/Sources/TwitterAPIKit/APIv2/Models/TwitterSearchTweetsSortOrderV2.swift new file mode 100644 index 00000000..d9e05d3d --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Models/TwitterSearchTweetsSortOrderV2.swift @@ -0,0 +1,32 @@ +// TwitterSearchTweetsSortOrderV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Sort order options for tweet search results +public enum TwitterSearchTweetsSortOrderV2: TwitterAPIv2RequestParameter, Sendable { + /// Sort by recency (newest first) + case recency + /// Sort by relevancy (most relevant first) + case relevancy + + public var stringValue: String { + switch self { + case .recency: "recency" + case .relevancy: "relevancy" + } + } +} + +/// Extension to bind sort order to request parameters +public extension TwitterSearchTweetsSortOrderV2 { + /// Extension to bind sort order to request parameters + func bind(param: inout [String: Any]) { + param["sort_order"] = stringValue + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Search/TwitterSearchTweetsSortOrderV2.swift b/Sources/TwitterAPIKit/APIv2/Models/TwitterWithheldV2.swift similarity index 51% rename from Sources/TwitterAPIKit/APIv2/Search/TwitterSearchTweetsSortOrderV2.swift rename to Sources/TwitterAPIKit/APIv2/Models/TwitterWithheldV2.swift index 6d4f0da3..ba1bdf2c 100644 --- a/Sources/TwitterAPIKit/APIv2/Search/TwitterSearchTweetsSortOrderV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Models/TwitterWithheldV2.swift @@ -1,4 +1,3 @@ -// TwitterSearchTweetsSortOrderV2.swift // Copyright (c) 2025 GetAutomaApp // All source code and related assets are the property of GetAutomaApp. // All rights reserved. @@ -8,11 +7,13 @@ import Foundation -public enum TwitterSearchTweetsSortOrderV2: String { - case recency - case relevancy +/// Represents withheld content information for a Twitter entity +public struct TwitterWithheldV2: Decodable, Sendable { + public let copyright: Bool + public let countryCodes: [String] - public func bind(param: inout [String: Any]) { - param["sort_order"] = rawValue + private enum CodingKeys: String, CodingKey { + case copyright + case countryCodes = "country_codes" } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Place/Models/TwitterPlaceV2.swift b/Sources/TwitterAPIKit/APIv2/Place/Models/TwitterPlaceV2.swift new file mode 100644 index 00000000..3fff1e23 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Place/Models/TwitterPlaceV2.swift @@ -0,0 +1,29 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a place entity in the Twitter API v2 +public struct TwitterPlaceV2: Decodable, Sendable { + public let id: String + public let fullName: String + public let country: String? + public let countryCode: String? + public let geo: TwitterGeoV2? + public let name: String? + public let placeType: String? + + private enum CodingKeys: String, CodingKey { + case id + case fullName = "full_name" + case country + case countryCode = "country_code" + case geo + case name + case placeType = "place_type" + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Poll/Models/TwitterPollV2.swift b/Sources/TwitterAPIKit/APIv2/Poll/Models/TwitterPollV2.swift new file mode 100644 index 00000000..4b2784d6 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Poll/Models/TwitterPollV2.swift @@ -0,0 +1,32 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a poll in the Twitter API v2 +public struct TwitterPollV2: Decodable, Sendable { + public let id: String + public let options: [TwitterPollOptionV2] + public let durationMinutes: Int + public let endDatetime: Date? + public let votingStatus: String? + + private enum CodingKeys: String, CodingKey { + case id + case options + case durationMinutes = "duration_minutes" + case endDatetime = "end_datetime" + case votingStatus = "voting_status" + } +} + +/// Represents a poll option in the Twitter API v2 +public struct TwitterPollOptionV2: Decodable, Sendable { + public let position: Int + public let label: String + public let votes: Int +} diff --git a/Sources/TwitterAPIKit/APIv2/Retweet/Requests/DeleteUsersRetweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Retweet/Requests/DeleteUsersRetweetsRequestV2.swift deleted file mode 100644 index b36a6024..00000000 --- a/Sources/TwitterAPIKit/APIv2/Retweet/Requests/DeleteUsersRetweetsRequestV2.swift +++ /dev/null @@ -1,39 +0,0 @@ -// DeleteUsersRetweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/delete-users-id-retweets-tweet_id -open class DeleteUsersRetweetsRequestV2: TwitterAPIRequest { - public let id: String - public let sourceTweetID: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/users/\(id)/retweets/\(sourceTweetID)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String, - sourceTweetID: String - ) { - self.id = id - self.sourceTweetID = sourceTweetID - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Retweet/Requests/GetTweetsRetweetedByRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Retweet/Requests/GetTweetsRetweetedByRequestV2.swift deleted file mode 100644 index 88e72106..00000000 --- a/Sources/TwitterAPIKit/APIv2/Retweet/Requests/GetTweetsRetweetedByRequestV2.swift +++ /dev/null @@ -1,70 +0,0 @@ -// GetTweetsRetweetedByRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/get-tweets-id-retweeted_by -open class GetTweetsRetweetedByRequestV2: TwitterAPIRequest { - /// Tweet ID - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/\(id)/retweeted_by" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Retweet/Requests/PostUsersRetweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Retweet/Requests/PostUsersRetweetsRequestV2.swift index 18c8fa5c..99ef2098 100644 --- a/Sources/TwitterAPIKit/APIv2/Retweet/Requests/PostUsersRetweetsRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Retweet/Requests/PostUsersRetweetsRequestV2.swift @@ -1,45 +1,30 @@ -// PostUsersRetweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/post-users-id-retweets -open class PostUsersRetweetsRequestV2: TwitterAPIRequest { - public let id: String - public let tweetID: String - - public var method: HTTPMethod { - .post +public struct PostUsersRetweetsResponseV2: Decodable, Sendable { + public struct Data: Decodable, Sendable { + public let retweeted: Bool } + public let data: Data +} - public var path: String { - "/2/users/\(id)/retweets" +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request creates a retweet of a specific tweet by the authenticated user. +/// The response includes a confirmation of whether the retweet was successful. +/// Note: This endpoint requires OAuth 1.0a User Context authentication. +public struct PostUsersRetweetsRequestV2: TwitterAPIRequest { + public typealias Response = PostUsersRetweetsResponseV2 + + public let method: HTTPMethod = .post + public let path: String + public let parameters: [String: Any] + + public init(userId: String, tweetId: String) { + self.path = "/2/users/\(userId)/retweets" + self.parameters = ["tweet_id": tweetId] } public var bodyContentType: BodyContentType { .json } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["tweet_id"] = tweetID - return params - } - - public init( - id: String, - tweetID: String - ) { - self.id = id - self.tweetID = tweetID - } - - deinit { - // de-init logic here - } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Retweet/RetweetAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Retweet/RetweetAPIv2.swift deleted file mode 100644 index 1c0aae9f..00000000 --- a/Sources/TwitterAPIKit/APIv2/Retweet/RetweetAPIv2.swift +++ /dev/null @@ -1,42 +0,0 @@ -// RetweetAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class RetweetAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/ - /// api-reference/get-tweets-id-retweeted_by - public func getRetweetedBy( - _ request: GetTweetsRetweetedByRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/ - /// api-reference/post-users-id-retweets - public func postRetweet( - _ request: PostUsersRetweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/ - /// api-reference/delete-users-id-retweets-tweet_id - public func deleteRetweet( - _ request: DeleteUsersRetweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Search/Requests/GetTweetsSearchAllRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Search/Requests/GetTweetsSearchAllRequestV2.swift deleted file mode 100644 index 675f6a1c..00000000 --- a/Sources/TwitterAPIKit/APIv2/Search/Requests/GetTweetsSearchAllRequestV2.swift +++ /dev/null @@ -1,91 +0,0 @@ -// GetTweetsSearchAllRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// This endpoint is only available to those users who have been approved for Academic Research access. -/// https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all -open class GetTweetsSearchAllRequestV2: TwitterAPIRequest { - public let query: String - public let endTime: Date? - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let nextToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let sinceID: String? - public let sortOrder: TwitterSearchTweetsSortOrderV2? - public let startTime: Date? - public let tweetFields: Set? - public let untilID: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/search/all" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["query"] = query - endTime?.bind(param: ¶ms, for: "end_time") - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - nextToken.map { params["next_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - sinceID.map { params["since_id"] = $0 } - sortOrder?.bind(param: ¶ms) - startTime?.bind(param: ¶ms, for: "start_time") - tweetFields?.bind(param: ¶ms) - untilID.map { params["until_id"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - query: String, - endTime: Date? = .none, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - nextToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - sinceID: String? = .none, - sortOrder: TwitterSearchTweetsSortOrderV2? = .none, - startTime: Date? = .none, - tweetFields: Set? = .none, - untilID: String? = .none, - userFields: Set? = .none - ) { - self.query = query - self.endTime = endTime - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.nextToken = nextToken - self.placeFields = placeFields - self.pollFields = pollFields - self.sinceID = sinceID - self.sortOrder = sortOrder - self.startTime = startTime - self.tweetFields = tweetFields - self.untilID = untilID - self.userFields = userFields - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Search/Requests/GetTweetsSearchRecentRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Search/Requests/GetTweetsSearchRecentRequestV2.swift deleted file mode 100644 index e561bb6b..00000000 --- a/Sources/TwitterAPIKit/APIv2/Search/Requests/GetTweetsSearchRecentRequestV2.swift +++ /dev/null @@ -1,99 +0,0 @@ -// GetTweetsSearchRecentRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent -open class GetTweetsSearchRecentRequestV2: TwitterAPIRequest { - public enum TwitterSearchTweetsSortOrderV2: String { - case recency - case relevancy - - public func bind(param: inout [String: Any]) { - param["sort_order"] = rawValue - } - } - - public let query: String - public let endTime: Date? - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let nextToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let sinceID: String? - public let sortOrder: TwitterSearchTweetsSortOrderV2? - public let startTime: Date? - public let tweetFields: Set? - public let untilID: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/search/recent" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["query"] = query - endTime?.bind(param: ¶ms, for: "end_time") - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - nextToken.map { params["next_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - sinceID.map { params["since_id"] = $0 } - sortOrder?.bind(param: ¶ms) - startTime?.bind(param: ¶ms, for: "start_time") - tweetFields?.bind(param: ¶ms) - untilID.map { params["until_id"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - query: String, - endTime: Date? = .none, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - nextToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - sinceID: String? = .none, - sortOrder: TwitterSearchTweetsSortOrderV2? = .none, - startTime: Date? = .none, - tweetFields: Set? = .none, - untilID: String? = .none, - userFields: Set? = .none - ) { - self.query = query - self.endTime = endTime - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.nextToken = nextToken - self.placeFields = placeFields - self.pollFields = pollFields - self.sinceID = sinceID - self.sortOrder = sortOrder - self.startTime = startTime - self.tweetFields = tweetFields - self.untilID = untilID - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Search/SearchAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Search/SearchAPIv2.swift deleted file mode 100644 index 43bc57be..00000000 --- a/Sources/TwitterAPIKit/APIv2/Search/SearchAPIv2.swift +++ /dev/null @@ -1,30 +0,0 @@ -// SearchAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class SearchAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent - public func searchTweetsRecent( - _ request: GetTweetsSearchRecentRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all - /// - Important: This endpoint is only available to those users who have been approved for Academic Research access. - public func searchTweetsAll( - _ request: GetTweetsSearchAllRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpaceRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpaceRequestV2.swift deleted file mode 100644 index 6d332e0a..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpaceRequestV2.swift +++ /dev/null @@ -1,53 +0,0 @@ -// GetSpaceRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id -open class GetSpaceRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let spaceFields: Set? - public let topicFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/spaces/\(id)" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - spaceFields?.bind(param: ¶ms) - topicFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - spaceFields: Set? = .none, - topicFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.spaceFields = spaceFields - self.topicFields = topicFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesBuyersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesBuyersRequestV2.swift deleted file mode 100644 index 13a199ae..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesBuyersRequestV2.swift +++ /dev/null @@ -1,61 +0,0 @@ -// GetSpacesBuyersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-buyers -open class GetSpacesBuyersRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let mediaFields: Set? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/spaces/\(id)/buyers" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - mediaFields: Set? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.mediaFields = mediaFields - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesByCreatorIDsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesByCreatorIDsRequestV2.swift deleted file mode 100644 index 4b72aeb9..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesByCreatorIDsRequestV2.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetSpacesByCreatorIDsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-by-creator-ids -open class GetSpacesByCreatorIDsRequestV2: TwitterAPIRequest { - public let userIDs: [String] - public let expansions: Set? - public let spaceFields: Set? - public let topicFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/spaces/by/creator_ids" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["user_ids"] = userIDs.joined(separator: ",") - expansions?.bind(param: ¶ms) - spaceFields?.bind(param: ¶ms) - topicFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - userIDs: [String], - expansions: Set? = .none, - spaceFields: Set? = .none, - topicFields: Set? = .none, - userFields: Set? = .none - ) { - self.userIDs = userIDs - self.expansions = expansions - self.spaceFields = spaceFields - self.topicFields = topicFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesRequestV2.swift deleted file mode 100644 index 082718f9..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesRequestV2.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetSpacesRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces -open class GetSpacesRequestV2: TwitterAPIRequest { - public let ids: [String] - public let expansions: Set? - public let spaceFields: Set? - public let topicFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/spaces" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["ids"] = ids.joined(separator: ",") - expansions?.bind(param: ¶ms) - spaceFields?.bind(param: ¶ms) - topicFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - ids: [String], - expansions: Set? = .none, - spaceFields: Set? = .none, - topicFields: Set? = .none, - userFields: Set? = .none - ) { - self.ids = ids - self.expansions = expansions - self.spaceFields = spaceFields - self.topicFields = topicFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesSearchRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesSearchRequestV2.swift deleted file mode 100644 index 0f58abb3..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesSearchRequestV2.swift +++ /dev/null @@ -1,67 +0,0 @@ -// GetSpacesSearchRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search -open class GetSpacesSearchRequestV2: TwitterAPIRequest { - public enum State: String { - case all - case live - case scheduled - public func bind(param: inout [String: Any]) { - param["state"] = rawValue - } - } - - public let query: String - public let expansions: Set? - public let spaceFields: Set? - public let state: State? - public let topicFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/spaces/search" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["query"] = query - expansions?.bind(param: ¶ms) - spaceFields?.bind(param: ¶ms) - state?.bind(param: ¶ms) - topicFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - query: String, - expansions: Set? = .none, - spaceFields: Set? = .none, - state: State? = .none, - topicFields: Set? = .none, - userFields: Set? = .none - ) { - self.query = query - self.expansions = expansions - self.spaceFields = spaceFields - self.state = state - self.topicFields = topicFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesTweetsRequestV2.swift deleted file mode 100644 index 5a010aa8..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/Requests/GetSpacesTweetsRequestV2.swift +++ /dev/null @@ -1,61 +0,0 @@ -// GetSpacesTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-tweets -open class GetSpacesTweetsRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let mediaFields: Set? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/spaces/\(id)/tweets" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - mediaFields: Set? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.mediaFields = mediaFields - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Spaces/SpacesAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Spaces/SpacesAPIv2.swift deleted file mode 100644 index 883870f5..00000000 --- a/Sources/TwitterAPIKit/APIv2/Spaces/SpacesAPIv2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// SpacesAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class SpacesAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id - public func getSpace( - _ request: GetSpaceRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces - public func getSpaces( - _ request: GetSpacesRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-by-creator-ids - public func getSpacesByCreators( - _ request: GetSpacesByCreatorIDsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-buyers - public func getSpacesBuyers( - _ request: GetSpacesBuyersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-tweets - public func getSPacesTweets( - _ request: GetSpacesTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search - public func searchSpaces( - _ request: GetSpacesSearchRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSampleStreamRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSampleStreamRequestV2.swift deleted file mode 100644 index f5f1dea3..00000000 --- a/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSampleStreamRequestV2.swift +++ /dev/null @@ -1,62 +0,0 @@ -// GetTweetsSampleStreamRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/volume-streams/api-reference/get-tweets-sample-stream -open class GetTweetsSampleStreamRequestV2: TwitterAPIRequest { - public let backfillMinutes: Int? - public let expansions: Set? - public let mediaFields: Set? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/sample/stream" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - backfillMinutes.map { params["backfill_minutes"] = $0 } - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - backfillMinutes: Int? = .none, - expansions: Set? = .none, - mediaFields: Set? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.backfillMinutes = backfillMinutes - self.expansions = expansions - self.mediaFields = mediaFields - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSearchStreamRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSearchStreamRequestV2.swift deleted file mode 100644 index faa9ee18..00000000 --- a/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSearchStreamRequestV2.swift +++ /dev/null @@ -1,62 +0,0 @@ -// GetTweetsSearchStreamRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/api-reference/get-tweets-search-stream -open class GetTweetsSearchStreamRequestV2: TwitterAPIRequest { - public let backfillMinutes: Int? - public let expansions: Set? - public let mediaFields: Set? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/search/stream" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - backfillMinutes.map { params["backfill_minutes"] = $0 } - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - backfillMinutes: Int? = .none, - expansions: Set? = .none, - mediaFields: Set? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.backfillMinutes = backfillMinutes - self.expansions = expansions - self.mediaFields = mediaFields - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSearchStreamRulesRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSearchStreamRulesRequestV2.swift deleted file mode 100644 index a7d6d24c..00000000 --- a/Sources/TwitterAPIKit/APIv2/Stream/Requests/GetTweetsSearchStreamRulesRequestV2.swift +++ /dev/null @@ -1,40 +0,0 @@ -// GetTweetsSearchStreamRulesRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream -/// /api-reference/get-tweets-search-stream-rules -open class GetTweetsSearchStreamRulesRequestV2: TwitterAPIRequest { - public let ids: [String]? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/search/stream/rules" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - ids.map { params["ids"] = $0.joined(separator: ",") } - return params - } - - public init( - ids: [String]? = .none - ) { - self.ids = ids - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Stream/Requests/PostTweetsSearchStreamRulesRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Stream/Requests/PostTweetsSearchStreamRulesRequestV2.swift deleted file mode 100644 index 7557d7c3..00000000 --- a/Sources/TwitterAPIKit/APIv2/Stream/Requests/PostTweetsSearchStreamRulesRequestV2.swift +++ /dev/null @@ -1,79 +0,0 @@ -// PostTweetsSearchStreamRulesRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/ -/// api-reference/post-tweets-search-stream-rules#Validate -open class PostTweetsSearchStreamRulesRequestV2: TwitterAPIRequest { - public struct Rule { - public let value: String - public let tag: String? - public init(value: String, tag: String? = .none) { - self.value = value - self.tag = tag - } - } - - public enum Operation { - case add([Rule]) - case delete([String] /* rule IDs */ ) - } - - public let dryRun: Bool? - public let operation: PostTweetsSearchStreamRulesRequestV2.Operation - - public var method: HTTPMethod { - .post - } - - public var path: String { - "/2/tweets/search/stream/rules" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var queryParameters: [String: Any] { - var params = [String: Any]() - dryRun.map { params["dry_run"] = $0 } - return params - } - - open var bodyParameters: [String: Any] { - var params = [String: Any]() - - switch operation { - case let .add(rules): - params["add"] = rules.map { - [ - "value": $0.value, - "tag": $0.tag, - ].compactMapValues { $0 } - } - case let .delete(ids): - params["delete"] = ["ids": ids] - } - - return params - } - - public init( - operation: Operation, - dryRun: Bool? = .none - ) { - self.operation = operation - self.dryRun = dryRun - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Stream/StreamAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Stream/StreamAPIv2.swift deleted file mode 100644 index 20fd93f7..00000000 --- a/Sources/TwitterAPIKit/APIv2/Stream/StreamAPIv2.swift +++ /dev/null @@ -1,51 +0,0 @@ -// StreamAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class StreamAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/volume-streams/ - /// api-reference/get-tweets-sample-stream - public func sampleStream( - _ request: GetTweetsSampleStreamRequestV2 - ) -> TwitterAPISessionStreamTask { - session.send(streamRequest: request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/ - /// api-reference/get-tweets-search-stream-rules - public func getSearchStreamRules( - _ request: GetTweetsSearchStreamRulesRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/ - /// api-reference/post-tweets-search-stream-rules#Validate - public func postSearchStreamRules( - _ request: PostTweetsSearchStreamRulesRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/ - /// api-reference/get-tweets-search-stream - public func searchStream( - _ request: GetTweetsSearchStreamRequestV2 - ) -> TwitterAPISessionStreamTask { - session.send(streamRequest: request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersMentionsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersMentionsRequestV2.swift deleted file mode 100644 index 5bf0bdfd..00000000 --- a/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersMentionsRequestV2.swift +++ /dev/null @@ -1,85 +0,0 @@ -// GetUsersMentionsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-mentions -open class GetUsersMentionsRequestV2: TwitterAPIRequest { - public let id: String - public let endTime: Date? - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let sinceID: String? - public let startTime: Date? - public let tweetFields: Set? - public let untilID: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/mentions" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - endTime?.bind(param: ¶ms, for: "end_time") - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - sinceID.map { params["since_id"] = $0 } - startTime?.bind(param: ¶ms, for: "start_time") - tweetFields?.bind(param: ¶ms) - untilID.map { params["until_id"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - endTime: Date? = .none, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - sinceID: String? = .none, - startTime: Date? = .none, - tweetFields: Set? = .none, - untilID: String? = .none, - userFields: Set? = .none - ) { - self.id = id - self.endTime = endTime - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.sinceID = sinceID - self.startTime = startTime - self.tweetFields = tweetFields - self.untilID = untilID - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersTimelinesReverseChronologicalRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersTimelinesReverseChronologicalRequestV2.swift deleted file mode 100644 index c642b7fe..00000000 --- a/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersTimelinesReverseChronologicalRequestV2.swift +++ /dev/null @@ -1,89 +0,0 @@ -// GetUsersTimelinesReverseChronologicalRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-reverse-chronological -open class GetUsersTimelinesReverseChronologicalRequestV2: TwitterAPIRequest { - public let id: String - public let endTime: Date? - public let exclude: Set? - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let sinceID: String? - public let startTime: Date? - public let tweetFields: Set? - public let untilID: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/timelines/reverse_chronological" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - endTime?.bind(param: ¶ms, for: "end_time") - exclude?.bind(param: ¶ms) - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - sinceID.map { params["since_id"] = $0 } - startTime?.bind(param: ¶ms, for: "start_time") - tweetFields?.bind(param: ¶ms) - untilID.map { params["until_id"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - endTime: Date? = .none, - exclude: Set? = .none, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - sinceID: String? = .none, - startTime: Date? = .none, - tweetFields: Set? = .none, - untilID: String? = .none, - userFields: Set? = .none - ) { - self.id = id - self.endTime = endTime - self.exclude = exclude - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.sinceID = sinceID - self.startTime = startTime - self.tweetFields = tweetFields - self.untilID = untilID - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersTweetsRequestV2.swift deleted file mode 100644 index 93e8d631..00000000 --- a/Sources/TwitterAPIKit/APIv2/Timeline/Requests/GetUsersTweetsRequestV2.swift +++ /dev/null @@ -1,89 +0,0 @@ -// GetUsersTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-tweets -open class GetUsersTweetsRequestV2: TwitterAPIRequest { - public let id: String - public let endTime: Date? - public let exclude: Set? - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let sinceID: String? - public let startTime: Date? - public let tweetFields: Set? - public let untilID: String? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)/tweets" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - endTime?.bind(param: ¶ms, for: "end_time") - exclude?.bind(param: ¶ms) - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - sinceID.map { params["since_id"] = $0 } - startTime?.bind(param: ¶ms, for: "start_time") - tweetFields?.bind(param: ¶ms) - untilID.map { params["until_id"] = $0 } - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - endTime: Date? = .none, - exclude: Set? = .none, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - sinceID: String? = .none, - startTime: Date? = .none, - tweetFields: Set? = .none, - untilID: String? = .none, - userFields: Set? = .none - ) { - self.id = id - self.endTime = endTime - self.exclude = exclude - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.sinceID = sinceID - self.startTime = startTime - self.tweetFields = tweetFields - self.untilID = untilID - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Timeline/TimelineAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Timeline/TimelineAPIv2.swift deleted file mode 100644 index 6173bdb0..00000000 --- a/Sources/TwitterAPIKit/APIv2/Timeline/TimelineAPIv2.swift +++ /dev/null @@ -1,43 +0,0 @@ -// TimelineAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class TimelineAPIv2: TwitterAPIBase { - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/ - /// api-reference/get-users-id-tweets - public func getUserTweets( - _ request: GetUsersTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/ - /// api-reference/get-users-id-mentions - public func getUserMensions( - _ request: GetUsersMentionsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// a.k.a Home Timeline - /// For more details, see: - /// https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/ - /// api-reference/get-users-id-reverse-chronological - public func getUserReverseChronological( - _ request: GetUsersTimelinesReverseChronologicalRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Timeline/TwitterTimelineExcludeV2.swift b/Sources/TwitterAPIKit/APIv2/Timeline/TwitterTimelineExcludeV2.swift deleted file mode 100644 index e53084f2..00000000 --- a/Sources/TwitterAPIKit/APIv2/Timeline/TwitterTimelineExcludeV2.swift +++ /dev/null @@ -1,32 +0,0 @@ -// TwitterTimelineExcludeV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// The types of items to exclude from the timeline. -public enum TwitterTimelineExcludeV2: String, TwitterAPIv2RequestParameter { - /// Exclude replies from the timeline. - case replies - /// Exclude retweets from the timeline. - case retweets - - /// The string value of the exclude type. - public var stringValue: String { - rawValue - } -} - -/// Extension to bind the exclude types to the request parameters. -public extension Set { - /// Binds the exclude types to the request parameters. - /// - Parameters: - /// - param: The parameters dictionary to bind to. - func bind(param: inout [String: Any]) { - param["exclude"] = commaSeparatedString - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterAPISuccessResponseV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterAPISuccessResponseV2.swift new file mode 100644 index 00000000..5a25ed5d --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterAPISuccessResponseV2.swift @@ -0,0 +1,19 @@ +// TwitterAPISuccessResponseV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Generic success response for Twitter API v2 endpoints that return a simple success object. +public struct TwitterAPISuccessResponseV2: Decodable, Sendable { + public let data: SuccessData + + public struct SuccessData: Decodable, Sendable { + public let retweeted: Bool? + public let deleted: Bool? + } +} diff --git a/Sources/TwitterAPIKit/Extensions/DispatchQueue.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterAttachmentsV2.swift similarity index 51% rename from Sources/TwitterAPIKit/Extensions/DispatchQueue.swift rename to Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterAttachmentsV2.swift index 9cf51e52..20578146 100644 --- a/Sources/TwitterAPIKit/Extensions/DispatchQueue.swift +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterAttachmentsV2.swift @@ -1,4 +1,3 @@ -// DispatchQueue.swift // Copyright (c) 2025 GetAutomaApp // All source code and related assets are the property of GetAutomaApp. // All rights reserved. @@ -8,9 +7,13 @@ import Foundation -public extension DispatchQueue { - /// A global queue used for processing Twitter API tasks with default QoS - static var processQueue: DispatchQueue { - .global(qos: .default) +/// Represents attachments in a tweet in the Twitter API v2 +public struct TwitterAttachmentsV2: Decodable, Sendable { + public let mediaKeys: [String]? + public let pollIds: [String]? + + private enum CodingKeys: String, CodingKey { + case mediaKeys = "media_keys" + case pollIds = "poll_ids" } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterContextAnnotationV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterContextAnnotationV2.swift new file mode 100644 index 00000000..0f9a70b2 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterContextAnnotationV2.swift @@ -0,0 +1,26 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a context annotation in the Twitter API v2 +public struct TwitterContextAnnotationV2: Decodable, Sendable { + public let domain: Domain + public let entity: Entity + + public struct Domain: Decodable, Sendable { + public let id: String + public let name: String + public let description: String? + } + + public struct Entity: Decodable, Sendable { + public let id: String + public let name: String + public let description: String? + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterEntitiesV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterEntitiesV2.swift new file mode 100644 index 00000000..e46b4e33 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterEntitiesV2.swift @@ -0,0 +1,76 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents entities in a tweet in the Twitter API v2 +public struct TwitterEntitiesV2: Decodable, Sendable { + public let annotations: [Annotation]? + public let cashtags: [Cashtag]? + public let hashtags: [Hashtag]? + public let mentions: [Mention]? + public let urls: [URLEntity]? + + public struct Annotation: Decodable, Sendable { + public let start: Int + public let end: Int + public let probability: Double + public let type: String + public let normalizedText: String + + private enum CodingKeys: String, CodingKey { + case start + case end + case probability + case type + case normalizedText = "normalized_text" + } + } + + public struct Cashtag: Decodable, Sendable { + public let start: Int + public let end: Int + public let tag: String + } + + public struct Hashtag: Decodable, Sendable { + public let start: Int + public let end: Int + public let tag: String + } + + public struct Mention: Decodable, Sendable { + public let start: Int + public let end: Int + public let username: String + public let id: String + } + + public struct URLEntity: Decodable, Sendable { + public let start: Int + public let end: Int + public let url: String + public let expandedUrl: String + public let displayUrl: String + public let status: Int? + public let title: String? + public let description: String? + public let unwoundUrl: String? + + private enum CodingKeys: String, CodingKey { + case start + case end + case url + case expandedUrl = "expanded_url" + case displayUrl = "display_url" + case status + case title + case description + case unwoundUrl = "unwound_url" + } + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterIncludesV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterIncludesV2.swift new file mode 100644 index 00000000..9cf587b1 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterIncludesV2.swift @@ -0,0 +1,17 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents the includes object in Twitter API v2 responses +public struct TwitterIncludesV2: Decodable, Sendable { + public let users: [TwitterUserV2]? + public let tweets: [TwitterTweetV2]? + public let media: [TwitterMediaV2]? + public let places: [TwitterPlaceV2]? + public let polls: [TwitterPollV2]? +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterReferencedTweetV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterReferencedTweetV2.swift new file mode 100644 index 00000000..0acdc491 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterReferencedTweetV2.swift @@ -0,0 +1,20 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a referenced tweet in the Twitter API v2 +public struct TwitterReferencedTweetV2: Decodable, Sendable { + public let type: ReferencedTweetType + public let id: String + + public enum ReferencedTweetType: String, Decodable, Sendable { + case repliedTo = "replied_to" + case retweeted = "retweeted" + case quoted = "quoted" + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterSearchTweetsResponseV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterSearchTweetsResponseV2.swift new file mode 100644 index 00000000..91dadd21 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterSearchTweetsResponseV2.swift @@ -0,0 +1,26 @@ +// TwitterSearchTweetsResponseV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Response type for tweet search endpoints +public struct TwitterSearchTweetsResponseV2: Decodable, Sendable { + public let data: [TwitterTweetV2] + public let includes: TwitterIncludesV2? + public let meta: Meta + + public struct Meta: Decodable, Sendable { + public let resultCount: Int + public let nextToken: String? + + private enum CodingKeys: String, CodingKey { + case resultCount = "result_count" + case nextToken = "next_token" + } + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Compliance/TwitterComplianceJobTypeV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterTweetResponseV2.swift similarity index 61% rename from Sources/TwitterAPIKit/APIv2/Compliance/TwitterComplianceJobTypeV2.swift rename to Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterTweetResponseV2.swift index 7d76b2f0..54385759 100644 --- a/Sources/TwitterAPIKit/APIv2/Compliance/TwitterComplianceJobTypeV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterTweetResponseV2.swift @@ -1,4 +1,3 @@ -// TwitterComplianceJobTypeV2.swift // Copyright (c) 2025 GetAutomaApp // All source code and related assets are the property of GetAutomaApp. // All rights reserved. @@ -8,11 +7,8 @@ import Foundation -public enum TwitterComplianceJobTypeV2: String { - case tweets - case users - - public func bind(param: inout [String: Any]) { - param["type"] = rawValue - } +/// Response type for the GetTweet endpoint +public struct TwitterTweetResponseV2: Decodable, Sendable { + public let data: TwitterTweetV2 + public let includes: TwitterIncludesV2? } diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterTweetV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterTweetV2.swift new file mode 100644 index 00000000..0b72166c --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Models/TwitterTweetV2.swift @@ -0,0 +1,47 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a Tweet in the Twitter API v2 +public struct TwitterTweetV2: Decodable, Sendable { + public let id: String + public let text: String + public let createdAt: Date? + public let authorId: String? + public let conversationId: String? + public let inReplyToUserId: String? + public let referencedTweets: [TwitterReferencedTweetV2]? + public let attachments: TwitterAttachmentsV2? + public let geo: TwitterGeoV2? + public let contextAnnotations: [TwitterContextAnnotationV2]? + public let entities: TwitterEntitiesV2? + public let withheld: TwitterWithheldV2? + public let publicMetrics: TwitterPublicMetricsV2? + public let possiblySensitive: Bool? + public let lang: String? + public let source: String? + + private enum CodingKeys: String, CodingKey { + case id + case text + case createdAt = "created_at" + case authorId = "author_id" + case conversationId = "conversation_id" + case inReplyToUserId = "in_reply_to_user_id" + case referencedTweets = "referenced_tweets" + case attachments + case geo + case contextAnnotations = "context_annotations" + case entities + case withheld + case publicMetrics = "public_metrics" + case possiblySensitive = "possibly_sensitive" + case lang + case source + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/DeleteTweetRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/DeleteTweetRequestV2.swift deleted file mode 100644 index bbcfb906..00000000 --- a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/DeleteTweetRequestV2.swift +++ /dev/null @@ -1,36 +0,0 @@ -// DeleteTweetRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id -open class DeleteTweetRequestV2: TwitterAPIRequest { - public let id: String - - public var method: HTTPMethod { - .delete - } - - public var path: String { - "/2/tweets/\(id)" - } - - open var parameters: [String: Any] { - [:] - } - - public init( - id: String - ) { - self.id = id - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/DeleteUsersRetweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/DeleteUsersRetweetsRequestV2.swift new file mode 100644 index 00000000..17ebc41b --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/DeleteUsersRetweetsRequestV2.swift @@ -0,0 +1,27 @@ +// DeleteUsersRetweetsRequestV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request removes a retweet of a specific tweet by the authenticated user. +/// The response includes a confirmation of whether the unretweet was successful. +/// Note: This endpoint requires OAuth 1.0a User Context authentication. +public struct DeleteUsersRetweetsRequestV2: TwitterAPIRequest { + public typealias Response = TwitterAPISuccessResponseV2 + + public let method: HTTPMethod = .delete + public let path: String + public let parameters: [String: Any] + + public init(userId: String, tweetId: String) { + self.path = "/2/users/\(userId)/retweets/\(tweetId)" + self.parameters = [:] + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetRequestV2.swift index a1761aa7..39350d53 100644 --- a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetRequestV2.swift @@ -8,54 +8,56 @@ import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id -open class GetTweetRequestV2: TwitterAPIRequest { +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves a single tweet by its ID. +/// The response includes the tweet's content, metrics, and can be expanded to include +/// additional fields like author information, referenced tweets, and more. +public struct GetTweetRequestV2: TwitterAPIRequest { + public typealias Response = TwitterTweetResponseV2 + public let id: String public let expansions: Set? + public let tweetFields: Set? + public let userFields: Set? public let mediaFields: Set? public let placeFields: Set? public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? public var method: HTTPMethod { - .get + return .get } public var path: String { - "/2/tweets/\(id)" + return "/2/tweets/\(id)" } - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params + public var parameters: [String: Any] { + var parameters: [String: Any] = [:] + parameters["expansions"] = expansions?.map(\.stringValue).joined(separator: ",") + parameters["tweet.fields"] = tweetFields?.map(\.stringValue).joined(separator: ",") + parameters["user.fields"] = userFields?.map(\.stringValue).joined(separator: ",") + parameters["media.fields"] = mediaFields?.map(\.stringValue).joined(separator: ",") + parameters["place.fields"] = placeFields?.map(\.stringValue).joined(separator: ",") + parameters["poll.fields"] = pollFields?.map(\.stringValue).joined(separator: ",") + return parameters } public init( id: String, expansions: Set? = .none, + tweetFields: Set? = .none, + userFields: Set? = .none, mediaFields: Set? = .none, placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none + pollFields: Set? = .none ) { self.id = id self.expansions = expansions + self.tweetFields = tweetFields + self.userFields = userFields self.mediaFields = mediaFields self.placeFields = placeFields self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // De-init Logic Here } } diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsQuoteTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsQuoteTweetsRequestV2.swift deleted file mode 100644 index 1281a3d9..00000000 --- a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsQuoteTweetsRequestV2.swift +++ /dev/null @@ -1,69 +0,0 @@ -// GetTweetsQuoteTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/quote-tweets/api-reference/get-tweets-id-quote_tweets -open class GetTweetsQuoteTweetsRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let maxResults: Int? - public let mediaFields: Set? - public let paginationToken: String? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/\(id)/quote_tweets" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - maxResults.map { params["max_results"] = $0 } - mediaFields?.bind(param: ¶ms) - paginationToken.map { params["pagination_token"] = $0 } - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - id: String, - expansions: Set? = .none, - maxResults: Int? = .none, - mediaFields: Set? = .none, - paginationToken: String? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.id = id - self.expansions = expansions - self.maxResults = maxResults - self.mediaFields = mediaFields - self.paginationToken = paginationToken - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsRequestV2.swift deleted file mode 100644 index c76e5291..00000000 --- a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsRequestV2.swift +++ /dev/null @@ -1,62 +0,0 @@ -// GetTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets -open class GetTweetsRequestV2: TwitterAPIRequest { - public let ids: [String] - public let expansions: Set? - public let mediaFields: Set? - public let placeFields: Set? - public let pollFields: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["ids"] = ids.joined(separator: ",") - expansions?.bind(param: ¶ms) - mediaFields?.bind(param: ¶ms) - placeFields?.bind(param: ¶ms) - pollFields?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - - public init( - ids: [String], - expansions: Set? = .none, - mediaFields: Set? = .none, - placeFields: Set? = .none, - pollFields: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.ids = ids - self.expansions = expansions - self.mediaFields = mediaFields - self.placeFields = placeFields - self.pollFields = pollFields - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsRetweetedByRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsRetweetedByRequestV2.swift new file mode 100644 index 00000000..b89343cb --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsRetweetedByRequestV2.swift @@ -0,0 +1,49 @@ +// GetTweetsRetweetedByRequestV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. + +import Foundation + +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves a list of users who have retweeted a specific tweet. +/// The response includes user objects with their profile information. +/// Note: This endpoint requires OAuth 1.0a User Context authentication. +public struct GetTweetsRetweetedByRequestV2: TwitterAPIRequest { + public typealias Response = TwitterUsersResponseV2 + + public let method: HTTPMethod = .get + public let path: String + public let parameters: [String: Any] + + public init( + tweetId: String, + expansions: Set? = nil, + maxResults: Int? = nil, + paginationToken: String? = nil, + tweetFields: Set? = nil, + userFields: Set? = nil + ) { + path = "/2/tweets/\(tweetId)/retweeted_by" + + var params: [String: Any] = [:] + if let expansions { + params["expansions"] = expansions.map(\.stringValue).joined(separator: ",") + } + if let maxResults { + params["max_results"] = maxResults + } + if let paginationToken { + params["pagination_token"] = paginationToken + } + if let tweetFields { + params["tweet.fields"] = tweetFields.map(\.stringValue).joined(separator: ",") + } + if let userFields { + params["user.fields"] = userFields.map(\.stringValue).joined(separator: ",") + } + + parameters = params + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsSearchAllRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsSearchAllRequestV2.swift new file mode 100644 index 00000000..f17943ab --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsSearchAllRequestV2.swift @@ -0,0 +1,91 @@ +// GetTweetsSearchAllRequestV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request searches for tweets across the entire Twitter archive. +/// The response includes tweet objects with their content and metadata. +/// Note: This endpoint requires Academic Research access. +public struct GetTweetsSearchAllRequestV2: TwitterAPIRequest { + public typealias Response = TwitterSearchTweetsResponseV2 + + public enum TwitterSearchTweetsSortOrderV2: String { + case recency + case relevancy + } + + public let method: HTTPMethod = .get + public let path: String = "/2/tweets/search/all" + public let parameters: [String: Any] + + // swiftlint:disable:next cyclomatic_complexity function_body_length + public init( + query: String, + endTime: Date? = nil, + expansions: Set? = nil, + maxResults: Int? = nil, + mediaFields: Set? = nil, + nextToken: String? = nil, + placeFields: Set? = nil, + pollFields: Set? = nil, + sinceID: String? = nil, + sortOrder: TwitterSearchTweetsSortOrderV2? = nil, + startTime: Date? = nil, + tweetFields: Set? = nil, + untilID: String? = nil, + userFields: Set? = nil + ) { + var params: [String: Any] = [ + "query": query + ] + + if let endTime { + params["end_time"] = ISO8601DateFormatter().string(from: endTime) + } + if let expansions { + params["expansions"] = expansions.map(\.stringValue).joined(separator: ",") + } + if let maxResults { + params["max_results"] = maxResults + } + if let mediaFields { + params["media.fields"] = mediaFields.map(\.stringValue).joined(separator: ",") + } + if let nextToken { + params["next_token"] = nextToken + } + if let placeFields { + params["place.fields"] = placeFields.map(\.stringValue).joined(separator: ",") + } + if let pollFields { + params["poll.fields"] = pollFields.map(\.stringValue).joined(separator: ",") + } + if let sinceID { + params["since_id"] = sinceID + } + if let sortOrder { + params["sort_order"] = sortOrder.rawValue + } + if let startTime { + params["start_time"] = ISO8601DateFormatter().string(from: startTime) + } + if let tweetFields { + params["tweet.fields"] = tweetFields.map(\.stringValue).joined(separator: ",") + } + if let untilID { + params["until_id"] = untilID + } + if let userFields { + params["user.fields"] = userFields.map(\.stringValue).joined(separator: ",") + } + + self.parameters = params + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsSearchRecentRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsSearchRecentRequestV2.swift new file mode 100644 index 00000000..8c9f3c1c --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetTweetsSearchRecentRequestV2.swift @@ -0,0 +1,97 @@ +// GetTweetsSearchRecentRequestV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent +public struct GetTweetsSearchRecentRequestV2: TwitterAPIRequest { + public typealias Response = TwitterSearchTweetsResponseV2 + + public enum TwitterSearchTweetsSortOrderV2: String { + case recency + case relevancy + } + + public let method: HTTPMethod = .get + public let path: String = "/2/tweets/search/recent" + public let parameters: [String: Any] + + // swiftlint:disable:next cyclomatic_complexity function_body_length + public init( + query: String, + endTime: Date? = nil, + expansions: Set? = nil, + maxResults: Int? = nil, + mediaFields: Set? = nil, + nextToken: String? = nil, + placeFields: Set? = nil, + pollFields: Set? = nil, + sinceID: String? = nil, + sortOrder: TwitterSearchTweetsSortOrderV2? = nil, + startTime: Date? = nil, + tweetFields: Set? = nil, + untilID: String? = nil, + userFields: Set? = nil + ) { + var params: [String: Any] = ["query": query] + + if let endTime { + params["end_time"] = ISO8601DateFormatter().string(from: endTime) + } + + if let expansions { + params["expansions"] = expansions.map(\.stringValue).joined(separator: ",") + } + + if let maxResults { + params["max_results"] = maxResults + } + + if let mediaFields { + params["media.fields"] = mediaFields.map(\.stringValue).joined(separator: ",") + } + + if let nextToken { + params["next_token"] = nextToken + } + + if let placeFields { + params["place.fields"] = placeFields.map(\.stringValue).joined(separator: ",") + } + + if let pollFields { + params["poll.fields"] = pollFields.map(\.stringValue).joined(separator: ",") + } + + if let sinceID { + params["since_id"] = sinceID + } + + if let sortOrder { + params["sort_order"] = sortOrder.rawValue + } + + if let startTime { + params["start_time"] = ISO8601DateFormatter().string(from: startTime) + } + + if let tweetFields { + params["tweet.fields"] = tweetFields.map(\.stringValue).joined(separator: ",") + } + + if let untilID { + params["until_id"] = untilID + } + + if let userFields { + params["user.fields"] = userFields.map(\.stringValue).joined(separator: ",") + } + + self.parameters = params + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetUserTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetUserTweetsRequestV2.swift new file mode 100644 index 00000000..079f629b --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/GetUserTweetsRequestV2.swift @@ -0,0 +1,138 @@ +import Foundation + +public struct GetUserTweetsResponseV2: Decodable, Sendable { + public let data: [Tweet] + public let includes: Includes? + public let meta: Meta + + public struct Tweet: Decodable, Sendable { + public let id: String + public let text: String + public let createdAt: Date + public let authorId: String? + public let conversationId: String? + public let inReplyToUserId: String? + public let referencedTweets: [TwitterReferencedTweetV2]? + public let attachments: TwitterAttachmentsV2? + public let geo: TwitterGeoV2? + public let contextAnnotations: [TwitterContextAnnotationV2]? + public let entities: TwitterEntitiesV2? + public let withheld: TwitterWithheldV2? + public let publicMetrics: TwitterPublicMetricsV2? + public let possiblySensitive: Bool? + public let lang: String? + public let source: String? + public let replySettings: TwitterReplySettingsV2? + + private enum CodingKeys: String, CodingKey { + case id + case text + case createdAt = "created_at" + case authorId = "author_id" + case conversationId = "conversation_id" + case inReplyToUserId = "in_reply_to_user_id" + case referencedTweets = "referenced_tweets" + case attachments + case geo + case contextAnnotations = "context_annotations" + case entities + case withheld + case publicMetrics = "public_metrics" + case possiblySensitive = "possibly_sensitive" + case lang + case source + case replySettings = "reply_settings" + } + } + + public struct Includes: Decodable, Sendable { + public let users: [TwitterUserV2]? + public let tweets: [Tweet]? + public let media: [TwitterMediaV2]? + public let places: [TwitterPlaceV2]? + public let polls: [TwitterPollV2]? + } + + public struct Meta: Decodable, Sendable { + public let resultCount: Int + public let newestId: String? + public let oldestId: String? + public let nextToken: String? + public let previousToken: String? + + private enum CodingKeys: String, CodingKey { + case resultCount = "result_count" + case newestId = "newest_id" + case oldestId = "oldest_id" + case nextToken = "next_token" + case previousToken = "previous_token" + } + } +} + +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves a user's recent tweets by their user ID. +/// The response includes a paginated list of tweets with their content, metrics, +/// and can be expanded to include additional fields like author information, +/// referenced tweets, and more. +public struct GetUserTweetsRequestV2: TwitterAPIRequest { + public typealias Response = GetUserTweetsResponseV2 + + public let method: HTTPMethod = .get + public let path: String + public let parameters: [String: Any] + + public init( + userId: String, + maxResults: Int = 10, + paginationToken: String? = nil, + tweetFields: Set? = nil, + expansions: Set? = nil, + mediaFields: Set? = nil, + pollFields: Set? = nil, + userFields: Set? = nil, + placeFields: Set? = nil, + exclude: Set? = nil, + startTime: Date? = nil, + endTime: Date? = nil, + sinceId: String? = nil, + untilId: String? = nil + ) { + self.path = "/2/users/\(userId)/tweets" + + var params: [String: Any] = [ + "max_results": maxResults + ] + + if let token = paginationToken { + params["pagination_token"] = token + } + + tweetFields?.bind(param: ¶ms) + expansions?.bind(param: ¶ms) + mediaFields?.bind(param: ¶ms) + pollFields?.bind(param: ¶ms) + userFields?.bind(param: ¶ms) + placeFields?.bind(param: ¶ms) + exclude?.bind(param: ¶ms) + + if let startTime { + params["start_time"] = ISO8601DateFormatter().string(from: startTime) + } + + if let endTime { + params["end_time"] = ISO8601DateFormatter().string(from: endTime) + } + + if let sinceId { + params["since_id"] = sinceId + } + + if let untilId { + params["until_id"] = untilId + } + + self.parameters = params + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PostTweetsRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PostTweetsRequestV2.swift index 3baaf44a..57ab01ed 100644 --- a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PostTweetsRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PostTweetsRequestV2.swift @@ -1,166 +1,31 @@ -// PostTweetsRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - +// PostTweetsRequest.swift import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets -open class PostTweetsRequestV2: TwitterAPIRequest { - public struct Geo { - public let placeID: String - - public init(placeID: String) { - self.placeID = placeID - } - - public func bind(param: inout [String: Any]) { - var params = [String: Any]() - - params["place_id"] = placeID - - param["geo"] = params - } - } - - public struct Media { - public let mediaIDs: [String] - public let taggedUserIDs: [String]? - - public init( - mediaIDs: [String], - taggedUserIDs: [String]? = .none - ) { - self.mediaIDs = mediaIDs - self.taggedUserIDs = taggedUserIDs - } - - public func bind(param: inout [String: Any]) { - var params = [String: Any]() - - params["media_ids"] = mediaIDs - taggedUserIDs.map { params["tagged_user_ids"] = $0 } - - param["media"] = params - } - } - - public struct Poll { - public let durationMinutes: Int - public let options: [String] - - public init( - durationMinutes: Int, - options: [String] - ) { - self.durationMinutes = durationMinutes - self.options = options - } - - public func bind(param: inout [String: Any]) { - var params = [String: Any]() - - params["duration_minutes"] = durationMinutes - params["options"] = options - - param["poll"] = params - } - } - - public struct Reply { - public let excludeReplyUserIDs: [String]? - public let inReplyToTweetID: String - - public init( - excludeReplyUserIDs: [String]? = .none, - inReplyToTweetID: String - ) { - self.excludeReplyUserIDs = excludeReplyUserIDs - self.inReplyToTweetID = inReplyToTweetID - } - - public func bind(param: inout [String: Any]) { - var params = [String: Any]() - - excludeReplyUserIDs.map { params["exclude_reply_user_ids"] = $0 } - params["in_reply_to_tweet_id"] = inReplyToTweetID - - param["reply"] = params - } - } - - public enum ReplySettings: String { - case mentionedUsers - case following - case everyone - - public func bind(param: inout [String: Any]) { - param["reply_settings"] = rawValue - } +public struct PostTweetsResponseV2: Decodable, Sendable { + public struct Data: Decodable, Sendable { + public let id: String + public let text: String } + public let data: Data +} - public let directMessageDeepLink: String? - public let forSuperFollowersOnly: Bool? - public let geo: Geo? - public let media: Media? - public let poll: Poll? - public let quoteTweetID: String? - public let reply: Reply? - public let replySettings: ReplySettings? - public let text: String? +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request creates a new tweet with the specified text content. +/// The response includes the newly created tweet's ID and content. +/// Note: This endpoint requires OAuth 1.0a User Context authentication. +public struct PostTweetsRequestV2: TwitterAPIRequest { + public typealias Response = PostTweetsResponseV2 - public var method: HTTPMethod { - .post - } + public let method: HTTPMethod = .post + public let path: String = "/2/tweets" + public let parameters: [String: Any] - public var path: String { - "/2/tweets" + public init(text: String) { + self.parameters = ["text": text] } public var bodyContentType: BodyContentType { .json } - - open var parameters: [String: Any] { - var params = [String: Any]() - directMessageDeepLink.map { params["direct_message_deep_link"] = $0 } - forSuperFollowersOnly.map { params["for_super_followers_only"] = $0 } - geo?.bind(param: ¶ms) - media?.bind(param: ¶ms) - poll?.bind(param: ¶ms) - quoteTweetID.map { params["quote_tweet_id"] = $0 } - reply?.bind(param: ¶ms) - replySettings?.bind(param: ¶ms) - text.map { params["text"] = $0 } - return params - } - - public init( - directMessageDeepLink: String? = .none, - forSuperFollowersOnly: Bool? = .none, - geo: PostTweetsRequestV2.Geo? = .none, - media: PostTweetsRequestV2.Media? = .none, - poll: PostTweetsRequestV2.Poll? = .none, - quoteTweetID: String? = .none, - reply: PostTweetsRequestV2.Reply? = .none, - replySettings: PostTweetsRequestV2.ReplySettings? = .none, - text: String? = .none - ) { - self.directMessageDeepLink = directMessageDeepLink - self.forSuperFollowersOnly = forSuperFollowersOnly - self.geo = geo - self.media = media - self.poll = poll - self.quoteTweetID = quoteTweetID - self.reply = reply - self.replySettings = replySettings - self.text = text - } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PutTweetsHiddenRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PutTweetsHiddenRequestV2.swift deleted file mode 100644 index 6905205c..00000000 --- a/Sources/TwitterAPIKit/APIv2/Tweet/Requests/PutTweetsHiddenRequestV2.swift +++ /dev/null @@ -1,46 +0,0 @@ -// PutTweetsHiddenRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// https://developer.twitter.com/en/docs/twitter-api/tweets/hide-replies/api-reference/put-tweets-id-hidden -open class PutTweetsHiddenRequestV2: TwitterAPIRequest { - /// Tweet ID - public let id: String - public let hidden: Bool - - public var method: HTTPMethod { - .put - } - - public var path: String { - "/2/tweets/\(id)/hidden" - } - - public var bodyContentType: BodyContentType { - .json - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["hidden"] = hidden - return params - } - - public init( - id: String, - hidden: Bool - ) { - self.id = id - self.hidden = hidden - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Tweet/TweetAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Tweet/TweetAPIv2.swift deleted file mode 100644 index 8b502a1f..00000000 --- a/Sources/TwitterAPIKit/APIv2/Tweet/TweetAPIv2.swift +++ /dev/null @@ -1,57 +0,0 @@ -// TweetAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class TweetAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets - public func getTweets( - _ request: GetTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id - public func getTweet( - _ request: GetTweetRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/quote-tweets/api-reference/get-tweets-id-quote_tweets - public func getQuoteTweets( - _ request: GetTweetsQuoteTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id - public func deleteTweet( - _ request: DeleteTweetRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets - public func postTweet( - _ request: PostTweetsRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/hide-replies/api-reference/put-tweets-id-hidden - public func hideReply( - _ request: PutTweetsHiddenRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/TweetCount/Models/TwitterTweetCountsResponseV2.swift b/Sources/TwitterAPIKit/APIv2/TweetCount/Models/TwitterTweetCountsResponseV2.swift new file mode 100644 index 00000000..5f7d7d97 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/TweetCount/Models/TwitterTweetCountsResponseV2.swift @@ -0,0 +1,27 @@ +import Foundation + +/// Response type for tweet count requests. +public struct TwitterTweetCountsResponseV2: Decodable, Sendable { + /// The tweet count data. + public struct Data: Decodable, Sendable { + /// The start time of the count period. + public let start: Date + /// The end time of the count period. + public let end: Date + /// The number of tweets in this period. + public let tweetCount: Int + } + + /// The tweet count data. + public let data: [Data] + /// Pagination metadata. + public let meta: Meta + + /// Pagination metadata for tweet count responses. + public struct Meta: Decodable, Sendable { + /// The total number of tweets counted. + public let totalTweetCount: Int + /// The next page token, if available. + public let nextToken: String? + } +} diff --git a/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsAllRequestV2.swift b/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsAllRequestV2.swift index 2758676b..d618869e 100644 --- a/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsAllRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsAllRequestV2.swift @@ -1,62 +1,47 @@ -// GetTweetsCountsAllRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-all -open class GetTweetsCountsAllRequestV2: TwitterAPIRequest { - public let query: String - public let endTime: Date? - public let granularity: TweetCountGranularityV2? - public let nextToken: String? - public let sinceID: String? - public let startTime: Date? - public let untilID: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/counts/all" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["query"] = query - endTime?.bind(param: ¶ms, for: "end_time") - granularity?.bind(param: ¶ms) - nextToken.map { params["next_token"] = $0 } - sinceID.map { params["since_id"] = $0 } - startTime?.bind(param: ¶ms, for: "start_time") - untilID.map { params["until_id"] = $0 } - return params - } - +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves the total count of tweets matching a search query across the entire Twitter archive. +/// The response includes tweet counts aggregated by the specified granularity (minute, hour, or day). +/// Note: This endpoint requires Academic Research access. +public struct GetTweetsCountsAllRequestV2: TwitterAPIRequest { + public typealias Response = TwitterTweetCountsResponseV2 + + public let method: HTTPMethod = .get + public let path: String = "/2/tweets/counts/all" + public let parameters: [String: Any] + public init( query: String, - endTime: Date? = .none, - granularity: TweetCountGranularityV2? = .none, - nextToken: String? = .none, - sinceID: String? = .none, - startTime: Date? = .none, - untilID: String? = .none + endTime: Date? = nil, + granularity: TweetCountGranularityV2? = nil, + nextToken: String? = nil, + sinceID: String? = nil, + startTime: Date? = nil, + untilID: String? = nil ) { - self.query = query - self.endTime = endTime - self.granularity = granularity - self.nextToken = nextToken - self.sinceID = sinceID - self.startTime = startTime - self.untilID = untilID - } - - deinit { - // de-init logic here + var params: [String: Any] = ["query": query] + + if let endTime { + params["end_time"] = ISO8601DateFormatter().string(from: endTime) + } + if let granularity { + params["granularity"] = granularity.rawValue + } + if let nextToken { + params["next_token"] = nextToken + } + if let sinceID { + params["since_id"] = sinceID + } + if let startTime { + params["start_time"] = ISO8601DateFormatter().string(from: startTime) + } + if let untilID { + params["until_id"] = untilID + } + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsRecentRequestV2.swift b/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsRecentRequestV2.swift index 9ebab2c7..86708fc5 100644 --- a/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsRecentRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/TweetCount/Requests/GetTweetsCountsRecentRequestV2.swift @@ -1,58 +1,42 @@ -// GetTweetsCountsRecentRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent -open class GetTweetsCountsRecentRequestV2: TwitterAPIRequest { - public let query: String - public let endTime: Date? - public let granularity: TweetCountGranularityV2? - public let sinceID: String? - public let startTime: Date? - public let untilID: String? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/tweets/counts/recent" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["query"] = query - endTime?.bind(param: ¶ms, for: "end_time") - granularity?.bind(param: ¶ms) - sinceID.map { params["since_id"] = $0 } - startTime?.bind(param: ¶ms, for: "start_time") - untilID.map { params["until_id"] = $0 } - return params - } - +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves the count of tweets matching a search query from the last 7 days. +/// The response includes tweet counts aggregated by the specified granularity (minute, hour, or day). +public struct GetTweetsCountsRecentRequestV2: TwitterAPIRequest { + public typealias Response = TwitterTweetCountsResponseV2 + + public let method: HTTPMethod = .get + public let path: String = "/2/tweets/counts/recent" + public let parameters: [String: Any] + public init( query: String, - endTime: Date? = .none, - granularity: TweetCountGranularityV2? = .none, - sinceID: String? = .none, - startTime: Date? = .none, - untilID: String? = .none + endTime: Date? = nil, + granularity: TweetCountGranularityV2? = nil, + sinceID: String? = nil, + startTime: Date? = nil, + untilID: String? = nil ) { - self.query = query - self.endTime = endTime - self.granularity = granularity - self.sinceID = sinceID - self.startTime = startTime - self.untilID = untilID - } - - deinit { - // de-init logic here + var params: [String: Any] = ["query": query] + + if let endTime { + params["end_time"] = ISO8601DateFormatter().string(from: endTime) + } + if let granularity { + params["granularity"] = granularity.rawValue + } + if let sinceID { + params["since_id"] = sinceID + } + if let startTime { + params["start_time"] = ISO8601DateFormatter().string(from: startTime) + } + if let untilID { + params["until_id"] = untilID + } + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/TweetCount/TweetCountAPIv2.swift b/Sources/TwitterAPIKit/APIv2/TweetCount/TweetCountAPIv2.swift deleted file mode 100644 index b1857d2d..00000000 --- a/Sources/TwitterAPIKit/APIv2/TweetCount/TweetCountAPIv2.swift +++ /dev/null @@ -1,30 +0,0 @@ -// TweetCountAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class TweetCountAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent - public func getTweetCountRecent( - _ request: GetTweetsCountsRecentRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-all - /// - Important: This endpoint is only available to those users who have been approved for Academic Research access. - public func getTweetCountAll( - _ request: GetTweetsCountsAllRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/APIv2/TwitterAPIv2.swift b/Sources/TwitterAPIKit/APIv2/TwitterAPIv2.swift deleted file mode 100644 index 1249291e..00000000 --- a/Sources/TwitterAPIKit/APIv2/TwitterAPIv2.swift +++ /dev/null @@ -1,98 +0,0 @@ -// TwitterAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -// https://developer.twitter.com/en/docs/api-reference-index - -/// Main class for interacting with Twitter API v2 endpoints. -/// This class provides access to various API modules for different Twitter functionalities. -/// Each property represents a specialized API client for specific Twitter features. -open class TwitterAPIv2 { - /// Client for managing block and mute relationships between users. - public let blockAndMute: BlockAndMuteAPIv2 - - /// Client for managing tweet bookmarks. - public let bookmarks: BookmarksAPIv2 - - /// Client for accessing Twitter's compliance and data management endpoints. - public let compliance: ComplianceAPIv2 - - /// Client for managing follow relationships between users. - public let friendships: FriendshipsAPIv2 - - /// Client for managing tweet likes (favorites). - public let like: LikeAPIv2 - - /// Client for managing Twitter lists. - public let list: ListAPIv2 - - /// Client for managing retweets. - public let retweet: RetweetAPIv2 - - /// Client for searching tweets. - public let search: SearchAPIv2 - - /// Client for managing Twitter Spaces. - public let spaces: SpacesAPIv2 - - /// Client for accessing Twitter's streaming endpoints. - public let stream: StreamAPIv2 - - /// Client for accessing user timelines. - public let timeline: TimelineAPIv2 - - /// Client for managing tweets. - public let tweet: TweetAPIv2 - - /// Client for retrieving tweet counts and metrics. - public let tweetCount: TweetCountAPIv2 - - /// Client for managing user profiles and information. - public let user: UserAPIv2 - - /// Client for managing direct messages. - public let dm: DirectMessageAPIv2 - - /// Initializes a new TwitterAPIv2 instance. - /// - Parameter session: The session to use for making API requests. - public init(session: TwitterAPISession) { - blockAndMute = .init(session: session) - bookmarks = .init(session: session) - compliance = .init(session: session) - friendships = .init(session: session) - like = .init(session: session) - list = .init(session: session) - retweet = .init(session: session) - search = .init(session: session) - spaces = .init(session: session) - stream = .init(session: session) - timeline = .init(session: session) - tweet = .init(session: session) - tweetCount = .init(session: session) - user = .init(session: session) - dm = .init(session: session) - } - - deinit { - // De-init Logic Here - } -} - -/// Protocol defining parameters that can be used in Twitter API v2 requests. -public protocol TwitterAPIv2RequestParameter { - /// The string representation of the parameter value. - var stringValue: String { get } -} - -public extension Collection where Element: TwitterAPIv2RequestParameter { - /// Joins multiple parameter values into a comma-separated string. - var commaSeparatedString: String { - map(\.stringValue).sorted().joined(separator: ",") - } -} diff --git a/Sources/TwitterAPIKit/APIv2/TwitterDmEventExpansionsV2.swift b/Sources/TwitterAPIKit/APIv2/TwitterDmEventExpansionsV2.swift deleted file mode 100644 index 3bc2d386..00000000 --- a/Sources/TwitterAPIKit/APIv2/TwitterDmEventExpansionsV2.swift +++ /dev/null @@ -1,145 +0,0 @@ -// TwitterDmEventExpansionsV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// For more details, see: -/// https://developer.twitter.com/en/docs/twitter-api/expansions -public protocol TwitterExpansionsParameterV2: TwitterAPIv2RequestParameter {} - -/// Binds the expansions to the request parameters. -public extension Set where Element: TwitterExpansionsParameterV2 { - /// Binds the expansions to the request parameters. - func bind(param: inout [String: Any]) { - param["expansions"] = commaSeparatedString - } -} - -public enum TwitterTweetExpansionsV2: TwitterExpansionsParameterV2, Hashable { - case attachmentsMediaKeys - case attachmentsPollIDs - case authorID - case entitiesMentionsUsername - case geoPlaceID - case inReplyToUserID - case other(String) - case referencedTweetsID - case referencedTweetsIDAuthorID - - public var stringValue: String { - switch self { - case .attachmentsMediaKeys: "attachments.media_keys" - case .attachmentsPollIDs: "attachments.poll_ids" - case .authorID: "author_id" - case .entitiesMentionsUsername: "entities.mentions.username" - case .geoPlaceID: "geo.place_id" - case .inReplyToUserID: "in_reply_to_user_id" - case let .other(string): string - case .referencedTweetsID: "referenced_tweets.id" - case .referencedTweetsIDAuthorID: "referenced_tweets.id.author_id" - } - } - - public static let all: Set = [ - .attachmentsMediaKeys, - .attachmentsPollIDs, - .authorID, - .entitiesMentionsUsername, - .geoPlaceID, - .inReplyToUserID, - .referencedTweetsID, - .referencedTweetsIDAuthorID, - ] -} - -public enum TwitterUserExpansionsV2: TwitterExpansionsParameterV2, Hashable { - case other(String) - case pinnedTweetID - - public var stringValue: String { - switch self { - case let .other(string): string - case .pinnedTweetID: "pinned_tweet_id" - } - } - - public static let all: Set = [ - .pinnedTweetID, - ] -} - -public enum TwitterListExpansionsV2: TwitterExpansionsParameterV2, Hashable { - case other(String) - case ownerID - - public var stringValue: String { - switch self { - case let .other(string): string - case .ownerID: "owner_id" - } - } - - public static let all: Set = [ - .ownerID, - ] -} - -public enum TwitterSpaceExpansionsV2: TwitterExpansionsParameterV2, Hashable { - case creatorID - case hostIDs - case invitedUserIDs - case other(String) - case speakerIDs - case topicIDs - - public var stringValue: String { - switch self { - case .creatorID: "creator_id" - case .hostIDs: "host_ids" - case .invitedUserIDs: "invited_user_ids" - case let .other(string): string - case .speakerIDs: "speaker_ids" - case .topicIDs: "topic_ids" - } - } - - public static let all: Set = [ - .creatorID, - .hostIDs, - .invitedUserIDs, - .speakerIDs, - .topicIDs, - ] -} - -/// A comma separated list of fields to expand. -/// expansions -public enum TwitterDmEventExpansionsV2: TwitterExpansionsParameterV2, Hashable { - case attachmentsMediaKeys - case other(String) - case participantIDs - case referencedTweetsID - case senderID - - public var stringValue: String { - switch self { - case .attachmentsMediaKeys: "attachments.media_keys" - case let .other(string): string - case .participantIDs: "participant_ids" - case .referencedTweetsID: "referenced_tweets.id" - case .senderID: "sender_id" - } - } - - public static let all: Set = [ - .attachmentsMediaKeys, - .participantIDs, - .referencedTweetsID, - .senderID, - ] -} diff --git a/Sources/TwitterAPIKit/APIv2/TwitterExpansionsV2.swift b/Sources/TwitterAPIKit/APIv2/TwitterExpansionsV2.swift new file mode 100644 index 00000000..706e50a5 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/TwitterExpansionsV2.swift @@ -0,0 +1,113 @@ +// TwitterExpansionsV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Protocol for Twitter API v2 expansion parameters +public protocol TwitterExpansionsV2: TwitterAPIv2RequestParameter {} + +/// Extension to bind expansions to request parameters +public extension Set where Element: TwitterExpansionsV2 { + /// Binds the expansions to comma separated strings + func bind(param: inout [String: Any]) { + param["expansions"] = commaSeparatedString + } +} + +// MARK: - Tweet Expansions + +/// Tweet expansions that can be requested from the Twitter API v2 +public enum TwitterTweetExpansionsV2: String, TwitterExpansionsV2, Sendable { + case attachmentsMediaKeys = "attachments.media_keys" + case attachmentsPollIDs = "attachments.poll_ids" + case authorID = "author_id" + case entitiesMentionsUsername = "entities.mentions.username" + case geoPlaceID = "geo.place_id" + case inReplyToUserID = "in_reply_to_user_id" + case referencedTweetsID = "referenced_tweets.id" + case referencedTweetsIDAuthorID = "referenced_tweets.id.author_id" + + public var stringValue: String { rawValue } + + public static let all: Set = [ + .attachmentsMediaKeys, + .attachmentsPollIDs, + .authorID, + .entitiesMentionsUsername, + .geoPlaceID, + .inReplyToUserID, + .referencedTweetsID, + .referencedTweetsIDAuthorID + ] +} + +// MARK: - User Expansions + +/// User expansions that can be requested from the Twitter API v2 +public enum TwitterUserExpansionsV2: String, TwitterExpansionsV2, Sendable { + case pinnedTweetID = "pinned_tweet_id" + + public var stringValue: String { rawValue } + + public static let all: Set = [ + .pinnedTweetID + ] +} + +// MARK: - List Expansions + +/// List expansions that can be requested from the Twitter API v2 +public enum TwitterListExpansionsV2: String, TwitterExpansionsV2, Sendable { + case ownerID = "owner_id" + + public var stringValue: String { rawValue } + + public static let all: Set = [ + .ownerID + ] +} + +// MARK: - Space Expansions + +/// Space expansions that can be requested from the Twitter API v2 +public enum TwitterSpaceExpansionsV2: String, TwitterExpansionsV2, Sendable { + case creatorID = "creator_id" + case hostIDs = "host_ids" + case invitedUserIDs = "invited_user_ids" + case speakerIDs = "speaker_ids" + case topicIDs = "topic_ids" + + public var stringValue: String { rawValue } + + public static let all: Set = [ + .hostIDs, + .creatorID, + .invitedUserIDs, + .speakerIDs, + .topicIDs + ] +} + +// MARK: - DM Event Expansions + +/// DM event expansions that can be requested from the Twitter API v2 +public enum TwitterDmEventExpansionsV2: String, TwitterExpansionsV2, Sendable { + case attachmentsMediaKeys = "attachments.media_keys" + case participantIDs = "participant_ids" + case referencedTweetsID = "referenced_tweets.id" + case senderID = "sender_id" + + public var stringValue: String { rawValue } + + public static let all: Set = [ + .attachmentsMediaKeys, + .referencedTweetsID, + .senderID, + .participantIDs + ] +} diff --git a/Sources/TwitterAPIKit/APIv2/TwitterFieldsV2.swift b/Sources/TwitterAPIKit/APIv2/TwitterFieldsV2.swift new file mode 100644 index 00000000..37c5e29f --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/TwitterFieldsV2.swift @@ -0,0 +1,317 @@ +// TwitterFieldsV2.swift +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +internal protocol TwitterFieldsV2 {} + +/// Protocol for Twitter API v2 request parameters +public protocol TwitterAPIv2RequestParameter: Hashable { + var stringValue: String { get } +} + +extension Set where Element: TwitterAPIv2RequestParameter { + /// Extension to provide common functionality for request parameters + public var commaSeparatedString: String { + map(\.stringValue).joined(separator: ",") + } +} + +// MARK: - Tweet Fields + +/// Tweet fields that can be requested from the Twitter API v2 +public enum TwitterTweetFieldsV2: TwitterAPIv2RequestParameter, Sendable { + case attachments + case authorID + case contextAnnotations + case conversationID + case createdAt + case entities + case geo + case id + case inReplyToUserID + case lang + case nonPublicMetrics + case organicMetrics + case other(String) + case possiblySensitive + case promotedMetrics + case publicMetrics + case referencedTweets + case replySettings + case source + case text + case withheld + + public var stringValue: String { + switch self { + case .attachments: "attachments" + case .authorID: "author_id" + case .contextAnnotations: "context_annotations" + case .conversationID: "conversation_id" + case .createdAt: "created_at" + case .entities: "entities" + case .geo: "geo" + case .id: "id" + case .inReplyToUserID: "in_reply_to_user_id" + case .lang: "lang" + case .nonPublicMetrics: "non_public_metrics" + case .organicMetrics: "organic_metrics" + case .other(let value): value + case .possiblySensitive: "possibly_sensitive" + case .promotedMetrics: "promoted_metrics" + case .publicMetrics: "public_metrics" + case .referencedTweets: "referenced_tweets" + case .replySettings: "reply_settings" + case .source: "source" + case .text: "text" + case .withheld: "withheld" + } + } + + public static let all: Set = [ + .attachments, + .authorID, + .contextAnnotations, + .conversationID, + .createdAt, + .entities, + .geo, + .id, + .inReplyToUserID, + .lang, + .nonPublicMetrics, + .organicMetrics, + .possiblySensitive, + .promotedMetrics, + .publicMetrics, + .referencedTweets, + .replySettings, + .source, + .text, + .withheld + ] +} + +// MARK: - User Fields + +/// User fields that can be requested from the Twitter API v2 +public enum TwitterUserFieldsV2: TwitterAPIv2RequestParameter, Sendable { + case `protected` + case createdAt + case description + case entities + case id + case location + case name + case other(String) + case pinnedTweetID + case profileImageUrl + case publicMetrics + case url + case username + case verified + case withheld + + public var stringValue: String { + switch self { + case .createdAt: "created_at" + case .description: "description" + case .entities: "entities" + case .id: "id" + case .location: "location" + case .name: "name" + case .other(let value): value + case .pinnedTweetID: "pinned_tweet_id" + case .profileImageUrl: "profile_image_url" + case .protected: "protected" + case .publicMetrics: "public_metrics" + case .url: "url" + case .username: "username" + case .verified: "verified" + case .withheld: "withheld" + } + } + + public static let all: Set = [ + .createdAt, + .description, + .entities, + .id, + .location, + .name, + .pinnedTweetID, + .profileImageUrl, + .protected, + .publicMetrics, + .url, + .username, + .verified, + .withheld + ] +} + +// MARK: - Place Fields + +/// Place fields that can be requested from the Twitter API v2 +public enum TwitterPlaceFieldsV2: TwitterAPIv2RequestParameter, Sendable { + case containedWithin + case country + case countryCode + case fullName + case geo + case id + case name + case other(String) + case placeType + + public var stringValue: String { + switch self { + case .containedWithin: "contained_within" + case .country: "country" + case .countryCode: "country_code" + case .fullName: "full_name" + case .geo: "geo" + case .id: "id" + case .name: "name" + case .other(let value): value + case .placeType: "place_type" + } + } + + public static let all: Set = [ + .containedWithin, + .country, + .countryCode, + .fullName, + .geo, + .id, + .name, + .placeType + ] +} + +// MARK: - Poll Fields + +/// Poll fields that can be requested from the Twitter API v2 +public enum TwitterPollFieldsV2: TwitterAPIv2RequestParameter, Sendable { + case durationMinutes + case endDatetime + case id + case options + case other(String) + case votingStatus + + public var stringValue: String { + switch self { + case .durationMinutes: "duration_minutes" + case .endDatetime: "end_datetime" + case .id: "id" + case .options: "options" + case .other(let value): value + case .votingStatus: "voting_status" + } + } + + public static let all: Set = [ + .durationMinutes, + .endDatetime, + .id, + .options, + .votingStatus + ] +} + +// MARK: - Media Fields + +/// Media fields that can be requested from the Twitter API v2 +public enum TwitterMediaFieldsV2: TwitterAPIv2RequestParameter, Sendable { + case altText + case durationMs + case height + case mediaKey + case nonPublicMetrics + case organicMetrics + case other(String) + case previewImageUrl + case promotedMetrics + case publicMetrics + case type + case url + case width + + public var stringValue: String { + switch self { + case .altText: "alt_text" + case .durationMs: "duration_ms" + case .height: "height" + case .mediaKey: "media_key" + case .nonPublicMetrics: "non_public_metrics" + case .organicMetrics: "organic_metrics" + case .other(let value): value + case .previewImageUrl: "preview_image_url" + case .promotedMetrics: "promoted_metrics" + case .publicMetrics: "public_metrics" + case .type: "type" + case .url: "url" + case .width: "width" + } + } + + public static let all: Set = [ + .altText, + .durationMs, + .height, + .mediaKey, + .nonPublicMetrics, + .organicMetrics, + .previewImageUrl, + .promotedMetrics, + .publicMetrics, + .type, + .url, + .width + ] +} + +// MARK: - Parameter Binding Extensions + +public extension Set where Element == TwitterTweetFieldsV2 { + /// Bind tweet.fields to the comma separated string value for it + func bind(param: inout [String: Any]) { + param["tweet.fields"] = commaSeparatedString + } +} + +public extension Set where Element == TwitterUserFieldsV2 { + /// Bind tweet.fields to the comma separated string value for it + func bind(param: inout [String: Any]) { + param["user.fields"] = commaSeparatedString + } +} + +public extension Set where Element == TwitterPlaceFieldsV2 { + /// Bind tweet.fields to the comma separated string value for it + func bind(param: inout [String: Any]) { + param["place.fields"] = commaSeparatedString + } +} + +public extension Set where Element == TwitterPollFieldsV2 { + /// Bind tweet.fields to the comma separated string value for it + func bind(param: inout [String: Any]) { + param["poll.fields"] = commaSeparatedString + } +} + +public extension Set where Element == TwitterMediaFieldsV2 { + /// Bind tweet.fields to the comma separated string value for it + func bind(param: inout [String: Any]) { + param["media.fields"] = commaSeparatedString + } +} diff --git a/Sources/TwitterAPIKit/APIv2/TwitterTweetFieldsV2.swift b/Sources/TwitterAPIKit/APIv2/TwitterTweetFieldsV2.swift deleted file mode 100644 index 5e46611a..00000000 --- a/Sources/TwitterAPIKit/APIv2/TwitterTweetFieldsV2.swift +++ /dev/null @@ -1,590 +0,0 @@ -// TwitterTweetFieldsV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -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 organicMetrics - case other(String) - case possiblySensitive - case promotedMetrics - case publicMetrics - case referencedTweets - case replySettings - case source - case text - case withheld - - public var stringValue: String { - switch self { - case .attachments: - "attachments" - case .authorID: - "author_id" - case .contextAnnotations: - "context_annotations" - case .conversationID: - "conversation_id" - case .createdAt: - "created_at" - case .entities: - "entities" - case .geo: - "geo" - case .id: - "id" - case .inReplyToUserID: - "in_reply_to_user_id" - case .lang: - "lang" - case .nonPublicMetrics: - "non_public_metrics" - case .organicMetrics: - "organic_metrics" - case let .other(other): - other - case .possiblySensitive: - "possibly_sensitive" - case .promotedMetrics: - "promoted_metrics" - case .publicMetrics: - "public_metrics" - case .referencedTweets: - "referenced_tweets" - case .replySettings: - "reply_settings" - case .source: - "source" - case .text: - "text" - case .withheld: - "withheld" - } - } - - public static let all: Set = [ - .attachments, - .authorID, - .contextAnnotations, - .conversationID, - .createdAt, - .entities, - .geo, - .id, - .inReplyToUserID, - .lang, - .nonPublicMetrics, - .organicMetrics, - .possiblySensitive, - .promotedMetrics, - .publicMetrics, - .referencedTweets, - .replySettings, - .source, - .text, - .withheld, - ] -} - -/// Extension to bind tweet fields to request parameters -public extension Set { - /// Binds the tweet fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - 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 other(String) - case pinnedTweetID - case profileImageUrl - case protected - case publicMetrics - case url - case username - case verified - case withheld - - public var stringValue: String { - switch self { - case .createdAt: - "created_at" - case .description: - "description" - case .entities: - "entities" - case .id: - "id" - case .location: - "location" - case .name: - "name" - case let .other(other): - other - case .pinnedTweetID: - "pinned_tweet_id" - case .profileImageUrl: - "profile_image_url" - case .protected: - "protected" - case .publicMetrics: - "public_metrics" - case .url: - "url" - case .username: - "username" - case .verified: - "verified" - case .withheld: - "withheld" - } - } - - public static let all: Set = [ - .createdAt, - .description, - .entities, - .id, - .location, - .name, - .pinnedTweetID, - .profileImageUrl, - .protected, - .publicMetrics, - .url, - .username, - .verified, - .withheld, - ] -} - -/// Extension to bind user fields to request parameters -public extension Set { - /// Binds the user fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - 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 other(String) - case placeType - - public var stringValue: String { - switch self { - case .containedWithin: - "contained_within" - case .country: - "country" - case .countryCode: - "country_code" - case .fullName: - "full_name" - case .geo: - "geo" - case .id: - "id" - case .name: - "name" - case let .other(other): - other - case .placeType: - "place_type" - } - } - - public static let all: Set = [ - .containedWithin, - .country, - .countryCode, - .fullName, - .geo, - .id, - .name, - .placeType, - ] -} - -/// Extension to bind place fields to request parameters -public extension Set { - /// Binds the place fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - 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 other(String) - case votingStatus - - public var stringValue: String { - switch self { - case .durationMinutes: - "duration_minutes" - case .endDatetime: - "end_datetime" - case .id: - "id" - case .options: - "options" - case let .other(other): - other - case .votingStatus: - "voting_status" - } - } - - public static let all: Set = [ - .durationMinutes, - .endDatetime, - .id, - .options, - .votingStatus, - ] -} - -/// Extension to bind poll fields to request parameters -public extension Set { - /// Binds the poll fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["poll.fields"] = commaSeparatedString - } -} - -/// media.fields -public enum TwitterMediaFieldsV2: TwitterAPIv2RequestParameter, Hashable { - case altText - case durationMs - case height - case mediaKey - case nonPublicMetrics - case organicMetrics - case other(String) - case previewImageUrl - case promotedMetrics - case publicMetrics - case type - case url - case variants - case width - - public var stringValue: String { - switch self { - case .altText: "alt_text" - case .durationMs: "duration_ms" - case .height: "height" - case .mediaKey: "media_key" - case .nonPublicMetrics: "non_public_metrics" - case .organicMetrics: "organic_metrics" - case let .other(string): string - case .previewImageUrl: "preview_image_url" - case .promotedMetrics: "promoted_metrics" - case .publicMetrics: "public_metrics" - case .type: "type" - case .url: "url" - case .variants: "variants" - case .width: "width" - } - } - - public static let all: Set = [ - .altText, - .durationMs, - .height, - .mediaKey, - .nonPublicMetrics, - .organicMetrics, - .previewImageUrl, - .promotedMetrics, - .publicMetrics, - .type, - .url, - .variants, - .width, - ] -} - -/// Extension to bind media fields to request parameters -public extension Set { - /// Binds the media fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["media.fields"] = commaSeparatedString - } -} - -/// list.fields -public enum TwitterListFieldsV2: TwitterAPIv2RequestParameter, Hashable { - // swiftlint:disable sorted_enum_cases - case createdAt - case description - case followerCount - case id - case memberCount - case name - case other(String) - case ownerID - case `private` - - public var stringValue: String { - switch self { - case .createdAt: "created_at" - case .description: "description" - case .followerCount: "follower_count" - case .id: "id" - case .memberCount: "member_count" - case .name: "name" - case let .other(string): string - case .ownerID: "owner_id" - case .private: "private" - } - } - - public static let all: Set = [ - .createdAt, - .description, - .followerCount, - .id, - .memberCount, - .name, - .ownerID, - .private, - ] - // swiftlint:enable sorted_enum_cases -} - -/// Extension to bind list fields to request parameters -public extension Set { - /// Binds the list fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["list.fields"] = commaSeparatedString - } -} - -/// space.fields -public enum TwitterSpaceFieldsV2: TwitterAPIv2RequestParameter, Hashable { - case createdAt - case creatorID - case endedAt - case hostIDs - case id - case invitedUserIDs - case isTicketed - case lang - case other(String) - case participantCount - case scheduledStart - case speakerIDs - case startedAt - case state - case subscriberCount - case title - case topicIDs - case updatedAt - - public var stringValue: String { - switch self { - case .createdAt: "created_at" - case .creatorID: "creator_id" - case .endedAt: "ended_at" - case .hostIDs: "host_ids" - case .id: "id" - case .invitedUserIDs: "invited_user_ids" - case .isTicketed: "is_ticketed" - case .lang: "lang" - case let .other(string): string - case .participantCount: "participant_count" - case .scheduledStart: "scheduled_start" - case .speakerIDs: "speaker_ids" - case .startedAt: "started_at" - case .state: "state" - case .subscriberCount: "subscriber_count" - case .title: "title" - case .topicIDs: "topic_ids" - case .updatedAt: "updated_at" - } - } - - public static let all: Set = [ - .createdAt, - .creatorID, - .endedAt, - .hostIDs, - .id, - .invitedUserIDs, - .isTicketed, - .lang, - .participantCount, - .scheduledStart, - .speakerIDs, - .startedAt, - .state, - .subscriberCount, - .title, - .topicIDs, - .updatedAt, - ] -} - -/// Extension to bind space fields to request parameters -public extension Set { - /// Binds the space fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["space.fields"] = commaSeparatedString - } -} - -/// topic.fields -public enum TwitterTopicFieldsV2: TwitterAPIv2RequestParameter, Hashable { - case description - case id - case name - case other(String) - - public var stringValue: String { - switch self { - case .description: "description" - case .id: "id" - case .name: "name" - case let .other(string): string - } - } - - public static let all: Set = [ - .description, - .id, - .name, - ] -} - -/// Extension to bind topic fields to request parameters -public extension Set { - /// Binds the topic fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["topic.fields"] = commaSeparatedString - } -} - -/// A comma separated list of DmEvent fields to display. -/// dm_event.fields -public enum TwitterDmEventFieldsV2: TwitterAPIv2RequestParameter, Hashable { - case attachments - case createdAt - case dmConversationID - case eventType - case id - case other(String) - case participantIDs - case referencedTweets - case senderID - case text - - public var stringValue: String { - switch self { - case .attachments: "attachments" - case .createdAt: "created_at" - case .dmConversationID: "dm_conversation_id" - case .eventType: "event_type" - case .id: "id" - case let .other(string): string - case .participantIDs: "participant_ids" - case .referencedTweets: "referenced_tweets" - case .senderID: "sender_id" - case .text: "text" - } - } - - public static let all: Set = [ - .attachments, - .createdAt, - .dmConversationID, - .eventType, - .id, - .participantIDs, - .referencedTweets, - .senderID, - .text, - ] -} - -/// Extension to bind DM event fields to request parameters -public extension Set { - /// Binds the DM event fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["dm_event.fields"] = commaSeparatedString - } -} - -/// A comma separated list of DmConversation fields to display. -/// dm_conversation.fields -public enum TwitterDmConversationFieldsV2: TwitterAPIv2RequestParameter, Hashable { - case id - case other(String) - - public var stringValue: String { - switch self { - case .id: "id" - case let .other(string): string - } - } - - public static let all: Set = [ - .id, - ] -} - -/// Extension to bind DM conversation fields to request parameters -public extension Set { - /// Binds the DM conversation fields to the request parameters - /// - Parameter param: The parameters dictionary to bind to - func bind(param: inout [String: Any]) { - param["dm_conversation.fields"] = commaSeparatedString - } -} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUserResponseV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUserResponseV2.swift new file mode 100644 index 00000000..15dfadfd --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUserResponseV2.swift @@ -0,0 +1,7 @@ +import Foundation + +/// Response type for single user endpoints +public struct TwitterUserResponseV2: Decodable, Sendable { + public let data: TwitterUserV2 + public let includes: TwitterIncludesV2? +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUserV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUserV2.swift new file mode 100644 index 00000000..739daab1 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUserV2.swift @@ -0,0 +1,41 @@ +// Copyright (c) 2025 GetAutomaApp +// All source code and related assets are the property of GetAutomaApp. +// All rights reserved. +// +// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. +// This Package is distributable through a modified version of the MIT License. + +import Foundation + +/// Represents a Twitter User in the Twitter API v2 +public struct TwitterUserV2: Decodable, Sendable { + public let id: String + public let name: String + public let username: String + public let createdAt: Date? + public let description: String? + public let location: String? + public let pinnedTweetId: String? + public let profileImageUrl: String? + public let protected: Bool? + public let publicMetrics: TwitterPublicMetricsV2? + public let url: String? + public let verified: Bool? + public let withheld: TwitterWithheldV2? + + private enum CodingKeys: String, CodingKey { + case id + case name + case username + case createdAt = "created_at" + case description + case location + case pinnedTweetId = "pinned_tweet_id" + case profileImageUrl = "profile_image_url" + case protected + case publicMetrics = "public_metrics" + case url + case verified + case withheld + } +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUsersResponseV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUsersResponseV2.swift new file mode 100644 index 00000000..5aff19b3 --- /dev/null +++ b/Sources/TwitterAPIKit/APIv2/Users/Models/TwitterUsersResponseV2.swift @@ -0,0 +1,7 @@ +import Foundation + +/// Response type for multiple user endpoints +public struct TwitterUsersResponseV2: Decodable, Sendable { + public let data: [TwitterUserV2] + public let includes: TwitterIncludesV2? +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUserRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUserRequestV2.swift index 8a1f6d37..c9b25a0f 100644 --- a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUserRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUserRequestV2.swift @@ -1,49 +1,30 @@ -// GetUserRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-id -open class GetUserRequestV2: TwitterAPIRequest { - public let id: String - public let expansions: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/\(id)" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves a single user's profile information by their Twitter ID. +/// The response includes the user's basic profile data and can be expanded to include +/// additional fields like pinned tweets, profile images, and more. +public struct GetUserRequestV2: TwitterAPIRequest { + public typealias Response = TwitterUserResponseV2 + + public let method: HTTPMethod = .get + public let path: String + public let parameters: [String: Any] + public init( id: String, - expansions: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none + expansions: Set? = nil, + tweetFields: Set? = nil, + userFields: Set? = nil ) { - self.id = id - self.expansions = expansions - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here + self.path = "/2/users/\(id)" + + var params: [String: Any] = [:] + expansions?.bind(param: ¶ms) + tweetFields?.bind(param: ¶ms) + userFields?.bind(param: ¶ms) + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByRequestV2.swift index fdfaf36c..5c37f68a 100644 --- a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByRequestV2.swift @@ -1,50 +1,31 @@ -// GetUsersByRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by -open class GetUsersByRequestV2: TwitterAPIRequest { - public let usernames: [String] - public let expansions: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/by" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["usernames"] = usernames.joined(separator: ",") - expansions?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves multiple users' profile information by their Twitter usernames. +/// The response includes each user's basic profile data and can be expanded to include +/// additional fields like pinned tweets, profile images, and more. +public struct GetUsersByRequestV2: TwitterAPIRequest { + public typealias Response = TwitterUsersResponseV2 + + public let method: HTTPMethod = .get + public let path: String = "/2/users/by" + public let parameters: [String: Any] + public init( usernames: [String], - expansions: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none + expansions: Set? = nil, + tweetFields: Set? = nil, + userFields: Set? = nil ) { - self.usernames = usernames - self.expansions = expansions - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here + var params: [String: Any] = [ + "usernames": usernames.joined(separator: ",") + ] + + expansions?.bind(param: ¶ms) + tweetFields?.bind(param: ¶ms) + userFields?.bind(param: ¶ms) + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByUsernameRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByUsernameRequestV2.swift index 6dcb8df9..fcc6f20f 100644 --- a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByUsernameRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersByUsernameRequestV2.swift @@ -1,49 +1,30 @@ -// GetUsersByUsernameRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by-username-username -open class GetUsersByUsernameRequestV2: TwitterAPIRequest { - public let username: String - public let expansions: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/by/username/\(username)" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - expansions?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves a single user's profile information by their Twitter username. +/// The response includes the user's basic profile data and can be expanded to include +/// additional fields like pinned tweets, profile images, and more. +public struct GetUsersByUsernameRequestV2: TwitterAPIRequest { + public typealias Response = TwitterUserResponseV2 + + public let method: HTTPMethod = .get + public let path: String + public let parameters: [String: Any] + public init( username: String, - expansions: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none + expansions: Set? = nil, + tweetFields: Set? = nil, + userFields: Set? = nil ) { - self.username = username - self.expansions = expansions - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here + self.path = "/2/users/by/username/\(username)" + + var params: [String: Any] = [:] + expansions?.bind(param: ¶ms) + tweetFields?.bind(param: ¶ms) + userFields?.bind(param: ¶ms) + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersMeRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersMeRequestV2.swift index 9d6457f8..f6060075 100644 --- a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersMeRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersMeRequestV2.swift @@ -1,46 +1,27 @@ -// GetUsersMeRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me -open class GetUsersMeRequestV2: TwitterAPIRequest { - public let expansions: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users/me" - } - - open var parameters: [String: Any] { - var params = [String: Any]() +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves the authenticated user's profile information. +/// The response includes the user's basic profile data and can be expanded to include +/// additional fields like pinned tweets, profile images, and more. +public struct GetUsersMeRequestV2: TwitterAPIRequest { + public typealias Response = TwitterUserResponseV2 + + public let method: HTTPMethod = .get + public let path: String = "/2/users/me" + public let parameters: [String: Any] + + public init( + expansions: Set? = nil, + tweetFields: Set? = nil, + userFields: Set? = nil + ) { + var params: [String: Any] = [:] expansions?.bind(param: ¶ms) tweetFields?.bind(param: ¶ms) userFields?.bind(param: ¶ms) - return params - } - - public init( - expansions: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none - ) { - self.expansions = expansions - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersRequestV2.swift b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersRequestV2.swift index 2747f426..b7573d54 100644 --- a/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersRequestV2.swift +++ b/Sources/TwitterAPIKit/APIv2/Users/Requests/GetUsersRequestV2.swift @@ -1,50 +1,31 @@ -// GetUsersRequestV2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -/// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users -open class GetUsersRequestV2: TwitterAPIRequest { - public let ids: [String] - public let expansions: Set? - public let tweetFields: Set? - public let userFields: Set? - - public var method: HTTPMethod { - .get - } - - public var path: String { - "/2/users" - } - - open var parameters: [String: Any] { - var params = [String: Any]() - params["ids"] = ids.joined(separator: ",") - expansions?.bind(param: ¶ms) - tweetFields?.bind(param: ¶ms) - userFields?.bind(param: ¶ms) - return params - } - +/// [DOCUMENTATION_LINK_PLACEHOLDER] +/// +/// This request retrieves multiple users' profile information by their Twitter IDs. +/// The response includes each user's basic profile data and can be expanded to include +/// additional fields like pinned tweets, profile images, and more. +public struct GetUsersRequestV2: TwitterAPIRequest { + public typealias Response = TwitterUsersResponseV2 + + public let method: HTTPMethod = .get + public let path: String = "/2/users" + public let parameters: [String: Any] + public init( ids: [String], - expansions: Set? = .none, - tweetFields: Set? = .none, - userFields: Set? = .none + expansions: Set? = nil, + tweetFields: Set? = nil, + userFields: Set? = nil ) { - self.ids = ids - self.expansions = expansions - self.tweetFields = tweetFields - self.userFields = userFields - } - - deinit { - // de-init logic here + var params: [String: Any] = [ + "ids": ids.joined(separator: ",") + ] + + expansions?.bind(param: ¶ms) + tweetFields?.bind(param: ¶ms) + userFields?.bind(param: ¶ms) + + self.parameters = params } -} +} diff --git a/Sources/TwitterAPIKit/APIv2/Users/UserAPIv2.swift b/Sources/TwitterAPIKit/APIv2/Users/UserAPIv2.swift deleted file mode 100644 index 923b29a3..00000000 --- a/Sources/TwitterAPIKit/APIv2/Users/UserAPIv2.swift +++ /dev/null @@ -1,50 +0,0 @@ -// UserAPIv2.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -open class UserAPIv2: TwitterAPIBase { - /// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-id - public func getUser( - _ request: GetUserRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users - public func getUsers( - _ request: GetUsersRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by-username-username - public func getUserByUsername( - _ request: GetUsersByUsernameRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by - public func getUsersByUsernames( - _ request: GetUsersByRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - /// https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me - public func getMe( - _ request: GetUsersMeRequestV2 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/AuthAPI/Models/TwitterOAuthScope.swift b/Sources/TwitterAPIKit/AuthAPI/Models/TwitterOAuthScope.swift new file mode 100644 index 00000000..43f08c3a --- /dev/null +++ b/Sources/TwitterAPIKit/AuthAPI/Models/TwitterOAuthScope.swift @@ -0,0 +1,20 @@ +public enum TwitterOAuthScope: String { + case blockRead = "block.read" + case blockWrite = "block.write" + case bookmarkRead = "bookmark.read" + case bookmarkWrite = "bookmark.write" + case followRead = "follow.read" + case followWrite = "follow.write" + case likeRead = "like.read" + case likeWrite = "like.write" + case listRead = "list.read" + case listWrite = "list.write" + case muteRead = "mute.read" + case muteWrite = "mute.write" + case offlineAccess = "offline.access" + case spaceRead = "space.read" + case tweetModerateWrite = "tweet.moderate.write" + case tweetRead = "tweet.read" + case tweetWrite = "tweet.write" + case usersRead = "users.read" +} diff --git a/Sources/TwitterAPIKit/AuthAPI/OAuth10aAPI.swift b/Sources/TwitterAPIKit/AuthAPI/OAuth10aAPI.swift index 3b4fbd4e..722505fa 100644 --- a/Sources/TwitterAPIKit/AuthAPI/OAuth10aAPI.swift +++ b/Sources/TwitterAPIKit/AuthAPI/OAuth10aAPI.swift @@ -8,27 +8,28 @@ import Foundation -open class OAuth10aAPI: TwitterAPIBase { +/// Oauth10aAPI +public struct OAuth10aAPI { + /// Twitter API Session + public let session: TwitterAPISession + + /// Initializes the Session + public init(session: TwitterAPISession) { + self.session = session + } + /// https://developer.twitter.com/en/docs/authentication/api-reference/request_token public func postOAuthRequestTokenData( _ request: PostOAuthRequestTokenRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) + ) async throws -> TwitterOAuthTokenV1 { + return try await session.send(request) } /// https://developer.twitter.com/en/docs/authentication/api-reference/request_token public func postOAuthRequestToken( _ request: PostOAuthRequestTokenRequestV1 - ) -> TwitterAPISessionSpecializedTask { - session.send(request) - .specialized { data in - guard let token = TwitterOAuthTokenV1(queryStringData: data) else { - throw TwitterAPIKitError.responseSerializeFailed( - reason: .cannotConvert(data: data, toTypeName: "TwitterOAuthTokenV1") - ) - } - return token - } + ) async throws -> TwitterOAuthTokenV1 { + return try await session.send(request) } /// Create https://developer.twitter.com/en/docs/authentication/api-reference/authorize URL. @@ -46,33 +47,21 @@ open class OAuth10aAPI: TwitterAPIBase { /// https://developer.twitter.com/en/docs/authentication/api-reference/access_token public func postOAuthAccessTokenData( _ request: PostOAuthAccessTokenRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) + ) async throws -> TwitterOAuthAccessTokenV1 { + return try await session.send(request) } /// https://developer.twitter.com/en/docs/authentication/api-reference/access_token public func postOAuthAccessToken( _ request: PostOAuthAccessTokenRequestV1 - ) -> TwitterAPISessionSpecializedTask { - session.send(request) - .specialized { data in - guard let token = TwitterOAuthAccessTokenV1(queryStringData: data) else { - throw TwitterAPIKitError.responseSerializeFailed( - reason: .cannotConvert(data: data, toTypeName: "TwitterOAuthAccessTokenV1") - ) - } - return token - } + ) async throws -> TwitterOAuthAccessTokenV1 { + return try await session.send(request) } /// https://developer.twitter.com/en/docs/authentication/api-reference/invalidate_access_token public func postInvalidateAccessToken( _ request: PostOAuthInvalidateTokenRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) - } - - deinit { - // De-init Logic Here + ) async throws -> TwitterAPIError { + return try await session.send(request) } } diff --git a/Sources/TwitterAPIKit/AuthAPI/OAuth20API.swift b/Sources/TwitterAPIKit/AuthAPI/OAuth20API.swift index 4d6c88ce..484bcf5a 100644 --- a/Sources/TwitterAPIKit/AuthAPI/OAuth20API.swift +++ b/Sources/TwitterAPIKit/AuthAPI/OAuth20API.swift @@ -8,35 +8,32 @@ import Foundation -open class OAuth20API: TwitterAPIBase { +/// Oauth2.0 API +public struct OAuth20API { + /// Twitter API Session + public let session: TwitterAPISession + + /// Initialize a new Oauth2.0 API session + public init( + session: TwitterAPISession + ) { + self.session = session + } + // MARK: - OAuth 2.0 Bearer Token /// https://developer.twitter.com/en/docs/authentication/api-reference/token public func postOAuth2BearerTokenData( _ request: PostOAuth2TokenRequestV1 - ) -> TwitterAPISessionDataTask { - session.send(request) + ) async throws -> TwitterOAuth2BearerToken { + return try await session.send(request) } /// https://developer.twitter.com/en/docs/authentication/api-reference/token public func postOAuth2BearerToken( _ request: PostOAuth2TokenRequestV1 - ) -> TwitterAPISessionSpecializedTask { - session.send(request) - .specialized { data in - do { - guard let token = try TwitterOAuth2BearerToken(jsonData: data) else { - throw TwitterAPIKitError.responseSerializeFailed( - reason: .cannotConvert(data: data, toTypeName: "TwitterOAuth2BearerToken") - ) - } - return token - } catch { - throw TwitterAPIKitError.responseSerializeFailed( - reason: .jsonSerializationFailed(error: error) - ) - } - } + ) async throws -> TwitterOAuth2BearerToken { + return try await session.send(request) } /// https://developer.twitter.com/en/docs/authentication/api-reference/invalidate_bearer_token @@ -47,8 +44,8 @@ open class OAuth20API: TwitterAPIBase { /// https://twittercommunity.com/t/invalidate-bearer-client-application-not-permitted/162761 public func postInvalidateOAuth2BearerToken( _ request: PostOAuth2InvalidateTokenRequestV1 - ) -> TwitterAPISessionJSONTask { - session.send(request) + ) async throws -> TwitterAPIError { + return try await session.send(request) } // MARK: - OAuth 2.0 Authorization Code Flow with PKCE @@ -58,39 +55,53 @@ open class OAuth20API: TwitterAPIBase { try? request.buildRequest(environment: session.environment).url } + /// Requests an OAuth 2.0 access token using the provided request data. + /// - Parameter request: The request object containing the necessary parameters for obtaining an access token. + /// - Returns: A `TwitterOAuth2AccessToken` containing the access token and related information. + /// - Throws: An error if the request fails. public func postOAuth2AccessTokenData( _ request: PostOAuth2AccessTokenRequestV2 - ) -> TwitterAPISessionDataTask { - session.send(request) + ) async throws -> TwitterOAuth2AccessToken { + return try await session.send(request) } + /// Requests an OAuth 2.0 access token using the provided request data. + /// - Parameter request: The request object containing the necessary parameters for obtaining an access token. + /// - Returns: A `TwitterOAuth2AccessToken` containing the access token and related information. + /// - Throws: An error if the request fails. public func postOAuth2AccessToken( _ request: PostOAuth2AccessTokenRequestV2 - ) -> TwitterAPISessionSpecializedTask { - postOAuth2AccessTokenData(request) - .specialized { try TwitterOAuth2AccessToken.fromResponse(data: $0) } + ) async throws -> TwitterOAuth2AccessToken { + return try await session.send(request) } + /// Requests a new OAuth 2.0 access token using a refresh token. + /// - Parameter request: The request object containing the refresh token and other required parameters. + /// - Returns: A `TwitterOAuth2AccessToken` containing the new access token and related information. + /// - Throws: An error if the request fails. public func postOAuth2RefreshTokenData( _ request: PostOAuth2RefreshTokenRequestV2 - ) -> TwitterAPISessionDataTask { - session.send(request) + ) async throws -> TwitterOAuth2AccessToken { + return try await session.send(request) } + /// Requests a new OAuth 2.0 access token using a refresh token. + /// - Parameter request: The request object containing the refresh token and other required parameters. + /// - Returns: A `TwitterOAuth2AccessToken` containing the new access token and related information. + /// - Throws: An error if the request fails. public func postOAuth2RefreshToken( _ request: PostOAuth2RefreshTokenRequestV2 - ) -> TwitterAPISessionSpecializedTask { - postOAuth2RefreshTokenData(request) - .specialized { try TwitterOAuth2AccessToken.fromResponse(data: $0) } + ) async throws -> TwitterOAuth2AccessToken { + return try await session.send(request) } + /// Revokes an OAuth 2.0 token using the provided request data. + /// - Parameter request: The request object containing the token to be revoked. + /// - Returns: A `TwitterAPIError` indicating the result of the revocation. + /// - Throws: An error if the request fails. public func postOAuth2RevokeToken( _ request: PostOAuth2RevokeTokenRequestV2 - ) -> TwitterAPISessionDataTask { - session.send(request) - } - - deinit { - // De-init Logic Here + ) async throws -> TwitterAPIError { + return try await session.send(request) } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuth2AuthorizeRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuth2AuthorizeRequestV1.swift index 93807745..3ddafe43 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuth2AuthorizeRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuth2AuthorizeRequestV1.swift @@ -10,14 +10,16 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code /// https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token -open class GetOAuth2AuthorizeRequestV1: TwitterAPIRequest { +public struct GetOAuth2AuthorizeRequestV1: TwitterAPIRequest { + public typealias Response = TwitterAPIError + public let responseType: String public let clientID: String public let redirectURI: String public let state: String public let codeChallenge: String public let codeChallengeMethod: String - public let scopes: [String] + public let scopes: [TwitterOAuthScope] public var method: HTTPMethod { .get @@ -32,17 +34,30 @@ open class GetOAuth2AuthorizeRequestV1: TwitterAPIRequest { } public var parameters: [String: Any] { - var params = [String: String]() + var params = [String: Any]() + // Match the exact format of the working URL params["response_type"] = responseType params["client_id"] = clientID params["redirect_uri"] = redirectURI + params["scope"] = scopes.map(\.rawValue).joined(separator: "+") params["state"] = state params["code_challenge"] = codeChallenge params["code_challenge_method"] = codeChallengeMethod - params["scope"] = scopes.joined(separator: " ") return params } + + public var queryParameters: [String: Any] { + parameters + } + + public var bodyParameters: [String: Any] { + [:] + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( responseType: String = "code", @@ -50,8 +65,8 @@ open class GetOAuth2AuthorizeRequestV1: TwitterAPIRequest { redirectURI: String, state: String, codeChallenge: String, - codeChallengeMethod: String, - scopes: [String] + codeChallengeMethod: String = "plain", + scopes: [TwitterOAuthScope] ) { self.responseType = responseType self.clientID = clientID @@ -61,8 +76,4 @@ open class GetOAuth2AuthorizeRequestV1: TwitterAPIRequest { self.codeChallengeMethod = codeChallengeMethod self.scopes = scopes } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthenticateRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthenticateRequestV1.swift index 8633ea46..a5f82176 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthenticateRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthenticateRequestV1.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/authenticate -open class GetOAuthAuthenticateRequestV1: TwitterAPIRequest { +public struct GetOAuthAuthenticateRequestV1: TwitterAPIRequest { + public typealias Response = TwitterAPIError + public let oauthToken: String public let forceLogin: Bool? public let screenName: String? @@ -22,25 +24,33 @@ open class GetOAuthAuthenticateRequestV1: TwitterAPIRequest { "/oauth/authenticate" } - open var parameters: [String: Any] { + public var parameters: [String: Any] { var params = [String: Any]() params["oauth_token"] = oauthToken forceLogin.map { params["force_login"] = $0 } screenName.map { params["screen_name"] = $0 } return params } + + public var queryParameters: [String: Any] { + parameters + } + + public var bodyParameters: [String: Any] { + [:] + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( oauthToken: String, - forceLogin: Bool? = .none, - screenName: String? = .none + forceLogin: Bool? = nil, + screenName: String? = nil ) { self.oauthToken = oauthToken self.forceLogin = forceLogin self.screenName = screenName } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthorizeRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthorizeRequestV1.swift index 788f6152..6337c108 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthorizeRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/GetOAuthAuthorizeRequestV1.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/authorize -open class GetOAuthAuthorizeRequestV1: TwitterAPIRequest { +public struct GetOAuthAuthorizeRequestV1: TwitterAPIRequest { + public typealias Response = TwitterAPIError + public let oauthToken: String public let forceLogin: Bool? public let screenName: String? @@ -22,25 +24,33 @@ open class GetOAuthAuthorizeRequestV1: TwitterAPIRequest { "/oauth/authorize" } - open var parameters: [String: Any] { + public var parameters: [String: Any] { var params = [String: Any]() params["oauth_token"] = oauthToken forceLogin.map { params["force_login"] = $0 } screenName.map { params["screen_name"] = $0 } return params } + + public var queryParameters: [String: Any] { + parameters + } + + public var bodyParameters: [String: Any] { + [:] + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( oauthToken: String, - forceLogin: Bool? = .none, - screenName: String? = .none + forceLogin: Bool? = nil, + screenName: String? = nil ) { self.oauthToken = oauthToken self.forceLogin = forceLogin self.screenName = screenName } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2AccessTokenRequestV2.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2AccessTokenRequestV2.swift index ffebfeef..3a9e20b5 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2AccessTokenRequestV2.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2AccessTokenRequestV2.swift @@ -8,7 +8,9 @@ import Foundation -open class PostOAuth2AccessTokenRequestV2: TwitterAPIRequest { +public struct PostOAuth2AccessTokenRequestV2: TwitterAPIRequest { + public typealias Response = TwitterOAuth2AccessToken + public let code: String public let grantType: String /// Required for Public Client. @@ -25,7 +27,7 @@ open class PostOAuth2AccessTokenRequestV2: TwitterAPIRequest { } public var parameters: [String: Any] { - var params = [String: String]() + var params = [String: Any]() params["code"] = code params["grant_type"] = grantType clientID.map { params["client_id"] = $0 } @@ -33,11 +35,23 @@ open class PostOAuth2AccessTokenRequestV2: TwitterAPIRequest { params["code_verifier"] = codeVerifier return params } + + public var queryParameters: [String: Any] { + [:] + } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( code: String, grantType: String = "authorization_code", - clientID: String? = .none, + clientID: String? = nil, redirectURI: String, codeVerifier: String ) { @@ -47,8 +61,4 @@ open class PostOAuth2AccessTokenRequestV2: TwitterAPIRequest { self.redirectURI = redirectURI self.codeVerifier = codeVerifier } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2InvalidateTokenRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2InvalidateTokenRequestV1.swift index 8a13e8e5..6dfd3ae2 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2InvalidateTokenRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2InvalidateTokenRequestV1.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/invalidate_bearer_token -open class PostOAuth2InvalidateTokenRequestV1: TwitterAPIRequest { +public struct PostOAuth2InvalidateTokenRequestV1: TwitterAPIRequest { + public typealias Response = TwitterAPIError + public let accessToken: String public var method: HTTPMethod { @@ -20,19 +22,27 @@ open class PostOAuth2InvalidateTokenRequestV1: TwitterAPIRequest { "/oauth2/invalidate_token" } - open var parameters: [String: Any] { + public var parameters: [String: Any] { var params = [String: Any]() params["access_token"] = accessToken return params } + + public var queryParameters: [String: Any] { + [:] + } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( accessToken: String ) { self.accessToken = accessToken } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RefreshTokenRequestV2.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RefreshTokenRequestV2.swift index 0c333965..baec2802 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RefreshTokenRequestV2.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RefreshTokenRequestV2.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token -open class PostOAuth2RefreshTokenRequestV2: TwitterAPIRequest { +public struct PostOAuth2RefreshTokenRequestV2: TwitterAPIRequest { + public typealias Response = TwitterOAuth2AccessToken + public let refreshToken: String public let grantType: String /// Required for Public Client. @@ -24,26 +26,32 @@ open class PostOAuth2RefreshTokenRequestV2: TwitterAPIRequest { } public var parameters: [String: Any] { - var params = [String: String]() - + var params = [String: Any]() params["refresh_token"] = refreshToken params["grant_type"] = grantType clientID.map { params["client_id"] = $0 } - return params } + + public var queryParameters: [String: Any] { + [:] + } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( refreshToken: String, grantType: String = "refresh_token", - clientID: String? = .none + clientID: String? = nil ) { self.refreshToken = refreshToken self.grantType = grantType self.clientID = clientID } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RevokeTokenRequestV2.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RevokeTokenRequestV2.swift index 90e23d26..dfc2a7e8 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RevokeTokenRequestV2.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2RevokeTokenRequestV2.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token -open class PostOAuth2RevokeTokenRequestV2: TwitterAPIRequest { +public struct PostOAuth2RevokeTokenRequestV2: TwitterAPIRequest { + public typealias Response = TwitterAPIError + public let token: String /// Required for Public Client. public let clientID: String? @@ -27,26 +29,33 @@ open class PostOAuth2RevokeTokenRequestV2: TwitterAPIRequest { "/2/oauth2/revoke" } - open var parameters: [String: Any] { - var params = [String: String]() + public var parameters: [String: Any] { + var params = [String: Any]() params["token"] = token tokenTypeHint.map { params["token_type_hint"] = $0 } clientID.map { params["client_id"] = $0 } - return params } + + public var queryParameters: [String: Any] { + [:] + } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( token: String, - clientID: String? = .none, - tokenTypeHint: String? = .none + clientID: String? = nil, + tokenTypeHint: String? = nil ) { self.token = token self.clientID = clientID self.tokenTypeHint = tokenTypeHint } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2TokenRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2TokenRequestV1.swift index 41f260a6..24eb777e 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2TokenRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuth2TokenRequestV1.swift @@ -9,30 +9,28 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/token -open class PostOAuth2TokenRequestV1: TwitterAPIRequest { +public struct PostOAuth2TokenRequestV1: TwitterAPIRequest { + public typealias Response = TwitterOAuth2BearerToken + public let grantType: String - + public var method: HTTPMethod { .post } - + public var path: String { "/oauth2/token" } - - open var parameters: [String: Any] { - var params = [String: Any]() + + public var parameterForOAuth: [String: String] { + var params = [String: String]() params["grant_type"] = grantType return params } - + public init( grantType: String = "client_credentials" ) { self.grantType = grantType } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthAccessTokenRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthAccessTokenRequestV1.swift index c169dec2..53e236c9 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthAccessTokenRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthAccessTokenRequestV1.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/access_token -open class PostOAuthAccessTokenRequestV1: TwitterAPIRequest { +public struct PostOAuthAccessTokenRequestV1: TwitterAPIRequest { + public typealias Response = TwitterOAuthAccessTokenV1 + public let oauthToken: String public let oauthVerifier: String @@ -21,12 +23,24 @@ open class PostOAuthAccessTokenRequestV1: TwitterAPIRequest { "/oauth/access_token" } - open var parameters: [String: Any] { + public var parameters: [String: Any] { var params = [String: Any]() params["oauth_token"] = oauthToken params["oauth_verifier"] = oauthVerifier return params } + + public var queryParameters: [String: Any] { + [:] + } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( oauthToken: String, @@ -35,8 +49,4 @@ open class PostOAuthAccessTokenRequestV1: TwitterAPIRequest { self.oauthToken = oauthToken self.oauthVerifier = oauthVerifier } - - deinit { - // De-init logic here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthInvalidateTokenRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthInvalidateTokenRequestV1.swift index d1ca3bcb..1b89e414 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthInvalidateTokenRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthInvalidateTokenRequestV1.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/invalidate_access_token -open class PostOAuthInvalidateTokenRequestV1: TwitterAPIRequest { +public struct PostOAuthInvalidateTokenRequestV1: TwitterAPIRequest { + public typealias Response = TwitterAPIError + public var method: HTTPMethod { .post } @@ -18,13 +20,21 @@ open class PostOAuthInvalidateTokenRequestV1: TwitterAPIRequest { "/1.1/oauth/invalidate_token" } - open var parameters: [String: Any] { + public var parameters: [String: Any] { [:] } + + public var queryParameters: [String: Any] { + [:] + } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init() {} - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthRequestTokenRequestV1.swift b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthRequestTokenRequestV1.swift index f39d12f9..8dad8d52 100644 --- a/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthRequestTokenRequestV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/Requests/PostOAuthRequestTokenRequestV1.swift @@ -9,7 +9,9 @@ import Foundation /// https://developer.twitter.com/en/docs/authentication/api-reference/request_token -open class PostOAuthRequestTokenRequestV1: TwitterAPIRequest { +public struct PostOAuthRequestTokenRequestV1: TwitterAPIRequest { + public typealias Response = TwitterOAuthTokenV1 + /// If you are using pin-based authorization, you will need to set this to oob public let oauthCallback: String @@ -24,22 +26,26 @@ open class PostOAuthRequestTokenRequestV1: TwitterAPIRequest { "/oauth/request_token" } - open var parameters: [String: Any] { - var params = [String: Any]() + public var parameters: [String: String] { + var params = [String: String]() params["oauth_callback"] = oauthCallback xAuthAccessType.map { params["x_auth_access_type"] = $0 } return params } + + public var bodyParameters: [String: Any] { + parameters + } + + public var bodyContentType: BodyContentType { + .wwwFormUrlEncoded + } public init( - oauthCallback: String, - xAuthAccessType: String? = .none + oauthCallback: String = "oob", + xAuthAccessType: String? = "write" ) { self.oauthCallback = oauthCallback self.xAuthAccessType = xAuthAccessType } - - deinit { - // De-init Logic Here - } } diff --git a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2AccessToken.swift b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2AccessToken.swift index dfda9a5f..4ff28128 100644 --- a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2AccessToken.swift +++ b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2AccessToken.swift @@ -29,7 +29,7 @@ import Foundation /// Represents an OAuth 2.0 access token response from Twitter's API. /// Contains the access token and associated metadata for both confidential and public clients. -public struct TwitterOAuth2AccessToken { +public struct TwitterOAuth2AccessToken: Decodable, Sendable { /// The scopes granted to this access token, as an array of permission strings. public let scope: [String] @@ -67,24 +67,3 @@ public struct TwitterOAuth2AccessToken { refreshToken = obj["refresh_token"] as? String } } - -public extension TwitterOAuth2AccessToken { - /// Creates an OAuth 2.0 access token from a Twitter API response. - /// - Parameter data: The raw response data from Twitter's OAuth 2.0 token endpoint. - /// - Throws: A `TwitterAPIKitError` if parsing fails. - /// - Returns: An initialized access token. - static func fromResponse(data: Data) throws -> Self { - do { - guard let token = try TwitterOAuth2AccessToken(jsonData: data) else { - throw TwitterAPIKitError.responseSerializeFailed( - reason: .cannotConvert(data: data, toTypeName: "TwitterOAuth2AccessToken") - ) - } - return token - } catch { - throw TwitterAPIKitError.responseSerializeFailed( - reason: .jsonSerializationFailed(error: error) - ) - } - } -} diff --git a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2BearerToken.swift b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2BearerToken.swift index 7930e8c2..f9806545 100644 --- a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2BearerToken.swift +++ b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuth2BearerToken.swift @@ -10,7 +10,7 @@ import Foundation /// Represents an OAuth 2.0 bearer token response from Twitter's API. /// This token type is used for application-only authentication. -public struct TwitterOAuth2BearerToken { +public struct TwitterOAuth2BearerToken: Decodable { /// The type of token, typically "bearer". public let tokenType: String diff --git a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthAccessTokenV1.swift b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthAccessTokenV1.swift index 2585aeb2..faadcbf3 100644 --- a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthAccessTokenV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthAccessTokenV1.swift @@ -9,7 +9,7 @@ import Foundation /// Represents an OAuth 1.0a access token for Twitter API v1 authentication. -public struct TwitterOAuthAccessTokenV1 { +public struct TwitterOAuthAccessTokenV1: Decodable, Sendable { /// The OAuth token string used for authentication. public let oauthToken: String diff --git a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthTokenV1.swift b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthTokenV1.swift index 3fa531e0..5a39fd0b 100644 --- a/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthTokenV1.swift +++ b/Sources/TwitterAPIKit/AuthAPI/TwitterOAuthTokenV1.swift @@ -10,7 +10,7 @@ import Foundation /// Represents an OAuth 1.0a request token response from Twitter's API. /// This token is used in the first step of the OAuth 1.0a authentication flow. -public struct TwitterOAuthTokenV1 { +public struct TwitterOAuthTokenV1: Decodable, Sendable { /// The OAuth token string used for authentication. public let oauthToken: String diff --git a/Sources/TwitterAPIKit/Extensions/Concurrency.swift b/Sources/TwitterAPIKit/Extensions/Concurrency.swift deleted file mode 100644 index 454f89e2..00000000 --- a/Sources/TwitterAPIKit/Extensions/Concurrency.swift +++ /dev/null @@ -1,156 +0,0 @@ -// Concurrency.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// A protocol that represents a concurrency. -public protocol Concurrency { - // No Logic Here -} - -#if compiler(>=5.5.2) && canImport(_Concurrency) - - // I'm not that familiar with Swift Concurrency, so please report any problems. - - /// Adds async/await support to TwitterAPISessionDataTask. - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public extension TwitterAPISessionDataTask { - /// Asynchronously retrieves the response data from the API request. - /// This property provides an async interface to the completion handler-based API. - /// - Returns: A TwitterAPIResponse containing the raw data response. - var responseData: TwitterAPIResponse { - get async { - await withTaskCancellationHandler( - operation: { - await withCheckedContinuation { continuation in - responseData { response in - continuation.resume(returning: response) - } - } - }, - onCancel: { - cancel() - } - ) - } - } - } - - /// Adds async/await support to TwitterAPISessionJSONTask. - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public extension TwitterAPISessionJSONTask { - /// Asynchronously retrieves the JSON response as a generic object. - /// This property provides an async interface to the completion handler-based API. - /// - Returns: A TwitterAPIResponse containing the parsed JSON object. - var responseObject: TwitterAPIResponse { - get async { - await withTaskCancellationHandler( - operation: { - await withCheckedContinuation { continuation in - responseObject { response in - continuation.resume(returning: response) - } - } - }, - onCancel: { - cancel() - } - ) - } - } - - /// Asynchronously decodes the JSON response into a specified Decodable type. - /// - Parameters: - /// - type: The Decodable type to decode the response into. - /// - decoder: The JSONDecoder to use for decoding. Defaults to TwitterAPIClient.defaultJSONDecoder. - /// - Returns: A TwitterAPIResponse containing the decoded object. - func responseDecodable( - type: T.Type, - decoder _: JSONDecoder = TwitterAPIClient.defaultJSONDecoder - ) async -> TwitterAPIResponse { - await withTaskCancellationHandler( - operation: { - await withCheckedContinuation { continuation in - responseDecodable(type: type) { response in - continuation.resume(returning: response) - } - } - }, - onCancel: { - cancel() - } - ) - } - } - - /// Adds async/await support to TwitterAPISessionSpecializedTask. - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public extension TwitterAPISessionSpecializedTask { - /// Asynchronously retrieves the specialized response object. - /// This property provides an async interface to the completion handler-based API. - /// - Returns: A TwitterAPIResponse containing the specialized success type. - var responseObject: TwitterAPIResponse { - get async { - await withTaskCancellationHandler( - operation: { - await withCheckedContinuation { continuation in - responseObject { response in - continuation.resume(returning: response) - } - } - }, onCancel: { - cancel() - } - ) - } - } - } - - /// Adds async/await support to TwitterAPISessionStreamTask. - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public extension TwitterAPISessionStreamTask { - /// Creates an AsyncStream for receiving streaming responses from the API. - /// - Parameter queue: The dispatch queue on which to receive responses. Defaults to the main queue. - /// - Returns: An AsyncStream that yields TwitterAPIResponse values. - func streamResponse(queue: DispatchQueue = .main) -> AsyncStream> { - AsyncStream { continuation in - streamResponse(queue: queue) { response in - continuation.yield(response) - if response.isError { - continuation.finish() - } - } - continuation.onTermination = { @Sendable _ in - cancel() - } - } - } - } - - /// Adds async/await support to TwitterAPIClient. - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public extension TwitterAPIClient { - /// Asynchronously refreshes the OAuth 2.0 token. - /// - Parameters: - /// - type: The type of OAuth 2.0 client to use for token refresh. - /// - forceRefresh: Whether to force a token refresh even if the current token is still valid. - /// - Returns: The result of the token refresh operation. - /// - Throws: A TwitterAPIKitError if the token refresh fails. - func refreshOAuth20Token( - type: TwitterAuthenticationMethod.OAuth20WithPKCEClientType, - forceRefresh: Bool = false - ) async throws -> RefreshOAuth20TokenResultValue { - try await withCheckedThrowingContinuation { continuation in - refreshOAuth20Token(type: type, forceRefresh: forceRefresh) { result in - continuation.resume(with: result) - } - } - } - } - -#endif diff --git a/Sources/TwitterAPIKit/Extensions/Data.swift b/Sources/TwitterAPIKit/Extensions/Data.swift deleted file mode 100644 index 249e3a8d..00000000 --- a/Sources/TwitterAPIKit/Extensions/Data.swift +++ /dev/null @@ -1,69 +0,0 @@ -// Data.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public extension Data { - /// Splits the data into chunks using the specified separator - /// - Parameters: - /// - separator: The data to use as a separator - /// - omittingEmptySubsequences: Whether to omit empty subsequences - /// - Returns: An array of data chunks - func split(separator: Data, omittingEmptySubsequences: Bool = true) -> [Data] { - var current = startIndex - var chunks = [Data]() - - while let range = self[current...].range(of: separator) { - if !omittingEmptySubsequences { - chunks.append(self[current ..< range.lowerBound]) - } else if range.lowerBound > current { - chunks.append(self[current ..< range.lowerBound]) - } - - current = range.upperBound - } - if current < endIndex { - chunks.append(self[current...]) - } - return chunks - } - - /// Attempts to serialize the data as JSON - /// - Returns: A Result containing either the serialized JSON object or an error - func serialize() -> Result { - do { - let jsonObj = try JSONSerialization.jsonObject(with: self, options: []) - return .success(jsonObj) - } catch { - return .failure( - .responseSerializeFailed( - reason: .jsonSerializationFailed(error: error) - ) - ) - } - } - - /// Attempts to decode the data into a specified Decodable type - /// - Parameters: - /// - type: The type to decode into - /// - decoder: The JSON decoder to use - /// - Returns: A Result containing either the decoded object or an error - func decode( - _ type: T.Type, - decoder: JSONDecoder - ) -> Result { - let result: Result = .init { - try decoder.decode(type, from: self) - } - return result.mapError { error in - .responseSerializeFailed( - reason: .jsonDecodeFailed(error: error) - ) - } - } -} diff --git a/Sources/TwitterAPIKit/Extensions/Date.swift b/Sources/TwitterAPIKit/Extensions/Date.swift deleted file mode 100644 index 9a9425a9..00000000 --- a/Sources/TwitterAPIKit/Extensions/Date.swift +++ /dev/null @@ -1,26 +0,0 @@ -// Date.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -private let formatter = ISO8601DateFormatter() -public extension Date { - /// Converts the date to an ISO8601 formatted string - /// - Returns: The date formatted as an ISO8601 string - func toISO8601String() -> String { - formatter.string(from: self) - } - - /// Binds the date as an ISO8601 string to the provided parameters dictionary - /// - Parameters: - /// - param: The parameters dictionary to bind to - /// - key: The key to use for the date value - func bind(param: inout [String: Any], for key: String) { - param[key] = toISO8601String() - } -} diff --git a/Sources/TwitterAPIKit/Extensions/Dictionary.swift b/Sources/TwitterAPIKit/Extensions/Dictionary.swift deleted file mode 100644 index 6cd7a911..00000000 --- a/Sources/TwitterAPIKit/Extensions/Dictionary.swift +++ /dev/null @@ -1,26 +0,0 @@ -// Dictionary.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public extension Dictionary { - /// Converts the dictionary into a URL-encoded query string - /// Format: key1=value1&key2=value2 - var urlEncodedQueryString: String { - var parts = [String]() - - for (key, value) in self { - let keyString = "\(key)".urlEncodedString - let valueString = "\(value)".urlEncodedString - let query = "\(keyString)=\(valueString)" - parts.append(query) - } - - return parts.joined(separator: "&") - } -} diff --git a/Sources/TwitterAPIKit/Extensions/HMAC.swift b/Sources/TwitterAPIKit/Extensions/HMAC.swift deleted file mode 100644 index 81eb905d..00000000 --- a/Sources/TwitterAPIKit/Extensions/HMAC.swift +++ /dev/null @@ -1,64 +0,0 @@ -// HMAC.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. - -import Foundation - -#if canImport(CommonCrypto) - import CommonCrypto - - internal protocol HMAC { - // Stub Logic for `swiftlint file_name` - } - - fileprivate extension Data { - func hmac(key: Data) -> Data { - // Thanks: https://github.com/jernejstrasner/SwiftCrypto - - let digestLen = Int(CC_SHA1_DIGEST_LENGTH) - return withUnsafeBytes { bytes -> Data in - let result = UnsafeMutablePointer.allocate(capacity: digestLen) - defer { - result.deallocate() - } - - key.withUnsafeBytes { body in - CCHmac( - CCHmacAlgorithm(kCCHmacAlgSHA1), - body.baseAddress, - key.count, - bytes.baseAddress, - count, - result - ) - } - - return Data(bytes: result, count: digestLen) - } - } - } - - /// Creates an HMAC-SHA1 signature for the given message using the provided key - /// - Parameters: - /// - key: The key to use for signing - /// - message: The message to sign - /// - Returns: The HMAC-SHA1 signature as Data - public func createHMACSHA1(key: Data, message: Data) -> Data { - message.hmac(key: key) - } - -#elseif canImport(Crypto) // for Linux - import Crypto - - /// Creates an HMAC-SHA1 signature for the given message using the provided key - /// - Parameters: - /// - key: The key to use for signing - /// - message: The message to sign - /// - Returns: The HMAC-SHA1 signature as Data - public func createHMACSHA1(key: Data, message: Data) -> Data { - Data(HMAC.authenticationCode(for: message, using: SymmetricKey(data: key))) - } -#else - #error("Crypto is not available in this environment.") -#endif diff --git a/Sources/TwitterAPIKit/Extensions/Result.swift b/Sources/TwitterAPIKit/Extensions/Result.swift deleted file mode 100644 index 1a1bfab2..00000000 --- a/Sources/TwitterAPIKit/Extensions/Result.swift +++ /dev/null @@ -1,23 +0,0 @@ -// Result.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public extension Result where Failure == TwitterAPIKitError { - /// Returns the success value if the result is a success, nil otherwise - var success: Success? { - guard case let .success(value) = self else { return nil } - return value - } - - /// Returns the error if the result is a failure, nil otherwise - var error: Failure? { - guard case let .failure(error) = self else { return nil } - return error - } -} diff --git a/Sources/TwitterAPIKit/Extensions/String.swift b/Sources/TwitterAPIKit/Extensions/String.swift index 130b46fe..63032282 100644 --- a/Sources/TwitterAPIKit/Extensions/String.swift +++ b/Sources/TwitterAPIKit/Extensions/String.swift @@ -1,18 +1,12 @@ -// String.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - import Foundation -public extension String { - /// Returns a URL-safe encoded version of the string - var urlEncodedString: String { - let allowedCharacterSet = NSMutableCharacterSet.alphanumeric() - allowedCharacterSet.addCharacters(in: "-._~") - return addingPercentEncoding(withAllowedCharacters: allowedCharacterSet as CharacterSet) ?? "" +extension String { + internal var urlEncoded: String { + self.addingPercentEncoding( + withAllowedCharacters: CharacterSet( + charactersIn: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~" + ) + // swiftlint:disable:next force_unwrapping + )! } } diff --git a/Sources/TwitterAPIKit/OAuthHelper.swift b/Sources/TwitterAPIKit/OAuthHelper.swift index 43ba73f2..eaaf86f1 100644 --- a/Sources/TwitterAPIKit/OAuthHelper.swift +++ b/Sources/TwitterAPIKit/OAuthHelper.swift @@ -6,25 +6,58 @@ // This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. // This Package is distributable through a modified version of the MIT License. +import Crypto import Foundation +/// Creates an HMAC-SHA1 signature for the given message using the provided key +/// - Parameters: +/// - key: The key to use for signing +/// - message: The message to sign +/// - Returns: The HMAC-SHA1 signature as Data +public func createHMACSHA1(key: Data, message: Data) -> Data { + Data(HMAC.authenticationCode(for: message, using: SymmetricKey(data: key))) +} + private let oauthVersion = "1.0" private let oauthSignatureMethod = "HMAC-SHA1" -// swiftlint:disable function_parameter_count function_body_length -/// Generates an OAuth authorization header for a given HTTP method, URL, and parameters. -/// - Parameters: -/// - method: The HTTP method to use. -/// - url: The URL to use. -/// - parameters: The parameters to use. -/// - consumerKey: The consumer key to use. -/// - consumerSecret: The consumer secret to use. -/// - oauthToken: The OAuth token to use. -/// - oauthTokenSecret: The OAuth token secret to use. -/// - oauthTimestamp: The OAuth timestamp to use. -/// - oauthNonce: The OAuth nonce to use. -/// - Returns: The OAuth authorization header. -public func authorizationHeader( +private func generateOAuthSignature( + method: String, + url: String, + params: [String: String], + consumerSecret: String, + tokenSecret: String? +) -> String { + let sortedParams = params.sorted { $0.key < $1.key } + + let paramString = sortedParams + .map { key, value in + let encodedKey = key.urlEncoded + let encodedValue = value.urlEncoded + return "\(encodedKey)=\(encodedValue)" + } + .joined(separator: "&") + + let encodedURL = url.urlEncoded + let encodedParamString = paramString.urlEncoded + let signatureBase = "\(method)&\(encodedURL)&\(encodedParamString)" + + let encodedConsumerSecret = consumerSecret.urlEncoded + let encodedTokenSecret = (tokenSecret ?? "").urlEncoded + let signingKey = "\(encodedConsumerSecret)&\(encodedTokenSecret)" + + // swiftlint:disable force_unwrapping + let key = signingKey.data(using: .utf8)! + let msg = signatureBase.data(using: .utf8)! + // swiftlint:enable force_unwrapping + + let hmac = HMAC + .authenticationCode(for: msg, using: SymmetricKey(data: key)) + return Data(hmac).base64EncodedString() +} + +// swiftlint:disable:next function_parameter_count +internal func authorizationHeader( for method: HTTPMethod, url: URL, parameters: [String: Any], @@ -32,66 +65,48 @@ public func authorizationHeader( consumerSecret: String, oauthToken: String?, oauthTokenSecret: String?, + oauthVersion: String = "1.0", + oauthSignatureMethod: String = "HMAC-SHA1", oauthTimestamp: String? = .none, oauthNonce: String? = .none ) -> String { - var authorizationParameters = [String: Any]() - authorizationParameters["oauth_version"] = oauthVersion - authorizationParameters["oauth_signature_method"] = oauthSignatureMethod - authorizationParameters["oauth_consumer_key"] = consumerKey - authorizationParameters["oauth_timestamp"] = oauthTimestamp ?? String(Int(Date().timeIntervalSince1970)) - authorizationParameters["oauth_nonce"] = oauthNonce ?? UUID().uuidString - if let oauthToken { - authorizationParameters["oauth_token"] = oauthToken + // OAuth parameters - EXACTLY like Python + var oauthParams: [String: String] = [ + "oauth_consumer_key": consumerKey, + "oauth_nonce": oauthNonce ?? UUID().uuidString, + "oauth_signature_method": oauthSignatureMethod, + "oauth_timestamp": oauthTimestamp ?? String(Int(Date().timeIntervalSince1970)), + "oauth_version": oauthVersion + ] + + // Only add oauth_token if it's not empty + if let token = oauthToken, !token.isEmpty { + oauthParams["oauth_token"] = token } - for (key, value) in parameters where key.hasPrefix("oauth_") { - authorizationParameters.updateValue(value, forKey: key) + + // Add query parameters to OAuth parameters for signature - EXACTLY like Python + for (key, value) in parameters { + oauthParams[key] = String(describing: value) } - let combinedParameters = authorizationParameters.merging(parameters) { $1 } - authorizationParameters["oauth_signature"] = oauthSignature( - for: method, - url: url, - parameters: combinedParameters, + // Generate signature + let signature = generateOAuthSignature( + method: method.rawValue, + url: url.absoluteString, + params: oauthParams, consumerSecret: consumerSecret, - oauthTokenSecret: oauthTokenSecret + tokenSecret: oauthTokenSecret ) - let authorizationParameterComponents = authorizationParameters - .urlEncodedQueryString - .components(separatedBy: "&") - .sorted() + oauthParams["oauth_signature"] = signature - var headerComponents = [String]() - for component in authorizationParameterComponents { - let subcomponent = component.components(separatedBy: "=") - if subcomponent.count == 2 { - headerComponents.append("\(subcomponent[0])=\"\(subcomponent[1])\"") - } + // Sort parameters alphabetically and create header - EXACTLY like Python + let sortedParams = oauthParams.sorted { $0.key < $1.key } + let headerComponents = sortedParams.map { key, value in + let encodedKey = key.urlEncoded + let encodedValue = value.urlEncoded + return "\(encodedKey)=\"\(encodedValue)\"" } return "OAuth " + headerComponents.joined(separator: ", ") } -// swiftlint:enable function_parameter_count function_body_length - -private func oauthSignature( - for method: HTTPMethod, - url: URL, - parameters: [String: Any], - consumerSecret: String, - oauthTokenSecret: String? -) -> String { - let tokenSecret = oauthTokenSecret?.urlEncodedString ?? "" - let encodedConsumerSecret = consumerSecret.urlEncodedString - let signingKey = "\(encodedConsumerSecret)&\(tokenSecret)" - let parameterComponents = parameters.urlEncodedQueryString.components(separatedBy: "&").sorted() - let parameterString = parameterComponents.joined(separator: "&") - let encodedParameterString = parameterString.urlEncodedString - let encodedURL = url.absoluteString.urlEncodedString - let signatureBaseString = "\(method.rawValue)&\(encodedURL)&\(encodedParameterString)" - - let key = signingKey.data(using: .utf8) ?? Data() - let msg = signatureBaseString.data(using: .utf8) ?? Data() - let sha1 = createHMACSHA1(key: key, message: msg) - return sha1.base64EncodedString(options: []) -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPIFailedTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPIFailedTask.swift deleted file mode 100644 index f6b6cc55..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPIFailedTask.swift +++ /dev/null @@ -1,162 +0,0 @@ -// TwitterAPIFailedTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public struct TwitterAPIFailedTask: TwitterAPISessionJSONTask, TwitterAPISessionStreamTask { - public let error: TwitterAPIKitError - - public init(_ error: TwitterAPIKitError) { - self.error = error - } - - public let taskIdentifier: Int = -1 - public let currentRequest: URLRequest? = nil - public let originalRequest: URLRequest? = nil - public let httpResponse: HTTPURLResponse? = nil - - public func responseData( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - queue.async { - block( - TwitterAPIResponse( - request: nil, - response: nil, - data: nil, - result: .failure(error), - rateLimit: nil - ) - ) - } - return self - } - - @discardableResult - public func responseData( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - responseData(queue: .main, block) - } - - @discardableResult - public func responseObject( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - queue.async { - block( - TwitterAPIResponse( - request: nil, - response: nil, - data: nil, - result: .failure(error), - rateLimit: nil - ) - ) - } - return self - } - - @discardableResult - public func responseObject( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - responseObject(queue: .main, block) - } - - @discardableResult - public func responseDecodable( - type _: T.Type, - decoder _: JSONDecoder, - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - queue.async { - block( - TwitterAPIResponse( - request: nil, - response: nil, - data: nil, - result: .failure(error), - rateLimit: nil - ) - ) - } - return self - } - - @discardableResult - public func responseDecodable( - type: T.Type, - decoder: JSONDecoder, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - responseDecodable( - type: type, - decoder: decoder, - queue: .main, - block - ) - } - - @discardableResult - public func responseDecodable( - type: T.Type, - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - responseDecodable( - type: type, - decoder: TwitterAPIClient.defaultJSONDecoder, - queue: queue, - block - ) - } - - @discardableResult - public func responseDecodable( - type: T.Type, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - responseDecodable( - type: type, - decoder: TwitterAPIClient.defaultJSONDecoder, - queue: .main, - block - ) - } - - @discardableResult - public func streamResponse( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - queue.async { - let response = TwitterAPIResponse( - request: nil, - response: nil, - data: nil, - result: .failure(error), - rateLimit: nil - ) - block(response) - } - return self - } - - @discardableResult - public func streamResponse( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - streamResponse(queue: .main, block) - } - - public func cancel() {} -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDataTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDataTask.swift deleted file mode 100644 index f31959b7..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDataTask.swift +++ /dev/null @@ -1,38 +0,0 @@ -// TwitterAPISessionDataTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public protocol TwitterAPISessionDataTask: TwitterAPISessionTask { - @discardableResult - func responseData( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func responseData( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self -} - -// MARK: - internal - -public extension TwitterAPISessionDataTask { - /// Specializes the task to return a new type. - /// - Parameters: - /// - transform: The transform to apply to the data. - /// - Returns: A new specialized task. - func specialized( - _ transform: @escaping (Data) throws -> NewSuccess - ) - -> TwitterAPISessionSpecializedTask - { - TwitterAPISessionSpecializedTask(task: self, transform: transform) - } -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDelegatedJSONTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDelegatedJSONTask.swift deleted file mode 100644 index e01adef6..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDelegatedJSONTask.swift +++ /dev/null @@ -1,220 +0,0 @@ -// TwitterAPISessionDelegatedJSONTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -internal protocol TwitterAPISessionDelegatedJSONTaskDelegate: AnyObject { - func didFinishQueueInJsonTask(task: TwitterAPISessionDelegatedJSONTask) -} - -public class TwitterAPISessionDelegatedJSONTask: TwitterAPISessionJSONTask, TwitterAPISessionDelegatedTask { - public var taskIdentifier: Int { - task.taskIdentifier - } - - public var currentRequest: URLRequest? { - task.currentRequest - } - - public var originalRequest: URLRequest? { - task.originalRequest - } - - public var httpResponse: HTTPURLResponse? { - task.httpResponse - } - - internal weak var delegate: TwitterAPISessionDelegatedJSONTaskDelegate? - - public private(set) var error: Error? - public var data: Data? { - guard completed else { return nil } - return dataChunk - } - - public private(set) var completed = false - - internal let task: TwitterAPISessionTask - - private let taskQueue: DispatchQueue - private var dataChunk: Data = .init() - private let group = DispatchGroup() - - public init(task: TwitterAPISessionTask) { - self.task = task - - // Serial queue - taskQueue = DispatchQueue(label: "TwitterAPIClient.task.\(task.taskIdentifier)") - taskQueue.suspend() - } - - deinit { - // EXC_BAD_INSTRUCTION will occur if the Dispatch Queue is released while suspended. - if !completed { - taskQueue.resume() - } - } - - public func append(chunk: Data) { - dataChunk.append(chunk) - } - - public func complete(error: Error?) { - self.error = error - completed = true - - group.notify(queue: taskQueue) { [weak self] in - guard let self else { return } - delegate?.didFinishQueueInJsonTask(task: self) - } - taskQueue.resume() - } - - // swiftlint:disable:next function_body_length - private func getResponse() -> TwitterAPIResponse { - guard completed, let data else { - fatalError("Request not completed yet.") - } - - guard error == nil, let httpResponse else { - return TwitterAPIResponse( - request: currentRequest, - response: httpResponse, - data: data, - result: .failure(.responseFailed(reason: .invalidResponse(error: error))), - rateLimit: nil - ) - } - - let rateLimit = TwitterRateLimit(header: httpResponse.allHeaderFields) - - guard 200 ..< 300 ~= httpResponse.statusCode else { - return TwitterAPIResponse( - request: currentRequest, - response: httpResponse, - data: data, - result: .failure( - .responseFailed( - reason: .unacceptableStatusCode( - statusCode: httpResponse.statusCode, error: .init(data: data), rateLimit: rateLimit - ) - ) - ), - rateLimit: rateLimit - ) - } - - return TwitterAPIResponse( - request: currentRequest, - response: httpResponse, - data: data, - result: .success(data), - rateLimit: rateLimit - ) - } - - private func registerResponseBlock( - queue: DispatchQueue, - flatMap transform: @escaping (Data) -> Result, - response block: @escaping ((TwitterAPIResponse) -> Void) - ) -> Self { - group.enter() - taskQueue.async { [weak self] in - guard let self else { return } - - let response = getResponse().flatMap(transform) - - queue.async { [weak self] in - guard let self else { return } - block(response) - group.leave() - } - } - - return self - } - - public func responseData(queue: DispatchQueue, _ block: @escaping (TwitterAPIResponse) -> Void) -> Self { - registerResponseBlock(queue: queue, flatMap: { .success($0) }, response: block) - } - - @discardableResult - public func responseData(_ block: @escaping (TwitterAPIResponse) -> Void) -> Self { - responseData(queue: .main, block) - } - - public func responseObject( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - registerResponseBlock( - queue: queue, - flatMap: { $0.serialize() }, - response: block - ) - } - - public func responseObject(_ block: @escaping (TwitterAPIResponse) -> Void) -> Self { - responseObject(queue: .main, block) - } - - public func responseDecodable( - type: T.Type, - decoder: JSONDecoder = TwitterAPIClient.defaultJSONDecoder, - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - registerResponseBlock( - queue: queue, - flatMap: { $0.decode(type, decoder: decoder) }, - response: block - ) - } - - public func responseDecodable( - type: T.Type, - decoder: JSONDecoder, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - responseDecodable( - type: type, - decoder: decoder, - queue: .main, - block - ) - } - - public func responseDecodable( - type: T.Type, - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - responseDecodable( - type: type, - decoder: TwitterAPIClient.defaultJSONDecoder, - queue: queue, - block - ) - } - - public func responseDecodable( - type: T.Type, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self where T: Decodable { - responseDecodable( - type: type, - decoder: TwitterAPIClient.defaultJSONDecoder, - queue: .main, - block - ) - } - - public func cancel() { - task.cancel() - } -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDelegatedStreamTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDelegatedStreamTask.swift deleted file mode 100644 index a4dae02c..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionDelegatedStreamTask.swift +++ /dev/null @@ -1,111 +0,0 @@ -// TwitterAPISessionDelegatedStreamTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -private let chunkSeparator = Data("\r\n".utf8) -public class TwitterAPISessionDelegatedStreamTask: TwitterAPISessionStreamTask, TwitterAPISessionDelegatedTask { - public var taskIdentifier: Int { task.taskIdentifier } - public var currentRequest: URLRequest? { task.currentRequest } - public var originalRequest: URLRequest? { task.originalRequest } - public var httpResponse: HTTPURLResponse? { - task.httpResponse - } - - private let task: TwitterAPISessionTask - private var dataBlocks = [(queue: DispatchQueue, block: (TwitterAPIResponse) -> Void)]() - private lazy var taskQueue = DispatchQueue(label: "TwitterAPISessionDelegatedStreamTask_\(taskIdentifier)") - - public init(task: TwitterAPISessionTask) { - self.task = task - } - - @discardableResult - public func streamResponse( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - dataBlocks.append((queue: queue, block: block)) - return self - } - - @discardableResult - public func streamResponse( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self { - dataBlocks.append((queue: .main, block: block)) - return self - } - - public func cancel() { - task.cancel() - } - - public func append(chunk: Data) { - taskQueue.async { [weak self] in - guard let self else { return } - - guard let httpResponse else { - notify(result: .failure(.responseFailed(reason: .invalidResponse(error: nil))), rateLimit: nil) - return - } - - let rateLimit = TwitterRateLimit(header: httpResponse.allHeaderFields) - - guard httpResponse.statusCode < 300 else { - let error = TwitterAPIErrorResponse(data: chunk) - notify( - result: .failure( - .responseFailed( - reason: .unacceptableStatusCode( - statusCode: httpResponse.statusCode, - error: error, - rateLimit: rateLimit - ) - ) - ), rateLimit: rateLimit - ) - - return - } - - for data in chunk.split(separator: chunkSeparator) { - notify(result: .success(data), rateLimit: rateLimit) - } - } - } - - public func complete(error: Error?) { - if let error { - taskQueue.async { [weak self] in - guard let self else { return } - notify(result: .failure(.responseFailed(reason: .invalidResponse(error: error))), rateLimit: nil) - } - } - } - - private func notify(result: Result, rateLimit: TwitterRateLimit?) { - let response = TwitterAPIResponse( - request: currentRequest, - response: httpResponse, - data: result.success, - result: result, - rateLimit: rateLimit - ) - - for (queue, block) in dataBlocks { - queue.async { - block(response) - } - } - } - - deinit { - // De-init Logic Here - } -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionJSONTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionJSONTask.swift deleted file mode 100644 index d57c0365..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionJSONTask.swift +++ /dev/null @@ -1,50 +0,0 @@ -// TwitterAPISessionJSONTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public protocol TwitterAPISessionJSONTask: TwitterAPISessionDataTask { - @discardableResult - func responseObject( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func responseObject( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func responseDecodable( - type: T.Type, - decoder: JSONDecoder, - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func responseDecodable( - type: T.Type, - decoder: JSONDecoder, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func responseDecodable( - type: T.Type, - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func responseDecodable( - type: T.Type, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionSpecializedTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionSpecializedTask.swift deleted file mode 100644 index cd674663..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionSpecializedTask.swift +++ /dev/null @@ -1,114 +0,0 @@ -// TwitterAPISessionSpecializedTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public protocol TwitterAPISessionSpecializedTaskProtocol: TwitterAPISessionDataTask { - associatedtype Success - @discardableResult - func responseObject( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> TwitterAPISessionSpecializedTask -} - -public struct TwitterAPISessionSpecializedTask: TwitterAPISessionSpecializedTaskProtocol { - public var taskIdentifier: Int { - innerTask.taskIdentifier - } - - public var currentRequest: URLRequest? { - innerTask.currentRequest - } - - public var originalRequest: URLRequest? { - innerTask.originalRequest - } - - public var httpResponse: HTTPURLResponse? { - innerTask.httpResponse - } - - private let innerTask: TwitterAPISessionDataTask - private let transform: (Data) throws -> Success - - public init( - task: TwitterAPISessionDataTask, - transform: @escaping (Data) throws -> Success - ) { - innerTask = task - self.transform = transform - } - - @discardableResult - public func responseObject( - queue: DispatchQueue = .main, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> TwitterAPISessionSpecializedTask { - innerTask.responseData(queue: queue) { response in - let success = response.tryMap(transform) - block(success) - } - return self - } - - @discardableResult - public func responseData( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> TwitterAPISessionSpecializedTask { - innerTask.responseData(queue: queue, block) - return self - } - - @discardableResult - public func responseData( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> TwitterAPISessionSpecializedTask< - Success - > { - responseData(queue: .main, block) - } - - public func cancel() { - innerTask.cancel() - } -} - -public extension Array where Element: TwitterAPISessionSpecializedTaskProtocol { - /// Specializes the task to return an array of responses. - /// - Parameters: - /// - queue: The queue to run the response on. - /// - block: The block to call with the responses. - func responseObject( - queue: DispatchQueue = .main, - _ block: @escaping ([TwitterAPIResponse]) -> Void - ) { - let group = DispatchGroup() - - var responses = [TwitterAPIResponse]() - let innerQueue = DispatchQueue(label: "TwitterAPISessionSpecializedTask.array") - innerQueue.suspend() - - for task in self { - group.enter() - innerQueue.async { - task.responseObject(queue: innerQueue) { - responses.append($0) - group.leave() - } - } - } - - group.notify(queue: queue) { - block(responses) - } - - innerQueue.resume() - } -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionStreamTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionStreamTask.swift deleted file mode 100644 index 9a9cbd28..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionStreamTask.swift +++ /dev/null @@ -1,22 +0,0 @@ -// TwitterAPISessionStreamTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -public protocol TwitterAPISessionStreamTask: TwitterAPISessionTask { - @discardableResult - func streamResponse( - queue: DispatchQueue, - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self - - @discardableResult - func streamResponse( - _ block: @escaping (TwitterAPIResponse) -> Void - ) -> Self -} diff --git a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionTask.swift b/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionTask.swift deleted file mode 100644 index 39bc8b73..00000000 --- a/Sources/TwitterAPIKit/SessionTask/TwitterAPISessionTask.swift +++ /dev/null @@ -1,31 +0,0 @@ -// TwitterAPISessionTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// A protocol that defines the properties and methods for a session task. -public protocol TwitterAPISessionTask { - /// The unique identifier for the task. - var taskIdentifier: Int { get } - /// The current request being processed. - var currentRequest: URLRequest? { get } - /// The original request that was used to create the task. - var originalRequest: URLRequest? { get } - /// The HTTP response received from the server. - var httpResponse: HTTPURLResponse? { get } - /// Cancels the task. - func cancel() -} - -/// A default implementation of the TwitterAPISessionTask protocol. -extension URLSessionTask: TwitterAPISessionTask { - /// The HTTP response received from the server. - public var httpResponse: HTTPURLResponse? { - response as? HTTPURLResponse - } -} diff --git a/Sources/TwitterAPIKit/TwitterAPI.swift b/Sources/TwitterAPIKit/TwitterAPI.swift deleted file mode 100644 index d518bd87..00000000 --- a/Sources/TwitterAPIKit/TwitterAPI.swift +++ /dev/null @@ -1,1507 +0,0 @@ -// TwitterAPI.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -// swift-format-ignore-file -import Foundation - -/// A protocol that represents a Twitter API. -public protocol TwitterAPI { - // No Logic Here -} - -/// Extension providing OAuth authentication methods for the Twitter API. -extension TwitterAuthAPI: TwitterAPI { - // MARK: - OAuth10aAPI - - /// Requests an OAuth request token from Twitter. - /// - Parameter request: The request parameters for obtaining a request token. - /// - Returns: A data task that will return the raw response data. - public func postOAuthRequestTokenData(_ request: PostOAuthRequestTokenRequestV1) -> TwitterAPISessionDataTask { - oauth10a.postOAuthRequestTokenData(request) - } - - /// Requests an OAuth request token from Twitter and parses the response. - /// - Parameter request: The request parameters for obtaining a request token. - /// - Returns: A specialized task that will return a parsed OAuth token. - public func postOAuthRequestToken(_ request: PostOAuthRequestTokenRequestV1) - -> TwitterAPISessionSpecializedTask - { - oauth10a.postOAuthRequestToken(request) - } - - /// Creates a URL for authorizing the application with OAuth. - /// - Parameter request: The request parameters for creating the authorization URL. - /// - Returns: The authorization URL if it can be created, nil otherwise. - public func makeOAuthAuthorizeURL(_ request: GetOAuthAuthorizeRequestV1) -> URL? { - oauth10a.makeOAuthAuthorizeURL(request) - } - - /// Creates a URL for authenticating with OAuth. - /// - Parameter request: The request parameters for creating the authentication URL. - /// - Returns: The authentication URL if it can be created, nil otherwise. - public func makeOAuthAuthenticateURL(_ request: GetOAuthAuthenticateRequestV1) -> URL? { - oauth10a.makeOAuthAuthenticateURL(request) - } - - /// Requests an OAuth access token from Twitter. - /// - Parameter request: The request parameters for obtaining an access token. - /// - Returns: A data task that will return the raw response data. - public func postOAuthAccessTokenData(_ request: PostOAuthAccessTokenRequestV1) -> TwitterAPISessionDataTask { - oauth10a.postOAuthAccessTokenData(request) - } - - /// Requests an OAuth access token from Twitter and parses the response. - /// - Parameter request: The request parameters for obtaining an access token. - /// - Returns: A specialized task that will return a parsed OAuth access token. - public func postOAuthAccessToken(_ request: PostOAuthAccessTokenRequestV1) - -> TwitterAPISessionSpecializedTask - { - oauth10a.postOAuthAccessToken(request) - } - - /// Invalidates the current OAuth access token. - /// - Parameter request: The request parameters for invalidating the token. - /// - Returns: A JSON task that will return the response. - public func postInvalidateAccessToken(_ request: PostOAuthInvalidateTokenRequestV1) -> TwitterAPISessionJSONTask { - oauth10a.postInvalidateAccessToken(request) - } - - // MARK: - OAuth20API - - /// Requests an OAuth 2.0 bearer token from Twitter. - /// - Parameter request: The request parameters for obtaining a bearer token. - /// - Returns: A data task that will return the raw response data. - public func postOAuth2BearerTokenData(_ request: PostOAuth2TokenRequestV1) -> TwitterAPISessionDataTask { - oauth20.postOAuth2BearerTokenData(request) - } - - /// Requests an OAuth 2.0 bearer token from Twitter and parses the response. - /// - Parameter request: The request parameters for obtaining a bearer token. - /// - Returns: A specialized task that will return a parsed OAuth 2.0 bearer token. - public func postOAuth2BearerToken(_ request: PostOAuth2TokenRequestV1) - -> TwitterAPISessionSpecializedTask - { - oauth20.postOAuth2BearerToken(request) - } - - /// Invalidates the current OAuth 2.0 bearer token. - /// - Parameter request: The request parameters for invalidating the token. - /// - Returns: A JSON task that will return the response. - public func postInvalidateOAuth2BearerToken( - _ request: PostOAuth2InvalidateTokenRequestV1 - ) -> TwitterAPISessionJSONTask { - oauth20.postInvalidateOAuth2BearerToken(request) - } - - /// Creates a URL for OAuth 2.0 authorization. - /// - Parameter request: The request parameters for creating the authorization URL. - /// - Returns: The authorization URL if it can be created, nil otherwise. - public func makeOAuth2AuthorizeURL(_ request: GetOAuth2AuthorizeRequestV1) -> URL? { - oauth20.makeOAuth2AuthorizeURL(request) - } - - /// Requests an OAuth 2.0 access token from Twitter. - /// - Parameter request: The request parameters for obtaining an access token. - /// - Returns: A data task that will return the raw response data. - public func postOAuth2AccessTokenData(_ request: PostOAuth2AccessTokenRequestV2) -> TwitterAPISessionDataTask { - oauth20.postOAuth2AccessTokenData(request) - } - - /// Requests an OAuth 2.0 access token from Twitter and parses the response. - /// - Parameter request: The request parameters for obtaining an access token. - /// - Returns: A specialized task that will return a parsed OAuth 2.0 access token. - public func postOAuth2AccessToken(_ request: PostOAuth2AccessTokenRequestV2) - -> TwitterAPISessionSpecializedTask - { - oauth20.postOAuth2AccessToken(request) - } - - /// Requests a refresh of the OAuth 2.0 access token. - /// - Parameter request: The request parameters for refreshing the token. - /// - Returns: A data task that will return the raw response data. - public func postOAuth2RefreshTokenData(_ request: PostOAuth2RefreshTokenRequestV2) -> TwitterAPISessionDataTask { - oauth20.postOAuth2RefreshTokenData(request) - } - - /// Requests a refresh of the OAuth 2.0 access token and parses the response. - /// - Parameter request: The request parameters for refreshing the token. - /// - Returns: A specialized task that will return a parsed OAuth 2.0 access token. - public func postOAuth2RefreshToken(_ request: PostOAuth2RefreshTokenRequestV2) - -> TwitterAPISessionSpecializedTask - { - oauth20.postOAuth2RefreshToken(request) - } - - /// Revokes an OAuth 2.0 token. - /// - Parameter request: The request parameters for revoking the token. - /// - Returns: A data task that will return the response. - public func postOAuth2RevokeToken(_ request: PostOAuth2RevokeTokenRequestV2) -> TwitterAPISessionDataTask { - oauth20.postOAuth2RevokeToken(request) - } -} - -/// Extension providing Twitter API v1 endpoints. -public extension TwitterAPIv1 { - // MARK: - AccountAPIv1 - - /// Retrieves the current account settings. - /// - Parameter request: The request parameters for retrieving account settings. - /// - Returns: A JSON task that will return the account settings. - func getAccountSetting(_ request: GetAccountSettingsRequestV1) -> TwitterAPISessionJSONTask { - account.getAccountSetting(request) - } - - /// Verifies the credentials of the current user. - /// - Parameter request: The request parameters for verifying credentials. - /// - Returns: A JSON task that will return the verification result. - func getAccountVerify(_ request: GetAccountVerifyCredentialsRequestV1) -> TwitterAPISessionJSONTask { - account.getAccountVerify(request) - } - - /// Removes the profile banner for the authenticated user. - /// - Parameter request: The request parameters for removing the profile banner. - /// - Returns: A JSON task that will return the response. - func postRemoveProfileBanner( - _ request: PostAccountRemoveProfileBannerRequestV1 - ) -> TwitterAPISessionJSONTask { - account.postRemoveProfileBanner(request) - } - - /// Updates the account settings for the authenticated user. - /// - Parameter request: The request parameters containing the new settings. - /// - Returns: A JSON task that will return the updated settings. - func postAccountSettings(_ request: PostAccountSettingsRequestV1) -> TwitterAPISessionJSONTask { - account.postAccountSettings(request) - } - - /// Updates the profile information for the authenticated user. - /// - Parameter request: The request parameters containing the new profile information. - /// - Returns: A JSON task that will return the updated profile. - func postAccountProfile(_ request: PostAccountUpdateProfileRequestV1) -> TwitterAPISessionJSONTask { - account.postAccountProfile(request) - } - - /// Updates the profile banner for the authenticated user. - /// - Parameter request: The request parameters containing the new banner image. - /// - Returns: A data task that will return the response. - func postProfileBanner(_ request: PostAccountUpdateProfileBannerRequestV1) -> TwitterAPISessionDataTask { - account.postProfileBanner(request) - } - - /// Updates the profile image for the authenticated user. - /// - Parameter request: The request parameters containing the new profile image. - /// - Returns: A JSON task that will return the response. - func postProfileImage(_ request: PostAccountUpdateProfileImageRequestV1) -> TwitterAPISessionJSONTask { - account.postProfileImage(request) - } - - // MARK: - ApplicationAPIv1 - - /// Retrieves the current rate limit status for the application. - /// - Parameter request: The request parameters for retrieving rate limit status. - /// - Returns: A JSON task that will return the rate limit information. - func getRateLimit(_ request: GetApplicationRateLimitStatusRequestV1) -> TwitterAPISessionJSONTask { - application.getRateLimit(request) - } - - // MARK: - BlockAndMuteAPIv1 - - /// Retrieves the IDs of users blocked by the authenticated user. - /// - Parameter request: The request parameters for retrieving blocked user IDs. - /// - Returns: A JSON task that will return the list of blocked user IDs. - func getBlockIDs(_ request: GetBlocksIDsRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.getBlockIDs(request) - } - - /// Retrieves detailed information about users blocked by the authenticated user. - /// - Parameter request: The request parameters for retrieving blocked users. - /// - Returns: A JSON task that will return the list of blocked users. - func getBlockUsers(_ request: GetBlocksListRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.getBlockUsers(request) - } - - /// Retrieves the IDs of users muted by the authenticated user. - /// - Parameter request: The request parameters for retrieving muted user IDs. - /// - Returns: A JSON task that will return the list of muted user IDs. - func getMuteIDs(_ request: GetMutesUsersIDsRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.getMuteIDs(request) - } - - /// Retrieves detailed information about users muted by the authenticated user. - /// - Parameter request: The request parameters for retrieving muted users. - /// - Returns: A JSON task that will return the list of muted users. - func getMuteUsers(_ request: GetMutesUsersListRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.getMuteUsers(request) - } - - /// Blocks a user. - /// - Parameter request: The request parameters containing the user to block. - /// - Returns: A JSON task that will return the blocked user information. - func postBlockUser(_ request: PostBlocksCreateRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.postBlockUser(request) - } - - /// Unblocks a user. - /// - Parameter request: The request parameters containing the user to unblock. - /// - Returns: A JSON task that will return the unblocked user information. - func postUnblockUser(_ request: PostBlocksDestroyRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.postUnblockUser(request) - } - - /// Mutes a user. - /// - Parameter request: The request parameters containing the user to mute. - /// - Returns: A JSON task that will return the muted user information. - func postMuteUser(_ request: PostMutesUsersCreateRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.postMuteUser(request) - } - - /// Unmutes a user. - /// - Parameter request: The request parameters containing the user to unmute. - /// - Returns: A JSON task that will return the unmuted user information. - func postUnmuteUser(_ request: PostMutesUsersDestroyRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.postUnmuteUser(request) - } - - /// Reports a user as spam. - /// - Parameter request: The request parameters containing the user to report. - /// - Returns: A JSON task that will return the response. - func postReportSpam(_ request: PostUsersReportSpamRequestV1) -> TwitterAPISessionJSONTask { - blockAndMute.postReportSpam(request) - } - - // MARK: - CollectionAPIv1 - - /// Retrieves entries from a collection. - /// - Parameter request: The request parameters for retrieving collection entries. - /// - Returns: A JSON task that will return the collection entries. - func getCollectionEntries(_ request: GetCollectionsEntriesRequestV1) -> TwitterAPISessionJSONTask { - collection.getCollectionEntries(request) - } - - /// Retrieves a list of collections owned by a user. - /// - Parameter request: The request parameters for retrieving collections. - /// - Returns: A JSON task that will return the list of collections. - func getCollections(_ request: GetCollectionsListRequestV1) -> TwitterAPISessionJSONTask { - collection.getCollections(request) - } - - /// Retrieves information about a specific collection. - /// - Parameter request: The request parameters for retrieving the collection. - /// - Returns: A JSON task that will return the collection information. - func getCollection(_ request: GetCollectionsShowRequestV1) -> TwitterAPISessionJSONTask { - collection.getCollection(request) - } - - /// Creates a new collection. - /// - Parameter request: The request parameters for creating the collection. - /// - Returns: A JSON task that will return the created collection. - func postCreateCollection(_ request: PostCollectionsCreateRequestV1) -> TwitterAPISessionJSONTask { - collection.postCreateCollection(request) - } - - /// Deletes a collection. - /// - Parameter request: The request parameters for deleting the collection. - /// - Returns: A JSON task that will return the response. - func postDestroyCollection(_ request: PostCollectionsDestroyRequestV1) -> TwitterAPISessionJSONTask { - collection.postDestroyCollection(request) - } - - /// Adds a tweet to a collection. - /// - Parameter request: The request parameters for adding the tweet. - /// - Returns: A JSON task that will return the response. - func postCollectionAddEntry(_ request: PostCollectionsEntriesAddRequestV1) -> TwitterAPISessionJSONTask { - collection.postCollectionAddEntry(request) - } - - /// Curates tweets in a collection. - /// - Parameter request: The request parameters for curating the collection. - /// - Returns: A JSON task that will return the response. - func postCollectionCurate(_ request: PostCollectionsEntriesCurateRequestV1) -> TwitterAPISessionJSONTask { - collection.postCollectionCurate(request) - } - - /// Moves a tweet to a different position in a collection. - /// - Parameter request: The request parameters for moving the tweet. - /// - Returns: A JSON task that will return the response. - func postCollectionMoveEntry(_ request: PostCollectionsEntriesMoveRequestV1) -> TwitterAPISessionJSONTask { - collection.postCollectionMoveEntry(request) - } - - /// Removes a tweet from a collection. - /// - Parameter request: The request parameters for removing the tweet. - /// - Returns: A JSON task that will return the response. - func postCollectionRemoveEntry( - _ request: PostCollectionsEntriesRemoveRequestV1 - ) -> TwitterAPISessionJSONTask { - collection.postCollectionRemoveEntry(request) - } - - /// Updates a collection's metadata. - /// - Parameter request: The request parameters containing the updated metadata. - /// - Returns: A JSON task that will return the updated collection. - func postCollectionUpdate(_ request: PostCollectionsUpdateRequestV1) -> TwitterAPISessionJSONTask { - collection.postCollectionUpdate(request) - } - - // MARK: - DirectMessageAPIv1 - - /// Sends a new direct message. - /// - Parameter request: The request parameters containing the message content. - /// - Returns: A JSON task that will return the sent message. - func postDirectMessage(_ request: PostDirectMessageRequestV1) -> TwitterAPISessionJSONTask { - directMessage.postDirectMessage(request) - } - - /// Deletes a direct message. - /// - Parameter request: The request parameters containing the message to delete. - /// - Returns: A data task that will return the response. - func deleteDirectMessage(_ request: DeleteDirectMessageRequestV1) -> TwitterAPISessionDataTask { - directMessage.deleteDirectMessage(request) - } - - /// Retrieves a specific direct message. - /// - Parameter request: The request parameters for retrieving the message. - /// - Returns: A JSON task that will return the message. - func getDirectMessage(_ request: GetDirectMessageRequestV1) -> TwitterAPISessionJSONTask { - directMessage.getDirectMessage(request) - } - - /// Retrieves a list of direct messages. - /// - Parameter request: The request parameters for retrieving messages. - /// - Returns: A JSON task that will return the list of messages. - func getDirectMessageList(_ request: GetDirectMessageListRequestV1) -> TwitterAPISessionJSONTask { - directMessage.getDirectMessageList(request) - } - - /// Marks a direct message as read. - /// - Parameter request: The request parameters containing the message to mark. - /// - Returns: A data task that will return the response. - func postDirectMessageMarkRead(_ request: PostDirectMessagesMarkReadRequestV1) -> TwitterAPISessionDataTask { - directMessage.postDirectMessageMarkRead(request) - } - - /// Indicates that the user is typing a direct message. - /// - Parameter request: The request parameters for the typing indicator. - /// - Returns: A data task that will return the response. - func postDirectMessageTypingIndicator(_ request: PostDirectMessagesIndicateTypingRequestV1) - -> TwitterAPISessionDataTask - { - directMessage.postDirectMessageTypingIndicator(request) - } - - // MARK: - FavoriteAPIv1 - - /// Favorites (likes) a tweet. - /// - Parameter request: The request parameters containing the tweet to favorite. - /// - Returns: A JSON task that will return the favorited tweet. - func postFavorite(_ request: PostFavoriteRequestV1) -> TwitterAPISessionJSONTask { - favorite.postFavorite(request) - } - - /// Removes a favorite (unlike) from a tweet. - /// - Parameter request: The request parameters containing the tweet to unfavorite. - /// - Returns: A JSON task that will return the unfavorited tweet. - func postUnFavorite(_ request: PostUnFavoriteRequestV1) -> TwitterAPISessionJSONTask { - favorite.postUnFavorite(request) - } - - /// Retrieves tweets favorited by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of favorited tweets. - func getFavorites(_ request: GetFavoritesRequestV1) -> TwitterAPISessionJSONTask { - favorite.getFavorites(request) - } - - // MARK: - FriendshipsAPIv1 - - /// Retrieves IDs of users following a specified user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of follower IDs. - func getFollowerIDs(_ request: GetFollowersIDsRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFollowerIDs(request) - } - - /// Retrieves detailed information about users following a specified user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of followers. - func getFollowers(_ request: GetFollowersListRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFollowers(request) - } - - /// Retrieves IDs of users a specified user is following. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of friend IDs. - func getFriendIDs(_ request: GetFriendsIDsRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFriendIDs(request) - } - - /// Retrieves detailed information about users a specified user is following. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of friends. - func getFriends(_ request: GetFriendsListRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFriends(request) - } - - /// Retrieves incoming follow requests for the authenticated user. - /// - Parameter request: The request parameters for retrieving incoming requests. - /// - Returns: A JSON task that will return the list of pending followers. - func getFriendshipsIncoming(_ request: GetFriendshipsIncomingRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFriendshipsIncoming(request) - } - - /// Retrieves detailed friendship information between users. - /// - Parameter request: The request parameters containing the user identifiers. - /// - Returns: A JSON task that will return the friendship details. - func getFriendshipsLookup(_ request: GetFriendshipsLookupRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFriendshipsLookup(request) - } - - /// Retrieves IDs of users whose retweets are disabled. - /// - Parameter request: The request parameters for retrieving no-retweet IDs. - /// - Returns: A JSON task that will return the list of user IDs. - func getFriendshipsNoRetweetsIDs( - _ request: GetFriendshipsNoRetweetsIDsRequestV1 - ) -> TwitterAPISessionJSONTask { - friendships.getFriendshipsNoRetweetsIDs(request) - } - - /// Retrieves outgoing follow requests from the authenticated user. - /// - Parameter request: The request parameters for retrieving outgoing requests. - /// - Returns: A JSON task that will return the list of pending friends. - func getFriendshipsOutgoing(_ request: GetFriendshipsOutgoingRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFriendshipsOutgoing(request) - } - - /// Retrieves detailed friendship information between two users. - /// - Parameter request: The request parameters containing the user identifiers. - /// - Returns: A JSON task that will return the friendship details. - func getFriendships(_ request: GetFriendshipsShowRequestV1) -> TwitterAPISessionJSONTask { - friendships.getFriendships(request) - } - - /// Follows a user. - /// - Parameter request: The request parameters containing the user to follow. - /// - Returns: A JSON task that will return the followed user information. - func postFollowUser(_ request: PostFriendshipsCreateRequestV1) -> TwitterAPISessionJSONTask { - friendships.postFollowUser(request) - } - - /// Unfollows a user. - /// - Parameter request: The request parameters containing the user to unfollow. - /// - Returns: A JSON task that will return the unfollowed user information. - func postUnfollowUser(_ request: PostFriendshipsDestroyRequestV1) -> TwitterAPISessionJSONTask { - friendships.postUnfollowUser(request) - } - - /// Updates friendship settings with a user. - /// - Parameter request: The request parameters containing the settings to update. - /// - Returns: A JSON task that will return the updated friendship information. - func postFriendshipsUpdate(_ request: PostFriendshipsUpdateRequestV1) -> TwitterAPISessionJSONTask { - friendships.postFriendshipsUpdate(request) - } - - // MARK: - GeoAPIv1 - - /// Retrieves location information for given coordinates. - /// - Parameter request: The request parameters containing the coordinates. - /// - Returns: A JSON task that will return the location information. - func getReverseGeocode(_ request: GetGeoReverseGeocodeRequestV1) -> TwitterAPISessionJSONTask { - geo.getReverseGeocode(request) - } - - /// Retrieves information about a specific place. - /// - Parameter request: The request parameters containing the place ID. - /// - Returns: A JSON task that will return the place information. - func getGeoPlace(_ request: GetGeoPlaceIDRequestV1) -> TwitterAPISessionJSONTask { - geo.getGeoPlace(request) - } - - /// Searches for places matching specified criteria. - /// - Parameter request: The request parameters containing the search criteria. - /// - Returns: A JSON task that will return the matching places. - func searchGeo(_ request: GetGeoSearchRequestV1) -> TwitterAPISessionJSONTask { - geo.searchGeo(request) - } - - // MARK: - HelpAPIv1 - - /// Retrieves the list of languages supported by Twitter. - /// - Parameter request: The request parameters for retrieving languages. - /// - Returns: A JSON task that will return the supported languages. - func getSupportedLanguages(_ request: GetHelpLanguagesRequestV1) -> TwitterAPISessionJSONTask { - help.getSupportedLanguages(request) - } - - // MARK: - ListAPIv1 - - /// Retrieves lists owned by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the owned lists. - func getLists(_ request: GetListsListRequestV1) -> TwitterAPISessionJSONTask { - list.getLists(request) - } - - /// Retrieves members of a list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list members. - func getListMembers(_ request: GetListsMembersRequestV1) -> TwitterAPISessionJSONTask { - list.getListMembers(request) - } - - /// Checks if a user is a member of a list. - /// - Parameter request: The request parameters containing the user and list identifiers. - /// - Returns: A JSON task that will return the membership status. - func getListMember(_ request: GetListsMembersShowRequestV1) -> TwitterAPISessionJSONTask { - list.getListMember(request) - } - - /// Retrieves lists that a user is a member of. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list memberships. - func getListMemberships(_ request: GetListsMembershipsRequestV1) -> TwitterAPISessionJSONTask { - list.getListMemberships(request) - } - - /// Retrieves lists owned by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the owned lists. - func getListOwnerships(_ request: GetListsOwnershipsRequestV1) -> TwitterAPISessionJSONTask { - list.getListOwnerships(request) - } - - /// Retrieves information about a specific list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list information. - func getList(_ request: GetListsShowRequestV1) -> TwitterAPISessionJSONTask { - list.getList(request) - } - - /// Retrieves tweets from a list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list tweets. - func getListStatuses(_ request: GetListsStatusesRequestV1) -> TwitterAPISessionJSONTask { - list.getListStatuses(request) - } - - /// Retrieves subscribers of a list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list subscribers. - func getListSubscribers(_ request: GetListsSubscribersRequestV1) -> TwitterAPISessionJSONTask { - list.getListSubscribers(request) - } - - /// Checks if a user is subscribed to a list. - /// - Parameter request: The request parameters containing the user and list identifiers. - /// - Returns: A JSON task that will return the subscription status. - func getListSubscriber(_ request: GetListsSubscribersShowRequestV1) -> TwitterAPISessionJSONTask { - list.getListSubscriber(request) - } - - /// Retrieves lists that a user is subscribed to. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the subscribed lists. - func getListSubscriptions(_ request: GetListsSubscriptionsRequestV1) -> TwitterAPISessionJSONTask { - list.getListSubscriptions(request) - } - - /// Creates a new list. - /// - Parameter request: The request parameters for creating the list. - /// - Returns: A JSON task that will return the created list. - func postCreateList(_ request: PostListsCreateRequestV1) -> TwitterAPISessionJSONTask { - list.postCreateList(request) - } - - /// Deletes a list. - /// - Parameter request: The request parameters containing the list to delete. - /// - Returns: A JSON task that will return the response. - func postDestroyList(_ request: PostListsDestroyRequestV1) -> TwitterAPISessionJSONTask { - list.postDestroyList(request) - } - - /// Adds a member to a list. - /// - Parameter request: The request parameters containing the user and list. - /// - Returns: A JSON task that will return the response. - func postAddListMember(_ request: PostListsMembersCreateRequestV1) -> TwitterAPISessionJSONTask { - list.postAddListMember(request) - } - - /// Adds multiple members to a list. - /// - Parameter request: The request parameters containing the users and list. - /// - Returns: A JSON task that will return the response. - func postAddListMembers(_ request: PostListsMembersCreateAllRequestV1) -> TwitterAPISessionJSONTask { - list.postAddListMembers(request) - } - - /// Removes a member from a list. - /// - Parameter request: The request parameters containing the user and list. - /// - Returns: A JSON task that will return the response. - func postRemoveListMember(_ request: PostListsMembersDestroyRequestV1) -> TwitterAPISessionJSONTask { - list.postRemoveListMember(request) - } - - /// Removes multiple members from a list. - /// - Parameter request: The request parameters containing the users and list. - /// - Returns: A JSON task that will return the response. - func postRemoveListMembers(_ request: PostListsMembersDestroyAllRequestV1) -> TwitterAPISessionJSONTask { - list.postRemoveListMembers(request) - } - - /// Subscribes the authenticated user to a list. - /// - Parameter request: The request parameters containing the list to subscribe to. - /// - Returns: A JSON task that will return the response. - func postSubscribeList(_ request: PostListsSubscribersCreateRequestV1) -> TwitterAPISessionJSONTask { - list.postSubscribeList(request) - } - - /// Unsubscribes the authenticated user from a list. - /// - Parameter request: The request parameters containing the list to unsubscribe from. - /// - Returns: A JSON task that will return the response. - func postUnsubscribeList(_ request: PostListsSubscribersDestroyRequestV1) -> TwitterAPISessionJSONTask { - list.postUnsubscribeList(request) - } - - /// Updates a list's metadata. - /// - Parameter request: The request parameters containing the updated information. - /// - Returns: A JSON task that will return the updated list. - func postUpdateList(_ request: PostListsUpdateRequestV1) -> TwitterAPISessionJSONTask { - list.postUpdateList(request) - } - - // MARK: - MediaAPIv1 - - /// Retrieves the status of a media upload. - /// - Parameter request: The request parameters for checking upload status. - /// - Returns: A JSON task that will return the upload status. - func getUploadMediaStatus(_ request: GetUploadMediaStatusRequestV1) -> TwitterAPISessionJSONTask { - media.getUploadMediaStatus(request) - } - - /// Initializes a media upload. - /// - Parameter request: The request parameters for initializing the upload. - /// - Returns: A JSON task that will return the initialization response. - func uploadMediaInit(_ request: UploadMediaInitRequestV1) -> TwitterAPISessionJSONTask { - media.uploadMediaInit(request) - } - - /// Appends media data to an initialized upload. - /// - Parameter request: The request parameters containing the media chunk. - /// - Returns: A JSON task that will return the append response. - func uploadMediaAppend(_ request: UploadMediaAppendRequestV1) -> TwitterAPISessionJSONTask { - media.uploadMediaAppend(request) - } - - /// Appends media data in chunks to an initialized upload. - /// - Parameters: - /// - request: The request parameters containing the media data. - /// - maxBytes: The maximum size of each chunk in bytes (default: 5MB). - /// - Returns: An array of tasks that will return the media ID for each chunk. - func uploadMediaAppendSplitChunks( - _ request: UploadMediaAppendRequestV1, - maxBytes: Int = 5_242_880 - ) -> [TwitterAPISessionSpecializedTask] { - media.uploadMediaAppendSplitChunks(request, maxBytes: maxBytes) - } - - /// Finalizes a media upload. - /// - Parameter request: The request parameters for finalizing the upload. - /// - Returns: A JSON task that will return the finalization response. - func uploadMediaFinalize(_ request: UploadMediaFinalizeRequestV1) -> TwitterAPISessionJSONTask { - media.uploadMediaFinalize(request) - } - - /// Uploads media in a single operation. - /// - Parameters: - /// - parameters: The parameters for the media upload. - /// - completionHandler: A closure to be called with the upload response. - func uploadMedia( - _ parameters: UploadMediaRequestParameters, - completionHandler: @escaping (TwitterAPIResponse) -> Void - ) { - media.uploadMedia(parameters, completionHandler: completionHandler) - } - - /// Waits for media processing to complete with a specified initial wait time. - /// - Parameters: - /// - mediaID: The ID of the media to wait for. - /// - initialWaitSec: The number of seconds to wait initially. - /// - completionHandler: A closure to be called with the processing status. - func waitMediaProcessing( - mediaID: String, - initialWaitSec: Int, - completionHandler: @escaping (TwitterAPIResponse) -> Void - ) { - media.waitMediaProcessing( - mediaID: mediaID, - initialWaitSec: initialWaitSec, - completionHandler: completionHandler - ) - } - - /// Waits for media processing to complete with default wait time. - /// - Parameters: - /// - mediaID: The ID of the media to wait for. - /// - completionHandler: A closure to be called with the processing status. - func waitMediaProcessing( - mediaID: String, - completionHandler: @escaping (TwitterAPIResponse) -> Void - ) { - media.waitMediaProcessing(mediaID: mediaID, completionHandler: completionHandler) - } - - /// Creates metadata for uploaded media. - /// - Parameter request: The request parameters containing the metadata. - /// - Returns: A data task that will return the response. - func createMediaMetadata(_ request: PostMediaMetadataCreateRequestV1) -> TwitterAPISessionDataTask { - media.createMediaMetadata(request) - } - - /// Creates subtitles for media. - /// - Parameter request: The request parameters containing the subtitle data. - /// - Returns: A data task that will return the response. - func createSubtitle(_ request: PostMediaSubtitlesCreateRequestV1) -> TwitterAPISessionDataTask { - media.createSubtitle(request) - } - - /// Deletes subtitles from media. - /// - Parameter request: The request parameters identifying the subtitles to delete. - /// - Returns: A data task that will return the response. - func deleteSubtitle(_ request: PostMediaSubtitlesDeleteRequestV1) -> TwitterAPISessionDataTask { - media.deleteSubtitle(request) - } - - // MARK: - RetweetAPIv1 - - /// Creates a retweet of a tweet. - /// - Parameter request: The request parameters containing the tweet to retweet. - /// - Returns: A JSON task that will return the retweet. - func postRetweet(_ request: PostRetweetRequestV1) -> TwitterAPISessionJSONTask { - retweet.postRetweet(request) - } - - /// Removes a retweet of a tweet. - /// - Parameter request: The request parameters containing the retweet to remove. - /// - Returns: A JSON task that will return the response. - func postUnRetweet(_ request: PostUnRetweetRequestV1) -> TwitterAPISessionJSONTask { - retweet.postUnRetweet(request) - } - - /// Retrieves retweets of a tweet. - /// - Parameter request: The request parameters for retrieving retweets. - /// - Returns: A JSON task that will return the list of retweets. - func getRetweets(_ request: GetRetweetsRequestV1) -> TwitterAPISessionJSONTask { - retweet.getRetweets(request) - } - - /// Retrieves tweets of the authenticated user that have been retweeted. - /// - Parameter request: The request parameters for retrieving retweeted tweets. - /// - Returns: A JSON task that will return the list of tweets. - func getRetweetsOfMe(_ request: GetRetweetsOfMeRequestV1) -> TwitterAPISessionJSONTask { - retweet.getRetweetsOfMe(request) - } - - /// Retrieves users who have retweeted a tweet. - /// - Parameter request: The request parameters for retrieving retweeters. - /// - Returns: A JSON task that will return the list of users. - func getRetweeters(_ request: GetRetweetersRequestV1) -> TwitterAPISessionJSONTask { - retweet.getRetweeters(request) - } - - // MARK: - SearchAPIv1 - - /// Searches for tweets matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the matching tweets. - func searchTweets(_ request: GetSearchTweetsRequestV1) -> TwitterAPISessionJSONTask { - search.searchTweets(request) - } - - /// Retrieves the authenticated user's saved searches. - /// - Parameter request: The request parameters for retrieving saved searches. - /// - Returns: A JSON task that will return the list of saved searches. - func getSavedSearches(_ request: GetSavedSearchesListRequestV1) -> TwitterAPISessionJSONTask { - search.getSavedSearches(request) - } - - /// Creates a new saved search for the authenticated user. - /// - Parameter request: The request parameters containing the search to save. - /// - Returns: A JSON task that will return the saved search. - func postCreateSavedSearch(_ request: PostSavedSearchesCreateRequestV1) -> TwitterAPISessionJSONTask { - search.postCreateSavedSearch(request) - } - - /// Deletes a saved search belonging to the authenticated user. - /// - Parameter request: The request parameters containing the search to delete. - /// - Returns: A JSON task that will return the response. - func postDestroySavedSearch(_ request: PostSavedSearchesCreateRequestV1) -> TwitterAPISessionJSONTask { - search.postDestroySavedSearch(request) - } - - // MARK: - TimelineAPIv1 - - /// Retrieves the authenticated user's home timeline. - /// - Parameter request: The request parameters for retrieving the timeline. - /// - Returns: A JSON task that will return the timeline tweets. - func getHomeTimeline(_ request: GetStatusesHomeTimelineRequestV1) -> TwitterAPISessionJSONTask { - timeline.getHomeTimeline(request) - } - - /// Retrieves tweets mentioning the authenticated user. - /// - Parameter request: The request parameters for retrieving mentions. - /// - Returns: A JSON task that will return the mentions. - func getMentionsTimeline(_ request: GetStatusesMentionsTimelineRequestV1) -> TwitterAPISessionJSONTask { - timeline.getMentionsTimeline(request) - } - - /// Retrieves a user's timeline. - /// - Parameter request: The request parameters for retrieving the user timeline. - /// - Returns: A JSON task that will return the timeline tweets. - func getUserTimeline(_ request: GetStatusesUserTimelineRequestV1) -> TwitterAPISessionJSONTask { - timeline.getUserTimeline(request) - } - - // MARK: - TrendAPIv1 - - /// Retrieves locations where trending topics are available. - /// - Parameter request: The request parameters for retrieving trend locations. - /// - Returns: A JSON task that will return the available locations. - func getTrendsAvailable(_ request: GetTrendsAvailableRequestV1) -> TwitterAPISessionJSONTask { - trend.getTrendsAvailable(request) - } - - /// Retrieves locations closest to a specified location where trends are available. - /// - Parameter request: The request parameters containing the location. - /// - Returns: A JSON task that will return the closest trend locations. - func getTrendsClosest(_ request: GetTrendsClosestRequestV1) -> TwitterAPISessionJSONTask { - trend.getTrendsClosest(request) - } - - /// Retrieves trending topics for a specific location. - /// - Parameter request: The request parameters containing the location. - /// - Returns: A JSON task that will return the trending topics. - func getTrends(_ request: GetTrendsPlaceRequestV1) -> TwitterAPISessionJSONTask { - trend.getTrends(request) - } - - // MARK: - TweetAPIv1 - - /// Posts a new tweet. - /// - Parameter request: The request parameters containing the tweet content. - /// - Returns: A JSON task that will return the posted tweet. - func postUpdateStatus(_ request: PostStatusesUpdateRequestV1) -> TwitterAPISessionJSONTask { - tweet.postUpdateStatus(request) - } - - /// Deletes a tweet. - /// - Parameter request: The request parameters containing the tweet to delete. - /// - Returns: A JSON task that will return the response. - func postDestroyStatus(_ request: PostStatusesDestroyRequestV1) -> TwitterAPISessionJSONTask { - tweet.postDestroyStatus(request) - } - - /// Retrieves a single tweet. - /// - Parameter request: The request parameters containing the tweet ID. - /// - Returns: A JSON task that will return the tweet. - func getShowStatus(_ request: GetStatusesShowRequestV1) -> TwitterAPISessionJSONTask { - tweet.getShowStatus(request) - } - - /// Retrieves multiple tweets by their IDs. - /// - Parameter request: The request parameters containing the tweet IDs. - /// - Returns: A JSON task that will return the tweets. - func getLookupStatuses(_ request: GetStatusesLookupRequestV1) -> TwitterAPISessionJSONTask { - tweet.getLookupStatuses(request) - } - - // MARK: - UserAPIv1 - - /// Retrieves detailed information about multiple users. - /// - Parameter request: The request parameters containing the user identifiers. - /// - Returns: A JSON task that will return the user information. - func getUsers(_ request: GetUsersLookupRequestV1) -> TwitterAPISessionJSONTask { - user.getUsers(request) - } - - /// Retrieves detailed information about a single user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the user information. - func getUser(_ request: GetUsersShowRequestV1) -> TwitterAPISessionJSONTask { - user.getUser(request) - } - - /// Searches for users matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the matching users. - func searchUser(_ request: GetUsersShowRequestV1) -> TwitterAPISessionJSONTask { - user.searchUser(request) - } - - /// Retrieves a user's profile banner. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the banner information. - func getUserProfileBanner(_ request: GetUsersProfileBannerRequestV1) -> TwitterAPISessionJSONTask { - user.getUserProfileBanner(request) - } -} - -extension TwitterAPIv2: TwitterAPI { - // MARK: - BlockAndMuteAPIv2 - - /// Retrieves users blocked by the authenticated user. - /// - Parameter request: The request parameters for retrieving blocked users. - /// - Returns: A JSON task that will return the list of blocked users. - public func getBlockUsers(_ request: GetUsersBlockingRequestV2) -> TwitterAPISessionJSONTask { - blockAndMute.getBlockUsers(request) - } - - /// Blocks a user. - /// - Parameter request: The request parameters containing the user to block. - /// - Returns: A JSON task that will return the response. - public func blockUser(_ request: PostUsersBlockingRequestV2) -> TwitterAPISessionJSONTask { - blockAndMute.blockUser(request) - } - - /// Unblocks a user. - /// - Parameter request: The request parameters containing the user to unblock. - /// - Returns: A JSON task that will return the response. - public func unblockUser(_ request: DeleteUsersBlockingRequestV2) -> TwitterAPISessionJSONTask { - blockAndMute.unblockUser(request) - } - - /// Retrieves users muted by the authenticated user. - /// - Parameter request: The request parameters for retrieving muted users. - /// - Returns: A JSON task that will return the list of muted users. - public func getMuteUsers(_ request: GetUsersMutingRequestV2) -> TwitterAPISessionJSONTask { - blockAndMute.getMuteUsers(request) - } - - /// Mutes a user. - /// - Parameter request: The request parameters containing the user to mute. - /// - Returns: A JSON task that will return the response. - public func muteUser(_ request: PostUsersMutingRequestV2) -> TwitterAPISessionJSONTask { - blockAndMute.muteUser(request) - } - - /// Unmutes a user. - /// - Parameter request: The request parameters containing the user to unmute. - /// - Returns: A JSON task that will return the response. - public func unmuteUser(_ request: DeleteUsersMutingRequestV2) -> TwitterAPISessionJSONTask { - blockAndMute.unmuteUser(request) - } - - // MARK: - BookmarksAPIv2 - - /// Retrieves the authenticated user's bookmarked tweets. - /// - Parameter request: The request parameters for retrieving bookmarks. - /// - Returns: A JSON task that will return the bookmarked tweets. - public func getBookmarks(_ request: GetUsersBookmarksRequestV2) -> TwitterAPISessionJSONTask { - bookmarks.getBookmarks(request) - } - - /// Bookmarks a tweet. - /// - Parameter request: The request parameters containing the tweet to bookmark. - /// - Returns: A JSON task that will return the response. - public func createBookmark(_ request: PostUsersBookmarksRequestV2) -> TwitterAPISessionJSONTask { - bookmarks.createBookmark(request) - } - - /// Removes a tweet from bookmarks. - /// - Parameter request: The request parameters containing the tweet to remove. - /// - Returns: A JSON task that will return the response. - public func deleteBookmark(_ request: DeleteUsersBookmarksRequestV2) -> TwitterAPISessionJSONTask { - bookmarks.deleteBookmark(request) - } - - // MARK: - ComplianceAPIv2 - - /// Retrieves information about a specific compliance job. - /// - Parameter request: The request parameters containing the job ID. - /// - Returns: A JSON task that will return the job information. - public func getComplianceJob(_ request: GetComplianceJobRequestV2) -> TwitterAPISessionJSONTask { - compliance.getComplianceJob(request) - } - - /// Retrieves a list of compliance jobs. - /// - Parameter request: The request parameters for retrieving compliance jobs. - /// - Returns: A JSON task that will return the list of jobs. - public func getComplianceJobj(_ request: GetComplianceJobsRequestV2) -> TwitterAPISessionJSONTask { - compliance.getComplianceJobj(request) - } - - /// Creates a new compliance job. - /// - Parameter request: The request parameters for creating the job. - /// - Returns: A JSON task that will return the created job. - public func createComplianceJob(_ request: PostComplianceJobsRequestV2) -> TwitterAPISessionJSONTask { - compliance.createComplianceJob(request) - } - - // MARK: - FriendshipsAPIv2 - - /// Retrieves users that a specified user is following. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of followed users. - public func getFollowing(_ request: GetUsersFollowingRequestV2) -> TwitterAPISessionJSONTask { - friendships.getFollowing(request) - } - - /// Retrieves followers of a specified user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of followers. - public func getFollowers(_ request: GetUsersFollowersRequestV2) -> TwitterAPISessionJSONTask { - friendships.getFollowers(request) - } - - /// Follows a user. - /// - Parameter request: The request parameters containing the user to follow. - /// - Returns: A JSON task that will return the response. - public func follow(_ request: PostUsersFollowingRequestV2) -> TwitterAPISessionJSONTask { - friendships.follow(request) - } - - /// Unfollows a user. - /// - Parameter request: The request parameters containing the user to unfollow. - /// - Returns: A JSON task that will return the response. - public func unfollow(_ request: DeleteUsersFollowingRequestV2) -> TwitterAPISessionJSONTask { - friendships.unfollow(request) - } - - // MARK: - LikeAPIv2 - - /// Retrieves users who have liked a tweet. - /// - Parameter request: The request parameters containing the tweet ID. - /// - Returns: A JSON task that will return the list of users. - public func getLikingUsers(_ request: GetTweetsLikingUsersRequestV2) -> TwitterAPISessionJSONTask { - like.getLikingUsers(request) - } - - /// Retrieves tweets liked by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list of liked tweets. - public func getLikedTweets(_ request: GetUsersLikedTweetsRequestV2) -> TwitterAPISessionJSONTask { - like.getLikedTweets(request) - } - - /// Likes a tweet. - /// - Parameter request: The request parameters containing the tweet to like. - /// - Returns: A JSON task that will return the response. - public func postLike(_ request: PostUsersLikesRequestV2) -> TwitterAPISessionJSONTask { - like.postLike(request) - } - - /// Unlikes a tweet. - /// - Parameter request: The request parameters containing the tweet to unlike. - /// - Returns: A JSON task that will return the response. - public func deleteLike(_ request: DeleteUsersLikesRequestV2) -> TwitterAPISessionJSONTask { - like.deleteLike(request) - } - - // MARK: - ListAPIv2 - - /// Retrieves tweets from a list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list tweets. - public func getListTweets(_ request: GetListsTweetsRequestV2) -> TwitterAPISessionJSONTask { - list.getListTweets(request) - } - - /// Retrieves information about a specific list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list information. - public func getList(_ request: GetListRequestV2) -> TwitterAPISessionJSONTask { - list.getList(request) - } - - /// Retrieves lists owned by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the owned lists. - public func getLists(_ request: GetUsersOwnedListsRequestV2) -> TwitterAPISessionJSONTask { - list.getLists(request) - } - - /// Follows a list. - /// - Parameter request: The request parameters containing the list to follow. - /// - Returns: A JSON task that will return the response. - public func followList(_ request: PostUsersFollowedListsRequestV2) -> TwitterAPISessionJSONTask { - list.followList(request) - } - - /// Unfollows a list. - /// - Parameter request: The request parameters containing the list to unfollow. - /// - Returns: A JSON task that will return the response. - public func unfollowList(_ request: DeleteUsersFollowedListsRequestV2) -> TwitterAPISessionJSONTask { - list.unfollowList(request) - } - - /// Retrieves followers of a list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list followers. - public func listFollowers(_ request: GetListsFollowersRequestV2) -> TwitterAPISessionJSONTask { - list.listFollowers(request) - } - - /// Retrieves lists followed by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the followed lists. - public func followedLists(_ request: GetUsersFollowedListsRequestV2) -> TwitterAPISessionJSONTask { - list.followedLists(request) - } - - /// Adds a member to a list. - /// - Parameter request: The request parameters containing the user and list. - /// - Returns: A JSON task that will return the response. - public func addListMember(_ request: PostListsMembersRequestV2) -> TwitterAPISessionJSONTask { - list.addListMember(request) - } - - /// Removes a member from a list. - /// - Parameter request: The request parameters containing the user and list. - /// - Returns: A JSON task that will return the response. - public func removeListMember(_ request: DeleteListsMembersRequestV2) -> TwitterAPISessionJSONTask { - list.removeListMember(request) - } - - /// Retrieves lists that a user is a member of. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the list memberships. - public func getListMemberships(_ request: GetUsersListMembershipsRequestV2) -> TwitterAPISessionJSONTask { - list.getListMemberships(request) - } - - /// Retrieves members of a list. - /// - Parameter request: The request parameters containing the list ID. - /// - Returns: A JSON task that will return the list members. - public func getListMembers(_ request: GetListsMembersRequestV2) -> TwitterAPISessionJSONTask { - list.getListMembers(request) - } - - /// Creates a new list. - /// - Parameter request: The request parameters for creating the list. - /// - Returns: A JSON task that will return the created list. - public func createList(_ request: PostListsRequestV2) -> TwitterAPISessionJSONTask { - list.createList(request) - } - - /// Updates a list's metadata. - /// - Parameter request: The request parameters containing the updated information. - /// - Returns: A JSON task that will return the updated list. - public func updateList(_ request: PutListRequestV2) -> TwitterAPISessionJSONTask { - list.updateList(request) - } - - /// Deletes a list. - /// - Parameter request: The request parameters containing the list to delete. - /// - Returns: A JSON task that will return the response. - public func deleteList(_ request: DeleteListRequestV2) -> TwitterAPISessionJSONTask { - list.deleteList(request) - } - - /// Retrieves a user's pinned lists. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the pinned lists. - public func pinnedList(_ request: GetUsersPinnedListsRequestV2) -> TwitterAPISessionJSONTask { - list.pinnedList(request) - } - - /// Pins a list to the user's profile. - /// - Parameter request: The request parameters containing the list to pin. - /// - Returns: A JSON task that will return the response. - public func pinList(_ request: PostUsersPinnedListsRequestV2) -> TwitterAPISessionJSONTask { - list.pinList(request) - } - - /// Unpins a list from the user's profile. - /// - Parameter request: The request parameters containing the list to unpin. - /// - Returns: A JSON task that will return the response. - public func unpinList(_ request: DeleteUsersPinnedListsRequestV2) -> TwitterAPISessionJSONTask { - list.unpinList(request) - } - - // MARK: - RetweetAPIv2 - - /// Retrieves users who have retweeted a tweet. - /// - Parameter request: The request parameters containing the tweet ID. - /// - Returns: A JSON task that will return the list of users. - public func getRetweetedBy(_ request: GetTweetsRetweetedByRequestV2) -> TwitterAPISessionJSONTask { - retweet.getRetweetedBy(request) - } - - /// Creates a retweet of a tweet. - /// - Parameter request: The request parameters containing the tweet to retweet. - /// - Returns: A JSON task that will return the response. - public func postRetweet(_ request: PostUsersRetweetsRequestV2) -> TwitterAPISessionJSONTask { - retweet.postRetweet(request) - } - - /// Removes a retweet of a tweet. - /// - Parameter request: The request parameters containing the retweet to remove. - /// - Returns: A JSON task that will return the response. - public func deleteRetweet(_ request: DeleteUsersRetweetsRequestV2) -> TwitterAPISessionJSONTask { - retweet.deleteRetweet(request) - } - - // MARK: - SearchAPIv2 - - /// Searches for recent tweets matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the matching tweets. - public func searchTweetsRecent(_ request: GetTweetsSearchRecentRequestV2) -> TwitterAPISessionJSONTask { - search.searchTweetsRecent(request) - } - - /// Searches for all tweets matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the matching tweets. - public func searchTweetsAll(_ request: GetTweetsSearchAllRequestV2) -> TwitterAPISessionJSONTask { - search.searchTweetsAll(request) - } - - // MARK: - SpacesAPIv2 - - /// Retrieves information about a specific space. - /// - Parameter request: The request parameters containing the space ID. - /// - Returns: A JSON task that will return the space information. - public func getSpace(_ request: GetSpaceRequestV2) -> TwitterAPISessionJSONTask { - spaces.getSpace(request) - } - - /// Retrieves information about multiple spaces. - /// - Parameter request: The request parameters containing the space IDs. - /// - Returns: A JSON task that will return the spaces information. - public func getSpaces(_ request: GetSpacesRequestV2) -> TwitterAPISessionJSONTask { - spaces.getSpaces(request) - } - - /// Retrieves spaces created by specified users. - /// - Parameter request: The request parameters containing the creator IDs. - /// - Returns: A JSON task that will return the spaces information. - public func getSpacesByCreators(_ request: GetSpacesByCreatorIDsRequestV2) -> TwitterAPISessionJSONTask { - spaces.getSpacesByCreators(request) - } - - /// Retrieves users who have purchased tickets to a space. - /// - Parameter request: The request parameters containing the space ID. - /// - Returns: A JSON task that will return the list of buyers. - public func getSpacesBuyers(_ request: GetSpacesBuyersRequestV2) -> TwitterAPISessionJSONTask { - spaces.getSpacesBuyers(request) - } - - /// Retrieves tweets shared in a space. - /// - Parameter request: The request parameters containing the space ID. - /// - Returns: A JSON task that will return the tweets. - public func getSPacesTweets(_ request: GetSpacesTweetsRequestV2) -> TwitterAPISessionJSONTask { - spaces.getSPacesTweets(request) - } - - /// Searches for spaces matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the matching spaces. - public func searchSpaces(_ request: GetSpacesSearchRequestV2) -> TwitterAPISessionJSONTask { - spaces.searchSpaces(request) - } - - // MARK: - StreamAPIv2 - - /// Connects to the sample stream of tweets. - /// - Parameter request: The request parameters for the sample stream. - /// - Returns: A stream task that will provide tweets in real-time. - public func sampleStream(_ request: GetTweetsSampleStreamRequestV2) -> TwitterAPISessionStreamTask { - stream.sampleStream(request) - } - - /// Retrieves rules for filtered stream. - /// - Parameter request: The request parameters for retrieving stream rules. - /// - Returns: A JSON task that will return the stream rules. - public func getSearchStreamRules(_ request: GetTweetsSearchStreamRulesRequestV2) -> TwitterAPISessionJSONTask { - stream.getSearchStreamRules(request) - } - - /// Updates rules for filtered stream. - /// - Parameter request: The request parameters containing the rule updates. - /// - Returns: A JSON task that will return the updated rules. - public func postSearchStreamRules(_ request: PostTweetsSearchStreamRulesRequestV2) -> TwitterAPISessionJSONTask { - stream.postSearchStreamRules(request) - } - - /// Connects to the filtered stream of tweets. - /// - Parameter request: The request parameters for the filtered stream. - /// - Returns: A stream task that will provide filtered tweets in real-time. - public func searchStream(_ request: GetTweetsSearchStreamRequestV2) -> TwitterAPISessionStreamTask { - stream.searchStream(request) - } - - // MARK: - TimelineAPIv2 - - /// Retrieves tweets posted by a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the user's tweets. - public func getUserTweets(_ request: GetUsersTweetsRequestV2) -> TwitterAPISessionJSONTask { - timeline.getUserTweets(request) - } - - /// Retrieves tweets mentioning a user. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the mentions. - public func getUserMensions(_ request: GetUsersMentionsRequestV2) -> TwitterAPISessionJSONTask { - timeline.getUserMensions(request) - } - - /// Retrieves a user's reverse chronological timeline. - /// - Parameter request: The request parameters containing the user identifier. - /// - Returns: A JSON task that will return the timeline tweets. - public func getUserReverseChronological(_ request: GetUsersTimelinesReverseChronologicalRequestV2) - -> TwitterAPISessionJSONTask - { - timeline.getUserReverseChronological(request) - } - - // MARK: - TweetAPIv2 - - /// Retrieves multiple tweets by their IDs. - /// - Parameter request: The request parameters containing the tweet IDs. - /// - Returns: A JSON task that will return the tweets. - public func getTweets(_ request: GetTweetsRequestV2) -> TwitterAPISessionJSONTask { - tweet.getTweets(request) - } - - /// Retrieves a single tweet. - /// - Parameter request: The request parameters containing the tweet ID. - /// - Returns: A JSON task that will return the tweet. - public func getTweet(_ request: GetTweetRequestV2) -> TwitterAPISessionJSONTask { - tweet.getTweet(request) - } - - /// Retrieves tweets quoting a tweet. - /// - Parameter request: The request parameters containing the tweet ID. - /// - Returns: A JSON task that will return the quote tweets. - public func getQuoteTweets(_ request: GetTweetsQuoteTweetsRequestV2) -> TwitterAPISessionJSONTask { - tweet.getQuoteTweets(request) - } - - /// Deletes a tweet. - /// - Parameter request: The request parameters containing the tweet to delete. - /// - Returns: A JSON task that will return the response. - public func deleteTweet(_ request: DeleteTweetRequestV2) -> TwitterAPISessionJSONTask { - tweet.deleteTweet(request) - } - - /// Posts a new tweet. - /// - Parameter request: The request parameters containing the tweet content. - /// - Returns: A JSON task that will return the posted tweet. - public func postTweet(_ request: PostTweetsRequestV2) -> TwitterAPISessionJSONTask { - tweet.postTweet(request) - } - - /// Hides a reply to a tweet. - /// - Parameter request: The request parameters containing the reply to hide. - /// - Returns: A JSON task that will return the response. - public func hideReply(_ request: PutTweetsHiddenRequestV2) -> TwitterAPISessionJSONTask { - tweet.hideReply(request) - } - - // MARK: - TweetCountAPIv2 - - /// Retrieves count of recent tweets matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the tweet count. - public func getTweetCountRecent(_ request: GetTweetsCountsRecentRequestV2) -> TwitterAPISessionJSONTask { - tweetCount.getTweetCountRecent(request) - } - - /// Retrieves count of all tweets matching a query. - /// - Parameter request: The request parameters containing the search query. - /// - Returns: A JSON task that will return the tweet count. - public func getTweetCountAll(_ request: GetTweetsCountsAllRequestV2) -> TwitterAPISessionJSONTask { - tweetCount.getTweetCountAll(request) - } - - // MARK: - UserAPIv2 - - /// Retrieves information about a specific user. - /// - Parameter request: The request parameters containing the user ID. - /// - Returns: A JSON task that will return the user information. - public func getUser(_ request: GetUserRequestV2) -> TwitterAPISessionJSONTask { - user.getUser(request) - } - - /// Retrieves information about multiple users. - /// - Parameter request: The request parameters containing the user IDs. - /// - Returns: A JSON task that will return the users information. - public func getUsers(_ request: GetUsersRequestV2) -> TwitterAPISessionJSONTask { - user.getUsers(request) - } - - /// Retrieves a user by their username. - /// - Parameter request: The request parameters containing the username. - /// - Returns: A JSON task that will return the user information. - public func getUserByUsername(_ request: GetUsersByUsernameRequestV2) -> TwitterAPISessionJSONTask { - user.getUserByUsername(request) - } - - /// Retrieves multiple users by their usernames. - /// - Parameter request: The request parameters containing the usernames. - /// - Returns: A JSON task that will return the users information. - public func getUsersByUsernames(_ request: GetUsersByRequestV2) -> TwitterAPISessionJSONTask { - user.getUsersByUsernames(request) - } - - /// Retrieves information about the authenticated user. - /// - Parameter request: The request parameters for retrieving user information. - /// - Returns: A JSON task that will return the user information. - public func getMe(_ request: GetUsersMeRequestV2) -> TwitterAPISessionJSONTask { - user.getMe(request) - } - - // MARK: - DirectMessageAPIv2 - - /// Retrieves direct message events. - /// - Parameter request: The request parameters for retrieving DM events. - /// - Returns: A JSON task that will return the DM events. - public func getDmEvents(_ request: GetDmEventsRequestV2) -> TwitterAPISessionJSONTask { - dm.getDmEvents(request) - } - - /// Retrieves direct message events with a specific participant. - /// - Parameter request: The request parameters containing the participant ID. - /// - Returns: A JSON task that will return the DM events. - public func getDmEventsWithParticipantId(_ request: GetDmConversationsWithParticipantIdDmEventsRequestV2) - -> TwitterAPISessionJSONTask - { - dm.getDmEventsWithParticipantId(request) - } - - /// Retrieves direct message events from a specific conversation. - /// - Parameter request: The request parameters containing the conversation ID. - /// - Returns: A JSON task that will return the DM events. - public func getDmEventsByConversationsId( - _ request: GetDmConversationsIdDmEventsRequestV2 - ) -> TwitterAPISessionJSONTask { - dm.getDmEventsByConversationsId(request) - } - - /// Posts a new direct message conversation. - /// - Parameter request: The request parameters for creating a new conversation. - /// - Returns: A JSON task that will return the created conversation. - public func postDmConversationById(_ request: PostDmConversationByIdRequestV2) -> TwitterAPISessionJSONTask { - dm.postDmConversationById(request) - } - - /// Posts a new direct message conversation with a specific user. - /// - Parameter request: The request parameters containing the user and message. - /// - Returns: A JSON task that will return the created conversation. - public func postDmConversationWithUser( - _ request: PostDmConversationWithUserRequestV2 - ) -> TwitterAPISessionJSONTask { - dm.postDmConversationWithUser(request) - } - - /// Posts a new direct message conversation with multiple participants. - /// - Parameter request: The request parameters containing the participants and message. - /// - Returns: A JSON task that will return the created conversation. - public func postDmConversation(_ request: PostDmConversationRequestV2) -> TwitterAPISessionJSONTask { - dm.postDmConversation(request) - } -} diff --git a/Sources/TwitterAPIKit/TwitterAPIClient.swift b/Sources/TwitterAPIKit/TwitterAPIClient.swift deleted file mode 100644 index fd2c9dd7..00000000 --- a/Sources/TwitterAPIKit/TwitterAPIClient.swift +++ /dev/null @@ -1,219 +0,0 @@ -// TwitterAPIClient.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Main client class for interacting with the Twitter API. -/// This class provides access to both v1.1 and v2 Twitter APIs, as well as authentication endpoints. -/// It handles authentication, request signing, and provides specialized API clients for different Twitter features. -open class TwitterAPIClient { - /// Default JSON decoder configured for Twitter API responses. - /// This decoder handles both v1 and v2 date formats and uses snake_case key decoding. - public static var defaultJSONDecoder: JSONDecoder = { - let decoder = JSONDecoder() - decoder.keyDecodingStrategy = .convertFromSnakeCase - - // for v1 - let dateFormatterV1 = DateFormatter() - dateFormatterV1.locale = Locale(identifier: "en_US_POSIX") - dateFormatterV1.dateFormat = "EEE MMM dd HH:mm:ss Z yyyy" - - // for v2 - let dateFormatterV2 = DateFormatter() - dateFormatterV2.locale = Locale(identifier: "en_hUS_POSIX") - dateFormatterV2.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" - - decoder.dateDecodingStrategy = .custom { decoder -> Date in - let container = try decoder.singleValueContainer() - let dateStr = try container.decode(String.self) - - if let date = dateFormatterV1.date(from: dateStr) { - return date - } - - if let date = dateFormatterV2.date(from: dateStr) { - return date - } - throw DecodingError.dataCorrupted( - .init(codingPath: decoder.codingPath, debugDescription: "Unexpected date format: \(dateStr)") - ) - } - - return decoder - }() - - /// Client for handling Twitter authentication flows (OAuth 1.0a and OAuth 2.0). - public let auth: TwitterAuthAPI - - /// Client for accessing Twitter API v1.1 endpoints. - public let v1: TwitterAPIv1 - - /// Client for accessing Twitter API v2 endpoints. - public let v2: TwitterAPIv2 - - /// The session used for making API requests. - public let session: TwitterAPISession - - /// The current authentication method being used. - public var apiAuth: TwitterAuthenticationMethod { - session.auth - } - - /// Client used for refreshing OAuth 2.0 tokens. - private var refreshOAuth20TokenClient: TwitterAPIClient? - - /// Creates a new TwitterAPIClient instance. - /// - Parameters: - /// - auth: The authentication method to use for API requests. - /// - configuration: The URLSession configuration to use. Defaults to .default. - /// - environment: The Twitter API environment configuration. Defaults to standard Twitter endpoints. - public init( - _ auth: TwitterAuthenticationMethod, - configuration: URLSessionConfiguration = .default, - environment: TwitterAPIEnvironment = .init() - ) { - session = TwitterAPISession( - auth: auth, - configuration: configuration, - environment: environment - ) - self.auth = TwitterAuthAPI(session: session) - v1 = TwitterAPIv1(session: session) - v2 = TwitterAPIv2(session: session) - } - - /// Convenience initializer for OAuth 1.0a authentication. - /// - Parameters: - /// - consumerKey: The application's consumer key. - /// - consumerSecret: The application's consumer secret. - /// - oauthToken: The user's OAuth token. - /// - oauthTokenSecret: The user's OAuth token secret. - public convenience init( - consumerKey: String, - consumerSecret: String, - oauthToken: String, - oauthTokenSecret: String - ) { - self.init( - .oauth10a( - .init( - consumerKey: consumerKey, - consumerSecret: consumerSecret, - oauthToken: oauthToken, - oauthTokenSecret: oauthTokenSecret - ) - ), - environment: .init() - ) - } - - deinit { - // De-init Logic Here - } -} - -// MARK: - Refresh OAuth2.0 token - -/// Extension providing OAuth 2.0 token refresh functionality. -public extension TwitterAPIClient { - /// Type alias for the result of a token refresh operation. - typealias RefreshOAuth20TokenResultValue = (token: TwitterAuthenticationMethod.OAuth20, refreshed: Bool) - - /// Refreshes the OAuth 2.0 access token if necessary. - /// - Parameters: - /// - type: The type of OAuth 2.0 client to use for token refresh. - /// - forceRefresh: Whether to force a token refresh even if the current token is still valid. - /// - block: Completion handler called with the result of the token refresh. - func refreshOAuth20Token( - type: TwitterAuthenticationMethod.OAuth20WithPKCEClientType, - forceRefresh: Bool = false, - _ block: @escaping (Result) -> Void - ) { - guard let (refreshToken, token) = handleBlockGuards(forceRefresh: forceRefresh, block) else { - return - } - - let refreshOAuth20TokenClient = TwitterAPIClient( - .requestOAuth20WithPKCE(type), - configuration: session.session.configuration, - environment: session.environment - ) - self.refreshOAuth20TokenClient = refreshOAuth20TokenClient - refreshOAuth20TokenClient.auth.oauth20.postOAuth2RefreshToken( - .init(refreshToken: refreshToken, clientID: token.clientID) - ) - .responseObject { [weak self] response in - guard let self else { return } - switch response.result { - case let .success(refreshedToken): - var token = token - token.refresh(token: refreshedToken) - session.refreshOAuth20Token(token) - block(.success((token: token, refreshed: true))) - NotificationCenter.default.post( - name: TwitterAPIClient.didRefreshOAuth20Token, - object: self, - userInfo: [TwitterAPIClient.tokenUserInfoKey: token] - ) - case let .failure(error): - block(.failure(error)) - } - self.refreshOAuth20TokenClient = nil - } - } - - /// Handles Block Guards for `refreshOAuth20Token` - func handleBlockGuards( - forceRefresh: Bool = false, - _ block: @escaping (Result) -> Void - ) -> (String, TwitterAuthenticationMethod.OAuth20)? { - guard case let .oauth20(token) = apiAuth else { - block(.failure(.refreshOAuth20TokenFailed(reason: .invalidAuthenticationMethod(apiAuth)))) - return nil - } - - guard let refreshToken = token.refreshToken else { - block(.failure(.refreshOAuth20TokenFailed(reason: .refreshTokenIsMissing))) - return nil - } - - if !forceRefresh, !token.expired { - block(.success((token: token, refreshed: false))) - return nil - } - - return (refreshToken, token) - } -} - -/// Base class for Twitter API clients. -/// Provides common functionality and session management for API clients. -open class TwitterAPIBase { - /// The session used for making API requests. - public let session: TwitterAPISession - - /// Creates a new TwitterAPIBase instance. - /// - Parameter session: The session to use for making API requests. - public init(session: TwitterAPISession) { - self.session = session - } - - deinit { - // De-init Logic Here - } -} - -/// Extension providing notification names and user info keys for OAuth 2.0 token refresh events. -public extension TwitterAPIClient { - /// Notification posted when an OAuth 2.0 token is refreshed. - static let didRefreshOAuth20Token = Notification - .Name(rawValue: "TwitterAPIKit.TwitterAPIClient.Notification.didRefreshOAuth20Token") - - /// User info key for accessing the refreshed token in the notification. - static let tokenUserInfoKey = "TwitterAPIKit.TwitterAPIClient.UserInfoKey.tokenUser" -} diff --git a/Sources/TwitterAPIKit/TwitterAPIErrorResponse.swift b/Sources/TwitterAPIKit/TwitterAPIErrorResponse.swift deleted file mode 100644 index ebd39902..00000000 --- a/Sources/TwitterAPIKit/TwitterAPIErrorResponse.swift +++ /dev/null @@ -1,239 +0,0 @@ -// TwitterAPIErrorResponse.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Represents error responses from the Twitter API. -/// This enum can handle both v1 and v2 API error formats, as well as unknown error responses. -public enum TwitterAPIErrorResponse: Equatable { - /// An error response from the Twitter API v1.1. - case apiVersion1(TwitterAPIErrorResponseV1) - - /// An error response from the Twitter API v2. - case apiVersion2(TwitterAPIErrorResponseV2) - - /// An unknown error response containing raw data. - case unknown(Data) - - /// Creates a new TwitterAPIErrorResponse from raw response data. - /// Attempts to parse the data as either a v1 or v2 error response. - /// - Parameter data: The raw response data from the Twitter API. - public init(data: Data) { - guard let obj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { - self = .unknown(data) - return - } - - if let version1 = TwitterAPIErrorResponseV1(obj: obj) { - self = .apiVersion1(version1) - } else if let version2 = TwitterAPIErrorResponseV2(obj: obj) { - self = .apiVersion2(version2) - } else { - self = .unknown(data) - } - } -} - -public extension TwitterAPIErrorResponse { - /// The error message from the response. - /// For v1 errors, this is the first error message. - /// For v2 errors, this is the detail field. - /// For unknown errors, this is the raw data as a string. - var message: String { - switch self { - case let .apiVersion1(version1Response): - version1Response.message - case let .apiVersion2(version2Response): - version2Response.detail - case let .unknown(data): - String(data: data, encoding: .utf8) ?? "Unknown" - } - } - - /// The error code from the response. - /// Only available for v1 errors. - var code: Int? { - if case let .apiVersion1(version1) = self { - return version1.code - } - return nil - } - - /// Indicates whether this is a v1 error response. - var isVersion1: Bool { - version1 != nil - } - - /// The v1 error response if this is a v1 error, nil otherwise. - var version1: TwitterAPIErrorResponseV1? { - if case let .apiVersion1(version1) = self { - return version1 - } - return nil - } - - /// Indicates whether this is a v2 error response. - var isVersion2: Bool { - version2 != nil - } - - /// The v2 error response if this is a v2 error, nil otherwise. - var version2: TwitterAPIErrorResponseV2? { - if case let .apiVersion2(version2) = self { - return version2 - } - return nil - } - - /// Indicates whether this is an unknown error response. - var isUnknown: Bool { - unknownData != nil - } - - /// The raw data if this is an unknown error, nil otherwise. - var unknownData: Data? { - if case let .unknown(data) = self { - return data - } - return nil - } -} - -/// Represents an error response from the Twitter API v1.1. -/// Format: {"errors":[{"message":"Sorry, that page does not exist","code":34}]} -public struct TwitterAPIErrorResponseV1 { - /// The first error message in the response. - public let message: String - - /// The first error code in the response. - public let code: Int - - /// All errors included in the response. - public let errors: [Self] - - /// Creates a new TwitterAPIErrorResponseV1. - /// - Parameters: - /// - message: The error message. - /// - code: The error code. - /// - errors: Additional errors in the response. - public init(message: String, code: Int, errors: [Self]) { - self.message = message - self.code = code - self.errors = errors - } - - /// Creates a new TwitterAPIErrorResponseV1 from a dictionary. - /// - Parameter obj: A dictionary containing the error response data. - /// - Returns: An initialized error response if the dictionary contains valid data, nil otherwise. - public init?(obj: [String: Any]) { - guard let errors = obj["errors"] as? [[String: Any]] else { - return nil - } - - let tErrors: [Self] = errors.compactMap { error in - guard let message = error["message"] as? String, let code = error["code"] as? Int else { return nil } - return Self(message: message, code: code, errors: []) - } - - guard !tErrors.isEmpty else { - return nil - } - - message = tErrors[0].message - code = tErrors[0].code - self.errors = tErrors - } - - /// Checks if this error response contains a specific error code. - /// - Parameter code: The error code to check for. - /// - Returns: true if the error code is present in this response or any nested errors. - public func contains(code: Int) -> Bool { - code == self.code || errors.contains { $0.code == code } - } -} - -extension TwitterAPIErrorResponseV1: Equatable {} - -/// https://developer.twitter.com/en/support/twitter-api/error-troubleshooting -/// Represents an error response from the Twitter API v2. -/// See: https://developer.twitter.com/en/support/twitter-api/error-troubleshooting -public struct TwitterAPIErrorResponseV2 { - /// Represents a specific error in a v2 error response. - public struct Error: Equatable { - /// The error message. - public let message: String - - /// Additional parameters associated with the error. - public let parameters: [String: [String]] - - /// Creates a new Error. - /// - Parameters: - /// - message: The error message. - /// - parameters: Additional parameters describing the error. - public init(message: String, parameters: [String: [String]]) { - self.message = message - self.parameters = parameters - } - - /// Creates a new Error from a dictionary. - /// - Parameter obj: A dictionary containing the error data. - public init(obj: [String: Any]) { - message = obj["message"].map { String(describing: $0) } ?? "" - parameters = (obj["parameters"] as? [String: [String]]) ?? [:] - } - } - - /// The title of the error. - public let title: String - - /// A detailed description of the error. - public let detail: String - - /// The type of error. - public let type: String - - /// Specific errors included in the response. - public let errors: [Error] - - /// Creates a new TwitterAPIErrorResponseV2. - /// - Parameters: - /// - title: The error title. - /// - detail: The detailed error description. - /// - type: The error type. - /// - errors: Specific errors included in the response. - public init( - title: String, - detail: String, - type: String, - errors: [Error] - ) { - self.title = title - self.detail = detail - self.type = type - self.errors = errors - } - - /// Creates a new TwitterAPIErrorResponseV2 from a dictionary. - /// - Parameter obj: A dictionary containing the error response data. - /// - Returns: An initialized error response if the dictionary contains valid data, nil otherwise. - public init?(obj: [String: Any]) { - guard let title = obj["title"] as? String, - let detail = obj["detail"] as? String, - let type = obj["type"] as? String - else { - return nil - } - - self.title = title - self.detail = detail - self.type = type - errors = ((obj["errors"] as? [[String: Any]]) ?? []).map { Error(obj: $0) } - } -} - -extension TwitterAPIErrorResponseV2: Equatable {} diff --git a/Sources/TwitterAPIKit/TwitterAPIKitError.swift b/Sources/TwitterAPIKit/TwitterAPIKitError.swift index 9f6b38a8..a8eb9572 100644 --- a/Sources/TwitterAPIKit/TwitterAPIKitError.swift +++ b/Sources/TwitterAPIKit/TwitterAPIKitError.swift @@ -8,359 +8,64 @@ import Foundation -/// Represents errors that can occur while using the Twitter API Kit. +/// Represents errors that can occur in the Twitter API Kit. public enum TwitterAPIKitError: Error { - /// Represents specific reasons why a request might fail. - public enum RequestFailureReason { - /// Indicates that a string could not be encoded to data. - case cannotEncodeStringToData(string: String) - - /// Indicates that a parameter was invalid with details about why. - case invalidParameter(parameter: [String: Any], cause: String) - - /// Indicates that the provided URL was invalid. - case invalidURL(url: String) - - /// Indicates that JSON serialization failed for an object. - case jsonSerializationFailed(obj: Any) - } - - /// Represents specific reasons why a response might fail. - public enum ResponseFailureReason { - /// Indicates that the response was invalid. - case invalidResponse(error: Error?) - - /// Indicates that the response status code was unacceptable. - case unacceptableStatusCode(statusCode: Int, error: TwitterAPIErrorResponse, rateLimit: TwitterRateLimit?) - } - - /// Represents specific reasons why response serialization might fail. - public enum ResponseSerializationFailureReason { - /// Indicates that data could not be converted to the expected type. - case cannotConvert(data: Data, toTypeName: String) - - /// Indicates that JSON decoding failed. - case jsonDecodeFailed(error: Error) - - /// Indicates that JSON serialization failed. - case jsonSerializationFailed(error: Error) - } - - /// Represents specific reasons why OAuth 2.0 token refresh might fail. - public enum RefreshOAuth20TokenFailureReason { - /// Indicates that the authentication method was invalid. - case invalidAuthenticationMethod(TwitterAuthenticationMethod) - - /// Indicates that the refresh token is missing. - case refreshTokenIsMissing - } - - /// Represents specific reasons why media upload might fail. - public enum UploadMediaFailureReason { - /// Indicates that media processing failed. - case processingFailed(error: UploadMediaError) - } - - case refreshOAuth20TokenFailed(reason: RefreshOAuth20TokenFailureReason) + case apiError(TwitterAPIError) case requestFailed(reason: RequestFailureReason) case responseFailed(reason: ResponseFailureReason) - case responseSerializeFailed(reason: ResponseSerializationFailureReason) - case unkonwn(error: Error) - case uploadMediaFailed(reason: UploadMediaFailureReason) - - /// Initializes a TwitterAPIKitError from a generic Error. - /// - Parameter error: The error to convert to TwitterAPIKitError. - public init(error: Error) { - if let error = error as? Self { - self = error - } else { - self = .unkonwn(error: error) - } - } -} - -public extension TwitterAPIKitError { - /// Indicates whether the error is a request failure. - var isRequestFailed: Bool { - if case .requestFailed = self { return true } - return false - } - - /// Indicates whether the error is a response failure. - var isResponseFailed: Bool { - if case .responseFailed = self { return true } - return false - } - - /// Indicates whether the error is a response serialization failure. - var isResponseSerializeFailed: Bool { - if case .responseSerializeFailed = self { return true } - return false - } - - /// Indicates whether the error is a media upload failure. - var isUploadMediaFailed: Bool { - if case .uploadMediaFailed = self { return true } - return false - } - - /// Indicates whether the error is an OAuth 2.0 token refresh failure. - var isRefreshOAuth20TokenFailed: Bool { - if case .refreshOAuth20TokenFailed = self { return true } - return false - } - - /// Indicates whether the error is unknown. - var isUnkonwn: Bool { - if case .unkonwn = self { return true } - return false - } - - /// The underlying error if one exists. - var underlyingError: Error? { - switch self { - case let .requestFailed(reason): - reason.underlyingError - case let .responseFailed(reason): - reason.underlyingError - case let .responseSerializeFailed(reason): - reason.underlyingError - case let .uploadMediaFailed(reason): - reason.underlyingError - case let .refreshOAuth20TokenFailed(reason): - reason.underlyingError - case let .unkonwn(error): - error - } - } - - /// Indicates whether the error was due to request cancellation. - var isCancelled: Bool { - guard let error = underlyingError as? URLError else { - return false - } - return error.code == .cancelled - } -} - -public extension TwitterAPIKitError { - /// Represents an error that occurred during media upload. - struct UploadMediaError: Decodable, Error { - /// The error code returned by the Twitter API. - public let code: Int - - /// The name of the error. - public let name: String - - /// A detailed message describing the error. - public let message: String - - /// Initializes a new UploadMediaError. - /// - Parameters: - /// - code: The error code - /// - name: The error name - /// - message: The error message - public init(code: Int, name: String, message: String) { - self.code = code - self.name = name - self.message = message - } - } -} - -extension TwitterAPIKitError: LocalizedError { - public var errorDescription: String? { - switch self { - case let .requestFailed(reason): - reason.localizedDescription - case let .responseFailed(reason): - reason.localizedDescription - case let .responseSerializeFailed(reason): - reason.localizedDescription - case let .uploadMediaFailed(reason): - reason.localizedDescription - case let .refreshOAuth20TokenFailed(reason): - reason.localizedDescription - case let .unkonwn(error): - error.localizedDescription - } - } -} - -extension TwitterAPIKitError.UploadMediaError: LocalizedError { - /// A localized description of the error. - public var errorDescription: String? { - "\(name)[code:\(code)]: \(message)" - } -} -public extension TwitterAPIKitError.RequestFailureReason { - /// A localized description of the request failure reason. - var localizedDescription: String { - switch self { - case let .invalidURL(url): - "URL is not valid: \(url)" - case let .invalidParameter(parameter, cause): - "Parameter is not valid: \(parameter), cause: \(cause)" - case let .cannotEncodeStringToData(string): - "Could not encode \"\(string)\"" - case let .jsonSerializationFailed(obj): - "JSON could not be serialized. May be invalid object \(String(describing: obj))" - } + public enum RequestFailureReason: Sendable { + case cannotEncodeStringToData(string: String) + case invalidParameter(parameter: String, cause: String) + case invalidURL(url: String) + case jsonSerializationFailed(obj: String) } - /// The underlying error if one exists. - var underlyingError: Error? { - switch self { - case .invalidURL, - .invalidParameter, - .cannotEncodeStringToData, - .jsonSerializationFailed: - nil - } + public enum ResponseFailureReason: Sendable { + case invalidResponse(response: URLResponse) + case responseSerializationFailed(reason: String) + case unacceptableStatusCode(statusCode: Int, response: HTTPURLResponse) } } -public extension TwitterAPIKitError.ResponseFailureReason { - /// A localized description of the response failure reason. - var localizedDescription: String { - switch self { - case let .invalidResponse(error: error): - if let error { - return "Response is invalid: \(error.localizedDescription)" +/// Represents errors returned by the Twitter API. +public struct TwitterAPIError: Error, Decodable { + public enum ErrorType { + case rateLimit + case unauthorized + case forbidden + case notFound + case serverError + case unknown + + public init(from statusCode: Int) { + switch statusCode { + case 401: + self = .unauthorized + case 403: + self = .forbidden + case 404: + self = .notFound + case 429: + self = .rateLimit + case 500...599: + self = .serverError + default: + self = .unknown } - return "Response is invalid" - case let .unacceptableStatusCode(statusCode, error: error, rateLimit: _): - return "Response status code was unacceptable: \(statusCode) with message: \(error.message)" - } - } - - /// The underlying error if one exists. - var underlyingError: Error? { - switch self { - case let .invalidResponse(error: error): - error - case .unacceptableStatusCode: - nil - } - } - - /// The status code in the case of unacceptableStatusCode. - var statusCode: Int? { - if case .unacceptableStatusCode(statusCode: let statusCode, error: _, rateLimit: _) = self { - return statusCode - } - return nil - } - - /// The rate limit in the case of unacceptableStatusCode. - var rateLimit: TwitterRateLimit? { - if case .unacceptableStatusCode(statusCode: _, error: _, rateLimit: let rateLimit) = self { - return rateLimit - } - return nil - } -} - -public extension TwitterAPIKitError.ResponseSerializationFailureReason { - /// A localized description of the response serialization failure reason. - var localizedDescription: String { - switch self { - case let .jsonSerializationFailed(error): - "Response could not be serialized because of error:\n\(error.localizedDescription)" - case let .jsonDecodeFailed(error): - "Response could not be decoded because of error:\n\(error.localizedDescription)" - case .cannotConvert(data: _, let toTypeName): - "Response could not convert to \"\(toTypeName)\"" - } - } - - /// The underlying error if one exists. - var underlyingError: Error? { - switch self { - case let .jsonSerializationFailed(error: error), - let .jsonDecodeFailed(error: error): - error - case .cannotConvert: - nil - } - } -} - -public extension TwitterAPIKitError.UploadMediaFailureReason { - /// A localized description of the upload media failure reason. - var localizedDescription: String { - switch self { - case let .processingFailed(error): - error.message - } - } - - /// The underlying error if one exists. - var underlyingError: Error? { - switch self { - case let .processingFailed(error: error): - error - } - } -} - -public extension TwitterAPIKitError.RefreshOAuth20TokenFailureReason { - /// A localized description of the refresh OAuth 2.0 token failure reason. - var localizedDescription: String { - switch self { - case let .invalidAuthenticationMethod(method): - """ - Token refresh is possible only when TwitterAuthenticationMethod is .oauth20. \ - You are currently \(method). - """ - case .refreshTokenIsMissing: - "Refresh token is missing." - } - } - - /// The underlying error if one exists. - var underlyingError: Error? { - switch self { - case .invalidAuthenticationMethod, .refreshTokenIsMissing: - nil } } -} - -public extension TwitterAPIKitError { - /// Returns the request failure reason if this error represents a request failure. - /// - Returns: The `RequestFailureReason` if present, nil otherwise. - var requestFailureReason: RequestFailureReason? { - guard case let .requestFailed(reason: reason) = self else { return nil } - return reason - } - /// Returns the response failure reason if this error represents a response failure. - /// - Returns: The `ResponseFailureReason` if present, nil otherwise. - var responseFailureReason: ResponseFailureReason? { - guard case let .responseFailed(reason) = self else { return nil } - return reason - } - - /// Returns the response serialization failure reason if this error represents a serialization failure. - /// - Returns: The `ResponseSerializationFailureReason` if present, nil otherwise. - var responseSerializationFailureReason: ResponseSerializationFailureReason? { - guard case let .responseSerializeFailed(reason) = self else { return nil } - return reason - } + public let title: String + public let type: String + public let status: Int + public let detail: String - /// Returns the OAuth 2.0 token refresh failure reason if this error represents a token refresh failure. - /// - Returns: The `RefreshOAuth20TokenFailureReason` if present, nil otherwise. - var refreshOAuth20TokenFailureReason: RefreshOAuth20TokenFailureReason? { - guard case let .refreshOAuth20TokenFailed(reason) = self else { return nil } - return reason + public var errorType: ErrorType { + ErrorType(from: status) } - /// Returns the upload media failure reason if this error represents a media upload failure. - /// - Returns: The `UploadMediaFailureReason` if present, nil otherwise. - var uploadMediaFailureReason: UploadMediaFailureReason? { - guard case let .uploadMediaFailed(reason) = self else { return nil } - return reason + public var localizedDescription: String { + return "(\(status)) \(title): \(detail) \(errorType)" } } diff --git a/Sources/TwitterAPIKit/TwitterAPIRequest.swift b/Sources/TwitterAPIKit/TwitterAPIRequest.swift index 57cbb87c..e0365338 100644 --- a/Sources/TwitterAPIKit/TwitterAPIRequest.swift +++ b/Sources/TwitterAPIKit/TwitterAPIRequest.swift @@ -95,6 +95,8 @@ extension MultipartFormDataPart: Equatable { /// Protocol defining the requirements for a Twitter API request. public protocol TwitterAPIRequest { + /// The Response Type From Twitter + associatedtype Response: Decodable /// The HTTP method to be used for the request. var method: HTTPMethod { get } @@ -151,6 +153,14 @@ public extension TwitterAPIRequest { } } +extension Dictionary where Key == String { + /// Encodes a dictionary + public var urlEncodedQueryString: String { + map { "\($0.key.urlEncoded)=\(String(describing: $0.value).urlEncoded)" } + .joined(separator: "&") + } +} + // swiftlint:disable function_body_length public extension TwitterAPIRequest { /// Builds a URL request for the given environment. @@ -170,7 +180,7 @@ public extension TwitterAPIRequest { urlComponent.percentEncodedQueryItems = queryParameters .sorted { first, second in first.key < second.key } - .map { .init(name: $0.urlEncodedString, value: "\($1)".urlEncodedString) } + .map { .init(name: $0.urlEncoded, value: "\($1)".urlEncoded) } } guard let url = urlComponent.url else { @@ -189,11 +199,10 @@ public extension TwitterAPIRequest { } request.httpBody = data case .multipartFormData: - guard let parts = Array(bodyParameters.values) as? [MultipartFormDataPart] else { throw TwitterAPIKitError.requestFailed( reason: .invalidParameter( - parameter: bodyParameters, + parameter: String(describing: bodyParameters), cause: """ Parameter must be specified in `MultipartFormDataPart` \ for `BodyContentType.multipartFormData`. @@ -213,20 +222,22 @@ public extension TwitterAPIRequest { String(request.httpBody?.count ?? 0), forHTTPHeaderField: "Content-Length" ) case .json: - let param = bodyParameters guard JSONSerialization.isValidJSONObject(param) else { - throw TwitterAPIKitError.requestFailed(reason: .jsonSerializationFailed(obj: param)) + throw TwitterAPIKitError.requestFailed( + reason: .jsonSerializationFailed(obj: String(describing: param)) + ) } do { request.httpBody = try JSONSerialization.data( withJSONObject: param, options: [] ) request.setValue(bodyContentType.rawValue, forHTTPHeaderField: "Content-Type") - } catch { // This path probably won't pass because it is pre-checked with `isValidJSONObject`. - throw TwitterAPIKitError.requestFailed(reason: .jsonSerializationFailed(obj: param)) + throw TwitterAPIKitError.requestFailed( + reason: .jsonSerializationFailed(obj: String(describing: param)) + ) } } } diff --git a/Sources/TwitterAPIKit/TwitterAPIResponse.swift b/Sources/TwitterAPIKit/TwitterAPIResponse.swift deleted file mode 100644 index 9514da5e..00000000 --- a/Sources/TwitterAPIKit/TwitterAPIResponse.swift +++ /dev/null @@ -1,198 +0,0 @@ -// TwitterAPIResponse.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// A generic response type that encapsulates the result of a Twitter API request. -public struct TwitterAPIResponse { - /// The original URL request that was sent to the Twitter API. - public let request: URLRequest? - - /// The HTTP response received from the Twitter API. - public let response: HTTPURLResponse? - - /// The raw data received in the response. - public let data: Data? - - /// The result of the API call, containing either the successful response or an error. - public let result: Result - - /// Rate limit information returned by the Twitter API. - public let rateLimit: TwitterRateLimit? - - /// The successful response value if the request succeeded, nil otherwise. - public var success: Success? { result.success } - - /// The error that occurred during the request, if any. - public var error: TwitterAPIKitError? { result.error } - - /// A boolean indicating whether the request resulted in an error. - public var isError: Bool { error != nil } - - /// Creates a new TwitterAPIResponse instance. - /// - Parameters: - /// - request: The original URL request sent to the API. - /// - response: The HTTP response received from the API. - /// - data: The raw data received in the response. - /// - result: The result containing either success or error. - /// - rateLimit: Rate limit information from the API. - public init( - request: URLRequest?, - response: HTTPURLResponse?, - data: Data?, - result: Result, - rateLimit: TwitterRateLimit? - ) { - self.request = request - self.response = response - self.data = data - self.result = result - self.rateLimit = rateLimit - } -} - -public extension TwitterAPIResponse { - /// Transforms the successful result to a new type using the provided transform function. - /// - Parameter transform: A closure that takes the current success value and returns a new value. - /// - Returns: A new TwitterAPIResponse with the transformed success type. - func map(_ transform: (Success) -> NewSuccess) -> TwitterAPIResponse { - .init( - request: request, - response: response, - data: data, - result: result.map(transform), - rateLimit: rateLimit - ) - } - - /// Transforms the successful result to a new type using a transform function that can return a Result. - /// - Parameter transform: A closure that takes the current success value and returns a Result. - /// - Returns: A new TwitterAPIResponse with the transformed success type. - func flatMap(_ transform: (Success) -> Result) - -> TwitterAPIResponse - { - .init( - request: request, - response: response, - data: data, - result: result.flatMap(transform), - rateLimit: rateLimit - ) - } - - /// Transforms the successful result to a new type using a transform function that can throw errors. - /// - Parameter transform: A closure that takes the current success value and can throw an error. - /// - Returns: A new TwitterAPIResponse with the transformed success type. - func tryMap(_ transform: (Success) throws -> NewSuccess) -> TwitterAPIResponse { - let nextResult: Result = result.flatMap { data in - let result: Result = .init { - try transform(data) - } - return result.mapError { TwitterAPIKitError(error: $0) } - } - return .init( - request: request, - response: response, - data: data, - result: nextResult, - rateLimit: rateLimit - ) - } - - /// Transforms the error in the response using the provided transform function. - /// - Parameter tranform: A closure that takes the current error and returns a new error. - /// - Returns: A new TwitterAPIResponse with the transformed error. - func mapError(_ tranform: (TwitterAPIKitError) -> TwitterAPIKitError) -> TwitterAPIResponse { - .init( - request: request, - response: response, - data: data, - result: result.mapError(tranform), - rateLimit: rateLimit - ) - } -} - -public extension TwitterAPIResponse { - /// Returns a formatted string representation of the API response for debugging purposes. - /// The string includes: - /// - Request method and URL - /// - Request headers (Content-Type, Content-Length) - /// - Response status code - /// - Response headers - /// - Rate limit information - /// - Response body (prettified if JSON) - /// - Error description (if any) - var prettyString: String { - let body = - data.map { data in - - // make pretty - if let json = try? JSONSerialization.jsonObject(with: data, options: []), - let jsonData = try? JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) - { - String(data: jsonData, encoding: .utf8) ?? "" - } else { - String(data: data, encoding: .utf8) ?? "Invalid data" - } - } ?? "No data" - - let contentType = "> Content-Type: \(request?.allHTTPHeaderFields?["Content-Type"] ?? "No Content-Type")" - let contentLength = - "> Content-Length: \(request?.allHTTPHeaderFields?["Content-Length"] ?? "No Content-Length")" - let request = "> \(request?.httpMethod?.uppercased() ?? "Unnown Method"): \(request?.url?.description ?? "")" - let statusCode = "< Status code: \(response?.statusCode ?? 0)" - let rateLimitStr = "< \(rateLimit.map { String(describing: $0) } ?? "No rate limit")" - - let responseContentType = "< Content-Type: \(response?.allHeaderFields["Content-Type"] ?? "No Content-Type")" - let responseContentLength = - "< Content-Length: \(response?.allHeaderFields["Content-Length"] ?? "No Content-Length")" - - switch result { - case let .failure(error): - return "-- Request failure --" - + "\n\(request)" - + "\n\(contentType)" - + "\n\(contentLength)" - + "\n\(statusCode)" - + "\n\(responseContentType)" - + "\n\(responseContentLength)" - + "\n\(rateLimitStr)" - + "\n\(error.localizedDescription)" - + "\n<" - + "\n\(body.isEmpty ? "Empty body" : body.unescapeSlash)" - case .success: - return "-- Request success --" - + "\n\(request)" - + "\n\(contentType)" - + "\n\(contentLength)" - + "\n\(statusCode)" - + "\n\(responseContentType)" - + "\n\(responseContentLength)" - + "\n\(rateLimitStr)" - + "\n<" - + "\n\(body.isEmpty ? "Empty body" : body.unescapeSlash)" - } - } -} - -private extension String { - var unescapeSlash: String { - replacingOccurrences(of: #"\/"#, with: #"/"#) - } - - var unescapingUnicodeCharacters: String { - #if os(Linux) - return self - #else - let mutableString = NSMutableString(string: self) - CFStringTransform(mutableString, nil, "Any-Hex/Java" as NSString, true) - return mutableString as String - #endif - } -} diff --git a/Sources/TwitterAPIKit/TwitterAPISession.swift b/Sources/TwitterAPIKit/TwitterAPISession.swift index 5d8f0167..1e46f3e3 100644 --- a/Sources/TwitterAPIKit/TwitterAPISession.swift +++ b/Sources/TwitterAPIKit/TwitterAPISession.swift @@ -6,129 +6,106 @@ // This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. // This Package is distributable through a modified version of the MIT License. +import Crypto import Foundation -/// A session class that handles Twitter API requests and authentication. -/// This class manages the authentication state, network requests, and environment configuration. -open class TwitterAPISession { - /// The current authentication method being used for API requests. - /// This property can be read publicly but only modified internally. - public private(set) var auth: TwitterAuthenticationMethod - - /// The URLSession instance used for making network requests. - public let session: URLSession +public enum AuthenticationType: Codable, Sendable { + case oauth10a( + consumerKey: String, + consumerSecret: String, + oauthToken: String?, + oauthTokenSecret: String? + ) + case oauth20( + clientId: String, + clientSecret: String, + accessToken: String, + refreshToken: String? + ) +} - /// The Twitter API environment configuration (e.g., API endpoints, version). +/// Class to Run Authenticated Twitter Requests +public final class TwitterAPISession { + /// Which environment to use public let environment: TwitterAPIEnvironment - internal let sessionDelegate = TwitterAPISessionDelegate() + private let session: URLSession + private let authenticationType: AuthenticationType - /// Creates a new TwitterAPISession instance. - /// - Parameters: - /// - auth: The authentication method to use for API requests. - /// - configuration: The URLSession configuration to use for network requests. - /// - environment: The Twitter API environment configuration. + /// Initialize TwitterAPI Session public init( - auth: TwitterAuthenticationMethod, - configuration: URLSessionConfiguration, - environment: TwitterAPIEnvironment + authenticationType: AuthenticationType, + environment: TwitterAPIEnvironment = .init(), + session: URLSession = .shared ) { - self.auth = auth - session = URLSession(configuration: configuration, delegate: sessionDelegate, delegateQueue: nil) + self.authenticationType = authenticationType self.environment = environment + self.session = session } - deinit { - session.invalidateAndCancel() - } + /// Sends a request & handles Authentication + public func send(_ request: T) async throws -> T.Response { + var urlRequest = try request.buildRequest(environment: environment) - /// Sends a Twitter API request and returns a JSON task. - /// - Parameter request: The Twitter API request to send. - /// - Returns: A task that will return JSON data when completed. - public func send(_ request: TwitterAPIRequest) -> TwitterAPISessionJSONTask { - do { - let urlRequest: URLRequest = try tryBuildURLRequest(request) - let task = session.dataTask(with: urlRequest) - return sessionDelegate.appendAndResume(task: task) - } catch { - return TwitterAPIFailedTask(.init(error: error)) + setAuthHeaderValue(request: &urlRequest, twitterRequest: request) + + if request.bodyContentType == .json { + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") } - } - /// Sends a streaming Twitter API request. - /// - Parameter streamRequest: The Twitter API request to stream. - /// - Returns: A task that will stream data continuously. - public func send(streamRequest: TwitterAPIRequest) -> TwitterAPISessionStreamTask { + let (data, response) = try await session.data(for: urlRequest) + do { - let urlRequest: URLRequest = try tryBuildURLRequest(streamRequest) - let task = session.dataTask(with: urlRequest) - return sessionDelegate.appendAndResumeStream(task: task) + if let httpResponse = response as? HTTPURLResponse, + !(200 ... 299).contains(httpResponse.statusCode) + { + let errorResponse = try JSONDecoder().decode(TwitterAPIError.self, from: data) + throw errorResponse + } + + if T.Response.self == TwitterOAuthTokenV1.self { + if let token = TwitterOAuthTokenV1(queryStringData: data) { + // swiftlint:disable:next force_cast + return token as! T.Response + } + } else if T.Response.self == TwitterOAuthAccessTokenV1.self { + if let token = TwitterOAuthAccessTokenV1(queryStringData: data) { + // swiftlint:disable:next force_cast + return token as! T.Response + } + } + + return try JSONDecoder().decode(T.Response.self, from: data) + } catch let error as TwitterAPIError { + throw error } catch { - return TwitterAPIFailedTask(.init(error: error)) + print("Raw response: \(String(describing: String(data: data, encoding: .utf8)))") + throw error } } - // swiftlint:disable:next function_body_length - private func tryBuildURLRequest(_ request: TwitterAPIRequest) throws -> URLRequest { - var urlRequest = try request.buildRequest(environment: environment) - - switch auth { - case let .oauth( - consumerKey: consumerKey, - consumerSecret: consumerSecret, - oauthToken: oauthToken, - oauthTokenSecret: oauthTokenSecret - ): + private func setAuthHeaderValue(request: inout URLRequest, twitterRequest: any TwitterAPIRequest) { + switch authenticationType { + case let .oauth10a(consumerKey, consumerSecret, oauthToken, oauthTokenSecret): + // For request token, we only need consumer credentials let authHeader = authorizationHeader( - for: request.method, - url: request.requestURL(for: environment), - parameters: request.parameterForOAuth, + for: twitterRequest.method, + url: twitterRequest.requestURL(for: environment), + parameters: twitterRequest.parameterForOAuth, consumerKey: consumerKey, consumerSecret: consumerSecret, oauthToken: oauthToken, oauthTokenSecret: oauthTokenSecret ) - urlRequest.setValue(authHeader, forHTTPHeaderField: "Authorization") - - case let .oauth10a(oauth10a): - let authHeader = authorizationHeader( - for: request.method, - url: request.requestURL(for: environment), - parameters: request.parameterForOAuth, - consumerKey: oauth10a.consumerKey, - consumerSecret: oauth10a.consumerSecret, - oauthToken: oauth10a.oauthToken, - oauthTokenSecret: oauth10a.oauthTokenSecret - ) - urlRequest.setValue(authHeader, forHTTPHeaderField: "Authorization") - - case let .oauth20(oauth20): - urlRequest.setValue("Bearer \(oauth20.accessToken)", forHTTPHeaderField: "Authorization") - - case let .requestOAuth20WithPKCE(.confidentialClient(clientID: apiKey, clientSecret: apiSecretKey)), - let .basic(apiKey: apiKey, apiSecretKey: apiSecretKey): - - let credential = "\(apiKey):\(apiSecretKey)" - guard let credentialData = credential.data(using: .utf8) else { - throw TwitterAPIKitError.requestFailed(reason: .cannotEncodeStringToData(string: credential)) - } - let credentialBase64 = credentialData.base64EncodedString(options: []) - let basicAuth = "Basic \(credentialBase64)" - urlRequest.setValue(basicAuth, forHTTPHeaderField: "Authorization") - - case let .bearer(token): - urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") - - case .none, .requestOAuth20WithPKCE(.publicClient): break + request.setValue(authHeader, forHTTPHeaderField: "Authorization") + case let .oauth20(_, _, accessToken, _): + let authHeader = "Bearer \(accessToken)" + print(authHeader) + request.setValue(authHeader, forHTTPHeaderField: "Authorization") } - - return urlRequest } - internal func refreshOAuth20Token(_ refreshedToken: TwitterAuthenticationMethod.OAuth20) { - guard case .oauth20 = auth else { - return - } - auth = .oauth20(refreshedToken) + deinit { + // De-init Logic } } diff --git a/Sources/TwitterAPIKit/TwitterAPISessionDelegate.swift b/Sources/TwitterAPIKit/TwitterAPISessionDelegate.swift deleted file mode 100644 index 8be9631d..00000000 --- a/Sources/TwitterAPIKit/TwitterAPISessionDelegate.swift +++ /dev/null @@ -1,64 +0,0 @@ -// TwitterAPISessionDelegate.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Protocol for delegated tasks that can receive data in chunks and handle completion -public protocol TwitterAPISessionDelegatedTask { - /// The unique identifier for this task - var taskIdentifier: Int { get } - - /// Appends a chunk of data received from the network - /// - Parameter chunk: The data chunk to append - func append(chunk: Data) - - /// Called when the task completes, with an optional error - /// - Parameter error: The error that occurred, if any - func complete(error: Error?) -} - -public class TwitterAPISessionDelegate: NSObject, URLSessionDataDelegate { - private var tasks = [Int /* taskIdentifier */: TwitterAPISessionDelegatedTask]() - - public func appendAndResume(task: URLSessionTask) -> TwitterAPISessionJSONTask { - let twTask = TwitterAPISessionDelegatedJSONTask(task: task) - twTask.delegate = self - tasks[task.taskIdentifier] = twTask - - task.resume() - - return twTask - } - - public func appendAndResumeStream(task: URLSessionTask) -> TwitterAPISessionDelegatedStreamTask { - let twTask = TwitterAPISessionDelegatedStreamTask(task: task) - tasks[task.taskIdentifier] = twTask - task.resume() - return twTask - } - - public func urlSession(_: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { - tasks[dataTask.taskIdentifier]?.append(chunk: data) - } - - public func urlSession(_: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { - guard let task = tasks[task.taskIdentifier] else { return } - - task.complete(error: error) - } - - deinit { - // De-init Logic Here - } -} - -extension TwitterAPISessionDelegate: TwitterAPISessionDelegatedJSONTaskDelegate { - public func didFinishQueueInJsonTask(task: TwitterAPISessionDelegatedJSONTask) { - tasks[task.taskIdentifier] = nil - } -} diff --git a/Sources/TwitterAPIKit/TwitterAuthenticationMethod.swift b/Sources/TwitterAPIKit/TwitterAuthenticationMethod.swift deleted file mode 100644 index fc58f4b2..00000000 --- a/Sources/TwitterAPIKit/TwitterAuthenticationMethod.swift +++ /dev/null @@ -1,178 +0,0 @@ -// TwitterAuthenticationMethod.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -/// Represents different methods of authentication available for Twitter API requests. -public enum TwitterAuthenticationMethod { - /// No authentication method specified. - case basic(apiKey: String, apiSecretKey: String) - - /// Bearer token authentication for OAuth2 app-only access. - case bearer(String) - - // swiftlint:disable discouraged_none_name - /// No authentication required. - case none - // swiftlint:enable discouraged_none_name - - /// Authentication using OAuth 1.0a protocol (legacy). - @available(*, deprecated, renamed: "oauth10a") - case oauth( - consumerKey: String, - consumerSecret: String, - oauthToken: String?, - oauthTokenSecret: String? - ) - - /// Authentication using OAuth 1.0a protocol. - case oauth10a(OAuth10a) - - /// Authentication using OAuth 2.0 protocol. - case oauth20(OAuth20) - - /// Used to execute the OAuth 2.0 Authorization Code Flow with PKCE authentication flow. - case requestOAuth20WithPKCE(OAuth20WithPKCEClientType) -} - -/// Extension containing OAuth-related types and functionality. -public extension TwitterAuthenticationMethod { - /// Represents OAuth 1.0a authentication credentials. - struct OAuth10a: Codable { - /// The consumer key (API key) provided by Twitter. - public var consumerKey: String - - /// The consumer secret (API secret key) provided by Twitter. - public var consumerSecret: String - - /// The OAuth token obtained after user authorization. - public var oauthToken: String? - - /// The OAuth token secret obtained after user authorization. - public var oauthTokenSecret: String? - - /// Initializes a new OAuth10a authentication structure. - /// - Parameters: - /// - consumerKey: The consumer key (API key) provided by Twitter - /// - consumerSecret: The consumer secret (API secret key) provided by Twitter - /// - oauthToken: The OAuth token obtained after user authorization - /// - oauthTokenSecret: The OAuth token secret obtained after user authorization - public init( - consumerKey: String, - consumerSecret: String, - oauthToken: String?, - oauthTokenSecret: String? - ) { - self.consumerKey = consumerKey - self.consumerSecret = consumerSecret - self.oauthToken = oauthToken - self.oauthTokenSecret = oauthTokenSecret - } - } - - /// Represents OAuth 2.0 authentication credentials and state. - struct OAuth20: Codable { - /// The client ID provided by Twitter. - public var clientID: String - - /// The creation timestamp of the token. - public var createdAt: Date - - /// The time in seconds until the token expires. - public var expiresIn: Int - - /// The OAuth 2.0 access token. - public var accessToken: String - - /// The refresh token for obtaining new access tokens (only for Public Client). - public var refreshToken: String? - - /// The authorized scopes for this token. - public var scope: [String] - - /// The type of token (usually "bearer"). - public var tokenType: String - - /// Estimates the expiration time of a token based on "expiresIn" and "createdAt". - /// Since the server response does not include the creation time of the token, it contains a margin of error of - /// a few seconds. - public var expiresAt: Date { - createdAt.addingTimeInterval(TimeInterval(expiresIn)) - } - - /// Indicates whether the token has expired. - public var expired: Bool { - expiresAt <= Date() - } - - /// Initializes a new OAuth20 authentication structure. - /// - Parameters: - /// - clientID: The client ID provided by Twitter - /// - scope: The authorized scopes for this token - /// - tokenType: The type of token (usually "bearer") - /// - expiresIn: The time in seconds until the token expires - /// - accessToken: The OAuth 2.0 access token - /// - refreshToken: The refresh token for obtaining new access tokens - /// - createdAt: The creation timestamp of the token - public init( - clientID: String, - scope: [String], - tokenType: String, - expiresIn: Int, - accessToken: String, - refreshToken: String?, - createdAt: Date = Date() - ) { - self.clientID = clientID - self.scope = scope - self.tokenType = tokenType - self.expiresIn = expiresIn - self.accessToken = accessToken - self.refreshToken = refreshToken - self.createdAt = createdAt - } - - /// Initializes a new OAuth20 authentication structure from a Twitter OAuth2 access token. - /// - Parameters: - /// - clientID: The client ID provided by Twitter - /// - token: The Twitter OAuth2 access token - /// - createdAt: The creation timestamp of the token - public init(clientID: String, token: TwitterOAuth2AccessToken, createdAt: Date = Date()) { - self.init( - clientID: clientID, - scope: token.scope, - tokenType: token.tokenType, - expiresIn: token.expiresIn, - accessToken: token.accessToken, - refreshToken: token.refreshToken, - createdAt: createdAt - ) - } - - /// Refreshes the OAuth20 token with new values. - /// - Parameters: - /// - token: The new Twitter OAuth2 access token - /// - refreshedAt: The timestamp when the token was refreshed - public mutating func refresh(token: TwitterOAuth2AccessToken, refreshedAt: Date = Date()) { - scope = token.scope - tokenType = token.tokenType - expiresIn = token.expiresIn - accessToken = token.accessToken - refreshToken = token.refreshToken - createdAt = refreshedAt - } - } - - /// Represents the client type for OAuth 2.0 with PKCE flow. - enum OAuth20WithPKCEClientType { - /// A confidential client with client ID and secret. - case confidentialClient(clientID: String, clientSecret: String) - /// A public client without a client secret. - case publicClient - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/GetAccountSettingsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/GetAccountSettingsRequestV1Tests.swift deleted file mode 100644 index d6e0ad63..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/GetAccountSettingsRequestV1Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// GetAccountSettingsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetAccountSettingsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetAccountSettingsRequestV1() - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/settings.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/GetAccountVerifyCredentialsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/GetAccountVerifyCredentialsRequestV1Tests.swift deleted file mode 100644 index 029b2ad9..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/GetAccountVerifyCredentialsRequestV1Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetAccountVerifyCredentialsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetAccountVerifyCredentialsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetAccountVerifyCredentialsRequestV1( - skipStatus: true, - includeEmail: true, - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/verify_credentials.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "skip_status": true, - "include_email": true, - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetAccountVerifyCredentialsRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountRemoveProfileBannerRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountRemoveProfileBannerRequestV1Tests.swift deleted file mode 100644 index a8bafa78..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountRemoveProfileBannerRequestV1Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// PostAccountRemoveProfileBannerRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostAccountRemoveProfileBannerRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostAccountRemoveProfileBannerRequestV1() - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/remove_profile_banner.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountSettingsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountSettingsRequestV1Tests.swift deleted file mode 100644 index c6ce9165..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountSettingsRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostAccountSettingsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostAccountSettingsRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostAccountSettingsRequestV1( - lang: "_l_", - timeZone: "_t_", - startSleepTime: 1, - endSleepTime: 10, - sleepTimeEnabled: true, - trendLocationWoeid: "_t_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/settings.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "lang": "_l_", - "time_zone": "_t_", - "start_sleep_time": 1, - "end_sleep_time": 10, - "sleep_time_enabled": true, - "trend_location_woeid": "_t_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostAccountSettingsRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileBannerRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileBannerRequestV1Tests.swift deleted file mode 100644 index 19e2ee55..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileBannerRequestV1Tests.swift +++ /dev/null @@ -1,74 +0,0 @@ -// PostAccountUpdateProfileBannerRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostAccountUpdateProfileBannerRequestV1Tests: XCTestCase { - public func test() throws { - let banner = Data([0, 1, 2]) - let req = PostAccountUpdateProfileBannerRequestV1( - banner: banner, - width: 2, - height: 3, - offsetTop: 4, - offsetLeft: 5 - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/update_profile_banner.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - - /* - 012 -> 00000000 00000001 00000010 - - 000000: A - 000000: A - 000100: E - 000010: C - */ - - AssertEqualAnyDict( - req.parameters, - [ - "banner": "AAEC", - "width": 2, - "height": 3, - "offset_top": 4, - "offset_left": 5, - ] - ) - } - - public func testDefaultArg() throws { - let banner = Data([0, 1]) - let req = PostAccountUpdateProfileBannerRequestV1( - banner: banner - ) - - /* - 01 - - 000000: A - 000000: A - 000100: E - - */ - AssertEqualAnyDict( - req.parameters, - [ - "banner": "AAE=", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileImageRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileImageRequestV1Tests.swift deleted file mode 100644 index b64fb1c1..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileImageRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostAccountUpdateProfileImageRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostAccountUpdateProfileImageRequestV1Tests: XCTestCase { - public func test() throws { - let image = Data([0, 1, 2]) - let req = PostAccountUpdateProfileImageRequestV1( - image: image, - skipStatus: true, - includeEntities: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/update_profile_image.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "image": "AAEC", - "skip_status": true, - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let image = Data([0, 1, 2]) - let req = PostAccountUpdateProfileImageRequestV1( - image: image - ) - - AssertEqualAnyDict( - req.parameters, - [ - "image": "AAEC", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileRequestV1Tests.swift deleted file mode 100644 index b61230fc..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Account/PostAccountUpdateProfileRequestV1Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// PostAccountUpdateProfileRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostAccountUpdateProfileRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostAccountUpdateProfileRequestV1( - url: "_u_", - name: "_n_", - location: "_l_", - skipStatus: true, - description: "_d_", - includeEntities: true, - profileLinkColor: "_p_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/account/update_profile.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "url": "_u_", - "name": "_n_", - "location": "_l_", - "skip_status": true, - "description": "_d_", - "include_entities": true, - "profile_link_color": "_p_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostAccountUpdateProfileRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Application/GetApplicationRateLimitStatusRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Application/GetApplicationRateLimitStatusRequestV1Tests.swift deleted file mode 100644 index 28f9f637..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Application/GetApplicationRateLimitStatusRequestV1Tests.swift +++ /dev/null @@ -1,42 +0,0 @@ -// GetApplicationRateLimitStatusRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetApplicationRateLimitStatusRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetApplicationRateLimitStatusRequestV1( - resources: ["a", "b"] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/application/rate_limit_status.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "resources": "a,b", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetApplicationRateLimitStatusRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetBlocksIDsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetBlocksIDsRequestV1Tests.swift deleted file mode 100644 index 5df0ae73..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetBlocksIDsRequestV1Tests.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetBlocksIDsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetBlocksIDsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetBlocksIDsRequestV1( - stringifyIDs: true, - cursor: "_c_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/blocks/ids.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "stringify_ids": true, - "cursor": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetBlocksIDsRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetBlocksListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetBlocksListRequestV1Tests.swift deleted file mode 100644 index 39a5377b..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetBlocksListRequestV1Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetBlocksListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetBlocksListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetBlocksListRequestV1( - includeEntities: true, - skipStatus: true, - cursor: "_c_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/blocks/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "include_entities": true, - "skip_status": true, - "cursor": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetBlocksListRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetMutesUsersIDsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetMutesUsersIDsRequestV1Tests.swift deleted file mode 100644 index dc25e01d..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetMutesUsersIDsRequestV1Tests.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetMutesUsersIDsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetMutesUsersIDsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetMutesUsersIDsRequestV1( - stringifyIDs: true, - cursor: "_c_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/mutes/users/ids.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "stringify_ids": true, - "cursor": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetMutesUsersIDsRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetMutesUsersListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetMutesUsersListRequestV1Tests.swift deleted file mode 100644 index a50d1ce6..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/GetMutesUsersListRequestV1Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetMutesUsersListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetMutesUsersListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetMutesUsersListRequestV1( - cursor: "_c_", - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/mutes/users/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "cursor": "_c_", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetMutesUsersListRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostBlocksCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostBlocksCreateRequestV1Tests.swift deleted file mode 100644 index 220637e4..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostBlocksCreateRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostBlocksCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostBlocksCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostBlocksCreateRequestV1( - user: .userID("uid"), - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/blocks/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostBlocksCreateRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostBlocksDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostBlocksDestroyRequestV1Tests.swift deleted file mode 100644 index f6cb4784..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostBlocksDestroyRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostBlocksDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostBlocksDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostBlocksDestroyRequestV1( - user: .userID("uid"), - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/blocks/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostBlocksDestroyRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostMutesUsersCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostMutesUsersCreateRequestV1Tests.swift deleted file mode 100644 index 1a3b8f95..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostMutesUsersCreateRequestV1Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// PostMutesUsersCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostMutesUsersCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostMutesUsersCreateRequestV1( - user: .userID("uid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/mutes/users/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - ] - ) - } - - public func testScreenName() throws { - let req = PostMutesUsersCreateRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostMutesUsersDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostMutesUsersDestroyRequestV1Tests.swift deleted file mode 100644 index dd8e664e..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostMutesUsersDestroyRequestV1Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// PostMutesUsersDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostMutesUsersDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostMutesUsersDestroyRequestV1( - user: .userID("uid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/mutes/users/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - ] - ) - } - - public func testScreenName() throws { - let req = PostMutesUsersDestroyRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostUsersReportSpamRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostUsersReportSpamRequestV1Tests.swift deleted file mode 100644 index be0c4852..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/BlockAndMute/PostUsersReportSpamRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostUsersReportSpamRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersReportSpamRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostUsersReportSpamRequestV1( - user: .userID("uid"), - performBlock: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/users/report_spam.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "perform_block": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostUsersReportSpamRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsEntriesRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsEntriesRequestV1Tests.swift deleted file mode 100644 index 3a90e771..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsEntriesRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetCollectionsEntriesRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetCollectionsEntriesRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetCollectionsEntriesRequestV1( - id: "_i_", - count: 12, - maxPosition: "_m_", - minPosition: "_m_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/entries.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "count": 12, - "max_position": "_m_", - "min_position": "_m_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetCollectionsEntriesRequestV1( - id: "i" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "i", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsListRequestV1Tests.swift deleted file mode 100644 index f2b40ada..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsListRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetCollectionsListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetCollectionsListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetCollectionsListRequestV1( - user: .userID("uid"), - count: 14, - cursor: "_c_", - tweetID: "_t_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 14, - "cursor": "_c_", - "tweet_id": "_t_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetCollectionsListRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsShowRequestV1Tests.swift deleted file mode 100644 index a8360f72..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/GetCollectionsShowRequestV1Tests.swift +++ /dev/null @@ -1,33 +0,0 @@ -// GetCollectionsShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetCollectionsShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetCollectionsShowRequestV1( - id: "_i_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsCreateRequestV1Tests.swift deleted file mode 100644 index dc96806d..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsCreateRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostCollectionsCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsCreateRequestV1( - name: "_n_", - url: "_u_", - description: "_d_", - timelineOrder: .curationReverseChron - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "name": "_n_", - "url": "_u_", - "description": "_d_", - "timeline_order": "curation_reverse_chron", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostCollectionsCreateRequestV1( - name: "n" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "name": "n", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsDestroyRequestV1Tests.swift deleted file mode 100644 index af2d7e16..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsDestroyRequestV1Tests.swift +++ /dev/null @@ -1,33 +0,0 @@ -// PostCollectionsDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsDestroyRequestV1( - id: "_i_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesAddRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesAddRequestV1Tests.swift deleted file mode 100644 index 717b706c..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesAddRequestV1Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// PostCollectionsEntriesAddRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsEntriesAddRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsEntriesAddRequestV1( - id: "_i_", - tweetID: "_t_", - above: true, - relativeTo: "_r_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/entries/add.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "tweet_id": "_t_", - "above": true, - "relative_to": "_r_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostCollectionsEntriesAddRequestV1( - id: "_i_", - tweetID: "_t_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "tweet_id": "_t_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesCurateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesCurateRequestV1Tests.swift deleted file mode 100644 index 5058e1af..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesCurateRequestV1Tests.swift +++ /dev/null @@ -1,41 +0,0 @@ -// PostCollectionsEntriesCurateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsEntriesCurateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsEntriesCurateRequestV1( - id: "_i_", - changes: [ - .add(tweetID: "add_id"), - .remove(tweetID: "remove_id"), - ] - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/entries/curate.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "changes": [ - ["op": "add", "tweet_id": "add_id"], - ["op": "remove", "tweet_id": "remove_id"], - ], - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesMoveRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesMoveRequestV1Tests.swift deleted file mode 100644 index b4a19c26..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesMoveRequestV1Tests.swift +++ /dev/null @@ -1,56 +0,0 @@ -// PostCollectionsEntriesMoveRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsEntriesMoveRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsEntriesMoveRequestV1( - id: "_i_", - tweetID: "_t_", - above: true, - relativeTo: "_r_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/entries/move.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "tweet_id": "_t_", - "above": true, - "relative_to": "_r_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostCollectionsEntriesMoveRequestV1( - id: "_i_", - tweetID: "_t_", - relativeTo: "_r_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "tweet_id": "_t_", - "relative_to": "_r_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesRemoveRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesRemoveRequestV1Tests.swift deleted file mode 100644 index b64d666a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsEntriesRemoveRequestV1Tests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// PostCollectionsEntriesRemoveRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsEntriesRemoveRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsEntriesRemoveRequestV1( - id: "_i_", - tweetID: "_t_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/entries/remove.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "tweet_id": "_t_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsUpdateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsUpdateRequestV1Tests.swift deleted file mode 100644 index 3e3bda47..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Collection/PostCollectionsUpdateRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostCollectionsUpdateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostCollectionsUpdateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostCollectionsUpdateRequestV1( - id: "_i_", - url: "_u_", - name: "_n_", - description: "_d_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/collections/update.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "url": "_u_", - "name": "_n_", - "description": "_d_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostCollectionsUpdateRequestV1( - id: "i" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "i", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/DeleteDirectMessageRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/DirectMessage/DeleteDirectMessageRequestV1Tests.swift deleted file mode 100644 index e58b662a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/DeleteDirectMessageRequestV1Tests.swift +++ /dev/null @@ -1,25 +0,0 @@ -// DeleteDirectMessageRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteDirectMessageRequestV1Tests: XCTestCase { - public func test() throws { - let req = DeleteDirectMessageRequestV1(id: "15") - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, ["id": "15"]) - AssertEqualAnyDict(req.queryParameters, ["id": "15"]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/GetDirectMessageListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/DirectMessage/GetDirectMessageListRequestV1Tests.swift deleted file mode 100644 index 1d478ce8..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/GetDirectMessageListRequestV1Tests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// GetDirectMessageListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetDirectMessageListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetDirectMessageListRequestV1( - count: 100, - cursor: "cursor_str" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "count": 100, - "cursor": "cursor_str", - ] - ) - XCTAssertTrue(req.bodyParameters.isEmpty) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/GetDirectMessageRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/DirectMessage/GetDirectMessageRequestV1Tests.swift deleted file mode 100644 index c5be1e3b..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/GetDirectMessageRequestV1Tests.swift +++ /dev/null @@ -1,25 +0,0 @@ -// GetDirectMessageRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetDirectMessageRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetDirectMessageRequestV1(id: "dm_id") - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, ["id": "dm_id"]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessageRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessageRequestV1Tests.swift deleted file mode 100644 index cb77b7a8..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessageRequestV1Tests.swift +++ /dev/null @@ -1,182 +0,0 @@ -// PostDirectMessageRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostDirectMessageRequestV1Tests: XCTestCase { - public func testText() throws { - let req = PostDirectMessageRequestV1( - targetUserID: "target", - message: "msg" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/new.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "event": [ - "type": "message_create", - "message_create": [ - "message_data": ["text": "msg"], - "target": ["recipient_id": "target"], - ], - ], - ] - ) - } - - // swiftlint:disable:next function_body_length - public func testQuickReplyOptions() throws { - let req = PostDirectMessageRequestV1( - targetUserID: "target", - message: "msg", - quickReplyOptions: [ - .init(label: "label", description: "label desc", metadata: "meta"), - .init(label: "label 2", description: "label desc 2", metadata: "meta 2"), - ] - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/new.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "event": [ - "type": "message_create", - "message_create": [ - "target": ["recipient_id": "target"], - "message_data": [ - "text": "msg", - "quick_reply": [ - "type": "options", - "options": [ - ["label": "label", "description": "label desc", "metadata": "meta"], - ["label": "label 2", "description": "label desc 2", "metadata": "meta 2"], - ], - ], - ], - ], - ], - ] - ) - } - - public func testAttachMedia() throws { - let req = PostDirectMessageRequestV1( - targetUserID: "target", - message: "msg with media", - attachment: .media("media_id") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/new.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "event": [ - "type": "message_create", - "message_create": [ - "message_data": [ - "text": "msg with media", - "attachment": [ - "type": "media", - "media": [ - "id": "media_id", - ], - ], - ], - "target": ["recipient_id": "target"], - ], - ], - ] - ) - } - - // swiftlint:disable:next function_body_length - public func testAttachLocation() throws { - let req = PostDirectMessageRequestV1( - targetUserID: "target", - message: "msg", - attachment: .location(.coordinate(.init(lat: 10, long: 20))) - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/direct_messages/events/new.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "event": [ - "type": "message_create", - "message_create": [ - "message_data": [ - "text": "msg", - "attachment": [ - "type": "location", - "location": [ - "type": "shared_coordinate", - "shared_coordinate": [ - "coordinates": [ - "type": "Point", - "coordinates": [10, 20], - ], - ], - ], - ], - ], - "target": ["recipient_id": "target"], - ], - ], - ] - ) - - let req2 = PostDirectMessageRequestV1( - targetUserID: "target", - message: "msg", - attachment: .location(.place("place_id")) - ) - - XCTAssertEqual(req2.method, .post) - XCTAssertEqual(req2.path, "/1.1/direct_messages/events/new.json") - XCTAssertEqual(req2.bodyContentType, .json) - AssertEqualAnyDict( - req2.parameters, - [ - "event": [ - "type": "message_create", - "message_create": [ - "message_data": [ - "text": "msg", - "attachment": [ - "type": "location", - "location": [ - "type": "shared_place", - "shared_place": [ - "place": [ - "id": "place_id", - ], - ], - ], - ], - ], - "target": ["recipient_id": "target"], - ], - ], - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessagesIndicateTypingRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessagesIndicateTypingRequestV1Tests.swift deleted file mode 100644 index 33720cc8..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessagesIndicateTypingRequestV1Tests.swift +++ /dev/null @@ -1,27 +0,0 @@ -// PostDirectMessagesIndicateTypingRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostDirectMessagesIndicateTypingRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostDirectMessagesIndicateTypingRequestV1( - recipientID: "234" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/direct_messages/indicate_typing.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, ["recipient_id": "234"]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessagesMarkReadRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessagesMarkReadRequestV1Tests.swift deleted file mode 100644 index 9deaeb64..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/DirectMessage/PostDirectMessagesMarkReadRequestV1Tests.swift +++ /dev/null @@ -1,31 +0,0 @@ -// PostDirectMessagesMarkReadRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostDirectMessagesMarkReadRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostDirectMessagesMarkReadRequestV1(lastReadEventID: "ev_id", recipientID: "r_id") - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/direct_messages/mark_read.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "last_read_event_id": "ev_id", - "recipient_id": "r_id", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Favorite/GetFavoritesRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Favorite/GetFavoritesRequestV1Tests.swift deleted file mode 100644 index d7c010e7..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Favorite/GetFavoritesRequestV1Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetFavoritesRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFavoritesRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFavoritesRequestV1( - target: .userID("uid"), - count: 100, - sinceID: "_s_", - maxID: "_m_", - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/favorites/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 100, - "since_id": "_s_", - "max_id": "_m_", - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFavoritesRequestV1( - target: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Favorite/PostFavoriteRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Favorite/PostFavoriteRequestV1Tests.swift deleted file mode 100644 index 53d81dc5..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Favorite/PostFavoriteRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostFavoriteRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostFavoriteRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostFavoriteRequestV1( - id: "_i_", - includeEntities: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/favorites/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostFavoriteRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Favorite/PostUnFavoriteRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Favorite/PostUnFavoriteRequestV1Tests.swift deleted file mode 100644 index 09881401..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Favorite/PostUnFavoriteRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostUnFavoriteRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUnFavoriteRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostUnFavoriteRequestV1( - id: "_i_", - includeEntities: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/favorites/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostUnFavoriteRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFollowersIDsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFollowersIDsRequestV1Tests.swift deleted file mode 100644 index 6a8a2537..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFollowersIDsRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetFollowersIDsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFollowersIDsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFollowersIDsRequestV1( - user: .userID("uid"), - count: 10, - cursor: "_c_", - stringifyIDs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/followers/ids.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 10, - "cursor": "_c_", - "stringify_ids": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFollowersIDsRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFollowersListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFollowersListRequestV1Tests.swift deleted file mode 100644 index 7680a608..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFollowersListRequestV1Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetFollowersListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFollowersListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFollowersListRequestV1( - user: .userID("uid"), - count: 1, - cursor: "_c_", - skipStatus: true, - includeUserEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/followers/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 1, - "cursor": "_c_", - "skip_status": true, - "include_user_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFollowersListRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendsIDsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendsIDsRequestV1Tests.swift deleted file mode 100644 index 772aaf03..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendsIDsRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetFriendsIDsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendsIDsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendsIDsRequestV1( - user: .userID("uid"), - count: 11, - cursor: "_c_", - stringifyIDs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friends/ids.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 11, - "cursor": "_c_", - "stringify_ids": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFriendsIDsRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendsListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendsListRequestV1Tests.swift deleted file mode 100644 index 56ec2e71..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendsListRequestV1Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetFriendsListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendsListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendsListRequestV1( - user: .userID("uid"), - count: 1, - cursor: "_c_", - skipStatus: true, - includeUserEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friends/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 1, - "cursor": "_c_", - "skip_status": true, - "include_user_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFriendsListRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsIncomingRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsIncomingRequestV1Tests.swift deleted file mode 100644 index ad0b7ab9..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsIncomingRequestV1Tests.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetFriendshipsIncomingRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendshipsIncomingRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendshipsIncomingRequestV1( - cursor: "_c_", - stringifyIDs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/incoming.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "cursor": "_c_", - "stringify_ids": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFriendshipsIncomingRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsLookupRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsLookupRequestV1Tests.swift deleted file mode 100644 index 44c4e556..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsLookupRequestV1Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// GetFriendshipsLookupRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendshipsLookupRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendshipsLookupRequestV1( - users: .userIDs(["uid1", "uid2"]) - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/lookup.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid1,uid2", - ] - ) - } - - public func testScreenName() throws { - let req = GetFriendshipsLookupRequestV1( - users: .screenNames(["s1", "s2"]) - ) - - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s1,s2", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsNoRetweetsIDsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsNoRetweetsIDsRequestV1Tests.swift deleted file mode 100644 index 5fe3c603..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsNoRetweetsIDsRequestV1Tests.swift +++ /dev/null @@ -1,42 +0,0 @@ -// GetFriendshipsNoRetweetsIDsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendshipsNoRetweetsIDsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendshipsNoRetweetsIDsRequestV1( - stringifyIDs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/no_retweets/ids.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "stringify_ids": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFriendshipsNoRetweetsIDsRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsOutgoingRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsOutgoingRequestV1Tests.swift deleted file mode 100644 index 8ac904e1..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsOutgoingRequestV1Tests.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetFriendshipsOutgoingRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendshipsOutgoingRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendshipsOutgoingRequestV1( - cursor: "_c_", - stringifyIDs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/outgoing") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "cursor": "_c_", - "stringify_ids": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetFriendshipsOutgoingRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsShowRequestV1Tests.swift deleted file mode 100644 index cf70ad02..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/GetFriendshipsShowRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetFriendshipsShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetFriendshipsShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetFriendshipsShowRequestV1( - sourceUser: .userID("suid"), - targetUser: .userID("tuid") - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "source_id": "suid", - "target_id": "tuid", - ] - ) - } - - public func testScreenName() throws { - let req = GetFriendshipsShowRequestV1( - sourceUser: .screenName("s"), - targetUser: .screenName("t") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "source_screen_name": "s", - "target_screen_name": "t", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsCreateRequestV1Tests.swift deleted file mode 100644 index dde8ae54..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsCreateRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostFriendshipsCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostFriendshipsCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostFriendshipsCreateRequestV1( - user: .userID("uid"), - follow: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "follow": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostFriendshipsCreateRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsDestroyRequestV1Tests.swift deleted file mode 100644 index 73b56b10..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsDestroyRequestV1Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// PostFriendshipsDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostFriendshipsDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostFriendshipsDestroyRequestV1( - user: .userID("uid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - ] - ) - } - - public func testScreenName() throws { - let req = PostFriendshipsDestroyRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsUpdateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsUpdateRequestV1Tests.swift deleted file mode 100644 index 62c1b7d6..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Friendships/PostFriendshipsUpdateRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostFriendshipsUpdateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostFriendshipsUpdateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostFriendshipsUpdateRequestV1( - user: .userID("uid"), - device: true, - retweets: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/friendships/update.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "device": true, - "retweets": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostFriendshipsUpdateRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoPlaceIDRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoPlaceIDRequestV1Tests.swift deleted file mode 100644 index a79cf538..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoPlaceIDRequestV1Tests.swift +++ /dev/null @@ -1,31 +0,0 @@ -// GetGeoPlaceIDRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetGeoPlaceIDRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetGeoPlaceIDRequestV1( - placeID: "_p_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/geo/id/_p_.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoReverseGeocodeRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoReverseGeocodeRequestV1Tests.swift deleted file mode 100644 index 48e79e80..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoReverseGeocodeRequestV1Tests.swift +++ /dev/null @@ -1,148 +0,0 @@ -// GetGeoReverseGeocodeRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetGeoReverseGeocodeRequestV1Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func testAccuracy() throws { - let req = GetGeoReverseGeocodeRequestV1( - location: .init(lat: 1, long: 2.5), - accuracy: .ft(2), - maxResults: 10, - granularity: .neighborhood - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/geo/reverse_geocode.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "lat": 1, - "long": 2.5, - "accuracy": "2ft", - "max_results": 10, - "granularity": "neighborhood", - ] - ) - - let req2 = GetGeoReverseGeocodeRequestV1( - location: .init(lat: 1, long: 2.5), - accuracy: .m(3), - maxResults: 10, - granularity: .neighborhood - ) - - AssertEqualAnyDict( - req2.parameters, - [ - "lat": 1, - "long": 2.5, - "accuracy": "3m", - "max_results": 10, - "granularity": "neighborhood", - ] - ) - } - - // swiftlint:disable:next function_body_length - public func testGranularity() throws { - let req = GetGeoReverseGeocodeRequestV1( - location: .init(lat: 1, long: 2.5), - accuracy: .ft(2), - maxResults: 10, - granularity: .neighborhood - ) - - AssertEqualAnyDict( - req.parameters, - [ - "lat": 1, - "long": 2.5, - "accuracy": "2ft", - "max_results": 10, - "granularity": "neighborhood", - ] - ) - - let req2 = GetGeoReverseGeocodeRequestV1( - location: .init(lat: 1, long: 2.5), - accuracy: .ft(2), - maxResults: 10, - granularity: .city - ) - - AssertEqualAnyDict( - req2.parameters, - [ - "lat": 1, - "long": 2.5, - "accuracy": "2ft", - "max_results": 10, - "granularity": "city", - ] - ) - - let req3 = GetGeoReverseGeocodeRequestV1( - location: .init(lat: 1, long: 2.5), - accuracy: .ft(2), - maxResults: 10, - granularity: .admin - ) - - AssertEqualAnyDict( - req3.parameters, - [ - "lat": 1, - "long": 2.5, - "accuracy": "2ft", - "max_results": 10, - "granularity": "admin", - ] - ) - - let req4 = GetGeoReverseGeocodeRequestV1( - location: .init(lat: 1, long: 2.5), - accuracy: .ft(2), - maxResults: 10, - granularity: .country - ) - - AssertEqualAnyDict( - req4.parameters, - [ - "lat": 1, - "long": 2.5, - "accuracy": "2ft", - "max_results": 10, - "granularity": "country", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetGeoReverseGeocodeRequestV1( - location: .init(lat: -10, long: 100) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "lat": -10, - "long": 100, - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoSearchRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoSearchRequestV1Tests.swift deleted file mode 100644 index 36784373..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Geo/GetGeoSearchRequestV1Tests.swift +++ /dev/null @@ -1,81 +0,0 @@ -// GetGeoSearchRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetGeoSearchRequestV1Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = GetGeoSearchRequestV1( - location: .coordinate(.init(lat: 10.12, long: -20)), - maxResults: 13, - granularity: .country - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/geo/search.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "lat": 10.12, - "long": -20, - "max_results": 13, - "granularity": "country", - ] - ) - - let req2 = GetGeoSearchRequestV1( - location: .query("ę—„ęœ¬"), - maxResults: 13, - granularity: .country - ) - AssertEqualAnyDict( - req2.parameters, - [ - "query": "ę—„ęœ¬", - "max_results": 13, - "granularity": "country", - ] - ) - - let req3 = GetGeoSearchRequestV1( - location: .ip("0.0.0.0"), - maxResults: 13, - granularity: .country - ) - AssertEqualAnyDict( - req3.parameters, - [ - "ip": "0.0.0.0", - "max_results": 13, - "granularity": "country", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetGeoSearchRequestV1( - location: .coordinate(.init(lat: 10.123, long: -20.1)) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "lat": 10.123, - "long": -20.1, - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Help/GetHelpLanguagesRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Help/GetHelpLanguagesRequestV1Tests.swift deleted file mode 100644 index 0fc23bc0..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Help/GetHelpLanguagesRequestV1Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// GetHelpLanguagesRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetHelpLanguagesRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetHelpLanguagesRequestV1() - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/help/languages.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsListRequestV1Tests.swift deleted file mode 100644 index ca01a5b6..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsListRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetListsListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsListRequestV1( - user: .userID("uid"), - reverse: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "reverse": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsListRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembersRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembersRequestV1Tests.swift deleted file mode 100644 index 0ae55d42..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembersRequestV1Tests.swift +++ /dev/null @@ -1,69 +0,0 @@ -// GetListsMembersRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsMembersRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsMembersRequestV1( - list: .listID("lid"), - count: 10, - cursor: "_c_", - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/members.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "count": 10, - "cursor": "_c_", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testSlugUserID() throws { - let req = GetListsMembersRequestV1( - list: .slug(slug: "s", owner: .userID("uid")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "s", - "owner_id": "uid", - ] - ) - } - - public func testSlugScreenName() throws { - let req = GetListsMembersRequestV1( - list: .slug(slug: "s", owner: .screenName("s")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "s", - "owner_screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembersShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembersShowRequestV1Tests.swift deleted file mode 100644 index 9275b8f9..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembersShowRequestV1Tests.swift +++ /dev/null @@ -1,86 +0,0 @@ -// GetListsMembersShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsMembersShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsMembersShowRequestV1( - list: .listID("lid"), - user: .userID("uid"), - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/members/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "user_id": "uid", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testScreenName() throws { - let req = GetListsMembersShowRequestV1( - list: .listID("lid"), - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "screen_name": "s", - ] - ) - } - - public func testSlugUserID() throws { - let req = GetListsMembersShowRequestV1( - list: .slug(slug: "s", owner: .userID("ouid")), - user: .userID("uid") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "s", - "owner_id": "ouid", - "user_id": "uid", - ] - ) - } - - public func testSlugScreenName() throws { - let req = GetListsMembersShowRequestV1( - list: .slug(slug: "s", owner: .screenName("os")), - user: .userID("uid") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "s", - "owner_screen_name": "os", - "user_id": "uid", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembershipsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembershipsRequestV1Tests.swift deleted file mode 100644 index dacd7cdc..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsMembershipsRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetListsMembershipsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsMembershipsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsMembershipsRequestV1( - user: .userID("uid"), - count: 11, - cursor: "_c_", - filterToOwnedLists: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/memberships.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 11, - "cursor": "_c_", - "filter_to_owned_lists": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsMembershipsRequestV1( - user: .screenName("name") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "name", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsOwnershipsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsOwnershipsRequestV1Tests.swift deleted file mode 100644 index 3b92b82a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsOwnershipsRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetListsOwnershipsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsOwnershipsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsOwnershipsRequestV1( - user: .userID("uid"), - count: 21, - cursor: "_c_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/ownerships.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 21, - "cursor": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsOwnershipsRequestV1( - user: .screenName("name") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "name", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsShowRequestV1Tests.swift deleted file mode 100644 index 0e43cb0e..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsShowRequestV1Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// GetListsShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsShowRequestV1( - list: .listID("lid") - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - ] - ) - } - - public func testSlugUserID() throws { - let req = GetListsShowRequestV1( - list: .slug(slug: "sl", owner: .userID("uid")) - ) - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_id": "uid", - ] - ) - } - - public func testSlugScreenName() throws { - let req = GetListsShowRequestV1( - list: .slug(slug: "sl", owner: .screenName("sname")) - ) - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "sname", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsStatusesRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsStatusesRequestV1Tests.swift deleted file mode 100644 index b3863863..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsStatusesRequestV1Tests.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetListsStatusesRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsStatusesRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsStatusesRequestV1( - list: .listID("lid"), - count: 15, - sinceID: "_s_", - maxID: "_m_", - includeEntities: true, - includeRTs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/statuses.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "count": 15, - "since_id": "_s_", - "max_id": "_m_", - "include_entities": true, - "include_rts": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsStatusesRequestV1( - list: .listID("lid") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscribersRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscribersRequestV1Tests.swift deleted file mode 100644 index 1a424a00..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscribersRequestV1Tests.swift +++ /dev/null @@ -1,55 +0,0 @@ -// GetListsSubscribersRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsSubscribersRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsSubscribersRequestV1( - list: .listID("lid"), - count: 17, - cursor: "_c_", - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/subscribers.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "count": 17, - "cursor": "_c_", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsSubscribersRequestV1( - list: .slug(slug: "sl", owner: .userID("uid")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_id": "uid", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscribersShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscribersShowRequestV1Tests.swift deleted file mode 100644 index 56751703..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscribersShowRequestV1Tests.swift +++ /dev/null @@ -1,55 +0,0 @@ -// GetListsSubscribersShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsSubscribersShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsSubscribersShowRequestV1( - list: .listID("lid"), - user: .userID("uid"), - includeEntities: true, - skipStatus: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/subscribers/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "user_id": "uid", - "include_entities": true, - "skip_status": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsSubscribersShowRequestV1( - list: .slug(slug: "sl", owner: .screenName("sn")), - user: .userID("uid") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "sn", - "user_id": "uid", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscriptionsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscriptionsRequestV1Tests.swift deleted file mode 100644 index 438ecd2f..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/GetListsSubscriptionsRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetListsSubscriptionsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsSubscriptionsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetListsSubscriptionsRequestV1( - user: .userID("uid"), - count: 19, - cursor: "_c_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/subscriptions.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 19, - "cursor": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsSubscriptionsRequestV1( - user: .screenName("sn") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "sn", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/ListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/ListRequestV1Tests.swift deleted file mode 100644 index 6ef7202f..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/ListRequestV1Tests.swift +++ /dev/null @@ -1,72 +0,0 @@ -// ListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class CustomListsListRequestV1: GetListsListRequestV1 { - public let custom: String - - override public var parameters: [String: Any] { - var params = super.parameters - params["custom"] = custom - return params - } - - public init(custom: String, user: TwitterUserIdentifierV1, reverse: Bool? = .none) { - self.custom = custom - super.init(user: user, reverse: reverse) - } - - deinit { - // De-init Logic Here - } -} - -internal class CapsuledListsListRequestV1: GetListsListRequestV1 { - public init() { - super.init(user: .userID("100"), reverse: true) - } - - deinit { - // De-init Logic Here - } -} - -internal class ListRequestV1Tests: XCTestCase { - // https://developer.twitter.com/en/docs/twitter-api/v1/ \ - // accounts-and-users/create-manage-lists/api-reference/get-lists-list - public func testGetListsListRequestV1() throws { - let list = GetListsListRequestV1(user: .userID("1234")) - - XCTAssertEqual(list.method, .get) - XCTAssertEqual(list.path, "/1.1/lists/list.json") - AssertEqualAnyDict(list.parameters, ["user_id": "1234"]) - - let list2 = GetListsListRequestV1(user: .screenName("name"), reverse: true) - AssertEqualAnyDict(list2.parameters, ["screen_name": "name", "reverse": true]) - } - - public func testCustomListsListRequestV1() throws { - let list = CustomListsListRequestV1(custom: "_custom_", user: .userID("12")) - XCTAssertEqual(list.method, .get) - XCTAssertEqual(list.path, "/1.1/lists/list.json") - AssertEqualAnyDict(list.parameters, ["user_id": "12", "custom": "_custom_"]) - } - - public func testCapsuledListsListRequestV1() throws { - let list = CapsuledListsListRequestV1() - XCTAssertEqual(list.method, .get) - XCTAssertEqual(list.path, "/1.1/lists/list.json") - AssertEqualAnyDict(list.parameters, ["user_id": "100", "reverse": true]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsCreateRequestV1Tests.swift deleted file mode 100644 index 93661250..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsCreateRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostListsCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsCreateRequestV1( - name: "_n_", - mode: .private, - description: "_d_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "name": "_n_", - "mode": "private", - "description": "_d_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostListsCreateRequestV1( - name: "n" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "name": "n", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsDestroyRequestV1Tests.swift deleted file mode 100644 index bd1f1610..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsDestroyRequestV1Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// PostListsDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsDestroyRequestV1( - list: .listID("lid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - ] - ) - } - - public func testSlug() throws { - let req = PostListsDestroyRequestV1( - list: .slug(slug: "sl", owner: .screenName("sname")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "sname", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersCreateAllRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersCreateAllRequestV1Tests.swift deleted file mode 100644 index e7ed0243..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersCreateAllRequestV1Tests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// PostListsMembersCreateAllRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsMembersCreateAllRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsMembersCreateAllRequestV1( - list: .listID("lid"), - users: .userIDs(["uid1", "uid2"]) - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/members/create_all.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "user_id": "uid1,uid2", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersCreateRequestV1Tests.swift deleted file mode 100644 index 660a4ce9..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersCreateRequestV1Tests.swift +++ /dev/null @@ -1,51 +0,0 @@ -// PostListsMembersCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsMembersCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsMembersCreateRequestV1( - list: .listID("lid"), - user: .userID("uid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/members/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "user_id": "uid", - ] - ) - } - - public func testScreenName() throws { - let req = PostListsMembersCreateRequestV1( - list: .slug(slug: "sl", owner: .screenName("osname")), - user: .screenName("sname") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "osname", - "screen_name": "sname", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersDestroyAllRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersDestroyAllRequestV1Tests.swift deleted file mode 100644 index ae30a705..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersDestroyAllRequestV1Tests.swift +++ /dev/null @@ -1,51 +0,0 @@ -// PostListsMembersDestroyAllRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsMembersDestroyAllRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsMembersDestroyAllRequestV1( - list: .listID("lid"), - users: .userIDs(["uid1", "uid2"]) - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/members/destroy_all.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "user_id": "uid1,uid2", - ] - ) - } - - public func testScreenName() throws { - let req = PostListsMembersDestroyAllRequestV1( - list: .slug(slug: "sl", owner: .screenName("oname")), - users: .screenNames(["s1", "s2"]) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "oname", - "screen_name": "s1,s2", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersDestroyRequestV1Tests.swift deleted file mode 100644 index b6b9afaa..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsMembersDestroyRequestV1Tests.swift +++ /dev/null @@ -1,51 +0,0 @@ -// PostListsMembersDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsMembersDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsMembersDestroyRequestV1( - list: .listID("lid"), - user: .userID("uid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/members/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "user_id": "uid", - ] - ) - } - - public func testScreenName() throws { - let req = PostListsMembersDestroyRequestV1( - list: .slug(slug: "sl", owner: .screenName("sc")), - user: .screenName("name") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "sc", - "screen_name": "name", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsSubscribersCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsSubscribersCreateRequestV1Tests.swift deleted file mode 100644 index ed0aca75..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsSubscribersCreateRequestV1Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// PostListsSubscribersCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsSubscribersCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsSubscribersCreateRequestV1( - list: .listID("lid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/subscribers/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - ] - ) - } - - public func testScreenName() throws { - let req = PostListsSubscribersCreateRequestV1( - list: .slug(slug: "sl", owner: .screenName("name")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "name", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsSubscribersDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsSubscribersDestroyRequestV1Tests.swift deleted file mode 100644 index 3ac31ee9..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsSubscribersDestroyRequestV1Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// PostListsSubscribersDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsSubscribersDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsSubscribersDestroyRequestV1( - list: .listID("lid") - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/subscribers/destroy.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - ] - ) - } - - public func testScreenName() throws { - let req = PostListsSubscribersDestroyRequestV1( - list: .slug(slug: "sl", owner: .screenName("name")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "name", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/List/PostListsUpdateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/List/PostListsUpdateRequestV1Tests.swift deleted file mode 100644 index 4507895a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/List/PostListsUpdateRequestV1Tests.swift +++ /dev/null @@ -1,53 +0,0 @@ -// PostListsUpdateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsUpdateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostListsUpdateRequestV1( - list: .listID("lid"), - name: "_n_", - mode: .public, - description: "_d_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/lists/update.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "lid", - "name": "_n_", - "mode": "public", - "description": "_d_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostListsUpdateRequestV1( - list: .slug(slug: "sl", owner: .screenName("name")) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "slug": "sl", - "owner_screen_name": "name", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/GetUploadMediaStatusRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/GetUploadMediaStatusRequestV1Tests.swift deleted file mode 100644 index 89efa494..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/GetUploadMediaStatusRequestV1Tests.swift +++ /dev/null @@ -1,31 +0,0 @@ -// GetUploadMediaStatusRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUploadMediaStatusRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetUploadMediaStatusRequestV1(mediaID: "m") - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/1.1/media/upload.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "command": "STATUS", - "media_id": "m", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaMetadataCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaMetadataCreateRequestV1Tests.swift deleted file mode 100644 index 1b5e2634..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaMetadataCreateRequestV1Tests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// PostMediaMetadataCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostMediaMetadataCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostMediaMetadataCreateRequestV1( - mediaID: "m", - altText: "alt" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .upload) - XCTAssertEqual(req.path, "/1.1/media/metadata/create.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "media_id": "m", - "alt_text": ["text": "alt"], - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaSubtitlesCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaSubtitlesCreateRequestV1Tests.swift deleted file mode 100644 index cf0a2892..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaSubtitlesCreateRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// PostMediaSubtitlesCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostMediaSubtitlesCreateRequestV1Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = PostMediaSubtitlesCreateRequestV1( - mediaID: "mediaID", - mediaCategory: "c", - subtitles: [ - .init( - mediaID: "subtitleMediaID", - languageCode: "l", - displayName: "d" - ), - ] - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .upload) - XCTAssertEqual(req.path, "/1.1/media/subtitles/create.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "media_id": "mediaID", - "media_category": "c", - "subtitle_info": [ - "subtitles": [ - [ - "media_id": "subtitleMediaID", - "language_code": "l", - "display_name": "d", - ], - ], - ], - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaSubtitlesDeleteRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaSubtitlesDeleteRequestV1Tests.swift deleted file mode 100644 index c9d1cd14..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/PostMediaSubtitlesDeleteRequestV1Tests.swift +++ /dev/null @@ -1,41 +0,0 @@ -// PostMediaSubtitlesDeleteRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostMediaSubtitlesDeleteRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostMediaSubtitlesDeleteRequestV1( - mediaID: "m", - mediaCategory: "c", - subtitleLanguageCodes: ["l1", "l2"] - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.path, "/1.1/media/subtitles/delete.json") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "media_id": "m", - "media_category": "c", - "subtitle_info": [ - "subtitles": [ - ["language_code": "l1"], - ["language_code": "l2"], - ], - ], - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaAppendRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaAppendRequestV1Tests.swift deleted file mode 100644 index a131bd18..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaAppendRequestV1Tests.swift +++ /dev/null @@ -1,105 +0,0 @@ -// UploadMediaAppendRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class UploadMediaAppendRequestV1Tests: XCTestCase { - public func test() throws { - let data = Data() - let req = UploadMediaAppendRequestV1( - mediaID: "m", - filename: "f", - mimeType: "m", - media: data, - segmentIndex: 1 - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .upload) - XCTAssertEqual(req.path, "/1.1/media/upload.json") - XCTAssertEqual(req.bodyContentType, .multipartFormData) - XCTAssertEqual( - req.parameters, - [ - "command": MultipartFormDataPart.value(name: "command", value: "APPEND"), - "media_id": MultipartFormDataPart.value(name: "media_id", value: "m"), - "media": MultipartFormDataPart.data(name: "media", value: data, filename: "f", mimeType: "m"), - "segment_index": MultipartFormDataPart.value(name: "segment_index", value: 1), - ] - ) - } - - public func testSegments() throws { - let data = Data([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - - let req = UploadMediaAppendRequestV1( - mediaID: "m", - filename: "f", - mimeType: "m", - media: data - ) - - let reqs = req.segments(maxBytes: 3) - - XCTAssertEqual(reqs.count, 4) - - XCTAssertEqual(reqs[0].mediaID, "m") - XCTAssertEqual(reqs[0].filename, "f") - XCTAssertEqual(reqs[0].mimeType, "m") - - XCTAssertEqual(reqs[0].media, Data([0, 1, 2])) - XCTAssertEqual(reqs[0].segmentIndex, 0) - - XCTAssertEqual(reqs[1].media, Data([3, 4, 5])) - XCTAssertEqual(reqs[1].segmentIndex, 1) - - XCTAssertEqual(reqs[2].media, Data([6, 7, 8])) - XCTAssertEqual(reqs[2].segmentIndex, 2) - - XCTAssertEqual(reqs[3].media, Data([9, 10])) - XCTAssertEqual(reqs[3].segmentIndex, 3) - } - - public func testSegumentsMiddle() throws { - // | 0 | 1 | 2 | 3 | 4 | 5 - let data = Data([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - - let req = UploadMediaAppendRequestV1( - mediaID: "m", - filename: "f", - mimeType: "m", - media: data, - segmentIndex: 2 - ) - - let reqs = req.segments(maxBytes: 2) - - XCTAssertEqual(reqs.count, 4) - - XCTAssertEqual(reqs[0].mediaID, "m") - XCTAssertEqual(reqs[0].filename, "f") - XCTAssertEqual(reqs[0].mimeType, "m") - - XCTAssertEqual(reqs[0].media, Data([4, 5])) - XCTAssertEqual(reqs[0].segmentIndex, 2) - - XCTAssertEqual(reqs[1].media, Data([6, 7])) - XCTAssertEqual(reqs[1].segmentIndex, 3) - - XCTAssertEqual(reqs[2].media, Data([8, 9])) - XCTAssertEqual(reqs[2].segmentIndex, 4) - - XCTAssertEqual(reqs[3].media, Data([10])) - XCTAssertEqual(reqs[3].segmentIndex, 5) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaFinalizeRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaFinalizeRequestV1Tests.swift deleted file mode 100644 index 21251cc3..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaFinalizeRequestV1Tests.swift +++ /dev/null @@ -1,32 +0,0 @@ -// UploadMediaFinalizeRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class UploadMediaFinalizeRequestV1Tests: XCTestCase { - public func test() throws { - let req = UploadMediaFinalizeRequestV1(mediaID: "m") - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .upload) - XCTAssertEqual(req.path, "/1.1/media/upload.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "command": "FINALIZE", - "media_id": "m", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaInitRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaInitRequestV1Tests.swift deleted file mode 100644 index 22f83f93..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Media/UploadMediaInitRequestV1Tests.swift +++ /dev/null @@ -1,40 +0,0 @@ -// UploadMediaInitRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class UploadMediaInitRequestV1Tests: XCTestCase { - public func test() throws { - let req = UploadMediaInitRequestV1( - totalBytes: 10, - mediaType: "image/jpg", - mediaCategory: "c", - additionalOwners: ["1", "2"] - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .upload) - XCTAssertEqual(req.path, "/1.1/media/upload.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "command": "INIT", - "total_bytes": 10, - "media_type": "image/jpg", - "media_category": "c", - "additional_owners": "1,2", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetersRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetersRequestV1Tests.swift deleted file mode 100644 index 20fa6a21..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetersRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetRetweetersRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetRetweetersRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetRetweetersRequestV1( - tweetID: "_i_", - count: 100, - cursor: "_c_", - stringifyIDs: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/retweeters/ids.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "count": 100, - "cursor": "_c_", - "stringify_ids": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetRetweetersRequestV1( - tweetID: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetsOfMeRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetsOfMeRequestV1Tests.swift deleted file mode 100644 index 08f2de06..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetsOfMeRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetRetweetsOfMeRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetRetweetsOfMeRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetRetweetsOfMeRequestV1( - count: 10, - sinceID: "_s_", - maxID: "_m_", - trimUser: true, - includeEntities: true, - includeUserEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/retweets_of_me.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "count": 10, - "since_id": "_s_", - "max_id": "_m_", - "trim_user": true, - "include_entities": true, - "include_user_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetRetweetsOfMeRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetsRequestV1Tests.swift deleted file mode 100644 index 806c206f..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Retweet/GetRetweetsRequestV1Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// GetRetweetsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetRetweetsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetRetweetsRequestV1( - id: "_i_", - count: 12, - trimUser: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/retweets/_i_.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "count": 12, - "trim_user": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetRetweetsRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Retweet/PostRetweetRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Retweet/PostRetweetRequestV1Tests.swift deleted file mode 100644 index b537bfcc..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Retweet/PostRetweetRequestV1Tests.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostRetweetRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostRetweetRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostRetweetRequestV1( - id: "_i_", - trimUser: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/retweet/_i_.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "trim_user": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostRetweetRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Retweet/PostUnRetweetRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Retweet/PostUnRetweetRequestV1Tests.swift deleted file mode 100644 index d1baf755..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Retweet/PostUnRetweetRequestV1Tests.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostUnRetweetRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUnRetweetRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostUnRetweetRequestV1( - id: "_i_", - trimUser: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/unretweet/_i_.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "trim_user": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostUnRetweetRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Search/GetSavedSearchesListRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Search/GetSavedSearchesListRequestV1Tests.swift deleted file mode 100644 index 67564328..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Search/GetSavedSearchesListRequestV1Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// GetSavedSearchesListRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSavedSearchesListRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetSavedSearchesListRequestV1() - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/saved_searches/list.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Search/GetSearchTweetsRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Search/GetSearchTweetsRequestV1Tests.swift deleted file mode 100644 index 4e4f2171..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Search/GetSearchTweetsRequestV1Tests.swift +++ /dev/null @@ -1,63 +0,0 @@ -// GetSearchTweetsRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSearchTweetsRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetSearchTweetsRequestV1( - query: "恂恂恂", - lang: "lang", - count: 20, - until: "2015-07-19", - maxID: "100", - locale: "locale", - geocode: "geo", - sinceID: "10", - resultType: .popular, - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/1.1/search/tweets.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "include_entities": true, - "lang": "lang", - "since_id": "10", - "q": "恂恂恂", - "until": "2015-07-19", - "geocode": "geo", - "result_type": "popular", - "count": 20, - "max_id": "100", - "locale": "locale", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSearchTweetsRequestV1( - query: "_q_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "q": "_q_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Search/PostSavedSearchesCreateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Search/PostSavedSearchesCreateRequestV1Tests.swift deleted file mode 100644 index 3da144f5..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Search/PostSavedSearchesCreateRequestV1Tests.swift +++ /dev/null @@ -1,33 +0,0 @@ -// PostSavedSearchesCreateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostSavedSearchesCreateRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostSavedSearchesCreateRequestV1( - query: "_q_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/saved_searches/create.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "query": "_q_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Search/PostSavedSearchesDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Search/PostSavedSearchesDestroyRequestV1Tests.swift deleted file mode 100644 index 4253b16a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Search/PostSavedSearchesDestroyRequestV1Tests.swift +++ /dev/null @@ -1,31 +0,0 @@ -// PostSavedSearchesDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostSavedSearchesDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostSavedSearchesDestroyRequestV1( - id: "_i_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/saved_searches/destroy/_i_.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesHomeTimelineRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesHomeTimelineRequestV1Tests.swift deleted file mode 100644 index 00ae9cb7..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesHomeTimelineRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetStatusesHomeTimelineRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetStatusesHomeTimelineRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetStatusesHomeTimelineRequestV1( - count: 11, - maxID: "_m_", - sinceID: "_s_", - trimUser: true, - excludeReplies: true, - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/home_timeline.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "count": 11, - "max_id": "_m_", - "since_id": "_s_", - "trim_user": true, - "exclude_replies": true, - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetStatusesHomeTimelineRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesMentionsTimelineRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesMentionsTimelineRequestV1Tests.swift deleted file mode 100644 index 149037c8..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesMentionsTimelineRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetStatusesMentionsTimelineRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetStatusesMentionsTimelineRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetStatusesMentionsTimelineRequestV1( - count: 100, - maxID: "_m_", - sinceID: "_s_", - trimUser: true, - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/mentions_timeline.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "count": 100, - "max_id": "_m_", - "since_id": "_s_", - "trim_user": true, - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetStatusesMentionsTimelineRequestV1() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesUserTimelineRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesUserTimelineRequestV1Tests.swift deleted file mode 100644 index 71a91eb5..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Timelines/GetStatusesUserTimelineRequestV1Tests.swift +++ /dev/null @@ -1,58 +0,0 @@ -// GetStatusesUserTimelineRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetStatusesUserTimelineRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetStatusesUserTimelineRequestV1( - user: .userID("uid"), - count: 12, - maxID: "_m_", - sinceID: "_s_", - trimUser: true, - includeRTs: true, - excludeReplies: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/user_timeline.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "count": 12, - "max_id": "_m_", - "since_id": "_s_", - "trim_user": true, - "include_rts": true, - "exclude_replies": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetStatusesUserTimelineRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsAvailableRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsAvailableRequestV1Tests.swift deleted file mode 100644 index ee2e6bca..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsAvailableRequestV1Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// GetTrendsAvailableRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTrendsAvailableRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetTrendsAvailableRequestV1() - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/trends/available.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsClosestRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsClosestRequestV1Tests.swift deleted file mode 100644 index 20b8fa3a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsClosestRequestV1Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// GetTrendsClosestRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTrendsClosestRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetTrendsClosestRequestV1( - location: TwitterCoordinateV1(lat: 37.7, long: -122.4) - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/trends/closest.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "lat": 37.7, - "long": -122.4, - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsPlaceRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsPlaceRequestV1Tests.swift deleted file mode 100644 index cd105248..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Trend/GetTrendsPlaceRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetTrendsPlaceRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTrendsPlaceRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetTrendsPlaceRequestV1( - woeid: "_w_", - exclude: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/trends/place.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "woeid": "_w_", - "exclude": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTrendsPlaceRequestV1( - woeid: "_w_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "woeid": "_w_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Tweet/GetStatusesLookupRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Tweet/GetStatusesLookupRequestV1Tests.swift deleted file mode 100644 index 0031ca4a..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Tweet/GetStatusesLookupRequestV1Tests.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetStatusesLookupRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetStatusesLookupRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetStatusesLookupRequestV1( - ids: ["a", "b"], - map: true, - trimUser: true, - includeCardUri: true, - includeEntities: true, - includeExtAltText: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/lookup.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "a,b", - "map": true, - "trim_user": true, - "include_card_uri": true, - "include_entities": true, - "include_ext_alt_text": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetStatusesLookupRequestV1( - ids: ["a"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "a", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Tweet/GetStatusesShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Tweet/GetStatusesShowRequestV1Tests.swift deleted file mode 100644 index 6c41e46f..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Tweet/GetStatusesShowRequestV1Tests.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetStatusesShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetStatusesShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetStatusesShowRequestV1( - id: "_i_", - trimUser: true, - includeCardUri: true, - includeEntities: true, - includeMyRetweet: true, - includeExtAltText: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - "trim_user": true, - "include_card_uri": true, - "include_entities": true, - "include_my_retweet": true, - "include_ext_alt_text": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetStatusesShowRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "id": "_i_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Tweet/PostStatusesDestroyRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Tweet/PostStatusesDestroyRequestV1Tests.swift deleted file mode 100644 index cbd67398..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Tweet/PostStatusesDestroyRequestV1Tests.swift +++ /dev/null @@ -1,45 +0,0 @@ -// PostStatusesDestroyRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostStatusesDestroyRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostStatusesDestroyRequestV1( - id: "_i_", - trimUser: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/destroy/_i_.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "trim_user": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostStatusesDestroyRequestV1( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Tweet/PostStatusesUpdateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Tweet/PostStatusesUpdateRequestV1Tests.swift deleted file mode 100644 index 4a1548a3..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Tweet/PostStatusesUpdateRequestV1Tests.swift +++ /dev/null @@ -1,74 +0,0 @@ -// PostStatusesUpdateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostStatusesUpdateRequestV1Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = PostStatusesUpdateRequestV1( - status: "_s_", - inReplyToStatusID: "_i_", - autoPopulateReplyMetadata: true, - excludeReplyUserIDs: ["786491", "54931584"], - attachmentUrl: "_a_", - mediaIDs: ["1", "2"], - possiblySensitive: true, - location: .init(lat: 10.1, long: -1.2), - placeID: "_p_", - displayCoordinates: true, - trimUser: true, - enableDMcommands: true, - failDMcommands: true, - cardUri: "_c_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/statuses/update.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "status": "_s_", - "in_reply_to_status_id": "_i_", - "auto_populate_reply_metadata": true, - "exclude_reply_user_ids": "786491,54931584", - "attachment_url": "_a_", - "media_ids": "1,2", - "possibly_sensitive": true, - "lat": 10.1, - "long": -1.2, - "place_id": "_p_", - "display_coordinates": true, - "trim_user": true, - "enable_dmcommands": true, - "fail_dmcommands": true, - "card_uri": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostStatusesUpdateRequestV1( - status: "_s_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "status": "_s_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersLookupRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersLookupRequestV1Tests.swift deleted file mode 100644 index 43467471..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersLookupRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersLookupRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersLookupRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetUsersLookupRequestV1( - users: .userIDs(["uid1", "uid2"]), - tweetMode: true, - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/users/lookup.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid1,uid2", - "tweet_mode": true, - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersLookupRequestV1( - users: .screenNames(["s1", "s2"]) - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s1,s2", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersProfileBannerRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersProfileBannerRequestV1Tests.swift deleted file mode 100644 index 9065d3a2..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersProfileBannerRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersProfileBannerRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersProfileBannerRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetUsersProfileBannerRequestV1( - user: .userID("uid") - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/users/profile_banner.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - ] - ) - } - - public func testScreenName() throws { - let req = GetUsersProfileBannerRequestV1( - user: .screenName("s") - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/users/profile_banner.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersSearchRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersSearchRequestV1Tests.swift deleted file mode 100644 index 4e6b3c15..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersSearchRequestV1Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetUsersSearchRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersSearchRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetUsersSearchRequestV1( - query: "_q_", - page: 11, - count: 100, - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/users/search.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "q": "_q_", - "page": 11, - "count": 100, - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersSearchRequestV1( - query: "qq" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "q": "qq", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersShowRequestV1Tests.swift b/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersShowRequestV1Tests.swift deleted file mode 100644 index 47f94ca8..00000000 --- a/Tests/TwitterAPIKitTests/APIv1/Users/GetUsersShowRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetUsersShowRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersShowRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetUsersShowRequestV1( - user: .userID("uid"), - includeEntities: true - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/users/show.json") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "uid", - "include_entities": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersShowRequestV1( - user: .screenName("s") - ) - - AssertEqualAnyDict( - req.parameters, - [ - "screen_name": "s", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/DeleteUsersBlockingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/DeleteUsersBlockingRequestV2Tests.swift deleted file mode 100644 index 3f5aef93..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/DeleteUsersBlockingRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteUsersBlockingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersBlockingRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersBlockingRequestV2( - sourceUserID: "_sourceUserID_", - targetUserID: "_targetUserID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_sourceUserID_/blocking/_targetUserID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/DeleteUsersMutingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/DeleteUsersMutingRequestV2Tests.swift deleted file mode 100644 index d0f61d65..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/DeleteUsersMutingRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteUsersMutingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersMutingRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersMutingRequestV2( - sourceUserID: "_sourceUserID_", - targetUserID: "_targetUserID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_sourceUserID_/muting/_targetUserID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/GetUsersBlockingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/GetUsersBlockingRequestV2Tests.swift deleted file mode 100644 index d6bfb85f..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/GetUsersBlockingRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersBlockingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersBlockingRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersBlockingRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 100, - paginationToken: "token", - tweetFields: [.entities, .geo, .contextAnnotations], - userFields: [.profileImageUrl, .protected, .publicMetrics] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/blocking") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.queryParameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 100, - "pagination_token": "token", - "tweet.fields": "context_annotations,entities,geo", - "user.fields": "profile_image_url,protected,public_metrics", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersBlockingRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/GetUsersMutingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/GetUsersMutingRequestV2Tests.swift deleted file mode 100644 index 465da98c..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/GetUsersMutingRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersMutingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersMutingRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersMutingRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 200, - paginationToken: "t", - tweetFields: [.id, .inReplyToUserID, .conversationID], - userFields: [.createdAt, .username, .verified] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/muting") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 200, - "pagination_token": "t", - "tweet.fields": "conversation_id,id,in_reply_to_user_id", - "user.fields": "created_at,username,verified", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersMutingRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/PostUsersBlockingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/PostUsersBlockingRequestV2Tests.swift deleted file mode 100644 index a04b4780..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/PostUsersBlockingRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersBlockingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersBlockingRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersBlockingRequestV2( - id: "_id_", - targetUserID: "_targetUserID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/blocking") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "target_user_id": "_targetUserID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/PostUsersMutingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/PostUsersMutingRequestV2Tests.swift deleted file mode 100644 index d825f07f..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/BlockAndMute/PostUsersMutingRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersMutingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersMutingRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersMutingRequestV2( - id: "_id_", - targetUserID: "_targetUserID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/muting") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "target_user_id": "_targetUserID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Bookmarks/DeleteUsersBookmarksRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Bookmarks/DeleteUsersBookmarksRequestV2Tests.swift deleted file mode 100644 index 6929fac4..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Bookmarks/DeleteUsersBookmarksRequestV2Tests.swift +++ /dev/null @@ -1,32 +0,0 @@ -// DeleteUsersBookmarksRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersBookmarksRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersBookmarksRequestV2( - id: "_i_", - tweetID: "_t_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_i_/bookmarks/_t_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Bookmarks/GetUsersBookmarksRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Bookmarks/GetUsersBookmarksRequestV2Tests.swift deleted file mode 100644 index ed0bcb8f..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Bookmarks/GetUsersBookmarksRequestV2Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// GetUsersBookmarksRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersBookmarksRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersBookmarksRequestV2( - id: "_i_", - expansions: [.authorID], - maxResults: 12, - mediaFields: [.height], - paginationToken: "_p_", - placeFields: [.name], - pollFields: [.options], - tweetFields: [.text], - userFields: [.entities] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_i_/bookmarks") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "author_id", - "max_results": 12, - "media.fields": "height", - "pagination_token": "_p_", - "place.fields": "name", - "poll.fields": "options", - "tweet.fields": "text", - "user.fields": "entities", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersBookmarksRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Bookmarks/PostUsersBookmarksRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Bookmarks/PostUsersBookmarksRequestV2Tests.swift deleted file mode 100644 index f8f15ff6..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Bookmarks/PostUsersBookmarksRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersBookmarksRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersBookmarksRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersBookmarksRequestV2( - id: "_i_", - tweetID: "_t_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_i_/bookmarks") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "tweet_id": "_t_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Compliance/GetComplianceJobRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Compliance/GetComplianceJobRequestV2Tests.swift deleted file mode 100644 index faa077b8..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Compliance/GetComplianceJobRequestV2Tests.swift +++ /dev/null @@ -1,28 +0,0 @@ -// GetComplianceJobRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetComplianceJobRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetComplianceJobRequestV2( - id: 1 - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/compliance/jobs/1") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Compliance/GetComplianceJobsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Compliance/GetComplianceJobsRequestV2Tests.swift deleted file mode 100644 index bbf7da6f..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Compliance/GetComplianceJobsRequestV2Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// GetComplianceJobsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetComplianceJobsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetComplianceJobsRequestV2( - type: .tweets, - status: .complete - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/compliance/jobs") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "type": "tweets", - "status": "complete", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetComplianceJobsRequestV2( - type: .users - ) - - AssertEqualAnyDict( - req.parameters, - [ - "type": "users", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Compliance/PostComplianceJobsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Compliance/PostComplianceJobsRequestV2Tests.swift deleted file mode 100644 index 0a7e247e..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Compliance/PostComplianceJobsRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostComplianceJobsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostComplianceJobsRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostComplianceJobsRequestV2( - type: .tweets, - name: "n", - resumable: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/compliance/jobs") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "type": "tweets", - "name": "n", - "resumable": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostComplianceJobsRequestV2( - type: .users - ) - - AssertEqualAnyDict( - req.parameters, - [ - "type": "users", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmConversationsIdDmEventsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmConversationsIdDmEventsRequestV2Tests.swift deleted file mode 100644 index 6f60dcab..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmConversationsIdDmEventsRequestV2Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// GetDmConversationsIdDmEventsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetDmConversationsIdDmEventsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetDmConversationsIdDmEventsRequestV2( - id: "_i_", - maxResults: 11, - paginationToken: "_p_", - eventTypes: [.messageCreate, .participantsJoin], - dmEventFields: [.senderID], - expansions: [.participantIDs], - mediaFields: [.durationMs], - userFields: [.id], - tweetFields: [.text] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/dm_conversations/_i_/dm_events") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "max_results": 11, - "pagination_token": "_p_", - "event_types": "MessageCreate,ParticipantsJoin", - "dm_event.fields": "sender_id", - "expansions": "participant_ids", - "media.fields": "duration_ms", - "user.fields": "id", - "tweet.fields": "text", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetDmConversationsIdDmEventsRequestV2( - id: "i" - ) - XCTAssertEqual(req.path, "/2/dm_conversations/i/dm_events") - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmConversationsWithParticipantIdDmEventsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmConversationsWithParticipantIdDmEventsRequestV2Tests.swift deleted file mode 100644 index b888d549..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmConversationsWithParticipantIdDmEventsRequestV2Tests.swift +++ /dev/null @@ -1,61 +0,0 @@ -// GetDmConversationsWithParticipantIdDmEventsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -// swiftlint:disable:next type_name -internal class GetDmConversationsWithParticipantIdDmEventsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetDmConversationsWithParticipantIdDmEventsRequestV2( - participantID: "_p_id", - maxResults: 12, - paginationToken: "_p_", - eventTypes: [.participantsLeave], - dmEventFields: [.eventType], - expansions: [.attachmentsMediaKeys], - mediaFields: [], - userFields: [], - tweetFields: [] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/dm_conversations/with/_p_id/dm_events") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "max_results": 12, - "pagination_token": "_p_", - "event_types": "ParticipantsLeave", - "dm_event.fields": "event_type", - "expansions": "attachments.media_keys", - "media.fields": "", - "user.fields": "", - "tweet.fields": "", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetDmConversationsWithParticipantIdDmEventsRequestV2( - participantID: "p" - ) - - XCTAssertEqual(req.path, "/2/dm_conversations/with/p/dm_events") - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmEventsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmEventsRequestV2Tests.swift deleted file mode 100644 index e218a1d2..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/GetDmEventsRequestV2Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// GetDmEventsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetDmEventsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetDmEventsRequestV2( - maxResults: 10, - paginationToken: "_p_", - eventTypes: [], - dmEventFields: [.referencedTweets], - expansions: [.referencedTweetsID], - mediaFields: [.altText], - userFields: [.username], - tweetFields: [.lang] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/dm_events") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "max_results": 10, - "pagination_token": "_p_", - "event_types": "", - "dm_event.fields": "referenced_tweets", - "expansions": "referenced_tweets.id", - "media.fields": "alt_text", - "user.fields": "username", - "tweet.fields": "lang", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationByIdRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationByIdRequestV2Tests.swift deleted file mode 100644 index ef6316c9..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationByIdRequestV2Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostDmConversationByIdRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostDmConversationByIdRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostDmConversationByIdRequestV2( - dmConversationID: "_d_id", - attachments: ["1", "2"], - text: "_t_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/dm_conversations/_d_id/messages") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "attachments": [["media_id": "1"], ["media_id": "2"]], - "text": "_t_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostDmConversationByIdRequestV2( - dmConversationID: "_d_" - ) - - XCTAssertEqual(req.path, "/2/dm_conversations/_d_/messages") - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationRequestV2Tests.swift deleted file mode 100644 index 54e44eaa..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationRequestV2Tests.swift +++ /dev/null @@ -1,57 +0,0 @@ -// PostDmConversationRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostDmConversationRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostDmConversationRequestV2( - conversationType: .group, - participantIDs: ["a", "b"], - attachments: ["2", "3"], - text: "_t_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/dm_conversations") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "conversation_type": "Group", - "participant_ids": ["a", "b"], - "message": [ - "attachments": [["media_id": "2"], ["media_id": "3"]], - "text": "_t_", - ], - ] - ) - } - - public func testDefaultArg() throws { - let req = PostDmConversationRequestV2( - conversationType: .group, - participantIDs: ["a", "b", "c"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "conversation_type": "Group", - "participant_ids": ["a", "b", "c"], - "message": [:], - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationWithUserRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationWithUserRequestV2Tests.swift deleted file mode 100644 index c6f8c352..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/DirectMessage/PostDmConversationWithUserRequestV2Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostDmConversationWithUserRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostDmConversationWithUserRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostDmConversationWithUserRequestV2( - participantID: "_p_", - attachments: ["10"], - text: "_t_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/dm_conversations/with/_p_/messages") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "attachments": [["media_id": "10"]], - "text": "_t_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostDmConversationWithUserRequestV2( - participantID: "_p_id" - ) - - XCTAssertEqual(req.path, "/2/dm_conversations/with/_p_id/messages") - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/ExpansionsV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/ExpansionsV2Tests.swift deleted file mode 100644 index e35f38fa..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/ExpansionsV2Tests.swift +++ /dev/null @@ -1,123 +0,0 @@ -// ExpansionsV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class ExpansionsV2Tests: XCTestCase { - public func testTwitterTweetExpansionsV2() throws { - let allCases: [TwitterTweetExpansionsV2] = [ - .attachmentsPollIDs, - .attachmentsMediaKeys, - .authorID, - .entitiesMentionsUsername, - .geoPlaceID, - .inReplyToUserID, - .referencedTweetsID, - .referencedTweetsIDAuthorID, - .other("~~~"), - ] - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.TweetExpansionsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "attachments.media_keys,attachments.poll_ids,author_id," + - "entities.mentions.username,geo.place_id,in_reply_to_user_id," + - "referenced_tweets.id,referenced_tweets.id.author_id,~~~" - ) - } - - public func testTwitterTweetExpansionsV2All() throws { - XCTAssertEqual(TwitterTweetExpansionsV2.all.count, 8) - } - - public func testTwitterUserExpansionsV2() throws { - let allCases: [TwitterUserExpansionsV2] = [ - .pinnedTweetID, - .other("~~~"), - ] - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.UserExpansionsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "pinned_tweet_id,~~~" - ) - } - - public func testTwitterUserExpansionsV2All() throws { - XCTAssertEqual(TwitterUserExpansionsV2.all.count, 1) - } - - public func testTwitterListExpansionsV2() throws { - let allCases: [TwitterListExpansionsV2] = [ - .ownerID, - .other("~~~"), - ] - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.ListExpansionsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "owner_id,~~~" - ) - } - - public func testTwitterListExpansionsV2All() throws { - XCTAssertEqual(TwitterListExpansionsV2.all.count, 1) - } - - public func testTwitterSpaceExpansionsV2() throws { - let allCases: [TwitterSpaceExpansionsV2] = [ - .invitedUserIDs, - .speakerIDs, - .creatorID, - .hostIDs, - .topicIDs, - .other("~~~"), - ] - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.SpaceExpansionsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "creator_id,host_ids,invited_user_ids,speaker_ids,topic_ids,~~~" - ) - } - - public func testTwitterSpaceExpansionsV2All() throws { - XCTAssertEqual(TwitterSpaceExpansionsV2.all.count, 5) - } - - public func testTwitterDmEventExpansionsV2() throws { - let allCases: [TwitterDmEventExpansionsV2] = [ - .attachmentsMediaKeys, - .participantIDs, - .referencedTweetsID, - .senderID, - .other("~~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.DmEventExpansionsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "attachments.media_keys,participant_ids,referenced_tweets.id,sender_id,~~~" - ) - } - - public func testTwitterDmEventExpansionsV2All() throws { - XCTAssertEqual(TwitterDmEventExpansionsV2.all.count, 4) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/FieldsV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/FieldsV2Tests.swift deleted file mode 100644 index 9f809bc2..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/FieldsV2Tests.swift +++ /dev/null @@ -1,294 +0,0 @@ -// FieldsV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class FieldsV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func testTwitterTweetFieldsV2() throws { - let allCases: [TwitterTweetFieldsV2] = [ - .attachments, - .authorID, - .contextAnnotations, - .conversationID, - .createdAt, - .entities, - .geo, - .id, - .inReplyToUserID, - .lang, - .nonPublicMetrics, - .publicMetrics, - .organicMetrics, - .promotedMetrics, - .possiblySensitive, - .referencedTweets, - .replySettings, - .source, - .text, - .withheld, - .other("~~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.TweetFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "attachments,author_id,context_annotations," + - "conversation_id,created_at,entities,geo,id," + - "in_reply_to_user_id,lang,non_public_metrics," + - "organic_metrics,possibly_sensitive,promoted_metrics," + - "public_metrics,referenced_tweets,reply_settings,source,text,withheld,~~~" - ) - } - - public func testTwitterTweetFieldsV2All() throws { - XCTAssertEqual(TwitterTweetFieldsV2.all.count, 20) - } - - public func testTwitterUserFieldsV2() throws { - let allCases: [TwitterUserFieldsV2] = [ - .createdAt, - .description, - .entities, - .id, - .location, - .name, - .pinnedTweetID, - .profileImageUrl, - .protected, - .publicMetrics, - .url, - .username, - .verified, - .withheld, - .other("~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.UserFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "created_at,description,entities," + - "id,location,name,pinned_tweet_id," + - "profile_image_url,protected,public_metrics,url,username,verified,withheld,~~" - ) - } - - public func testTwitterUserFieldsV2All() throws { - XCTAssertEqual(TwitterUserFieldsV2.all.count, 14) - } - - public func testTwitterPlaceFieldsV2() throws { - let allCases: [TwitterPlaceFieldsV2] = [ - .containedWithin, - .country, - .countryCode, - .fullName, - .geo, - .id, - .name, - .placeType, - .other("~~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.PlaceFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "contained_within,country,country_code,full_name,geo,id,name,place_type,~~~" - ) - } - - public func testTwitterPlaceFieldsV2All() throws { - XCTAssertEqual(TwitterPlaceFieldsV2.all.count, 8) - } - - public func testTwitterPollFieldsV2() throws { - let allCases: [TwitterPollFieldsV2] = [ - .durationMinutes, - .endDatetime, - .id, - .options, - .votingStatus, - .other("~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.PollFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "duration_minutes,end_datetime,id,options,voting_status,~~" - ) - } - - public func testTwitterPollFieldsV2All() throws { - XCTAssertEqual(TwitterPollFieldsV2.all.count, 5) - } - - public func testTwitterMediaFieldsV2() throws { - let allCases: [TwitterMediaFieldsV2] = [ - .durationMs, - .height, - .mediaKey, - .previewImageUrl, - .type, - .url, - .width, - .publicMetrics, - .nonPublicMetrics, - .organicMetrics, - .promotedMetrics, - .altText, - .variants, - .other("~~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.MediaFieldsParameter.schema.items.enum | sort | join(",")' - - // Note: `url` is missing in - // https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media - // https://twittercommunity.com/t/documentation-for-media-object-missing-url-field/163062 - XCTAssertEqual( - allCases.commaSeparatedString, - "alt_text,duration_ms,height,media_key" + - ",non_public_metrics,organic_metrics,preview_image_url" + - ",promoted_metrics,public_metrics,type,url,variants,width,~~~" - ) - } - - public func testTwitterMediaFieldsV2All() throws { - XCTAssertEqual(TwitterMediaFieldsV2.all.count, 13) - } - - public func testTwitterListFieldsV2() throws { - let allCases: [TwitterListFieldsV2] = [ - .createdAt, - .followerCount, - .memberCount, - .private, - .description, - .id, - .name, - .ownerID, - .other("~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.ListFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "created_at,description,follower_count,id,member_count,name,owner_id,private,~" - ) - } - - public func testTwitterListFieldsV2All() throws { - XCTAssertEqual(TwitterListFieldsV2.all.count, 8) - } - - public func testTwitterSpaceFieldsV2() throws { - let allCases: [TwitterSpaceFieldsV2] = [ - .id, - .state, - .hostIDs, - .createdAt, - .creatorID, - .lang, - .invitedUserIDs, - .participantCount, - .speakerIDs, - .startedAt, - .endedAt, - .subscriberCount, - .topicIDs, - .title, - .updatedAt, - .scheduledStart, - .isTicketed, - .other("~~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.SpaceFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "created_at,creator_id,ended_at,host_ids," + - "id,invited_user_ids,is_ticketed,lang,participant_count," + - "scheduled_start,speaker_ids,started_at,state,subscriber_count,title,topic_ids,updated_at,~~" - ) - } - - public func testTwitterSpaceFieldsV2All() throws { - XCTAssertEqual(TwitterSpaceFieldsV2.all.count, 17) - } - - public func testTwitterTopicFieldsV2() throws { - let allCases: [TwitterTopicFieldsV2] = [ - .id, - .name, - .description, - .other("~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.TopicFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "description,id,name,~" - ) - } - - public func testTwitterTopicFieldsV2All() throws { - XCTAssertEqual(TwitterTopicFieldsV2.all.count, 3) - } - - public func testTwitterDmEventFieldsV2() throws { - let allCases: [TwitterDmEventFieldsV2] = [ - .attachments, - .createdAt, - .dmConversationID, - .eventType, - .id, - .participantIDs, - .referencedTweets, - .senderID, - .text, - .other("~"), - ].shuffled() - - // curl https://api.twitter.com/2/openapi.json | \ - // jq '.components.parameters.DmEventFieldsParameter.schema.items.enum | sort | join(",")' - XCTAssertEqual( - allCases.commaSeparatedString, - "attachments,created_at,dm_conversation_id,event_type,id,participant_ids,referenced_tweets,sender_id,text,~" - ) - } - - public func testTwitterDmEventFieldsV2All() throws { - XCTAssertEqual(TwitterDmEventFieldsV2.all.count, 9) - } - - public func testTwitterDmConversationFieldsV2() throws { - let allCases: [TwitterDmConversationFieldsV2] = [ - .id, - .other("~"), - ].shuffled() - XCTAssertEqual(allCases.commaSeparatedString, "id,~") - } - - public func testTwitterDmConversationFieldsV2All() throws { - XCTAssertEqual(TwitterDmConversationFieldsV2.all.count, 1) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Friendships/DeleteUsersFollowingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Friendships/DeleteUsersFollowingRequestV2Tests.swift deleted file mode 100644 index 15e4c03e..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Friendships/DeleteUsersFollowingRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteUsersFollowingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersFollowingRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersFollowingRequestV2( - sourceUserID: "_sourceUserID_", - targetUserID: "_targetUserID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_sourceUserID_/following/_targetUserID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Friendships/GetUsersFollowersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Friendships/GetUsersFollowersRequestV2Tests.swift deleted file mode 100644 index 120af232..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Friendships/GetUsersFollowersRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersFollowersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersFollowersRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersFollowersRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 10, - paginationToken: "token", - tweetFields: [.conversationID], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/followers") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 10, - "pagination_token": "token", - "tweet.fields": "conversation_id", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersFollowersRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Friendships/GetUsersFollowingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Friendships/GetUsersFollowingRequestV2Tests.swift deleted file mode 100644 index 16e1cd7d..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Friendships/GetUsersFollowingRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersFollowingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersFollowingRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersFollowingRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 20, - paginationToken: "t", - tweetFields: [.text], - userFields: [.name] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/following") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 20, - "pagination_token": "t", - "tweet.fields": "text", - "user.fields": "name", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersFollowingRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Friendships/PostUsersFollowingRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Friendships/PostUsersFollowingRequestV2Tests.swift deleted file mode 100644 index f4743c4c..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Friendships/PostUsersFollowingRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// PostUsersFollowingRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersFollowingRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersFollowingRequestV2( - id: "_id_", - targetUserID: "_targetUserID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/following") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict(req.parameters, ["target_user_id": "_targetUserID_"]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Like/DeleteUsersLikesRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Like/DeleteUsersLikesRequestV2Tests.swift deleted file mode 100644 index 78160025..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Like/DeleteUsersLikesRequestV2Tests.swift +++ /dev/null @@ -1,32 +0,0 @@ -// DeleteUsersLikesRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersLikesRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersLikesRequestV2( - id: "_id_", - tweetID: "_tweetID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/likes/_tweetID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Like/GetTweetsLikingUsersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Like/GetTweetsLikingUsersRequestV2Tests.swift deleted file mode 100644 index e974f826..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Like/GetTweetsLikingUsersRequestV2Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// GetTweetsLikingUsersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsLikingUsersRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsLikingUsersRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 11, - mediaFields: [.url, .height], - paginationToken: "p", - placeFields: [.name], - pollFields: [.votingStatus], - tweetFields: [.entities], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/_id_/liking_users") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 11, - "media.fields": "height,url", - "pagination_token": "p", - "place.fields": "name", - "poll.fields": "voting_status", - "tweet.fields": "entities", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsLikingUsersRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Like/GetUsersLikedTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Like/GetUsersLikedTweetsRequestV2Tests.swift deleted file mode 100644 index 7db9ffdf..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Like/GetUsersLikedTweetsRequestV2Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// GetUsersLikedTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersLikedTweetsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersLikedTweetsRequestV2( - id: "_id_", - expansions: [.authorID], - maxResults: 10, - mediaFields: [.durationMs], - paginationToken: "p", - placeFields: [.name], - pollFields: [.id], - tweetFields: [.entities], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/liked_tweets") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "author_id", - "max_results": 10, - "media.fields": "duration_ms", - "pagination_token": "p", - "place.fields": "name", - "poll.fields": "id", - "tweet.fields": "entities", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersLikedTweetsRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Like/PostUsersLikesRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Like/PostUsersLikesRequestV2Tests.swift deleted file mode 100644 index 111fc941..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Like/PostUsersLikesRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersLikesRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersLikesRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersLikesRequestV2( - id: "_id_", - tweetID: "_tweetID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/likes") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "tweet_id": "_tweetID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/DeleteListRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/DeleteListRequestV2Tests.swift deleted file mode 100644 index 3a895760..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/DeleteListRequestV2Tests.swift +++ /dev/null @@ -1,28 +0,0 @@ -// DeleteListRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteListRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteListRequestV2( - id: "_id_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/DeleteListsMembersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/DeleteListsMembersRequestV2Tests.swift deleted file mode 100644 index 8770a651..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/DeleteListsMembersRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteListsMembersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteListsMembersRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteListsMembersRequestV2( - id: "_id_", - userID: "_userID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_/members/_userID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/DeleteUsersFollowedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/DeleteUsersFollowedListsRequestV2Tests.swift deleted file mode 100644 index 85085f82..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/DeleteUsersFollowedListsRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteUsersFollowedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersFollowedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersFollowedListsRequestV2( - id: "_id_", - listID: "_listID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/followed_lists/_listID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/DeleteUsersPinnedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/DeleteUsersPinnedListsRequestV2Tests.swift deleted file mode 100644 index eec920d5..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/DeleteUsersPinnedListsRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteUsersPinnedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersPinnedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersPinnedListsRequestV2( - id: "_id_", - listID: "_listID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/pinned_lists/_listID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetListRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetListRequestV2Tests.swift deleted file mode 100644 index 3f5ae942..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetListRequestV2Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetListRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetListRequestV2( - id: "_id_", - expansions: [.ownerID], - listFields: [.ownerID, .description], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "owner_id", - "list.fields": "description,owner_id", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetListsFollowersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetListsFollowersRequestV2Tests.swift deleted file mode 100644 index a1c986ac..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetListsFollowersRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetListsFollowersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsFollowersRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetListsFollowersRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 12, - paginationToken: "t", - tweetFields: [.entities], - userFields: [.verified] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_/followers") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 12, - "pagination_token": "t", - "tweet.fields": "entities", - "user.fields": "verified", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsFollowersRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetListsMembersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetListsMembersRequestV2Tests.swift deleted file mode 100644 index a0529143..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetListsMembersRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetListsMembersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsMembersRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetListsMembersRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 100, - paginationToken: "t", - tweetFields: [.createdAt], - userFields: [.protected] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_/members") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 100, - "pagination_token": "t", - "tweet.fields": "created_at", - "user.fields": "protected", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsMembersRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetListsTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetListsTweetsRequestV2Tests.swift deleted file mode 100644 index 21186da1..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetListsTweetsRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetListsTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetListsTweetsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetListsTweetsRequestV2( - id: "_id_", - expansions: [.referencedTweetsIDAuthorID], - maxResults: 10, - paginationToken: "t", - tweetFields: [.text], - userFields: [.profileImageUrl] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_/tweets") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "referenced_tweets.id.author_id", - "max_results": 10, - "pagination_token": "t", - "tweet.fields": "text", - "user.fields": "profile_image_url", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetListsTweetsRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersFollowedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetUsersFollowedListsRequestV2Tests.swift deleted file mode 100644 index 6086e435..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersFollowedListsRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersFollowedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersFollowedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersFollowedListsRequestV2( - id: "_id_", - expansions: [.ownerID], - listFields: [.name], - maxResults: 10, - paginationToken: "t", - userFields: [.entities] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/followed_lists") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "owner_id", - "list.fields": "name", - "max_results": 10, - "pagination_token": "t", - "user.fields": "entities", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersFollowedListsRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersListMembershipsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetUsersListMembershipsRequestV2Tests.swift deleted file mode 100644 index d62138c4..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersListMembershipsRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersListMembershipsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersListMembershipsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersListMembershipsRequestV2( - id: "_id_", - expansions: [.ownerID], - listFields: [.followerCount], - maxResults: 10, - paginationToken: "t", - userFields: [.protected] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/list_memberships") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "owner_id", - "list.fields": "follower_count", - "max_results": 10, - "pagination_token": "t", - "user.fields": "protected", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersListMembershipsRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersOwnedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetUsersOwnedListsRequestV2Tests.swift deleted file mode 100644 index d644dcdd..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersOwnedListsRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetUsersOwnedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersOwnedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersOwnedListsRequestV2( - id: "_id_", - expansions: [.ownerID], - listFields: [.memberCount], - maxResults: 11, - paginationToken: "t", - userFields: [.createdAt] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/owned_lists") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "owner_id", - "list.fields": "member_count", - "max_results": 11, - "pagination_token": "t", - "user.fields": "created_at", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersOwnedListsRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersPinnedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/GetUsersPinnedListsRequestV2Tests.swift deleted file mode 100644 index 4de03202..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/GetUsersPinnedListsRequestV2Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetUsersPinnedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersPinnedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersPinnedListsRequestV2( - id: "_id_", - expansions: [.ownerID], - listFields: [.id], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/pinned_lists") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "owner_id", - "list.fields": "id", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersPinnedListsRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/PostListsMembersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/PostListsMembersRequestV2Tests.swift deleted file mode 100644 index a9cd4561..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/PostListsMembersRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostListsMembersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsMembersRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostListsMembersRequestV2( - id: "_id_", - userID: "_userID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_/members") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "user_id": "_userID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/PostListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/PostListsRequestV2Tests.swift deleted file mode 100644 index a216657e..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/PostListsRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostListsRequestV2( - name: "_name_", - description: "d", - private: true - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "name": "_name_", - "description": "d", - "private": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PostListsRequestV2( - name: "n" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "name": "n", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/PostUsersFollowedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/PostUsersFollowedListsRequestV2Tests.swift deleted file mode 100644 index 59ef86c5..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/PostUsersFollowedListsRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersFollowedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersFollowedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersFollowedListsRequestV2( - id: "_id_", - listID: "_listID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/followed_lists") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "_listID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/PostUsersPinnedListsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/PostUsersPinnedListsRequestV2Tests.swift deleted file mode 100644 index 33f245d0..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/PostUsersPinnedListsRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersPinnedListsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersPinnedListsRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersPinnedListsRequestV2( - id: "_id_", - listID: "_listID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/pinned_lists") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "list_id": "_listID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/List/PutListRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/List/PutListRequestV2Tests.swift deleted file mode 100644 index bc613516..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/List/PutListRequestV2Tests.swift +++ /dev/null @@ -1,49 +0,0 @@ -// PutListRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PutListRequestV2Tests: XCTestCase { - public func test() throws { - let req = PutListRequestV2( - id: "_id_", - description: "d", - name: "n", - private: true - ) - - XCTAssertEqual(req.method, .put) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/lists/_id_") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "description": "d", - "name": "n", - "private": true, - ] - ) - } - - public func testDefaultArg() throws { - let req = PutListRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Retweet/DeleteUsersRetweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Retweet/DeleteUsersRetweetsRequestV2Tests.swift deleted file mode 100644 index 85b99823..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Retweet/DeleteUsersRetweetsRequestV2Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// DeleteUsersRetweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteUsersRetweetsRequestV2Tests: XCTestCase { - public func test() throws { - let req = DeleteUsersRetweetsRequestV2( - id: "_id_", - sourceTweetID: "_sourceTweetID_" - ) - - XCTAssertEqual(req.method, .delete) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/retweets/_sourceTweetID_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Retweet/GetTweetsRetweetedByRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Retweet/GetTweetsRetweetedByRequestV2Tests.swift deleted file mode 100644 index dbf0b65c..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Retweet/GetTweetsRetweetedByRequestV2Tests.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetTweetsRetweetedByRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsRetweetedByRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsRetweetedByRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - maxResults: 11, - mediaFields: [.height, .nonPublicMetrics], - paginationToken: "t", - placeFields: [.id, .placeType, .countryCode], - pollFields: [.options, .endDatetime], - tweetFields: [.nonPublicMetrics, .contextAnnotations], - userFields: [.username, .withheld] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/_id_/retweeted_by") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "max_results": 11, - "media.fields": "height,non_public_metrics", - "pagination_token": "t", - "place.fields": "country_code,id,place_type", - "poll.fields": "end_datetime,options", - "tweet.fields": "context_annotations,non_public_metrics", - "user.fields": "username,withheld", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsRetweetedByRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict(req.parameters, [:]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Retweet/PostUsersRetweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Retweet/PostUsersRetweetsRequestV2Tests.swift deleted file mode 100644 index f4e59918..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Retweet/PostUsersRetweetsRequestV2Tests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// PostUsersRetweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostUsersRetweetsRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostUsersRetweetsRequestV2( - id: "_id_", - tweetID: "_tweetID_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_/retweets") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict( - req.parameters, - [ - "tweet_id": "_tweetID_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Search/GetTweetsSearchAllRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Search/GetTweetsSearchAllRequestV2Tests.swift deleted file mode 100644 index 7d4f4ca5..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Search/GetTweetsSearchAllRequestV2Tests.swift +++ /dev/null @@ -1,73 +0,0 @@ -// GetTweetsSearchAllRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsSearchAllRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = GetTweetsSearchAllRequestV2( - query: "_q_", - endTime: Date(timeIntervalSince1970: 2), - expansions: [.referencedTweetsID], - maxResults: 13, - mediaFields: [.nonPublicMetrics], - nextToken: "_n_", - placeFields: [.geo], - pollFields: [.options], - sinceID: "_s_", - sortOrder: .relevancy, - startTime: Date(timeIntervalSince1970: 1), - tweetFields: [.id], - untilID: "_u_", - userFields: [.verified] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/search/all") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "query": "_q_", - "end_time": "1970-01-01T00:00:02Z", - "expansions": "referenced_tweets.id", - "max_results": 13, - "media.fields": "non_public_metrics", - "next_token": "_n_", - "place.fields": "geo", - "poll.fields": "options", - "since_id": "_s_", - "sort_order": "relevancy", - "start_time": "1970-01-01T00:00:01Z", - "tweet.fields": "id", - "until_id": "_u_", - "user.fields": "verified", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsSearchAllRequestV2( - query: "_q1_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "query": "_q1_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Search/GetTweetsSearchRecentRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Search/GetTweetsSearchRecentRequestV2Tests.swift deleted file mode 100644 index 14925af7..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Search/GetTweetsSearchRecentRequestV2Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// GetTweetsSearchRecentRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsSearchRecentRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = GetTweetsSearchRecentRequestV2( - query: "Q", - endTime: Date(timeIntervalSince1970: 100), - expansions: [.authorID, .attachmentsPollIDs], - maxResults: 10, - mediaFields: [.url, .altText], - nextToken: "next_token", - placeFields: [.id, .name], - pollFields: [.endDatetime], - sinceID: "since_id", - sortOrder: .recency, - startTime: Date(timeIntervalSince1970: 1), - tweetFields: [.id, .text], - untilID: "untile_id", - userFields: [.username, .pinnedTweetID] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/2/tweets/search/recent") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "query": "Q", - "end_time": "1970-01-01T00:01:40Z", - "expansions": "attachments.poll_ids,author_id", - "max_results": 10, - "media.fields": "alt_text,url", - "next_token": "next_token", - "place.fields": "id,name", - "poll.fields": "end_datetime", - "since_id": "since_id", - "sort_order": "recency", - "start_time": "1970-01-01T00:00:01Z", - "tweet.fields": "id,text", - "until_id": "untile_id", - "user.fields": "pinned_tweet_id,username", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpaceRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpaceRequestV2Tests.swift deleted file mode 100644 index 0ff7dfd7..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpaceRequestV2Tests.swift +++ /dev/null @@ -1,51 +0,0 @@ -// GetSpaceRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSpaceRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetSpaceRequestV2( - id: "_i_", - expansions: [.hostIDs], - spaceFields: [.title], - topicFields: [.name], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/spaces/_i_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "host_ids", - "space.fields": "title", - "topic.fields": "name", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSpaceRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesBuyersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesBuyersRequestV2Tests.swift deleted file mode 100644 index fd3d70fd..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesBuyersRequestV2Tests.swift +++ /dev/null @@ -1,55 +0,0 @@ -// GetSpacesBuyersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSpacesBuyersRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetSpacesBuyersRequestV2( - id: "_i_", - expansions: [.pinnedTweetID], - mediaFields: [.url], - placeFields: [.geo], - pollFields: [.options], - tweetFields: [.entities], - userFields: [.protected] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/spaces/_i_/buyers") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "media.fields": "url", - "place.fields": "geo", - "poll.fields": "options", - "tweet.fields": "entities", - "user.fields": "protected", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSpacesBuyersRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesByCreatorIDsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesByCreatorIDsRequestV2Tests.swift deleted file mode 100644 index 4fc4c78b..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesByCreatorIDsRequestV2Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetSpacesByCreatorIDsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSpacesByCreatorIDsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetSpacesByCreatorIDsRequestV2( - userIDs: ["a", "b"], - expansions: [.invitedUserIDs], - spaceFields: [.isTicketed], - topicFields: [.name], - userFields: [.verified] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/spaces/by/creator_ids") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "user_ids": "a,b", - "expansions": "invited_user_ids", - "space.fields": "is_ticketed", - "topic.fields": "name", - "user.fields": "verified", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSpacesByCreatorIDsRequestV2( - userIDs: ["a", "b", "c"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "user_ids": "a,b,c", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesRequestV2Tests.swift deleted file mode 100644 index d43c3d35..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesRequestV2Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetSpacesRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSpacesRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetSpacesRequestV2( - ids: ["a", "b"], - expansions: [.speakerIDs], - spaceFields: [.lang], - topicFields: [.description], - userFields: [.withheld] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/spaces") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "ids": "a,b", - "expansions": "speaker_ids", - "space.fields": "lang", - "topic.fields": "description", - "user.fields": "withheld", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSpacesRequestV2( - ids: ["a", "b", "恂"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "ids": "a,b,恂", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesSearchRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesSearchRequestV2Tests.swift deleted file mode 100644 index eac621e2..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesSearchRequestV2Tests.swift +++ /dev/null @@ -1,56 +0,0 @@ -// GetSpacesSearchRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSpacesSearchRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetSpacesSearchRequestV2( - query: "_q_", - expansions: [.creatorID], - spaceFields: [.invitedUserIDs], - state: .scheduled, - topicFields: [.name], - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/spaces/search") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "query": "_q_", - "expansions": "creator_id", - "space.fields": "invited_user_ids", - "state": "scheduled", - "topic.fields": "name", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSpacesSearchRequestV2( - query: "恂" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "query": "恂", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesTweetsRequestV2Tests.swift deleted file mode 100644 index 53479633..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Spaces/GetSpacesTweetsRequestV2Tests.swift +++ /dev/null @@ -1,55 +0,0 @@ -// GetSpacesTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetSpacesTweetsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetSpacesTweetsRequestV2( - id: "_i_", - expansions: [.entitiesMentionsUsername], - mediaFields: [.url], - placeFields: [.placeType], - pollFields: [.votingStatus], - tweetFields: [.contextAnnotations], - userFields: [.publicMetrics] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/spaces/_i_/tweets") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "entities.mentions.username", - "media.fields": "url", - "place.fields": "place_type", - "poll.fields": "voting_status", - "tweet.fields": "context_annotations", - "user.fields": "public_metrics", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetSpacesTweetsRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSampleStreamRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSampleStreamRequestV2Tests.swift deleted file mode 100644 index f20d99f1..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSampleStreamRequestV2Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetTweetsSampleStreamRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsSampleStreamRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsSampleStreamRequestV2( - backfillMinutes: 2, - expansions: [.entitiesMentionsUsername], - mediaFields: [.durationMs], - placeFields: [.countryCode], - pollFields: [.options], - tweetFields: [.entities], - userFields: [.pinnedTweetID] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/sample/stream") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "backfill_minutes": 2, - "expansions": "entities.mentions.username", - "media.fields": "duration_ms", - "place.fields": "country_code", - "poll.fields": "options", - "tweet.fields": "entities", - "user.fields": "pinned_tweet_id", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsSampleStreamRequestV2() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSearchStreamRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSearchStreamRequestV2Tests.swift deleted file mode 100644 index 8bc8ebe2..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSearchStreamRequestV2Tests.swift +++ /dev/null @@ -1,54 +0,0 @@ -// GetTweetsSearchStreamRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsSearchStreamRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsSearchStreamRequestV2( - backfillMinutes: 1, - expansions: [.referencedTweetsIDAuthorID], - mediaFields: [.height], - placeFields: [.name], - pollFields: [.endDatetime], - tweetFields: [.geo], - userFields: [.withheld] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/search/stream") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "backfill_minutes": 1, - "expansions": "referenced_tweets.id.author_id", - "media.fields": "height", - "place.fields": "name", - "poll.fields": "end_datetime", - "tweet.fields": "geo", - "user.fields": "withheld", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsSearchStreamRequestV2() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSearchStreamRulesRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSearchStreamRulesRequestV2Tests.swift deleted file mode 100644 index 8d7d2522..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Stream/GetTweetsSearchStreamRulesRequestV2Tests.swift +++ /dev/null @@ -1,42 +0,0 @@ -// GetTweetsSearchStreamRulesRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsSearchStreamRulesRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsSearchStreamRulesRequestV2( - ids: ["10", "20"] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/search/stream/rules") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "ids": "10,20", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsSearchStreamRulesRequestV2() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Stream/PostTweetsSearchStreamRulesRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Stream/PostTweetsSearchStreamRulesRequestV2Tests.swift deleted file mode 100644 index 52624a99..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Stream/PostTweetsSearchStreamRulesRequestV2Tests.swift +++ /dev/null @@ -1,85 +0,0 @@ -// PostTweetsSearchStreamRulesRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostTweetsSearchStreamRulesRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let add = PostTweetsSearchStreamRulesRequestV2( - operation: .add([ - .init(value: "value", tag: "tag"), - .init(value: "hoge"), - ]) - ) - - XCTAssertEqual(add.method, .post) - XCTAssertEqual(add.path, "/2/tweets/search/stream/rules") - XCTAssertEqual(add.bodyContentType, .json) - - AssertEqualAnyDict(add.parameters, [:]) - AssertEqualAnyDict( - add.bodyParameters, - [ - "add": [ - ["value": "value", "tag": "tag"], - ["value": "hoge"], - ], - ] - ) - AssertEqualAnyDict(add.queryParameters, [:]) - - let delete = PostTweetsSearchStreamRulesRequestV2(operation: .delete(["1", "20"])) - - XCTAssertEqual(delete.method, .post) - XCTAssertEqual(delete.path, "/2/tweets/search/stream/rules") - XCTAssertEqual(delete.bodyContentType, .json) - - AssertEqualAnyDict(delete.parameters, [:]) - AssertEqualAnyDict( - delete.bodyParameters, - [ - "delete": [ - "ids": ["1", "20"], - ], - ] - ) - AssertEqualAnyDict(delete.queryParameters, [:]) - } - - public func testDryRun() throws { - let add = PostTweetsSearchStreamRulesRequestV2( - operation: .add([ - .init(value: "value", tag: "tag"), - .init(value: "hoge"), - ]), dryRun: true - ) - - XCTAssertEqual(add.method, .post) - XCTAssertEqual(add.path, "/2/tweets/search/stream/rules") - XCTAssertEqual(add.bodyContentType, .json) - - AssertEqualAnyDict(add.parameters, [:]) - AssertEqualAnyDict( - add.bodyParameters, - [ - "add": [ - ["value": "value", "tag": "tag"], - ["value": "hoge"], - ], - ] - ) - - AssertEqualAnyDict(add.queryParameters, ["dry_run": true]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersMentionsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersMentionsRequestV2Tests.swift deleted file mode 100644 index e289f72a..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersMentionsRequestV2Tests.swift +++ /dev/null @@ -1,68 +0,0 @@ -// GetUsersMentionsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersMentionsRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = GetUsersMentionsRequestV2( - id: "_i_", - endTime: Date(timeIntervalSince1970: 11), - expansions: [.geoPlaceID], - maxResults: 150, - mediaFields: [.url], - paginationToken: "_p_", - placeFields: [.geo], - pollFields: [.id], - sinceID: "_s_", - startTime: Date(timeIntervalSince1970: 2), - tweetFields: [.entities], - untilID: "_u_", - userFields: [.username] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_i_/mentions") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "end_time": "1970-01-01T00:00:11Z", - "expansions": "geo.place_id", - "max_results": 150, - "media.fields": "url", - "pagination_token": "_p_", - "place.fields": "geo", - "poll.fields": "id", - "since_id": "_s_", - "start_time": "1970-01-01T00:00:02Z", - "tweet.fields": "entities", - "until_id": "_u_", - "user.fields": "username", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersMentionsRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersTimelinesReverseChronologicalRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersTimelinesReverseChronologicalRequestV2Tests.swift deleted file mode 100644 index 328f3c19..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersTimelinesReverseChronologicalRequestV2Tests.swift +++ /dev/null @@ -1,71 +0,0 @@ -// GetUsersTimelinesReverseChronologicalRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -// swiftlint:disable:next type_name -internal class GetUsersTimelinesReverseChronologicalRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = GetUsersTimelinesReverseChronologicalRequestV2( - id: "_i_", - endTime: Date(timeIntervalSince1970: 50), - exclude: [.retweets], - expansions: [.authorID], - maxResults: 10, - mediaFields: [.altText], - paginationToken: "_p_", - placeFields: [.country], - pollFields: [.options], - sinceID: "_s_", - startTime: Date(timeIntervalSince1970: 10), - tweetFields: [.geo], - untilID: "_u_", - userFields: [.location] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_i_/timelines/reverse_chronological") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "end_time": "1970-01-01T00:00:50Z", - "exclude": "retweets", - "expansions": "author_id", - "max_results": 10, - "media.fields": "alt_text", - "pagination_token": "_p_", - "place.fields": "country", - "poll.fields": "options", - "since_id": "_s_", - "start_time": "1970-01-01T00:00:10Z", - "tweet.fields": "geo", - "until_id": "_u_", - "user.fields": "location", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersTimelinesReverseChronologicalRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersTweetsRequestV2Tests.swift deleted file mode 100644 index 91855a2a..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Timeline/GetUsersTweetsRequestV2Tests.swift +++ /dev/null @@ -1,70 +0,0 @@ -// GetUsersTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersTweetsRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let req = GetUsersTweetsRequestV2( - id: "_i_", - endTime: Date(timeIntervalSince1970: 10), - exclude: [.replies, .retweets], - expansions: [.authorID], - maxResults: 100, - mediaFields: [.publicMetrics], - paginationToken: "_p_", - placeFields: [.containedWithin], - pollFields: [.options], - sinceID: "_s_", - startTime: Date(timeIntervalSince1970: 1), - tweetFields: [.entities], - untilID: "_u_", - userFields: [.protected] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_i_/tweets") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "end_time": "1970-01-01T00:00:10Z", - "exclude": "replies,retweets", - "expansions": "author_id", - "max_results": 100, - "media.fields": "public_metrics", - "pagination_token": "_p_", - "place.fields": "contained_within", - "poll.fields": "options", - "since_id": "_s_", - "start_time": "1970-01-01T00:00:01Z", - "tweet.fields": "entities", - "until_id": "_u_", - "user.fields": "protected", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersTweetsRequestV2( - id: "_i_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Tweet/DeleteTweetRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Tweet/DeleteTweetRequestV2Tests.swift deleted file mode 100644 index 5b3c0b87..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Tweet/DeleteTweetRequestV2Tests.swift +++ /dev/null @@ -1,24 +0,0 @@ -// DeleteTweetRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class DeleteTweetRequestV2Tests: XCTestCase { - public func test() throws { - let request = DeleteTweetRequestV2(id: "123") - XCTAssertEqual(request.method, .delete) - XCTAssertEqual(request.path, "/2/tweets/123") - XCTAssertEqual(request.bodyContentType, .wwwFormUrlEncoded) - XCTAssertTrue(request.parameters.isEmpty) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetRequestV2Tests.swift deleted file mode 100644 index 5f1c9e9e..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetRequestV2Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetTweetRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetRequestV2Tests: XCTestCase { - public func test() throws { - let tweet = GetTweetRequestV2(id: "123") - - XCTAssertEqual(tweet.method, .get) - XCTAssertEqual(tweet.path, "/2/tweets/123") - AssertEqualAnyDict(tweet.parameters, [:]) - - let tweet2 = GetTweetRequestV2( - id: "1234", - expansions: [.authorID], - mediaFields: [.url, .altText], - placeFields: [.name, .id], - pollFields: [.id], - tweetFields: [.text, .id], - userFields: [.entities] - ) - - AssertEqualAnyDict( - tweet2.parameters, - [ - "expansions": "author_id", - "media.fields": "alt_text,url", - "place.fields": "id,name", - "poll.fields": "id", - "tweet.fields": "id,text", - "user.fields": "entities", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetsQuoteTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetsQuoteTweetsRequestV2Tests.swift deleted file mode 100644 index 05cefb4d..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetsQuoteTweetsRequestV2Tests.swift +++ /dev/null @@ -1,60 +0,0 @@ -// GetTweetsQuoteTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsQuoteTweetsRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsQuoteTweetsRequestV2( - id: "_i_", - expansions: [.attachmentsMediaKeys], - maxResults: 10, - mediaFields: [.height], - paginationToken: "_p_", - placeFields: [.country], - pollFields: [.options], - tweetFields: [.authorID], - userFields: [.entities] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/tweets/_i_/quote_tweets") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "attachments.media_keys", - "max_results": 10, - "media.fields": "height", - "pagination_token": "_p_", - "place.fields": "country", - "poll.fields": "options", - "tweet.fields": "author_id", - "user.fields": "entities", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetTweetsQuoteTweetsRequestV2( - id: "i" - ) - - XCTAssertEqual(req.path, "/2/tweets/i/quote_tweets") - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetsRequestV2Tests.swift deleted file mode 100644 index 36d1f11e..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Tweet/GetTweetsRequestV2Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// GetTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsRequestV2Tests: XCTestCase { - public func test() throws { - let tweet = GetTweetsRequestV2(ids: ["123", "abc"]) - - XCTAssertEqual(tweet.method, .get) - XCTAssertEqual(tweet.path, "/2/tweets") - AssertEqualAnyDict(tweet.parameters, ["ids": "123,abc"]) - - let tweet2 = GetTweetsRequestV2( - ids: ["1234"], - expansions: [.attachmentsMediaKeys], - mediaFields: [.url, .altText], - placeFields: [.name, .id], - pollFields: [.id], - tweetFields: [.text, .id], - userFields: [.entities] - ) - - AssertEqualAnyDict( - tweet2.parameters, - [ - "ids": "1234", - "expansions": "attachments.media_keys", - "media.fields": "alt_text,url", - "place.fields": "id,name", - "poll.fields": "id", - "tweet.fields": "id,text", - "user.fields": "entities", - ] - ) - } - - deinit { - // De-init Logic Her - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Tweet/PostTweetsRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Tweet/PostTweetsRequestV2Tests.swift deleted file mode 100644 index 00136249..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Tweet/PostTweetsRequestV2Tests.swift +++ /dev/null @@ -1,53 +0,0 @@ -// PostTweetsRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostTweetsRequestV2Tests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let request = PostTweetsRequestV2( - directMessageDeepLink: "deep_link", - forSuperFollowersOnly: true, - geo: .init(placeID: "place"), - media: .init( - mediaIDs: ["media_1", "media_2"], - taggedUserIDs: ["user_1", "user_2"] - ), - poll: .init(durationMinutes: 100, options: ["o1", "o2"]), - quoteTweetID: "quote_id", - reply: .init(excludeReplyUserIDs: ["r_1", "r_2"], inReplyToTweetID: "t_1"), - replySettings: .following, - text: "text" - ) - - XCTAssertEqual(request.path, "/2/tweets") - XCTAssertEqual(request.method, .post) - XCTAssertEqual(request.bodyContentType, .json) - - AssertEqualAnyDict( - request.parameters, - [ - "direct_message_deep_link": "deep_link", - "for_super_followers_only": true, - "geo": ["place_id": "place"], - "media": ["tagged_user_ids": ["user_1", "user_2"], "media_ids": ["media_1", "media_2"]], - "poll": ["options": ["o1", "o2"], "duration_minutes": 100], - "quote_tweet_id": "quote_id", - "reply": ["in_reply_to_tweet_id": "t_1", "exclude_reply_user_ids": ["r_1", "r_2"]], - "reply_settings": "following", - "text": "text", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Tweet/PutTweetsHiddenRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Tweet/PutTweetsHiddenRequestV2Tests.swift deleted file mode 100644 index 8957b4c2..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Tweet/PutTweetsHiddenRequestV2Tests.swift +++ /dev/null @@ -1,24 +0,0 @@ -// PutTweetsHiddenRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PutTweetsHiddenRequestV2Tests: XCTestCase { - public func test() throws { - let req = PutTweetsHiddenRequestV2(id: "12", hidden: true) - XCTAssertEqual(req.method, .put) - XCTAssertEqual(req.path, "/2/tweets/12/hidden") - XCTAssertEqual(req.bodyContentType, .json) - AssertEqualAnyDict(req.parameters, ["hidden": true]) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/TweetCount/GetTweetsCountsAllRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/TweetCount/GetTweetsCountsAllRequestV2Tests.swift deleted file mode 100644 index 595416cd..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/TweetCount/GetTweetsCountsAllRequestV2Tests.swift +++ /dev/null @@ -1,44 +0,0 @@ -// GetTweetsCountsAllRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsCountsAllRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsCountsAllRequestV2( - query: "a", - endTime: Date(timeIntervalSince1970: 10), - granularity: .minute, - nextToken: "n", - sinceID: "s", - startTime: Date(timeIntervalSince1970: 5), - untilID: "u" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/2/tweets/counts/all") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "query": "a", - "end_time": "1970-01-01T00:00:10Z", - "granularity": "minute", - "next_token": "n", - "since_id": "s", - "start_time": "1970-01-01T00:00:05Z", - "until_id": "u", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/TweetCount/GetTweetsCountsRecentRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/TweetCount/GetTweetsCountsRecentRequestV2Tests.swift deleted file mode 100644 index 11b8acd8..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/TweetCount/GetTweetsCountsRecentRequestV2Tests.swift +++ /dev/null @@ -1,42 +0,0 @@ -// GetTweetsCountsRecentRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetTweetsCountsRecentRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetTweetsCountsRecentRequestV2( - query: "q", - endTime: Date(timeIntervalSince1970: 0), - granularity: .hour, - sinceID: "s", - startTime: Date(timeIntervalSince1970: 120), - untilID: "u" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.path, "/2/tweets/counts/recent") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "query": "q", - "end_time": "1970-01-01T00:00:00Z", - "granularity": "hour", - "since_id": "s", - "start_time": "1970-01-01T00:02:00Z", - "until_id": "u", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Users/GetUserRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Users/GetUserRequestV2Tests.swift deleted file mode 100644 index 90463869..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Users/GetUserRequestV2Tests.swift +++ /dev/null @@ -1,49 +0,0 @@ -// GetUserRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUserRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUserRequestV2( - id: "_id_", - expansions: [.pinnedTweetID], - tweetFields: [.entities], - userFields: [.protected] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/_id_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "tweet.fields": "entities", - "user.fields": "protected", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUserRequestV2( - id: "_id_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersByRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersByRequestV2Tests.swift deleted file mode 100644 index 2e91b47f..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersByRequestV2Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetUsersByRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersByRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersByRequestV2( - usernames: ["a", "b"], - expansions: [.pinnedTweetID], - tweetFields: [.geo], - userFields: [.url] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/by") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "usernames": "a,b", - "expansions": "pinned_tweet_id", - "tweet.fields": "geo", - "user.fields": "url", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersByRequestV2( - usernames: ["a", "b"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "usernames": "a,b", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersByUsernameRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersByUsernameRequestV2Tests.swift deleted file mode 100644 index f0c79306..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersByUsernameRequestV2Tests.swift +++ /dev/null @@ -1,49 +0,0 @@ -// GetUsersByUsernameRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersByUsernameRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersByUsernameRequestV2( - username: "_username_", - expansions: [.pinnedTweetID], - tweetFields: [.withheld], - userFields: [.profileImageUrl] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/by/username/_username_") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "tweet.fields": "withheld", - "user.fields": "profile_image_url", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersByUsernameRequestV2( - username: "_username_" - ) - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersMeRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersMeRequestV2Tests.swift deleted file mode 100644 index c4a96a3c..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersMeRequestV2Tests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// GetUsersMeRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersMeRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersMeRequestV2( - expansions: [.pinnedTweetID], - tweetFields: [.geo], - userFields: [.id] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users/me") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "expansions": "pinned_tweet_id", - "tweet.fields": "geo", - "user.fields": "id", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersMeRequestV2() - - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersRequestV2Tests.swift b/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersRequestV2Tests.swift deleted file mode 100644 index 29c1eeaf..00000000 --- a/Tests/TwitterAPIKitTests/APIv2/Users/GetUsersRequestV2Tests.swift +++ /dev/null @@ -1,52 +0,0 @@ -// GetUsersRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetUsersRequestV2Tests: XCTestCase { - public func test() throws { - let req = GetUsersRequestV2( - ids: ["a", "b"], - expansions: [.pinnedTweetID], - tweetFields: [.createdAt], - userFields: [.publicMetrics] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/users") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "ids": "a,b", - "expansions": "pinned_tweet_id", - "tweet.fields": "created_at", - "user.fields": "public_metrics", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetUsersRequestV2( - ids: ["a", "b"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "ids": "a,b", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/GetOAuth2AuthorizeRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/GetOAuth2AuthorizeRequestV1Tests.swift deleted file mode 100644 index 45f3a900..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/GetOAuth2AuthorizeRequestV1Tests.swift +++ /dev/null @@ -1,69 +0,0 @@ -// GetOAuth2AuthorizeRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetOAuth2AuthorizeRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetOAuth2AuthorizeRequestV1( - responseType: "_r_", - clientID: "_c_id_", - redirectURI: "_r_uri_", - state: "_s_", - codeChallenge: "_c_", - codeChallengeMethod: "_cm_", - scopes: ["a", "b"] - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .twitter) - XCTAssertEqual(req.path, "/i/oauth2/authorize") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "response_type": "_r_", - "client_id": "_c_id_", - "redirect_uri": "_r_uri_", - "state": "_s_", - "code_challenge": "_c_", - "code_challenge_method": "_cm_", - "scope": "a b", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetOAuth2AuthorizeRequestV1( - clientID: "_ci_", - redirectURI: "_r_", - state: "_s_", - codeChallenge: "_c_", - codeChallengeMethod: "_cm_", - scopes: ["a"] - ) - - AssertEqualAnyDict( - req.parameters, - [ - "response_type": "code", - "client_id": "_ci_", - "redirect_uri": "_r_", - "state": "_s_", - "code_challenge": "_c_", - "code_challenge_method": "_cm_", - "scope": "a", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/GetOAuthAuthenticateRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/GetOAuthAuthenticateRequestV1Tests.swift deleted file mode 100644 index a229eb30..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/GetOAuthAuthenticateRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetOAuthAuthenticateRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetOAuthAuthenticateRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetOAuthAuthenticateRequestV1( - oauthToken: "_o_", - forceLogin: true, - screenName: "_s_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/oauth/authenticate") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "oauth_token": "_o_", - "force_login": true, - "screen_name": "_s_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetOAuthAuthenticateRequestV1( - oauthToken: "_o_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "oauth_token": "_o_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/GetOAuthAuthorizeRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/GetOAuthAuthorizeRequestV1Tests.swift deleted file mode 100644 index 1ed9a3e7..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/GetOAuthAuthorizeRequestV1Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// GetOAuthAuthorizeRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class GetOAuthAuthorizeRequestV1Tests: XCTestCase { - public func test() throws { - let req = GetOAuthAuthorizeRequestV1( - oauthToken: "_o_", - forceLogin: true, - screenName: "_s_" - ) - - XCTAssertEqual(req.method, .get) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/oauth/authorize") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "oauth_token": "_o_", - "force_login": true, - "screen_name": "_s_", - ] - ) - } - - public func testDefaultArg() throws { - let req = GetOAuthAuthorizeRequestV1( - oauthToken: "_o_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "oauth_token": "_o_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2AccessTokenRequestV2Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2AccessTokenRequestV2Tests.swift deleted file mode 100644 index ac146e33..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2AccessTokenRequestV2Tests.swift +++ /dev/null @@ -1,59 +0,0 @@ -// PostOAuth2AccessTokenRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuth2AccessTokenRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostOAuth2AccessTokenRequestV2( - code: "_c_", - grantType: "_g_", - clientID: "_cid_", - redirectURI: "_r_", - codeVerifier: "_cv_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/oauth2/token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "code": "_c_", - "grant_type": "_g_", - "client_id": "_cid_", - "redirect_uri": "_r_", - "code_verifier": "_cv_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostOAuth2AccessTokenRequestV2( - code: "_c_", - redirectURI: "_r_", - codeVerifier: "_cv_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "code": "_c_", - "grant_type": "authorization_code", - "redirect_uri": "_r_", - "code_verifier": "_cv_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2InvalidateTokenRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2InvalidateTokenRequestV1Tests.swift deleted file mode 100644 index 7c8eea06..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2InvalidateTokenRequestV1Tests.swift +++ /dev/null @@ -1,33 +0,0 @@ -// PostOAuth2InvalidateTokenRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuth2InvalidateTokenRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostOAuth2InvalidateTokenRequestV1( - accessToken: "_a_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/oauth2/invalidate_token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "access_token": "_a_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2RefreshTokenRequestV2Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2RefreshTokenRequestV2Tests.swift deleted file mode 100644 index 3fb92c30..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2RefreshTokenRequestV2Tests.swift +++ /dev/null @@ -1,51 +0,0 @@ -// PostOAuth2RefreshTokenRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuth2RefreshTokenRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostOAuth2RefreshTokenRequestV2( - refreshToken: "_r_", - grantType: "_g_", - clientID: "_c_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/oauth2/token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "refresh_token": "_r_", - "grant_type": "_g_", - "client_id": "_c_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostOAuth2RefreshTokenRequestV2( - refreshToken: "_rt_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "refresh_token": "_rt_", - "grant_type": "refresh_token", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2RevokeTokenRequestV2Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2RevokeTokenRequestV2Tests.swift deleted file mode 100644 index cc3178a2..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2RevokeTokenRequestV2Tests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// PostOAuth2RevokeTokenRequestV2Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuth2RevokeTokenRequestV2Tests: XCTestCase { - public func test() throws { - let req = PostOAuth2RevokeTokenRequestV2( - token: "_t_", - clientID: "_c_", - tokenTypeHint: "hint" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/2/oauth2/revoke") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "token": "_t_", - "client_id": "_c_", - "token_type_hint": "hint", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostOAuth2RevokeTokenRequestV2( - token: "_tt_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "token": "_tt_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2TokenRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2TokenRequestV1Tests.swift deleted file mode 100644 index 0cf31502..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuth2TokenRequestV1Tests.swift +++ /dev/null @@ -1,44 +0,0 @@ -// PostOAuth2TokenRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuth2TokenRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostOAuth2TokenRequestV1( - grantType: "_g_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/oauth2/token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "grant_type": "_g_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostOAuth2TokenRequestV1() - - AssertEqualAnyDict( - req.parameters, - [ - "grant_type": "client_credentials", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthAccessTokenRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthAccessTokenRequestV1Tests.swift deleted file mode 100644 index 2941b6c2..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthAccessTokenRequestV1Tests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// PostOAuthAccessTokenRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuthAccessTokenRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostOAuthAccessTokenRequestV1( - oauthToken: "_ot_", - oauthVerifier: "_ov_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/oauth/access_token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "oauth_token": "_ot_", - "oauth_verifier": "_ov_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthInvalidateTokenRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthInvalidateTokenRequestV1Tests.swift deleted file mode 100644 index ffcf7876..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthInvalidateTokenRequestV1Tests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// PostOAuthInvalidateTokenRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuthInvalidateTokenRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostOAuthInvalidateTokenRequestV1() - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/1.1/oauth/invalidate_token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [:] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthRequestTokenRequestV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthRequestTokenRequestV1Tests.swift deleted file mode 100644 index 6d87d8b6..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/PostOAuthRequestTokenRequestV1Tests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// PostOAuthRequestTokenRequestV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class PostOAuthRequestTokenRequestV1Tests: XCTestCase { - public func test() throws { - let req = PostOAuthRequestTokenRequestV1( - oauthCallback: "_o_", - xAuthAccessType: "_x_" - ) - - XCTAssertEqual(req.method, .post) - XCTAssertEqual(req.baseURLType, .api) - XCTAssertEqual(req.path, "/oauth/request_token") - XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded) - AssertEqualAnyDict( - req.parameters, - [ - "oauth_callback": "_o_", - "x_auth_access_type": "_x_", - ] - ) - } - - public func testDefaultArg() throws { - let req = PostOAuthRequestTokenRequestV1( - oauthCallback: "_o_" - ) - - AssertEqualAnyDict( - req.parameters, - [ - "oauth_callback": "_o_", - ] - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/TwitterAuthAPITests.swift b/Tests/TwitterAPIKitTests/AuthAPI/TwitterAuthAPITests.swift deleted file mode 100644 index cb69779d..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/TwitterAuthAPITests.swift +++ /dev/null @@ -1,75 +0,0 @@ -// TwitterAuthAPITests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterAuthAPITests: XCTestCase { - public var client: TwitterAuthAPI! - - override public func setUpWithError() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - client = - TwitterAPIClient( - .oauth10a(.init(consumerKey: "", consumerSecret: "", oauthToken: "", oauthTokenSecret: "")), - configuration: config - ).auth - } - - override public func tearDownWithError() throws { - MockURLProtocol.cleanup() - } - - public func testMakeOAuthAuthorizeURL() throws { - let url = client.oauth10a.makeOAuthAuthorizeURL( - .init(oauthToken: "token", forceLogin: true, screenName: "name") - ) - XCTAssertEqual( - url?.absoluteString, - "https://api.twitter.com/oauth/authorize?force_login=true&oauth_token=token&screen_name=name" - ) - } - - public func testMakeOAuthAuthenticateURL() throws { - let url = client.oauth10a.makeOAuthAuthenticateURL( - .init(oauthToken: "token", forceLogin: true, screenName: "name") - ) - XCTAssertEqual( - url?.absoluteString, - "https://api.twitter.com/oauth/authenticate?force_login=true&oauth_token=token&screen_name=name" - ) - } - - public func testMakeOAuth2AuthorizeURL() throws { - let url = client.oauth20.makeOAuth2AuthorizeURL( - .init( - clientID: "cid", - redirectURI: "callback", - state: "state", - codeChallenge: "challenge", - codeChallengeMethod: "plain", - scopes: [ - "users.read", "tweet.read", - ] - ) - ) - - XCTAssertEqual( - url?.absoluteString, - "https://twitter.com/i/oauth2/authorize?client_id=cid&code_challenge=challenge&" + - "code_challenge_method=plain&redirect_uri=callback&response_type=code&" + - "scope=users.read%20tweet.read&state=state" - ) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuth2AccessTokenTests.swift b/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuth2AccessTokenTests.swift deleted file mode 100644 index cf1383ec..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuth2AccessTokenTests.swift +++ /dev/null @@ -1,79 +0,0 @@ -// TwitterOAuth2AccessTokenTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class TwitterOAuth2AccessTokenTests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let data = Data( - #""" - { - "scope" : "tweet.write tweet.read", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "" - } - """#.utf8 - ) - guard let token = try TwitterOAuth2AccessToken(jsonData: data) else { - XCTFail("Failed to create test token") - return - } - XCTAssertEqual(token.scope, ["tweet.write", "tweet.read"]) - XCTAssertEqual(token.tokenType, "bearer") - XCTAssertEqual(token.expiresIn, 7_200) - XCTAssertEqual(token.accessToken, "") - XCTAssertNil(token.refreshToken) - - let data2 = Data( - #""" - { - "scope" : "tweet.write tweet.read offline.access", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "", - "refresh_token" : "" - } - """#.utf8 - ) - guard let token2 = try TwitterOAuth2AccessToken(jsonData: data2) else { - XCTFail("Failed to create test token") - return - } - XCTAssertEqual(token2.scope, ["tweet.write", "tweet.read", "offline.access"]) - XCTAssertEqual(token2.tokenType, "bearer") - XCTAssertEqual(token2.expiresIn, 7_200) - XCTAssertEqual(token2.accessToken, "") - XCTAssertEqual(token2.refreshToken, "") - } - - public func testError() throws { - XCTAssertThrowsError(try TwitterOAuth2AccessToken.fromResponse(data: Data("aa".utf8))) { error in - guard let error = error as? TwitterAPIKitError else { - XCTFail("Expected TwitterAPIKitError") - return - } - XCTAssertTrue(error.isResponseSerializeFailed) - } - - XCTAssertThrowsError(try TwitterOAuth2AccessToken.fromResponse(data: Data("{}".utf8))) { error in - guard let error = error as? TwitterAPIKitError else { - XCTFail("Expected TwitterAPIKitError") - return - } - XCTAssertTrue(error.isResponseSerializeFailed) - } - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuth2BearerTokenTests.swift b/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuth2BearerTokenTests.swift deleted file mode 100644 index a8f26343..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuth2BearerTokenTests.swift +++ /dev/null @@ -1,37 +0,0 @@ -// TwitterOAuth2BearerTokenTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterOAuth2BearerTokenTests: XCTestCase { - public func testJsonData() throws { - let data = Data(#"{"token_type":"bearer","access_token":"token"}"#.utf8) - guard let token = try TwitterOAuth2BearerToken(jsonData: data) else { - XCTFail("Failed to create test token") - return - } - - XCTAssertEqual(token.tokenType, "bearer") - XCTAssertEqual(token.accessToken, "token") - } - - public func testNil() throws { - let data = Data("{}".utf8) - XCTAssertNil(try TwitterOAuth2BearerToken(jsonData: data)) - } - - public func testThrow() throws { - let data = Data("".utf8) - XCTAssertThrowsError(try TwitterOAuth2BearerToken(jsonData: data)) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuthAccessTokenV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuthAccessTokenV1Tests.swift deleted file mode 100644 index f8786fcb..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuthAccessTokenV1Tests.swift +++ /dev/null @@ -1,47 +0,0 @@ -// TwitterOAuthAccessTokenV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterOAuthAccessTokenV1Tests: XCTestCase { - public func test() throws { - let token = TwitterOAuthAccessTokenV1( - oauthToken: "token", oauthTokenSecret: "secret", userID: "uid", screenName: "sn" - ) - XCTAssertEqual(token.oauthToken, "token") - XCTAssertEqual(token.oauthTokenSecret, "secret") - XCTAssertEqual(token.userID, "uid") - XCTAssertEqual(token.screenName, "sn") - } - - public func testQueryStringData() throws { - let data = Data( - "oauth_token=token&oauth_token_secret=secret&user_id=uid&screen_name=name".utf8 - ) - - guard let token = TwitterOAuthAccessTokenV1(queryStringData: data) else { - XCTFail("Failed to decode token Response") - return - } - - XCTAssertEqual(token.oauthToken, "token") - XCTAssertEqual(token.oauthTokenSecret, "secret") - XCTAssertEqual(token.userID, "uid") - XCTAssertEqual(token.screenName, "name") - } - - public func testNil() throws { - let data = Data("".utf8) - XCTAssertNil(TwitterOAuthAccessTokenV1(queryStringData: data)) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuthTokenV1Tests.swift b/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuthTokenV1Tests.swift deleted file mode 100644 index a83ad50d..00000000 --- a/Tests/TwitterAPIKitTests/AuthAPI/TwitterOAuthTokenV1Tests.swift +++ /dev/null @@ -1,40 +0,0 @@ -// TwitterOAuthTokenV1Tests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterOAuthTokenV1Tests: XCTestCase { - public func test() throws { - let token = TwitterOAuthTokenV1(oauthToken: "token", oauthTokenSecret: "secret", oauthCallbackConfirmed: true) - XCTAssertEqual(token.oauthToken, "token") - XCTAssertEqual(token.oauthTokenSecret, "secret") - XCTAssertTrue(token.oauthCallbackConfirmed ?? false) - } - - public func testQueryStringData() { - let data = Data("oauth_token=token&oauth_token_secret=secret&oauth_callback_confirmed=true".utf8) - guard let token = TwitterOAuthTokenV1(queryStringData: data) else { - XCTFail("Failed to create test token") - return - } - - XCTAssertEqual(token.oauthToken, "token") - XCTAssertEqual(token.oauthTokenSecret, "secret") - XCTAssertTrue(token.oauthCallbackConfirmed ?? false) - } - - public func testNil() { - let data = Data("".utf8) - XCTAssertNil(TwitterOAuthTokenV1(queryStringData: data)) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/Extensions/ConcurrencyTests.swift b/Tests/TwitterAPIKitTests/Extensions/ConcurrencyTests.swift deleted file mode 100644 index 3e45f1a4..00000000 --- a/Tests/TwitterAPIKitTests/Extensions/ConcurrencyTests.swift +++ /dev/null @@ -1,285 +0,0 @@ -// ConcurrencyTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -#if compiler(>=5.5.2) && canImport(_Concurrency) - - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - internal class ConcurrencyTests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() async throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - DispatchQueue.global(qos: .default).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - guard let url = URL(string: "http://example.com") else { - XCTFail("Invalid Url") - return - } - - mockTask.httpResponse = .init( - url: url, - statusCode: 200, - httpVersion: "1.1", - headerFields: [:] - ) - - task.complete(error: nil) - } - - async let response = task.responseData - async let responseObj = task.responseObject - async let responseDecodable = task.responseDecodable(type: DecodableObj.self) - async let aResponse = task.specialized { _ in "a" }.responseObject - - do { - let data = await response.success - XCTAssertEqual(data, Data("{\"key\":\"value\"}".utf8)) - } - - do { - let obj = await responseObj.success - AssertEqualAnyDict(obj as? [String: Any] ?? [:], ["key": "value"]) - } - - do { - let obj = await responseDecodable.success - XCTAssertEqual(obj, .init(key: "value")) - } - - do { - let aSuccess = await aResponse.success - XCTAssertEqual(aSuccess, "a") - } - } - - // swiftlint:disable:next function_body_length - public func testCancel() async throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - DispatchQueue.global(qos: .default).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - // emurate cancel - task.cancel() - task.complete(error: URLError(.cancelled)) - } - - async let response = task.responseData - async let responseObj = task.responseObject - async let responseDecodable = task.responseDecodable(type: DecodableObj.self) - async let aResponse = task.specialized { _ in "a" }.responseObject - - do { - let error = await response.error - XCTAssertTrue(error?.isCancelled ?? false) - } - - do { - let error = await responseObj.error - XCTAssertTrue(error?.isCancelled ?? false) - } - - do { - let error = await responseDecodable.error - XCTAssertTrue(error?.isCancelled ?? false) - } - - do { - let error = await aResponse.error - XCTAssertTrue(error?.isCancelled ?? false) - } - - XCTAssertTrue(mockTask.cancelled) - } - - public func testTaskCancel() async throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - let asyncTask = Task { () -> [TwitterAPIResponse] in - async let rt0 = task.responseData.map { _ in () } - async let rt1 = task.responseObject.map { _ in () } - async let rt2 = task.responseDecodable(type: DecodableObj.self).map { _ in () } - async let rt3 = task.specialized { _ in () }.responseObject - return await [rt0, rt1, rt2, rt3] - } - - DispatchQueue.global(qos: .default).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - asyncTask.cancel() - task.complete(error: URLError(.cancelled)) - } - - let rss = await asyncTask.value - XCTAssertTrue(mockTask.cancelled) - XCTAssertTrue(asyncTask.isCancelled) - XCTAssertEqual(rss.count, 4) - for res in rss { - guard let error = res.error else { - XCTFail("No Response") - return - } - - XCTAssertTrue(error.isCancelled) - } - } - - // swiftlint:disable:next function_body_length - public func testStream() async throws { - guard let url = URL(string: "http://example.com") else { - XCTFail("Invalid Url") - return - } - - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: nil, - originalRequest: nil, - httpResponse: .init( - url: url, - statusCode: 200, - httpVersion: "1.1", - headerFields: [:] - ) - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - - let stream = task.streamResponse(queue: .main) - DispatchQueue.global(qos: .default).async { - task.append(chunk: Data("aaaa\r\nbbbb".utf8)) - task.append(chunk: Data("šŸ„“šŸ„“\r\n恂".utf8)) - } - - var count = 0 - for await response in stream { - switch count { - case 0: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "aaaa") - case 1: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "bbbb") - case 2: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "šŸ„“šŸ„“") - case 3: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "恂") - default: - XCTFail("Invalid Response") - } - count += 1 - if count == 4 { - break - } - } - XCTAssertEqual(count, 4) - } - - public func testStreamCancel() async throws { - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: nil, - originalRequest: nil, - httpResponse: nil - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - let stream = task.streamResponse(queue: .main) - let asyncTask = Task { - for await resp in stream { - XCTFail(resp.prettyString) - } - } - - DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + .milliseconds(1)) { - asyncTask.cancel() - task.append(chunk: Data("aaaa\r\nbbbb".utf8)) - } - - await asyncTask.value - - XCTAssertTrue(asyncTask.isCancelled) - XCTAssertTrue(mockTask.cancelled) - } - - // swiftlint:disable:next function_body_length - public func testStreamError() async { - guard let exampleUrl = URL(string: "https://example.com") else { - XCTFail("Invalid Example Url") - return - } - - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: nil, - originalRequest: nil, - httpResponse: .init( - url: exampleUrl, - statusCode: 200, - httpVersion: "1.1", - headerFields: [:] - ) - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - let stream = task - .streamResponse( - queue: .main - ) - .map { resp in resp.map { String(data: $0, encoding: .utf8) } } - let asyncTask = Task { - var count = 0 - for await resp in stream { - switch count { - case 0: - XCTAssertEqual(resp.success, "aaaa") - XCTAssertFalse(resp.isError) - case 1: - XCTAssertEqual(resp.success, "bbbb") - XCTAssertFalse(resp.isError) - case 2: - XCTAssertTrue(resp.isError) - default: - XCTFail("Invalid Response") - } - count += 1 - } - } - - DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + .milliseconds(1)) { - task.append(chunk: Data("aaaa\r\nbbbb".utf8)) - task.complete(error: URLError(.badServerResponse)) - task.append(chunk: Data("ccc\r\n".utf8)) - } - - await asyncTask.value - } - - deinit { - // De-init Logic Here - } - } -#endif diff --git a/Tests/TwitterAPIKitTests/Extensions/DataTests.swift b/Tests/TwitterAPIKitTests/Extensions/DataTests.swift deleted file mode 100644 index 830d17de..00000000 --- a/Tests/TwitterAPIKitTests/Extensions/DataTests.swift +++ /dev/null @@ -1,48 +0,0 @@ -// DataTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class DataTests: XCTestCase { - public func testSerialize() throws { - let data = Data("{\"a\":1}".utf8) - let serialized = data.serialize() - XCTAssertEqual(serialized.success as? [String: Int], ["a": 1]) - - let data2 = Data() - let serialized2 = data2.serialize() - guard let error = serialized2.error else { - XCTFail("Expected error but got nil") - return - } - XCTAssertTrue(error.isResponseSerializeFailed) - } - - public func testDecode() throws { - struct Obj: Decodable { - let abc: Int - } - let data = Data("{\"abc\":1}".utf8) - let serialized = data.decode(Obj.self, decoder: JSONDecoder()) - XCTAssertEqual(serialized.success?.abc, 1) - - let data2 = Data() - let serialized2 = data2.decode(Obj.self, decoder: JSONDecoder()) - guard let error = serialized2.error else { - XCTFail("Expected error but got nil") - return - } - XCTAssertTrue(error.isResponseSerializeFailed) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/Extensions/StringTests.swift b/Tests/TwitterAPIKitTests/Extensions/StringTests.swift deleted file mode 100644 index 02c8f94c..00000000 --- a/Tests/TwitterAPIKitTests/Extensions/StringTests.swift +++ /dev/null @@ -1,26 +0,0 @@ -// StringTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class StringTests: XCTestCase { - /// https://developer.twitter.com/en/docs/authentication/oauth-1-0a/percent-encoding-parameters - public func testEncode() throws { - XCTAssertEqual("Ladies + Gentlemen".urlEncodedString, "Ladies%20%2B%20Gentlemen") - XCTAssertEqual("An encoded string!".urlEncodedString, "An%20encoded%20string%21") - XCTAssertEqual("Dogs, Cats & Mice".urlEncodedString, "Dogs%2C%20Cats%20%26%20Mice") - XCTAssertEqual("☃".urlEncodedString, "%E2%98%83") - XCTAssertEqual("1970-01-01T00:01:00Z".urlEncodedString, "1970-01-01T00%3A01%3A00Z") - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/Helper/Assert.swift b/Tests/TwitterAPIKitTests/Helper/Assert.swift deleted file mode 100644 index e8ccbe93..00000000 --- a/Tests/TwitterAPIKitTests/Helper/Assert.swift +++ /dev/null @@ -1,22 +0,0 @@ -// Assert.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation -import XCTest - -// swiftlint:disable:next identifier_name -internal func AssertEqualAnyDict( - _ left: [String: Any], - _ right: [String: Any], - _ message: @autoclosure () -> String = "", - file: StaticString = #filePath, - line: UInt = #line -) { - // It works well most of the time. - XCTAssertEqual(NSDictionary(dictionary: left), NSDictionary(dictionary: right), message(), file: file, line: line) -} diff --git a/Tests/TwitterAPIKitTests/Helper/CombinationsSequence.swift b/Tests/TwitterAPIKitTests/Helper/CombinationsSequence.swift deleted file mode 100644 index ccf27258..00000000 --- a/Tests/TwitterAPIKitTests/Helper/CombinationsSequence.swift +++ /dev/null @@ -1,270 +0,0 @@ -// CombinationsSequence.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -/// A collection wrapper that generates combinations of a base collection. -public struct CombinationsSequence { - /// The collection to iterate over for combinations. - @usableFromInline internal let base: Base - - @usableFromInline internal let baseCount: Int - - /// The range of accepted sizes of combinations. - /// - /// - Note: This may be `nil` if the attempted range entirely exceeds the - /// upper bounds of the size of the `base` collection. - @usableFromInline internal let combinationRange: Range? - - /// Initializes a `CombinationsSequence` for all combinations of `base` of - /// size `k`. - /// - /// - Parameters: - /// - base: The collection to iterate over for combinations. - /// - size: The expected size of each combination. - @inlinable - internal init(_ base: Base, size: Int) { - self.init(base, kRange: size ... size) - } - - /// Initializes a `CombinationsSequence` for all combinations of `base` of - /// sizes within a given range. - /// - /// - Parameters: - /// - base: The collection to iterate over for combinations. - /// - kRange: The range of accepted sizes of combinations. - @inlinable - internal init( - _ base: Base, kRange: R - ) where R.Bound == Int { - let range = kRange.relative(to: 0 ..< .max) - self.base = base - let baseCount = base.count - self.baseCount = baseCount - let upperBound = baseCount + 1 - combinationRange = - range.lowerBound < upperBound - ? range.clamped(to: 0 ..< upperBound) - : nil - } - - /// The total number of combinations. - @inlinable public var count: Int { - guard let range = combinationRange else { return 0 } - let total = baseCount - if range == 0 ..< (total + 1) { - return 1 << total - } - - func binomial(total: Int, size: Int) -> Int { - switch size { - case total, 0: 1 - case total...: 0 - case (total / 2 + 1)...: binomial(total: total, size: total - size) - default: total * binomial(total: total - 1, size: size - 1) / size - } - } - - return range - .map { - binomial(total: total, size: $0) - } - .reduce(0, +) - } -} - -extension CombinationsSequence: Sequence { - /// The iterator for a `CombinationsSequence` instance. - public struct Iterator: IteratorProtocol { - @usableFromInline internal let base: Base - - /// The current range of accepted sizes of combinations. - /// - /// - Note: The range is contracted until empty while iterating over - /// combinations of different sizes. When the range is empty, iteration is - /// finished. - @usableFromInline internal var kRange: Range - - /// Whether or not iteration is finished (`kRange` is empty) - @inlinable internal var isFinished: Bool { - kRange.isEmpty - } - - @usableFromInline internal var indexes: [Base.Index] - - @inlinable - internal init(_ combinations: CombinationsSequence) { - base = combinations.base - kRange = combinations.combinationRange ?? 0 ..< 0 - indexes = Array(combinations.base.indices.prefix(kRange.lowerBound)) - } - - /// Advances the current indices to the next set of combinations. If - /// `indexes.count == 3` and `base.count == 5`, the indices advance like - /// this: - /// - /// [0, 1, 2] - /// [0, 1, 3] - /// [0, 1, 4] * - /// // * `base.endIndex` reached in `indexes.last` - /// // Advance penultimate index and propagate that change - /// [0, 2, 3] - /// [0, 2, 4] * - /// [0, 3, 4] * - /// [1, 2, 3] - /// [1, 2, 4] * - /// [1, 3, 4] * - /// [2, 3, 4] * - /// // Can't advance without needing to go past `base.endIndex`, - /// // so the iteration is finished. - @inlinable - internal mutating func advance() { - // Advances `kRange` by incrementing its `lowerBound` until the range is - // empty, when iteration is finished. - func advanceKRange() { - if kRange.lowerBound < kRange.upperBound { - let advancedLowerBound = kRange.lowerBound + 1 - kRange = advancedLowerBound ..< kRange.upperBound - indexes.removeAll(keepingCapacity: true) - indexes.append(contentsOf: base.indices.prefix(kRange.lowerBound)) - } - } - - guard !indexes.isEmpty else { - // Initial state for combinations of 0 elements is an empty array with - // `finished == false`. Even though no indexes are involved, advancing - // from that state means we are finished with iterating. - advanceKRange() - return - } - - let lastIndex = indexes.count - 1 - base.formIndex(after: &indexes[lastIndex]) - if indexes[lastIndex] != base.endIndex { return } - - var currentIndex = lastIndex - while indexes[lastIndex] == base.endIndex { - currentIndex -= 1 - guard currentIndex >= 0 else { - // Finished iterating over combinations of this size. - advanceKRange() - return - } - - base.formIndex(after: &indexes[currentIndex]) - for nextIndex in indexes.indices[(currentIndex + 1)...] { - indexes[nextIndex] = base.index(after: indexes[nextIndex - 1]) - if indexes[nextIndex] == base.endIndex { - break - } - } - } - } - - @inlinable - public mutating func next() -> [Base.Element]? { - guard !isFinished else { return nil } - defer { advance() } - return indexes.map { index in base[index] } - } - } - - @inlinable - public func makeIterator() -> Iterator { - Iterator(self) - } -} - -extension CombinationsSequence: LazySequenceProtocol - where Base: LazySequenceProtocol {} - -// ===----------------------------------------------------------------------===// -// combinations(ofCount:) -// ===----------------------------------------------------------------------===// - -public extension Collection { - /// Returns a collection of combinations of this collection's elements, with - /// each combination having the specified number of elements. - /// - /// This example prints the different combinations of 1 and 2 from an array of - /// four colors: - /// - /// let colors = ["fuchsia", "cyan", "mauve", "magenta"] - /// for combo in colors.combinations(ofCount: 1...2) { - /// print(combo.joined(separator: ", ")) - /// } - /// // fuchsia - /// // cyan - /// // mauve - /// // magenta - /// // fuchsia, cyan - /// // fuchsia, mauve - /// // fuchsia, magenta - /// // cyan, mauve - /// // cyan, magenta - /// // mauve, magenta - /// - /// The returned collection presents combinations in a consistent order, where - /// the indices in each combination are in ascending lexicographical order. - /// That is, in the example above, the combinations in order are the elements - /// at `[0]`, `[1]`, `[2]`, `[3]`, `[0, 1]`, `[0, 2]`, `[0, 3]`, `[1, 2]`, - /// `[1, 3]`, and finally `[2, 3]`. - /// - /// This example prints _all_ the combinations (including an empty array and - /// the original collection) from an array of numbers: - /// - /// let numbers = [10, 20, 30, 40] - /// for combo in numbers.combinations(ofCount: 0...) { - /// print(combo) - /// } - /// // [] - /// // [10] - /// // [20] - /// // [30] - /// // [40] - /// // [10, 20] - /// // [10, 30] - /// // [10, 40] - /// // [20, 30] - /// // [20, 40] - /// // [30, 40] - /// // [10, 20, 30] - /// // [10, 20, 40] - /// // [10, 30, 40] - /// // [20, 30, 40] - /// // [10, 20, 30, 40] - /// - /// If `kRange` is `0...0`, the resulting sequence has exactly one element, an - /// empty array. The given range is limited to `0...base.count`. If the - /// limited range is empty, the resulting sequence has no elements. - /// - /// - Parameter kRange: The range of numbers of elements to include in each - /// combination. - /// - /// - Complexity: O(1) for random-access base collections. O(*n*) where *n* - /// is the number of elements in the base collection, since - /// `CombinationsSequence` accesses the `count` of the base collection. - @inlinable - func combinations( - ofCount range: R - ) -> CombinationsSequence where R.Bound == Int { - CombinationsSequence(self, kRange: range) - } - - /// Returns a collection of combinations of this collection's elements, with - /// each combination having the specified number of elements. - /// - /// - Parameter size: The number of elements to include in each combination. - /// - /// - Complexity: O(1) for random-access base collections. O(*n*) where *n* - /// is the number of elements in the base collection, since - /// `CombinationsSequence` accesses the `count` of the base collection. - @inlinable - func combinations(ofCount size: Int) -> CombinationsSequence { - precondition(size >= 0, "Can't have combinations with a negative number of elements.") - return CombinationsSequence(self, size: size) - } -} diff --git a/Tests/TwitterAPIKitTests/Mock/MockURLProtocol.swift b/Tests/TwitterAPIKitTests/Mock/MockURLProtocol.swift deleted file mode 100644 index bc0b31a2..00000000 --- a/Tests/TwitterAPIKitTests/Mock/MockURLProtocol.swift +++ /dev/null @@ -1,81 +0,0 @@ -// MockURLProtocol.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation - -#if canImport(FoundationNetworking) -import FoundationNetworking -#endif - -internal func convertOptionalHttpUrlResponseToHttpUrlResponse( - _ response: HTTPURLResponse? -) -> HTTPURLResponse { - // swiftlint:disable:next force_unwrapping - return response! -} - -internal class MockURLProtocol: URLProtocol { - public static var requestHandler: ((URLRequest) throws -> (HTTPURLResponse, Data?))? - public static var requestAssert: ((URLRequest) throws -> Void)? - - override public class func canInit(with _: URLRequest) -> Bool { - true - } - - override public class func canonicalRequest(for request: URLRequest) -> URLRequest { - request - } - - public static func cleanup() { - requestHandler = nil - requestAssert = nil - } - - override public func startLoading() { - guard request.url != nil else { - client?.urlProtocol(self, didFailWithError: URLError(.badURL)) - return - } - - let handler: (URLRequest) throws -> (HTTPURLResponse, Data?) = Self.requestHandler ?? { request in - guard let requestURL = request.url else { - throw URLError(.badURL) - } - return ( - convertOptionalHttpUrlResponseToHttpUrlResponse(HTTPURLResponse( - url: requestURL, - statusCode: 200, - httpVersion: "2.0", - headerFields: nil - )), - Data() - ) - } - - do { - try Self.requestAssert?(request) - - let (response, data): (URLResponse, Data?) = try handler(request) - client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed) - - if let data { - client?.urlProtocol(self, didLoad: data) - } - - client?.urlProtocolDidFinishLoading(self) - } catch { - client?.urlProtocol(self, didFailWithError: error) - } - } - - override public func stopLoading() {} - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/MultipartFormDataPartTests.swift b/Tests/TwitterAPIKitTests/MultipartFormDataPartTests.swift deleted file mode 100644 index 1a9a5994..00000000 --- a/Tests/TwitterAPIKitTests/MultipartFormDataPartTests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// MultipartFormDataPartTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class MultipartFormDataPartTests: XCTestCase { - public func testEqualValue() throws { - let dataA = MultipartFormDataPart.value(name: "n", value: 1) - let dataB = MultipartFormDataPart.value(name: "n", value: "1") - let dataC = MultipartFormDataPart.value(name: "n", value: Float(1)) - let dataD = MultipartFormDataPart.value(name: "m", value: 1) - - for combo in [dataA, dataB, dataC, dataD].combinations(ofCount: 2) { - XCTAssertNotEqual(combo[0], combo[1]) - } - } - - public func testEqualData() throws { - let data = Data() - let dataA = MultipartFormDataPart.data(name: "n", value: data, filename: "f", mimeType: "m") - let dataB = MultipartFormDataPart.data(name: "m", value: data, filename: "f", mimeType: "m") - let dataC = MultipartFormDataPart.data(name: "n", value: data, filename: "ff", mimeType: "m") - let dataD = MultipartFormDataPart.data(name: "n", value: data, filename: "f", mimeType: "mm") - let dataE = MultipartFormDataPart.data( - name: "n", - value: Data(repeating: 1, count: 1), - filename: "f", - mimeType: "m" - ) - let dataF = MultipartFormDataPart.value(name: "n", value: data) - - let dataA1 = MultipartFormDataPart.data(name: "n", value: Data(), filename: "f", mimeType: "m") - - for combo in [dataA, dataB, dataC, dataD, dataE, dataF].combinations(ofCount: 2) { - XCTAssertNotEqual(combo[0], combo[1]) - } - - XCTAssertEqual(dataA, dataA1) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/OAuthHelperTests.swift b/Tests/TwitterAPIKitTests/OAuthHelperTests.swift deleted file mode 100644 index 8578ac47..00000000 --- a/Tests/TwitterAPIKitTests/OAuthHelperTests.swift +++ /dev/null @@ -1,50 +0,0 @@ -// OAuthHelperTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class OAuthHelperTests: XCTestCase { - override public func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the internal class. - } - - // https://developer.twitter.com/en/docs/authentication/oauth-1-0a/authorizing-a-request - // https://developer.twitter.com/en/docs/authentication/oauth-1-0a/creating-a-signature - public func test() throws { - guard let url = URL(string: "https://api.twitter.com/1.1/statuses/update.json") else { - XCTFail("Failed to create test URL") - return - } - - let header = authorizationHeader( - for: .post, - url: url, - parameters: ["status": "Hello Ladies + Gentlemen, a signed OAuth request!", "include_entities": true], - consumerKey: "xvz1evFS4wEEPTGEFPHBog", - consumerSecret: "kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw", - oauthToken: "370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb", - oauthTokenSecret: "LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE", - oauthTimestamp: "1318622958", - oauthNonce: "kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg" - ) - let expectedHeader = "OAuth oauth_consumer_key=\"xvz1evFS4wEEPTGEFPHBog\", " + - "oauth_nonce=\"kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg\", " + - "oauth_signature=\"hCtSmYh%2BiHYCEqBWrE7C7hYmtUk%3D\", " + - "oauth_signature_method=\"HMAC-SHA1\", " + - "oauth_timestamp=\"1318622958\", " + - "oauth_token=\"370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb\", " + - "oauth_version=\"1.0\"" - XCTAssertEqual(header, expectedHeader) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/SessionTask/MockTwitterAPISessionTask.swift b/Tests/TwitterAPIKitTests/SessionTask/MockTwitterAPISessionTask.swift deleted file mode 100644 index 412b0ff2..00000000 --- a/Tests/TwitterAPIKitTests/SessionTask/MockTwitterAPISessionTask.swift +++ /dev/null @@ -1,82 +0,0 @@ -// MockTwitterAPISessionTask.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import Foundation -import TwitterAPIKit - -internal class MockTwitterAPISessionTask: TwitterAPISessionTask { - public var taskIdentifier: Int - public var currentRequest: URLRequest? - public var originalRequest: URLRequest? - public var httpResponse: HTTPURLResponse? - public var cancelled = false - - public init( - taskIdentifier: Int, - currentRequest: URLRequest? = nil, - originalRequest: URLRequest? = nil, - httpResponse: HTTPURLResponse? = nil - ) { - self.taskIdentifier = taskIdentifier - self.currentRequest = currentRequest - self.originalRequest = originalRequest - self.httpResponse = httpResponse - } - - public func cancel() { - cancelled = true - } - - deinit { - // De-init Logic Here - } -} - -internal class MockTwitterAPISessionDataTask: MockTwitterAPISessionTask, TwitterAPISessionDataTask { - public var data: Data - - public init( - data: Data, - taskIdentifier: Int, - currentRequest: URLRequest? = nil, - originalRequest: URLRequest? = nil, - httpResponse: HTTPURLResponse? = nil - ) { - self.data = data - super.init( - taskIdentifier: taskIdentifier, - currentRequest: currentRequest, - originalRequest: originalRequest, - httpResponse: httpResponse - ) - } - - public func responseData(queue: DispatchQueue, _ block: @escaping (TwitterAPIResponse) -> Void) -> Self { - queue.async { [weak self] in - guard let self else { return } - block( - .init( - request: currentRequest, - response: httpResponse, - data: data, - result: .success(data), - rateLimit: TwitterRateLimit(header: [:]) - ) - ) - } - return self - } - - public func responseData(_ block: @escaping (TwitterAPIResponse) -> Void) -> Self { - responseData(queue: .main, block) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPIFailedTaskTests.swift b/Tests/TwitterAPIKitTests/SessionTask/TwitterAPIFailedTaskTests.swift deleted file mode 100644 index cfee0c2c..00000000 --- a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPIFailedTaskTests.swift +++ /dev/null @@ -1,106 +0,0 @@ -// TwitterAPIFailedTaskTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterAPIFailedTaskTests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let task = TwitterAPIFailedTask(.responseFailed(reason: .invalidResponse(error: nil))) - - XCTAssertTrue(task.error.isResponseFailed) - XCTAssertEqual(task.taskIdentifier, -1) - XCTAssertNil(task.currentRequest) - XCTAssertNil(task.originalRequest) - XCTAssertNil(task.httpResponse) - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 8 - task.responseData { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.main)) - exp.fulfill() - } - .responseData(queue: .global(qos: .utility)) { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.global(qos: .utility))) - exp.fulfill() - } - .responseObject { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.main)) - exp.fulfill() - } - .responseObject(queue: .global(qos: .default)) { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.global(qos: .default))) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self) { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.main)) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self, queue: .global(qos: .default)) { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.global(qos: .default))) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self, decoder: JSONDecoder()) { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.main)) - exp.fulfill() - } - .responseDecodable( - type: DecodableObj.self, - decoder: JSONDecoder(), - queue: .global(qos: .userInteractive) - ) { response in - - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.global(qos: .userInteractive))) - exp.fulfill() - } - - wait(for: [exp], timeout: 10) - } - - public func testStream() throws { - let task = TwitterAPIFailedTask(.responseFailed(reason: .invalidResponse(error: nil))) - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 2 - task.streamResponse { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.main)) - exp.fulfill() - } - .streamResponse(queue: .global(qos: .utility)) { response in - XCTAssertNotNil(response.error) - XCTAssertTrue(response.isError) - dispatchPrecondition(condition: .onQueue(.global(qos: .utility))) - exp.fulfill() - } - - wait(for: [exp], timeout: 10) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionDelegatedJSONTaskTests.swift b/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionDelegatedJSONTaskTests.swift deleted file mode 100644 index 7bef60ec..00000000 --- a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionDelegatedJSONTaskTests.swift +++ /dev/null @@ -1,250 +0,0 @@ -// TwitterAPISessionDelegatedJSONTaskTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal struct DecodableObj: Decodable, Equatable { - public let key: String -} - -internal class TwitterAPISessionDelegatedJSONTaskTests: XCTestCase { - // swiftlint:disable:next force_unwrapping - internal let testURL = URL(string: "http://example.com")! - - // swiftlint:disable:next function_body_length - public func testSuccess() throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - XCTAssertEqual(task.taskIdentifier, 1) - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 6 - - _ = task.responseData(queue: .global(qos: .background)) { response in - - XCTAssertEqual(response.success, Data("{\"key\":\"value\"}".utf8)) - XCTAssertNotNil(response.rateLimit) - XCTAssertEqual(response.rateLimit?.limit, 15) - XCTAssertEqual(response.rateLimit?.remaining, 1) - XCTAssertEqual(response.rateLimit?.reset, 1_647_099_944) - - XCTAssertFalse(Thread.isMainThread) - exp.fulfill() - } - .responseData { _ in - XCTAssertTrue(Thread.isMainThread) - exp.fulfill() - } - .responseObject(queue: .global(qos: .background)) { response in - if let dict = response.success as? [String: Any] { - AssertEqualAnyDict(dict, ["key": "value"]) - } else { - XCTFail("Expected response.success to be [String: Any]") - } - XCTAssertFalse(Thread.isMainThread) - exp.fulfill() - } - .responseObject { _ in - XCTAssertTrue(Thread.isMainThread) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self, queue: .global(qos: .background)) { response in - XCTAssertEqual(response.success, .init(key: "value")) - XCTAssertFalse(Thread.isMainThread) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self) { _ in - XCTAssertTrue(Thread.isMainThread) - exp.fulfill() - } - - DispatchQueue.global(qos: .background).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - mockTask.httpResponse = .init( - url: self.testURL, - statusCode: 200, - httpVersion: "1.1", - headerFields: [ - "x-rate-limit-limit": "15", - "x-rate-limit-remaining": "1", - "x-rate-limit-reset": "1647099944", - ] - ) - - task.complete(error: nil) - } - - wait(for: [exp], timeout: 10) - } - - // swiftlint:disable:next function_body_length - public func testInvalidStatusCode() throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 3 - - _ = task - .responseData(queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - XCTAssertNotNil(response.rateLimit) - XCTAssertEqual(response.rateLimit?.limit, 100) - XCTAssertEqual(response.rateLimit?.remaining, 2) - XCTAssertEqual(response.rateLimit?.reset, 1_647_099_945) - - exp.fulfill() - } - .responseObject(queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self, queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - exp.fulfill() - } - - DispatchQueue.global(qos: .background).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - // Status code is 400 - mockTask.httpResponse = .init( - url: self.testURL, - statusCode: 400, - httpVersion: "1.1", - headerFields: [ - "x-rate-limit-limit": "100", - "x-rate-limit-remaining": "2", - "x-rate-limit-reset": "1647099945", - ] - ) - - task.complete(error: nil) - } - - wait(for: [exp], timeout: 10) - } - - // swiftlint:disable:next function_body_length - public func testCompleteWithError() throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 3 - - _ = task - .responseData(queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - if let urlError = response.error?.underlyingError as? URLError { - XCTAssertEqual(urlError, URLError(.badServerResponse)) - } else { - XCTFail("Expected URLError") - } - exp.fulfill() - } - .responseObject(queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self, queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - exp.fulfill() - } - - DispatchQueue.global(qos: .background).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - mockTask.httpResponse = .init( - url: self.testURL, statusCode: 200, httpVersion: "1.1", headerFields: [:] - ) - - task.complete(error: URLError(.badServerResponse)) - } - - wait(for: [exp], timeout: 10) - } - - // swiftlint:disable:next function_body_length - public func testCancel() throws { - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - - let task = TwitterAPISessionDelegatedJSONTask( - task: mockTask - ) - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 3 - - _ = task - .responseData(queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - if let urlError = response.error?.underlyingError as? URLError { - XCTAssertEqual(urlError, URLError(.cancelled)) - } else { - XCTFail("Expected URLError") - } - exp.fulfill() - } - .responseObject(queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - exp.fulfill() - } - .responseDecodable(type: DecodableObj.self, queue: .global(qos: .background)) { response in - XCTAssertTrue(response.isError) - if let urlError = response.error?.underlyingError as? URLError { - XCTAssertEqual(urlError, URLError(.cancelled)) - } else { - XCTFail("Expected URLError") - } - exp.fulfill() - } - - DispatchQueue.global(qos: .background).async { - task.append(chunk: Data("{\"key\"".utf8)) - task.append(chunk: Data(":\"value\"}".utf8)) - - mockTask.httpResponse = .init( - url: self.testURL, statusCode: 200, httpVersion: "1.1", headerFields: [:] - ) - - task.complete(error: URLError(.cancelled)) - } - - task.cancel() - - wait(for: [exp], timeout: 10) - XCTAssertTrue(mockTask.cancelled) - } - - public func testEXC_BAD_INSTRUCTION() throws { - // EXC_BAD_INSTRUCTION will occur if the Dispatch Queue is released while suspended. - let mockTask = MockTwitterAPISessionTask(taskIdentifier: 1) - _ = TwitterAPISessionDelegatedJSONTask(task: mockTask) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionDelegatedStreamTaskTests.swift b/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionDelegatedStreamTaskTests.swift deleted file mode 100644 index f67ecb8b..00000000 --- a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionDelegatedStreamTaskTests.swift +++ /dev/null @@ -1,311 +0,0 @@ -// TwitterAPISessionDelegatedStreamTaskTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class TwitterAPISessionDelegatedStreamTaskTests: XCTestCase { - override public func setUpWithError() throws {} - - override public func tearDownWithError() throws {} - - public func testProps() throws { - guard let currentURL = URL(string: "http://example.com/current"), - let originalURL = URL(string: "http://example.com/original"), - let responseURL = URL(string: "https://example.com") - else { - XCTFail("Failed to create test URLs") - return - } - - let cReq = URLRequest(url: currentURL) - let oReq = URLRequest(url: originalURL) - guard let resp = HTTPURLResponse( - url: responseURL, - statusCode: 200, - httpVersion: "1.1", - headerFields: [:] - ) else { - XCTFail("Failed to create test response") - return - } - - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: cReq, - originalRequest: oReq, - httpResponse: resp - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - - XCTAssertEqual(mockTask.currentRequest, cReq) - XCTAssertEqual(mockTask.originalRequest, oReq) - XCTAssertEqual(task.httpResponse, resp) - } - - // swiftlint:disable:next function_body_length - public func test() throws { - guard let responseURL = URL(string: "https://example.com"), - let response = HTTPURLResponse( - url: responseURL, - statusCode: 200, - httpVersion: "1.1", - headerFields: [ - "x-rate-limit-limit": "15", - "x-rate-limit-remaining": "1", - "x-rate-limit-reset": "1647099944", - ] - ) - else { - XCTFail("Failed to create test response") - return - } - - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: nil, - originalRequest: nil, - httpResponse: response - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - - DispatchQueue.main.async { - task.append(chunk: Data("aaaa\r\nbbbb".utf8)) - task.append(chunk: Data("šŸ„“šŸ„“\r\n恂".utf8)) - task.complete(error: nil) - } - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 8 - - var count = 0 - task - .streamResponse { response in - XCTAssertTrue(Thread.isMainThread) - - guard let rateLimit = response.rateLimit else { - XCTFail("Rate limit should not be nil") - return - } - - XCTAssertEqual(rateLimit.limit, 15) - XCTAssertEqual(rateLimit.remaining, 1) - XCTAssertEqual(rateLimit.reset, 1_647_099_944) - - switch count { - case 0: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "aaaa") - case 1: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "bbbb") - case 2: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "šŸ„“šŸ„“") - case 3: - XCTAssertEqual(response.success.map { String(data: $0, encoding: .utf8) }, "恂") - default: - XCTFail("Invalid Response") - } - - count += 1 - exp.fulfill() - } - .streamResponse(queue: .global(qos: .default)) { _ in - XCTAssertFalse(Thread.isMainThread) - exp.fulfill() - } - - wait(for: [exp], timeout: 100) - XCTAssertEqual(count, 4) - } - - // swiftlint:disable:next function_body_length - public func testInvalidStatusCode() throws { - guard let responseURL = URL(string: "https://example.com"), - let response = HTTPURLResponse( - url: responseURL, - statusCode: 400, - httpVersion: "1.1", - headerFields: [ - "x-rate-limit-limit": "15", - "x-rate-limit-remaining": "1", - "x-rate-limit-reset": "1647099944", - ] - ) - else { - XCTFail("Failed to create test response") - return - } - - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 2, - currentRequest: nil, - originalRequest: nil, - httpResponse: response - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - - DispatchQueue.main.async { - task.append( - chunk: Data( - ( - "{\"detail\":\"Authenticating with OAuth 1.0a User Context is forbidden for this endpoint. " + - "Supported authentication types are [OAuth 2.0 Application-Only].\",\"title\":\"Unsupported " + - "Authentication\",\"status\":403,\"type\":\"https://api.twitter.com/2/problems/unsupported-" + - "authentication\"}" - ).utf8 - ) - ) - task.complete(error: nil) - } - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 2 - - var count = 0 - task - .streamResponse { response in - XCTAssertTrue(Thread.isMainThread) - - guard let rateLimit = response.rateLimit else { - XCTFail("Rate limit should not be nil") - return - } - - XCTAssertEqual(rateLimit.limit, 15) - XCTAssertEqual(rateLimit.remaining, 1) - XCTAssertEqual(rateLimit.reset, 1_647_099_944) - - switch count { - case 0: - guard let error = response.error else { - XCTFail("Expected error but got nil") - return - } - XCTAssertTrue(error.isResponseFailed) - default: - XCTFail("Invalid Response") - } - - count += 1 - exp.fulfill() - } - .streamResponse(queue: .global(qos: .default)) { response in - XCTAssertFalse(Thread.isMainThread) - guard let error = response.error else { - XCTFail("Expected error but got nil") - return - } - XCTAssertTrue(error.isResponseFailed) - exp.fulfill() - } - - wait(for: [exp], timeout: 100) - XCTAssertEqual(count, 1) - } - - // swiftlint:disable:next function_body_length - public func testNilResponse() throws { - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: nil, - originalRequest: nil, - httpResponse: nil - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - - DispatchQueue.main.async { - task.append(chunk: Data("aaaa\r\nbbbb".utf8)) - } - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 2 - - var count = 0 - task - .streamResponse { response in - XCTAssertTrue(Thread.isMainThread) - - switch count { - case 0: - XCTAssertTrue(response.isError) - guard let error = response.error else { - XCTFail("Expected error but got nil") - return - } - XCTAssertTrue(error.isResponseFailed) - default: - XCTFail("Invalid Response") - } - - count += 1 - exp.fulfill() - } - .streamResponse(queue: .global(qos: .default)) { _ in - XCTAssertFalse(Thread.isMainThread) - exp.fulfill() - } - - wait(for: [exp], timeout: 100) - XCTAssertEqual(count, 1) - } - - // swiftlint:disable:next function_body_length - public func testError() throws { - let mockTask = MockTwitterAPISessionTask( - taskIdentifier: 1, - currentRequest: nil, - originalRequest: nil, - httpResponse: nil - ) - - let task = TwitterAPISessionDelegatedStreamTask(task: mockTask) - - DispatchQueue.main.async { - task.complete(error: URLError(.notConnectedToInternet)) - } - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 2 - - var count = 0 - task - .streamResponse { response in - - XCTAssertTrue(Thread.isMainThread) - - XCTAssertNil(response.rateLimit) - - switch count { - case 0: - XCTAssertTrue(response.isError) - - default: - XCTFail("Invalid Response") - } - - count += 1 - exp.fulfill() - } - .streamResponse(queue: .global(qos: .default)) { response in - XCTAssertFalse(Thread.isMainThread) - XCTAssertTrue(response.isError) - exp.fulfill() - } - - wait(for: [exp], timeout: 100) - XCTAssertEqual(count, 1) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionSpecializedTaskTests.swift b/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionSpecializedTaskTests.swift deleted file mode 100644 index cb0f4eaf..00000000 --- a/Tests/TwitterAPIKitTests/SessionTask/TwitterAPISessionSpecializedTaskTests.swift +++ /dev/null @@ -1,82 +0,0 @@ -// TwitterAPISessionSpecializedTaskTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -internal class TwitterAPISessionSpecializedTaskTests: XCTestCase { - public func test() throws { - let mockTask = MockTwitterAPISessionDataTask( - data: Data("hoge".utf8), taskIdentifier: 10, currentRequest: nil, originalRequest: nil, httpResponse: nil - ) - - let task = TwitterAPISessionSpecializedTask(task: mockTask) { data in - guard let str = String(data: data, encoding: .utf8) else { - XCTFail("Failed to decode UTF-8 string") - return "" - } - return str - } - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 2 - task - .responseObject(queue: .main) { response in - XCTAssertEqual(response.success, "hoge") - exp.fulfill() - } - .responseData { response in - XCTAssertEqual(response.success, Data("hoge".utf8)) - exp.fulfill() - } - - wait(for: [exp], timeout: 100) - } - - public func testArray() throws { - let mockTask1 = MockTwitterAPISessionDataTask( - data: Data("hoge1".utf8), taskIdentifier: 10, currentRequest: nil, originalRequest: nil, httpResponse: nil - ) - let mockTask2 = MockTwitterAPISessionDataTask( - data: Data("hoge2".utf8), taskIdentifier: 10, currentRequest: nil, originalRequest: nil, httpResponse: nil - ) - - let task1 = TwitterAPISessionSpecializedTask(task: mockTask1) { data in - guard let str = String(data: data, encoding: .utf8) else { - XCTFail("Failed to decode UTF-8 string") - return "" - } - return str - } - - let task2 = TwitterAPISessionSpecializedTask(task: mockTask2) { data in - guard let str = String(data: data, encoding: .utf8) else { - XCTFail("Failed to decode UTF-8 string") - return "" - } - return str - } - - let exp = expectation(description: "") - - [task1, task2].responseObject { responses in - XCTAssertEqual(responses.count, 2) - XCTAssertEqual(responses[0].success, "hoge1") - XCTAssertEqual(responses[1].success, "hoge2") - - exp.fulfill() - } - - wait(for: [exp], timeout: 100) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAPIClientTests.swift b/Tests/TwitterAPIKitTests/TwitterAPIClientTests.swift deleted file mode 100644 index 51d0ab78..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPIClientTests.swift +++ /dev/null @@ -1,313 +0,0 @@ -// TwitterAPIClientTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterAPIClientTests: XCTestCase { - override public func tearDownWithError() throws { - MockURLProtocol.cleanup() - } - - public func testJSONDecoder() throws { - let decoder = TwitterAPIClient.defaultJSONDecoder - - let dateV1 = try decoder.decode(Date.self, from: Data("\"Sun Jul 03 04:32:05 +0000 2022\"".utf8)) - let dateV2 = try decoder.decode(Date.self, from: Data("\"2022-07-03T04:32:05.000Z\"".utf8)) - XCTAssertEqual(dateV1, dateV2) - } - - // swiftlint:disable:next function_body_length - public func testRefreshToken() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let client = TwitterAPIClient( - .oauth20( - .init(clientID: "c", scope: [], tokenType: "t", expiresIn: 0, accessToken: "a", refreshToken: "r") - ), - configuration: config - ) - - MockURLProtocol.requestHandler = { request in - guard let url = request.url else { - throw URLError(.badURL) - } - - let data = Data( - #""" - { - "scope" : "tweet.write", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "", - "refresh_token" : "" - } - """#.utf8 - ) - - guard let response = HTTPURLResponse( - url: url, - statusCode: 200, - httpVersion: "2.0", - headerFields: nil - ) else { - throw URLError(.badServerResponse) - } - - return (response, data) - } - - if case let .oauth20(token) = client.apiAuth { - XCTAssertEqual(token.accessToken, "a") - XCTAssertEqual(token.refreshToken, "r") - } else { - XCTFail("Invalid Response") - } - - let exp = expectation(description: "") - client.refreshOAuth20Token(type: .publicClient) { result in - do { - let newToken = try result.get() - XCTAssertTrue(newToken.refreshed) - XCTAssertEqual(newToken.token.accessToken, "") - XCTAssertEqual(newToken.token.refreshToken, "") - } catch { - XCTFail("Error: \(error)") - } - exp.fulfill() - } - wait(for: [exp], timeout: 10) - - // check refresh - if case let .oauth20(token) = client.apiAuth { - XCTAssertEqual(token.accessToken, "") - XCTAssertEqual(token.refreshToken, "") - } else { - XCTFail("Invalid Response") - } - } - - // swiftlint:disable:next function_body_length - public func testRefreshTokenForceRefresh() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let client = TwitterAPIClient( - .oauth20( - .init(clientID: "c", scope: [], tokenType: "t", expiresIn: 1_000, accessToken: "a", refreshToken: "r") - ), - configuration: config - ) - - MockURLProtocol.requestHandler = { request in - guard let url = request.url else { - throw URLError(.badURL) - } - - let data = Data( - #""" - { - "scope" : "tweet.write", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "", - "refresh_token" : "" - } - """#.utf8 - ) - - guard let response = HTTPURLResponse( - url: url, - statusCode: 200, - httpVersion: "2.0", - headerFields: nil - ) else { - throw URLError(.badServerResponse) - } - - return (response, data) - } - - let exp = expectation(description: "") - client.refreshOAuth20Token(type: .publicClient, forceRefresh: true) { result in - do { - let newToken = try result.get() - XCTAssertTrue(newToken.refreshed) - XCTAssertEqual(newToken.token.accessToken, "") - XCTAssertEqual(newToken.token.refreshToken, "") - } catch { - XCTFail("Error: \(error)") - } - exp.fulfill() - } - wait(for: [exp], timeout: 10) - - // check refresh - if case let .oauth20(token) = client.apiAuth { - XCTAssertEqual(token.accessToken, "") - XCTAssertEqual(token.refreshToken, "") - } else { - XCTFail("Invalid Response") - } - } - - public func testRefreshToken_invalidAuthenticationMethod() throws { - let client = TwitterAPIClient(.none) - let exp = expectation(description: "") - client.refreshOAuth20Token(type: .publicClient) { result in - switch result { - case .failure(.refreshOAuth20TokenFailed(reason: .invalidAuthenticationMethod(.none))): - break - default: - XCTFail("Invalid Response") - } - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testRefreshToken_refreshTokenIsMissing() throws { - let client = TwitterAPIClient( - .oauth20( - .init( - clientID: "", - scope: [], - tokenType: "", - expiresIn: 0, - accessToken: "", - refreshToken: nil - ) - ) - ) - let exp = expectation(description: "") - client.refreshOAuth20Token(type: .publicClient) { result in - switch result { - case .failure(.refreshOAuth20TokenFailed(reason: .refreshTokenIsMissing)): - break - default: - XCTFail("Invalid Response") - } - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testRefreshTokenNotExpired() throws { - let now = Date() - let client = TwitterAPIClient( - .oauth20( - .init( - clientID: "c", - scope: [], - tokenType: "t", - expiresIn: 100, - accessToken: "a", - refreshToken: "r", - createdAt: now - ) - ) - ) - - let exp = expectation(description: "") - client.refreshOAuth20Token(type: .publicClient) { result in - switch result { - case let .success(newToken): - XCTAssertFalse(newToken.refreshed) - XCTAssertEqual(newToken.token.clientID, "c") - XCTAssertEqual(newToken.token.refreshToken, "r") - XCTAssertEqual(newToken.token.createdAt, now) - default: - XCTFail("Invalid Response") - } - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - #if compiler(>=5.5.2) && canImport(_Concurrency) - - // swiftlint:disable function_body_length - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public func testRefreshTokenAsync() async throws { - // swiftlint:enable function_body_length - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let client = TwitterAPIClient( - .oauth20( - .init(clientID: "c", scope: [], tokenType: "t", expiresIn: 0, accessToken: "a", refreshToken: "r") - ), - configuration: config - ) - - MockURLProtocol.requestHandler = { request in - guard let url = request.url else { - throw URLError(.badURL) - } - - let data = Data( - #""" - { - "scope" : "tweet.write", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "", - "refresh_token" : "" - } - """#.utf8 - ) - - guard let response = HTTPURLResponse( - url: url, - statusCode: 200, - httpVersion: "2.0", - headerFields: nil - ) else { - throw URLError(.badServerResponse) - } - - return (response, data) - } - - let newToken = try await client.refreshOAuth20Token(type: .publicClient) - XCTAssertTrue(newToken.refreshed) - XCTAssertEqual(newToken.token.accessToken, "") - XCTAssertEqual(newToken.token.refreshToken, "") - - // check refresh - if case let .oauth20(token) = client.apiAuth { - XCTAssertEqual(token.accessToken, "") - XCTAssertEqual(token.refreshToken, "") - } else { - XCTFail("Invalid Response") - } - } - - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) - public func testRefreshTokenInvalidAuthenticationMethodAsync() async throws { - let client = TwitterAPIClient(.none) - - do { - _ = try await client.refreshOAuth20Token(type: .publicClient) - XCTFail("Invalid Response") - } catch { - switch error { - case TwitterAPIKitError.refreshOAuth20TokenFailed(reason: .invalidAuthenticationMethod(.none)): - break - default: - XCTFail("Invalid Response") - } - } - } - #endif - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAPIErrorResponseTests.swift b/Tests/TwitterAPIKitTests/TwitterAPIErrorResponseTests.swift deleted file mode 100644 index b339a65a..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPIErrorResponseTests.swift +++ /dev/null @@ -1,177 +0,0 @@ -// TwitterAPIErrorResponseTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterAPIErrorResponseTests: XCTestCase { - // swiftlint:disable:next function_body_length - public func testTwitterAPIErrorResponseV1() throws { - let v1Response = TwitterAPIErrorResponseV1(message: "_message_", code: 100, errors: []) - XCTAssertEqual(v1Response.message, "_message_") - XCTAssertEqual(v1Response.code, 100) - XCTAssertEqual(v1Response.errors, [TwitterAPIErrorResponseV1]()) - XCTAssertTrue(v1Response.contains(code: 100)) - XCTAssertFalse(v1Response.contains(code: 1)) - - let obj: [String: Any] = [ - "errors": [ - [ - "message": "message1", - "code": 1, - ], - [ - "message": "message2", - "code": 2, - ], - ], - ] - - guard let v1Response2 = TwitterAPIErrorResponseV1(obj: obj) else { - XCTFail("Failed to parse response") - return - } - - XCTAssertEqual(v1Response2.message, "message1") - XCTAssertEqual(v1Response2.code, 1) - XCTAssertEqual( - v1Response2.errors, - [ - .init(message: "message1", code: 1, errors: []), - .init(message: "message2", code: 2, errors: []), - ] - ) - XCTAssertTrue(v1Response2.contains(code: 1)) - XCTAssertFalse(v1Response2.contains(code: 100)) - - XCTAssertEqual( - v1Response2, - .init( - message: "message1", - code: 1, - errors: [ - .init(message: "message1", code: 1, errors: []), - .init(message: "message2", code: 2, errors: []), - ] - ) - ) - - XCTAssertNil(TwitterAPIErrorResponseV1(obj: [:])) - } - - // swiftlint:disable:next function_body_length - public func testTwitterAPIErrorResponseV2() throws { - let v2Response = TwitterAPIErrorResponseV2(title: "t", detail: "d", type: "ty", errors: []) - XCTAssertEqual(v2Response.title, "t") - XCTAssertEqual(v2Response.detail, "d") - XCTAssertEqual(v2Response.type, "ty") - XCTAssertEqual(v2Response.errors, []) - - let obj: [String: Any] = [ - "title": "_title_", - "detail": "_detail_", - "type": "_type_", - "errors": [ - ["message": "_message_", "parameters": ["param": ["b"]]], - ], - ] - guard let v2Response2 = TwitterAPIErrorResponseV2(obj: obj) else { - XCTFail("Failed to parse response") - return - } - - XCTAssertEqual(v2Response2.title, "_title_") - XCTAssertEqual(v2Response2.detail, "_detail_") - XCTAssertEqual(v2Response2.type, "_type_") - XCTAssertEqual(v2Response2.errors.first?.message, "_message_") - XCTAssertEqual(v2Response2.errors.first?.parameters["param"], ["b"]) - - XCTAssertEqual( - v2Response2, - TwitterAPIErrorResponseV2( - title: "_title_", - detail: "_detail_", - type: "_type_", - errors: [.init(message: "_message_", parameters: ["param": ["b"]])] - ) - ) - - XCTAssertNil(TwitterAPIErrorResponseV2(obj: [:])) - } - - // swiftlint:disable:next function_body_length - public func testTwitterAPIErrorResponse() throws { - let obj: [String: Any] = [ - "errors": [ - [ - "message": "message1", - "code": 1, - ], - [ - "message": "message2", - "code": 2, - ], - ], - ] - - let data = try JSONSerialization.data(withJSONObject: obj, options: []) - let error = TwitterAPIErrorResponse(data: data) - - XCTAssertTrue(error.isVersion1) - XCTAssertNotNil(error.version1) - - XCTAssertFalse(error.isVersion2) - XCTAssertNil(error.version2) - - XCTAssertFalse(error.isUnknown) - XCTAssertNil(error.unknownData) - - XCTAssertEqual(error.message, "message1") - XCTAssertEqual(error.code, 1) - - let obj2: [String: Any] = [ - "title": "_title_", - "detail": "_detail_", - "type": "_type_", - "errors": [ - ["message": "_message_", "parameters": ["param": ["b"]]], - ], - ] - let data2 = try JSONSerialization.data(withJSONObject: obj2, options: []) - let error2 = TwitterAPIErrorResponse(data: data2) - - XCTAssertFalse(error2.isVersion1) - XCTAssertNil(error2.version1) - - XCTAssertTrue(error2.isVersion2) - XCTAssertNotNil(error2.version2) - - XCTAssertFalse(error2.isUnknown) - XCTAssertNil(error2.unknownData) - - XCTAssertEqual(error2.message, "_detail_") - XCTAssertNil(error2.code) - - let error3 = TwitterAPIErrorResponse(data: Data()) - XCTAssertEqual(error3, .unknown(Data())) - XCTAssertTrue(error3.isUnknown) - XCTAssertEqual(error3.message, "") - XCTAssertNil(error3.code) - - let data4 = Data("{}".utf8) - let error4 = TwitterAPIErrorResponse(data: data4) - XCTAssertEqual(error4, .unknown(data4)) - XCTAssertTrue(error4.isUnknown) - XCTAssertEqual(error4.unknownData, data4) - XCTAssertEqual(error4.message, "{}") - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAPIKitErrorTests.swift b/Tests/TwitterAPIKitTests/TwitterAPIKitErrorTests.swift deleted file mode 100644 index 713ded6b..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPIKitErrorTests.swift +++ /dev/null @@ -1,83 +0,0 @@ -// TwitterAPIKitErrorTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterAPIKitErrorTests: XCTestCase { - public func testInit() throws { - let error = TwitterAPIKitError(error: NSError(domain: "", code: 0, userInfo: nil)) - XCTAssertTrue(error.isUnkonwn) - - let error2 = TwitterAPIKitError( - error: TwitterAPIKitError.responseFailed(reason: .invalidResponse(error: nil)) - ) - XCTAssertFalse(error2.isUnkonwn) - XCTAssertTrue(error2.isResponseFailed) - } - - public func testRequestFailed() throws { - XCTAssertTrue(TwitterAPIKitError.requestFailed(reason: .invalidURL(url: "")).isRequestFailed) - XCTAssertTrue( - TwitterAPIKitError.requestFailed(reason: .invalidParameter(parameter: [:], cause: "hoge")).isRequestFailed - ) - XCTAssertTrue(TwitterAPIKitError.requestFailed(reason: .cannotEncodeStringToData(string: "")).isRequestFailed) - XCTAssertTrue( - TwitterAPIKitError.requestFailed( - reason: .jsonSerializationFailed(obj: [:]) - ).isRequestFailed - ) - } - - public func testResponseFailed() throws { - XCTAssertTrue(TwitterAPIKitError.responseFailed(reason: .invalidResponse(error: nil)).isResponseFailed) - XCTAssertTrue( - TwitterAPIKitError.responseFailed( - reason: .unacceptableStatusCode(statusCode: 200, error: .unknown(Data()), rateLimit: .init(header: [:])) - ).isResponseFailed - ) - } - - public func testResponseSerializationFailure() throws { - XCTAssertTrue( - TwitterAPIKitError.responseSerializeFailed( - reason: .jsonSerializationFailed(error: NSError(domain: "", code: 0, userInfo: nil)) - ).isResponseSerializeFailed - ) - XCTAssertTrue( - TwitterAPIKitError.responseSerializeFailed( - reason: .jsonDecodeFailed( - error: DecodingError.typeMismatch( - Any.self, .init(codingPath: [], debugDescription: "", underlyingError: nil) - ) - ) - ).isResponseSerializeFailed - ) - XCTAssertTrue( - TwitterAPIKitError.responseSerializeFailed( - reason: .cannotConvert(data: Data(), toTypeName: "") - ).isResponseSerializeFailed - ) - } - - public func testUploadMediaFailure() throws { - XCTAssertTrue( - TwitterAPIKitError.uploadMediaFailed( - reason: .processingFailed(error: .init(code: 1, name: "n", message: "m")) - ).isUploadMediaFailed - ) - } - - public func testUnknown() throws { - XCTAssertTrue(TwitterAPIKitError.unkonwn(error: NSError(domain: "", code: 0, userInfo: nil)).isUnkonwn) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAPIKitTests.swift b/Tests/TwitterAPIKitTests/TwitterAPIKitTests.swift deleted file mode 100644 index 0e7d90ea..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPIKitTests.swift +++ /dev/null @@ -1,18 +0,0 @@ -// TwitterAPIKitTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal final class TwitterAPIKitTests: XCTestCase { - public func testExample() throws {} - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAPIRequestTests.swift b/Tests/TwitterAPIKitTests/TwitterAPIRequestTests.swift deleted file mode 100644 index f7c70795..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPIRequestTests.swift +++ /dev/null @@ -1,270 +0,0 @@ -// TwitterAPIRequestTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -// swiftlint:disable force_cast force_unwrapping -internal class TwitterAPIRequestTests: XCTestCase { - - private struct MockTwitterAPIRequest: TwitterAPIRequest { - var method: HTTPMethod = .get - var path: String = "/mock" - var parameters: [String: Any] - var baseURLType: TwitterBaseURLType = .api - var bodyContentType: BodyContentType = .wwwFormUrlEncoded - } - - private struct MockTwitterAPIQueryAndBodyRequest: TwitterAPIRequest { - var method: HTTPMethod = .get - var path: String = "/mock" - var queryParameters: [String: Any] - var bodyParameters: [String: Any] - var baseURLType: TwitterBaseURLType = .api - var bodyContentType: BodyContentType = .wwwFormUrlEncoded - } - - private let env = TwitterAPIEnvironment( - apiURL: .init(string: "https://api.example.com")!, - uploadURL: .init(string: "https://upload.example.com")! - ) - - public func testRequestURL() throws { - let req = MockTwitterAPIRequest(parameters: ["key": "value"], baseURLType: .api) - XCTAssertEqual(req.requestURL(for: env).absoluteString, "https://api.example.com/mock") - - let req2 = MockTwitterAPIRequest(parameters: ["key": "value"], baseURLType: .upload) - XCTAssertEqual(req2.requestURL(for: env).absoluteString, "https://upload.example.com/mock") - } - - public func testParameterForOAuth() throws { - let req = MockTwitterAPIRequest(parameters: ["key": "value"], bodyContentType: .wwwFormUrlEncoded) - XCTAssertEqual(req.parameterForOAuth as? [String: String], ["key": "value"]) - - let req2 = MockTwitterAPIRequest(parameters: ["key": "value"], bodyContentType: .json) - XCTAssertEqual(req2.parameterForOAuth as? [String: String], [:]) - - let req3 = MockTwitterAPIRequest(parameters: ["key": "value"], bodyContentType: .multipartFormData) - XCTAssertEqual(req3.parameterForOAuth as? [String: String], [:]) - } - - // swiftlint:disable:next function_body_length - public func testParameterByMethods() throws { - // šŸ„“ = F0 9F A5 93 - - let req = MockTwitterAPIRequest( - method: .get, - parameters: ["key": "value,šŸ„“"] - ) - - XCTAssertEqual(req.queryParameters as? [String: String], ["key": "value,šŸ„“"]) - XCTAssertEqual(req.bodyParameters as? [String: String], [:]) - - let urlReq = try req.buildRequest(environment: env) - - XCTAssertEqual(urlReq.httpMethod, "GET") - XCTAssertEqual(urlReq.url?.query, "key=value%2C%F0%9F%A5%93") - XCTAssertNil(urlReq.httpBody) - - let req2 = MockTwitterAPIRequest( - method: .post, - parameters: ["key": "value,šŸ„“"] - ) - - XCTAssertEqual(req2.queryParameters as! [String: String], [:]) - XCTAssertEqual(req2.bodyParameters as! [String: String], ["key": "value,šŸ„“"]) - - let urlReq2 = try req2.buildRequest(environment: env) - - XCTAssertEqual(urlReq2.httpMethod, "POST") - XCTAssertNil(urlReq2.url?.query) - XCTAssertEqual(String(data: urlReq2.httpBody!, encoding: .utf8)!, "key=value%2C%F0%9F%A5%93") - - let req3 = MockTwitterAPIRequest( - method: .put, - parameters: ["key": "value,šŸ„“"] - ) - - XCTAssertEqual(req3.queryParameters as! [String: String], [:]) - XCTAssertEqual(req3.bodyParameters as! [String: String], ["key": "value,šŸ„“"]) - - let urlReq3 = try req3.buildRequest(environment: env) - - XCTAssertEqual(urlReq3.httpMethod, "PUT") - XCTAssertNil(urlReq3.url?.query) - XCTAssertEqual(String(data: urlReq3.httpBody!, encoding: .utf8)!, "key=value%2C%F0%9F%A5%93") - - let req4 = MockTwitterAPIRequest( - method: .delete, - parameters: ["key": "value,šŸ„“"] - ) - - XCTAssertEqual(req4.queryParameters as! [String: String], ["key": "value,šŸ„“"]) - XCTAssertEqual(req4.bodyParameters as! [String: String], [:]) - - let urlReq4 = try req4.buildRequest(environment: env) - - XCTAssertEqual(urlReq4.httpMethod, "DELETE") - XCTAssertEqual(urlReq4.url?.query, "key=value%2C%F0%9F%A5%93") - XCTAssertNil(urlReq4.httpBody) - } - - public func testURLQueryPercentEncode() throws { - - let req = MockTwitterAPIRequest( - method: .get, - parameters: [ - "☃": "1970-01-01T00:01:00Z", - "key": "v a l u e", - "ć‚­ćƒ¼": "値", - ] - ) - - let urlReq = try req.buildRequest(environment: env) - - XCTAssertEqual( - urlReq.url?.query, #"key=v%20a%20l%20u%20e&%E2%98%83=1970-01-01T00%3A01%3A00Z&%E3%82%AD%E3%83%BC=%E5%80%A4"# - ) - } - - public func testBodyAndQueryParameter() throws { - let req = MockTwitterAPIQueryAndBodyRequest( - method: .post, - queryParameters: ["key": "value,šŸ„“"], - bodyParameters: ["body": "恂"] - ) - - XCTAssertEqual(req.parameters as! [String: String], [:]) - XCTAssertEqual(req.queryParameters as! [String: String], ["key": "value,šŸ„“"]) - XCTAssertEqual(req.bodyParameters as! [String: String], ["body": "恂"]) - - let urlReq = try req.buildRequest(environment: env) - - XCTAssertEqual(urlReq.httpMethod, "POST") - XCTAssertEqual(urlReq.url?.query, "key=value%2C%F0%9F%A5%93") - XCTAssertEqual(String(data: urlReq.httpBody!, encoding: .utf8)!, "body=%E3%81%82") - } - - public func testFormUrlEncodedBodyContentType() throws { - let req = try MockTwitterAPIRequest( - method: .post, - parameters: ["key": "value,šŸ„“"], - bodyContentType: .wwwFormUrlEncoded - ).buildRequest(environment: env) - - guard let httpBody = req.httpBody, - let body = String(data: httpBody, encoding: .utf8) else { - XCTFail("Failed to get HTTP body") - return - } - - XCTAssertEqual(body, "key=value%2C%F0%9F%A5%93") - } - - // swiftlint:disable:next function_body_length - public func testMultipartFormDataBodyContentType() throws { - let req = try MockTwitterAPIRequest( - method: .post, - parameters: [ - "a-value": MultipartFormDataPart.value(name: "a", value: "value"), - "b-data": MultipartFormDataPart.data( - name: "b", - value: Data("ab".utf8), - filename: "test.txt", - mimeType: "plain/text" - ), - ], - bodyContentType: .multipartFormData - ).buildRequest(environment: env) - - guard let contentType = req.allHTTPHeaderFields?["Content-Type"], - contentType.hasPrefix("multipart/form-data; boundary=TwitterAPIKit-"), - let httpBody = req.httpBody, - let body = String(data: httpBody, encoding: .utf8) else { - XCTFail("Failed to get content type or body") - return - } - - let boundary = contentType.replacingOccurrences( - of: "multipart/form-data; boundary=", - with: "" - ) - - let expect = "--\(boundary)\r\n" + - "Content-Disposition: form-data; name=\"a\"\r\n" + - "\r\n" + - "value\r\n" + - "--\(boundary)\r\n" + - "Content-Disposition: form-data; name=\"b\"; filename=\"test.txt\"\r\n" + - "Content-Type: plain/text\r\n" + - "\r\n" + - "ab\r\n" + - "--\(boundary)--\r\n" - - XCTAssertEqual(body, expect) - } - - - public func testInvalidMultipartFormData() throws { - XCTAssertThrowsError( - try MockTwitterAPIRequest( - method: .post, - parameters: ["key": "value,šŸ„“"], - bodyContentType: .multipartFormData - ).buildRequest(environment: env) - ) { error in - XCTAssertTrue(error is TwitterAPIKitError, "Error should be TwitterAPIKitError") - } - } - - public func testJsonBodyContentType() throws { - let req = try MockTwitterAPIRequest( - method: .post, - parameters: ["key": "value,šŸ„“"], - bodyContentType: .json - ).buildRequest(environment: env) - - guard let httpBody = req.httpBody else { - XCTFail("HTTP body should not be nil") - return - } - - let body = try JSONSerialization.jsonObject(with: httpBody, options: []) - guard let bodyDict = body as? [String: String] else { - XCTFail("Body should be [String: String]") - return - } - - XCTAssertEqual(bodyDict, ["key": "value,šŸ„“"]) - } - - public func testInvalidJsonSerialization() throws { - XCTAssertThrowsError( - try MockTwitterAPIRequest( - method: .post, - parameters: ["key": Data()], - bodyContentType: .json - ).buildRequest(environment: env) - ) { error in - guard let apiError = error as? TwitterAPIKitError else { - XCTFail("Error should be TwitterAPIKitError") - return - } - guard case .jsonSerializationFailed = apiError.requestFailureReason else { - XCTFail("Error should be jsonSerializationFailed") - return - } - } - } - - deinit { - // De-init logic here - } -} -// swiftlint:enable force_cast force_unwrapping diff --git a/Tests/TwitterAPIKitTests/TwitterAPIResponseTests.swift b/Tests/TwitterAPIKitTests/TwitterAPIResponseTests.swift deleted file mode 100644 index fc46f3fd..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPIResponseTests.swift +++ /dev/null @@ -1,79 +0,0 @@ -// TwitterAPIResponseTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterAPIResponseTests: XCTestCase { - // swiftlint:disable:next function_body_length - public func test() throws { - let rateLimit = TwitterRateLimit(header: [ - "x-rate-limit-limit": "10", - "x-rate-limit-remaining": "1", - "x-rate-limit-reset": "10000", - ]) - let data = Data("{}".utf8) - guard let url = URL(string: "https://example.com") else { - XCTFail("Failed to decode url Response") - return - } - - let response: TwitterAPIResponse = TwitterAPIResponse( - request: .init(url: url), - response: .init(url: url, statusCode: 200, httpVersion: "1.1", headerFields: [:]), - data: data, - result: .success(data), - rateLimit: rateLimit - ) - - XCTAssertEqual(response.request?.url, url) - XCTAssertEqual(response.response?.url, url) - XCTAssertEqual(response.success, data) - XCTAssertEqual(try response.result.get(), data) - XCTAssertNil(response.error) - XCTAssertFalse(response.isError) - XCTAssertTrue(response.prettyString.hasPrefix("-- Request success --")) - - let mapped = response.map { data in - try? JSONSerialization.jsonObject(with: data, options: []) - } - XCTAssertEqual(mapped.success as? [String: String], [:]) - - let mapped2 = response.tryMap { data in - try JSONSerialization.jsonObject(with: data, options: []) - } - XCTAssertEqual(mapped2.success as? [String: String], [:]) - - let mapped3 = response.tryMap { _ in - throw NSError(domain: "", code: 0, userInfo: nil) - } - XCTAssertTrue(mapped3.isError) - XCTAssertTrue(mapped3.prettyString.hasPrefix("-- Request failure --")) - - let errored = mapped3.mapError { _ in - .responseFailed(reason: .invalidResponse(error: nil)) - } - - guard let error = errored.error else { - XCTFail("No Response") - return - } - XCTAssertTrue(error.isResponseFailed) - - let mapped4 = response.mapError { _ in - XCTFail("do not call") - fatalError() - } - - XCTAssertNotNil(mapped4.success) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAPISessionTests.swift b/Tests/TwitterAPIKitTests/TwitterAPISessionTests.swift deleted file mode 100644 index f41a7ea1..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAPISessionTests.swift +++ /dev/null @@ -1,340 +0,0 @@ -// TwitterAPISessionTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import XCTest - -@testable import TwitterAPIKit - -private class GetTwitterReqeust: TwitterAPIRequest { - var method: HTTPMethod { .get } - var path: String { "/get.json" } - var parameters: [String: Any] { - ["hoge": "šŸ˜€"] // = %F0%9F%98%80 - } - - deinit { - // De-init Logic Here - } -} - -private class PostTwitterReqeust: TwitterAPIRequest { - var method: HTTPMethod { .post } - var path: String { "/post.json" } - var parameters: [String: Any] { - ["hoge": "šŸ˜€"] // = %F0%9F%98%80 - } - - deinit { - // De-init Logic Here - } -} - -private class EmptyRequest: TwitterAPIRequest { - var method: HTTPMethod { .get } - var path: String { "/empty.json" } - var parameters: [String: Any] { - [:] - } - - deinit { - // De-init Logic Here - } -} - -internal class TwitterAPISessionTests: XCTestCase { - private let environment: TwitterAPIEnvironment = { - guard let twitterURL = URL(string: "https://twitter.example.com"), - let apiURL = URL(string: "https://api.example.com"), - let uploadURL = URL(string: "https://upload.xample.com") - else { - fatalError("Invalid test URLs") - } - return TwitterAPIEnvironment( - twitterURL: twitterURL, - apiURL: apiURL, - uploadURL: uploadURL - ) - }() - - private lazy var session: TwitterAPISession = { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - return TwitterAPISession( - auth: .oauth10a(.init(consumerKey: "", consumerSecret: "", oauthToken: "", oauthTokenSecret: "")), - configuration: config, - environment: environment - ) - }() - - override public func tearDownWithError() throws { - MockURLProtocol.cleanup() - } - - public func testGET() throws { - MockURLProtocol.requestAssert = { request in - XCTAssertEqual(request.httpMethod, "GET") - XCTAssertEqual(request.url?.absoluteString, "https://api.example.com/get.json?hoge=%F0%9F%98%80") - XCTAssertNil(request.httpBody) - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testEmpty() throws { - MockURLProtocol.requestAssert = { request in - XCTAssertEqual(request.httpMethod, "GET") - XCTAssertEqual(request.url?.absoluteString, "https://api.example.com/empty.json") - XCTAssertNil(request.httpBody) - } - - let exp = expectation(description: "") - session.send(EmptyRequest()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - // swiftlint:disable:next function_body_length - public func testStream() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let session = TwitterAPISession( - auth: .bearer("bearer_token"), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestHandler = { request in - guard let url = request.url else { - throw URLError(.badURL) - } - - let data = Data("aaaa\r\nbbbb\r\n".utf8) - guard let response = HTTPURLResponse( - url: url, - statusCode: 200, - httpVersion: "2.0", - headerFields: nil - ) else { - throw URLError(.badServerResponse) - } - - return (response, data) - } - - MockURLProtocol.requestAssert = { request in - print(request) - } - - let exp = expectation(description: "") - exp.expectedFulfillmentCount = 4 - session.send(streamRequest: GetTwitterReqeust()) - .streamResponse(queue: .global(qos: .default)) { _ in - exp.fulfill() - } - .streamResponse { _ in - XCTAssertTrue(Thread.isMainThread) - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - // MARK: - Auth - - public func testBasicAuth() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let session = TwitterAPISession( - auth: .basic(apiKey: "api_key", apiSecretKey: "api_secret_key"), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertEqual(request.allHTTPHeaderFields?["Authorization"], "Basic YXBpX2tleTphcGlfc2VjcmV0X2tleQ==") - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testBearerAuth() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let session = TwitterAPISession( - auth: .bearer("bearer_token"), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertEqual(request.allHTTPHeaderFields?["Authorization"], "Bearer bearer_token") - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testNoneAuth() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - - let session = TwitterAPISession( - auth: .none, - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertNil(request.allHTTPHeaderFields?["Authorization"]) - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testOAuth10aAuth() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - let session = TwitterAPISession( - auth: .oauth10a(.init(consumerKey: "", consumerSecret: "", oauthToken: "", oauthTokenSecret: "")), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertNotNil(request.allHTTPHeaderFields?["Authorization"]) - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testOAuth20() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - let session = TwitterAPISession( - auth: .oauth20( - .init( - clientID: "", - scope: [], - tokenType: "", - expiresIn: 0, - accessToken: "", - refreshToken: "" - ) - ), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertEqual(request.allHTTPHeaderFields?["Authorization"], "Bearer ") - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testRequestOAuth20WithPKCEConfidentialClient() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - let session = TwitterAPISession( - auth: .requestOAuth20WithPKCE(.confidentialClient(clientID: "client_id", clientSecret: "client_secret")), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertEqual(request.allHTTPHeaderFields?["Authorization"], "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=") - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - public func testRequestOAuth20WithPKCEPublicClient() throws { - let config = URLSessionConfiguration.default - config.protocolClasses = [MockURLProtocol.self] - let session = TwitterAPISession( - auth: .requestOAuth20WithPKCE(.publicClient), - configuration: config, - environment: environment - ) - - MockURLProtocol.requestAssert = { request in - XCTAssertNil(request.allHTTPHeaderFields?["Authorization"]) - } - - let exp = expectation(description: "") - session.send(GetTwitterReqeust()).responseData(queue: .main) { _ in - exp.fulfill() - } - wait(for: [exp], timeout: 10) - } - - deinit { - // De-init Logic Here - } -} - -public extension Data { - /// Initialize a Data object by reading from an InputStream. - /// - Parameter input: The InputStream to read from. - /// - Throws: An error if the InputStream is nil or an error occurs while reading. - init(reading input: InputStream) throws { - self.init() - input.open() - defer { - input.close() - } - - let bufferSize = 1_024 - let buffer = UnsafeMutablePointer.allocate(capacity: bufferSize) - defer { - buffer.deallocate() - } - while input.hasBytesAvailable { - let read = input.read(buffer, maxLength: bufferSize) - if read < 0 { - // Stream error occured - throw input.streamError ?? URLError(.unknown) - } else if read == 0 { - // EOF - break - } - append(buffer, count: read) - } - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterAuthenticationMethodTests.swift b/Tests/TwitterAPIKitTests/TwitterAuthenticationMethodTests.swift deleted file mode 100644 index ead69090..00000000 --- a/Tests/TwitterAPIKitTests/TwitterAuthenticationMethodTests.swift +++ /dev/null @@ -1,167 +0,0 @@ -// TwitterAuthenticationMethodTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal final class TwitterAuthenticationMethodTests: XCTestCase { - // MARK: - OAuth10a - - public func testOAuth10aInit() throws { - let oauth10 = TwitterAuthenticationMethod.OAuth10a( - consumerKey: "ck", - consumerSecret: "cs", - oauthToken: "t", - oauthTokenSecret: "ts" - ) - - XCTAssertEqual(oauth10.consumerKey, "ck") - XCTAssertEqual(oauth10.consumerSecret, "cs") - XCTAssertEqual(oauth10.oauthToken, "t") - XCTAssertEqual(oauth10.oauthTokenSecret, "ts") - } - - // MARK: - OAuth20 - // swiftlint:disable:next function_body_length - public func testOAuth20Init() throws { - do { - let createdAt = Date(timeIntervalSince1970: 2) - - let oauth20 = TwitterAuthenticationMethod.OAuth20( - clientID: "client_id", - scope: ["scope"], - tokenType: "token_type", - expiresIn: 10, - accessToken: "access_token", - refreshToken: "refresh_token", - createdAt: createdAt - ) - - XCTAssertEqual(oauth20.clientID, "client_id") - XCTAssertEqual(oauth20.scope, ["scope"]) - XCTAssertEqual(oauth20.tokenType, "token_type") - XCTAssertEqual(oauth20.expiresIn, 10) - XCTAssertEqual(oauth20.accessToken, "access_token") - XCTAssertEqual(oauth20.refreshToken, "refresh_token") - XCTAssertEqual(oauth20.createdAt, createdAt) - } - - do { - let createdAt = Date(timeIntervalSince1970: 3) - let tokenJSON = Data( - """ - { - "refresh_token" : "", - "scope" : "tweet.write tweet.read offline.access", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "" - } - """.utf8 - ) - guard let token = try TwitterOAuth2AccessToken(jsonData: tokenJSON) else { - XCTFail("Failed to decode token Response") - return - } - let oauth20 = TwitterAuthenticationMethod.OAuth20( - clientID: "_client_id_", - token: token, - createdAt: createdAt - ) - - XCTAssertEqual(oauth20.clientID, "_client_id_") - XCTAssertEqual(oauth20.scope, ["tweet.write", "tweet.read", "offline.access"]) - XCTAssertEqual(oauth20.tokenType, "bearer") - XCTAssertEqual(oauth20.expiresIn, 7_200) - XCTAssertEqual(oauth20.accessToken, "") - XCTAssertEqual(oauth20.refreshToken, "") - XCTAssertEqual(oauth20.createdAt, createdAt) - } - } - - // swiftlint:disable:next function_body_length - public func testOAuth20Refresh() throws { - let createdAt = Date(timeIntervalSince1970: 2) - - var oauth20 = TwitterAuthenticationMethod.OAuth20( - clientID: "client_id", - scope: ["scope"], - tokenType: "token_type", - expiresIn: 10, - accessToken: "access_token", - refreshToken: "refresh_token", - createdAt: createdAt - ) - - XCTAssertEqual(oauth20.refreshToken, "refresh_token") - XCTAssertEqual(oauth20.createdAt, createdAt) - - let refreshedAt = Date(timeIntervalSince1970: 3) - let tokenJSON = Data( - """ - { - "refresh_token" : "", - "scope" : "tweet.write tweet.read offline.access", - "token_type" : "bearer", - "expires_in" : 7200, - "access_token" : "" - } - """.utf8 - ) - guard let token = try TwitterOAuth2AccessToken(jsonData: tokenJSON) else { - XCTFail("Failed to decode token Response") - return - } - - oauth20.refresh(token: token, refreshedAt: refreshedAt) - - XCTAssertEqual(oauth20.clientID, "client_id") - XCTAssertEqual(oauth20.scope, ["tweet.write", "tweet.read", "offline.access"]) - XCTAssertEqual(oauth20.tokenType, "bearer") - XCTAssertEqual(oauth20.expiresIn, 7_200) - XCTAssertEqual(oauth20.accessToken, "") - XCTAssertEqual(oauth20.refreshToken, "") - XCTAssertEqual(oauth20.createdAt, refreshedAt) - } - - public func testOAuth20Expired() throws { - let createdAt = Date(timeIntervalSince1970: 0) - let oauth20 = TwitterAuthenticationMethod.OAuth20( - clientID: "", - scope: [], - tokenType: "", - expiresIn: 10, - accessToken: "", - refreshToken: "", - createdAt: createdAt - ) - - XCTAssertEqual(oauth20.expiresAt, createdAt.addingTimeInterval(10)) - XCTAssertTrue(oauth20.expired) - } - - public func testOAuth20NotExpired() throws { - let createdAt = Date() - let oauth20 = TwitterAuthenticationMethod.OAuth20( - clientID: "", - scope: [], - tokenType: "", - expiresIn: 10, - accessToken: "", - refreshToken: "", - createdAt: createdAt - ) - - XCTAssertEqual(oauth20.expiresAt, createdAt.addingTimeInterval(10)) - XCTAssertFalse(oauth20.expired) - } - - deinit { - // De-init Logic Here - } -} diff --git a/Tests/TwitterAPIKitTests/TwitterRateLimitTests.swift b/Tests/TwitterAPIKitTests/TwitterRateLimitTests.swift deleted file mode 100644 index f0a32879..00000000 --- a/Tests/TwitterAPIKitTests/TwitterRateLimitTests.swift +++ /dev/null @@ -1,72 +0,0 @@ -// TwitterRateLimitTests.swift -// Copyright (c) 2025 GetAutomaApp -// All source code and related assets are the property of GetAutomaApp. -// All rights reserved. -// -// This Package is a heavily modified fork of https://github.com/mironal/TwitterAPIKit. -// This Package is distributable through a modified version of the MIT License. - -import TwitterAPIKit -import XCTest - -internal class TwitterRateLimitTests: XCTestCase { - public func test() throws { - let header = [ - "x-rate-limit-limit": 15, - "x-rate-limit-remaining": 13, - "x-rate-limit-reset": 1_644_417_523, - ] - - guard let rateLimit = TwitterRateLimit(header: header) else { - XCTFail("Failed to decode rateLimit Response") - return - } - - XCTAssertEqual(rateLimit.limit, 15) - XCTAssertEqual(rateLimit.remaining, 13) - XCTAssertEqual(rateLimit.reset, 1_644_417_523) - XCTAssertEqual(rateLimit.resetDate.timeIntervalSince1970, 1_644_417_523) - - let header2 = [ - "x-rate-limit-limit": "15", - "x-rate-limit-remaining": "3", - "x-rate-limit-reset": "1644417524", - ] - - guard let rateLimit2 = TwitterRateLimit(header: header2) else { - XCTFail("Failed to decode rateLimit Response") - return - } - - XCTAssertEqual(rateLimit2.limit, 15) - XCTAssertEqual(rateLimit2.remaining, 3) - XCTAssertEqual(rateLimit2.reset, 1_644_417_524) - } - - public func testNil() throws { - let header = [ - "x-rate-limit-remaining": "3", - "x-rate-limit-reset": "1644417524", - ] - - XCTAssertNil(TwitterRateLimit(header: header)) - - let header2 = [ - "x-rate-limit-limit": "15", - "x-rate-limit-reset": "1644417524", - ] - - XCTAssertNil(TwitterRateLimit(header: header2)) - - let header3 = [ - "x-rate-limit-limit": "15", - "x-rate-limit-remaining": "3", - ] - - XCTAssertNil(TwitterRateLimit(header: header3)) - } - - deinit { - // De-init Logic Here - } -}