Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eeeb89f
fix: format
AdonisCodes May 10, 2025
ea61932
chore: update submodules
AdonisCodes May 10, 2025
9a24f78
fix: fix all public-class-deinit issues (50% of the errors resolved)
AdonisCodes May 10, 2025
fc88cf0
fix: fix more linting issues
AdonisCodes May 11, 2025
30293ed
feat: fix more linting issues
AdonisCodes May 11, 2025
3aa8233
feat: convert p -> params
AdonisCodes May 12, 2025
fbc4bfa
fixes: fix invalid test cases
AdonisCodes May 12, 2025
8b93949
fix: convert q -> query (keep string params the same)
AdonisCodes May 12, 2025
f0670d2
fix: more fixes
AdonisCodes May 14, 2025
f1ab727
fix: more errors
AdonisCodes May 14, 2025
016ed0e
fix: fix file
AdonisCodes May 15, 2025
865b611
fix: Reduce function body length in TwitterAPIRequestTests.swift
AdonisCodes May 15, 2025
75ba052
fix: Replace force cast with safe optional binding in TwitterAPISessi…
AdonisCodes May 15, 2025
43e0ebb
chore: update submodules
AdonisCodes May 17, 2025
2f00bdc
fix: fix issues
AdonisCodes May 17, 2025
469afc8
fix: fix issues
AdonisCodes May 17, 2025
089da08
fix: fix lints
AdonisCodes May 17, 2025
5bc6f41
fix: fix more lints
AdonisCodes May 17, 2025
7715cc7
fix: add de-inits everywhere
AdonisCodes May 17, 2025
d7346b8
fix: fix length errors
AdonisCodes May 17, 2025
29979cc
fix: fix more issues
AdonisCodes May 17, 2025
f573d11
fix: fix unsorted enums
AdonisCodes May 17, 2025
83285e4
fix: more > 120 line errors
AdonisCodes May 17, 2025
5315c73
fix: fix all links
AdonisCodes May 18, 2025
c1d5f90
fix: fix more issues
AdonisCodes May 18, 2025
4fc88bc
feat: fix all lint issues
AdonisCodes May 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .dotfiles
1 change: 1 addition & 0 deletions .swiftformat
5 changes: 5 additions & 0 deletions BuildTools/Empty.swift
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
// Empty.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation
19 changes: 11 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,39 @@
// If CommonCrypto is not available, swift-crypto should be used.

#if canImport(CommonCrypto)
let dependencies: [Package.Dependency] = []
let tDependencies: [Target.Dependency] = []
let dependencies: [Package.Dependency] = []

Check warning on line 10 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

All declarations should specify Access Control Level keywords explicitly (explicit_acl)

Check warning on line 10 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Top-level declarations should specify Access Control Level keywords explicitly (explicit_top_level_acl)
let tDependencies: [Target.Dependency] = []

Check warning on line 11 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

All declarations should specify Access Control Level keywords explicitly (explicit_acl)

Check warning on line 11 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Top-level declarations should specify Access Control Level keywords explicitly (explicit_top_level_acl)
#else // for Linux
let dependencies: [Package.Dependency] = [.package(url: "https://github.com/apple/swift-crypto.git", from: "3.8.0")]
let tDependencies: [Target.Dependency] = [.product(name: "Crypto", package: "swift-crypto")]
let dependencies: [Package.Dependency] = [.package(url: "https://github.com/apple/swift-crypto.git", from: "3.8.0")]

Check warning on line 13 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

All declarations should specify Access Control Level keywords explicitly (explicit_acl)

Check warning on line 13 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Top-level declarations should specify Access Control Level keywords explicitly (explicit_top_level_acl)
let tDependencies: [Target.Dependency] = [.product(name: "Crypto", package: "swift-crypto")]

Check warning on line 14 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

All declarations should specify Access Control Level keywords explicitly (explicit_acl)
#endif

let package = Package(

Check warning on line 17 in Package.swift

View workflow job for this annotation

GitHub Actions / swiftlint

All declarations should specify Access Control Level keywords explicitly (explicit_acl)
name: "TwitterAPIKit",
platforms: [
.macOS(.v10_14),
.iOS(.v12),
.tvOS(.v12),
.watchOS(.v6)
.watchOS(.v6),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "TwitterAPIKit",
targets: ["TwitterAPIKit"]),
targets: ["TwitterAPIKit"]
),
],
dependencies: dependencies,
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: tDependencies
),
.testTarget(
name: "TwitterAPIKitTests",
dependencies: ["TwitterAPIKit"]),
dependencies: ["TwitterAPIKit"]
),
]
)
38 changes: 30 additions & 8 deletions Sources/TwitterAPIKit/APIv1/Account/AccountAPIv1.swift
Original file line number Diff line number Diff line change
@@ -1,53 +1,75 @@
// AccountAPIv1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

open class AccountAPIv1: TwitterAPIBase {

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-settings
/// 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 {
return session.send(request)
}

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
/// 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 {
return session.send(request)
}

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-remove_profile_banner
/// 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 {
return session.send(request)
}

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-settings
/// 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 {
return session.send(request)
}

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile
/// 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 {
return session.send(request)
}

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner
/// 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 {
return session.send(request)
}

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
/// 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 {
return session.send(request)
}

deinit {
// De-init Logic Here
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// GetAccountSettingsRequestV1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-settings
/// 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 {
return .get
}
Expand All @@ -15,6 +21,9 @@ open class GetAccountSettingsRequestV1: TwitterAPIRequest {
return [:]
}

public init() {
public init() {}

deinit {
// De-init Logic Here
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// GetAccountVerifyCredentialsRequestV1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
/// 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?
Expand All @@ -16,11 +22,11 @@ open class GetAccountVerifyCredentialsRequestV1: TwitterAPIRequest {
}

open var parameters: [String: Any] {
var p = [String: Any]()
skipStatus.map { p["skip_status"] = $0 }
includeEmail.map { p["include_email"] = $0 }
includeEntities.map { p["include_entities"] = $0 }
return p
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(
Expand All @@ -32,4 +38,8 @@ open class GetAccountVerifyCredentialsRequestV1: TwitterAPIRequest {
self.includeEmail = includeEmail
self.includeEntities = includeEntities
}

deinit {
// De-init Logic Here
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// PostAccountRemoveProfileBannerRequestV1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-remove_profile_banner
/// 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 {
return .post
}
Expand All @@ -16,4 +22,8 @@ open class PostAccountRemoveProfileBannerRequestV1: TwitterAPIRequest {
}

public init() {}

deinit {
// De-init Logic Here
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// PostAccountSettingsRequestV1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-settings
/// 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
Expand All @@ -24,14 +30,14 @@ open class PostAccountSettingsRequestV1: TwitterAPIRequest {
}

open var parameters: [String: Any] {
var p = [String: Any]()
lang.map { p["lang"] = $0 }
timeZone.map { p["time_zone"] = $0 }
startSleepTime.map { p["start_sleep_time"] = $0 }
endSleepTime.map { p["end_sleep_time"] = $0 }
sleepTimeEnabled.map { p["sleep_time_enabled"] = $0 }
trendLocationWoeid.map { p["trend_location_woeid"] = $0 }
return p
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(
Expand All @@ -49,4 +55,8 @@ open class PostAccountSettingsRequestV1: TwitterAPIRequest {
self.sleepTimeEnabled = sleepTimeEnabled
self.trendLocationWoeid = trendLocationWoeid
}

deinit {
// De-init Logic Here
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// PostAccountUpdateProfileBannerRequestV1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner
/// 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?
Expand All @@ -18,13 +24,13 @@ open class PostAccountUpdateProfileBannerRequestV1: TwitterAPIRequest {
}

open var parameters: [String: Any] {
var p = [String: Any]()
p["banner"] = banner.base64EncodedString()
width.map { p["width"] = $0 }
height.map { p["height"] = $0 }
offsetTop.map { p["offset_top"] = $0 }
offsetLeft.map { p["offset_left"] = $0 }
return p
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(
Expand All @@ -41,4 +47,7 @@ open class PostAccountUpdateProfileBannerRequestV1: TwitterAPIRequest {
self.offsetLeft = offsetLeft
}

deinit {
// De-init Logic Here
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// PostAccountUpdateProfileImageRequestV1.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import Foundation

/// https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
/// 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?
Expand All @@ -16,11 +22,11 @@ open class PostAccountUpdateProfileImageRequestV1: TwitterAPIRequest {
}

open var parameters: [String: Any] {
var p = [String: Any]()
p["image"] = image.base64EncodedString()
skipStatus.map { p["skip_status"] = $0 }
includeEntities.map { p["include_entities"] = $0 }
return p
var params = [String: Any]()
params["image"] = image.base64EncodedString()
skipStatus.map { params["skip_status"] = $0 }
includeEntities.map { params["include_entities"] = $0 }
return params
}

public init(
Expand All @@ -32,4 +38,8 @@ open class PostAccountUpdateProfileImageRequestV1: TwitterAPIRequest {
self.skipStatus = skipStatus
self.includeEntities = includeEntities
}

deinit {
// De-init Logic Here
}
}
Loading
Loading