Skip to content

Commit

Permalink
Update Twifter
Browse files Browse the repository at this point in the history
  • Loading branch information
SNQ-2001 committed Apr 23, 2022
1 parent c20e9cb commit 9afe465
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 281 deletions.
94 changes: 47 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,51 @@ Coming soon

## Functions
```Swift
try await Twifter().generate_guest_token()
try await Twifter().rate_limit_status()
try await Twifter().collections_entries(id: "custom-539487832448843776")
try await Twifter().followers_ids(user_id: 1218659670)
try await Twifter().friends_ids(screen_name: "_SNQ")
try await Twifter().followers_list(user_id: 1218659670)
try await Twifter().followers_list(screen_name: "_SNQ")
try await Twifter().friends_ids(user_id: 1218659670)
try await Twifter().friends_ids(screen_name: "_SNQ")
try await Twifter().friends_list(user_id: 1218659670)
try await Twifter().friends_list(screen_name: "_SNQ")
try await Twifter().friendships_show(source_id: 1218659670, target_id: 1468966997438640128)
try await Twifter().friendships_show(source_screen_name: "_SNQ", target_screen_name: "Shadow_Ban_Bot")
try await Twifter().geo_id(place_id: "06ef846bfc783874")
try await Twifter().geo_reverse_geocode(lat: 35.79449997305192, long: 139.79078800000002)
try await Twifter().geo_search(query: "Tokyo")
try await Twifter().geo_search(lat: 35.79449997305192, long: 139.79078800000002)
try await Twifter().geo_search(ip: "1.2.3.4")
try await Twifter().lists_list(user_id: 1218659670)
try await Twifter().lists_list(screen_name: "_SNQ")
try await Twifter().lists_members(list_id: 1517792406514839552)
try await Twifter().lists_memberships(user_id: 1218659670)
try await Twifter().lists_memberships(screen_name: "_SNQ")
try await Twifter().lists_ownerships(user_id: 1218659670)
try await Twifter().lists_ownerships(screen_name: "_SNQ")
try await Twifter().lists_show(list_id: 1517792406514839552)
try await Twifter().lists_statuses(list_id: 1517792406514839552)
try await Twifter().lists_subscribers(list_id: 1517792406514839552)
try await Twifter().lists_subscriptions(user_id: 1218659670)
try await Twifter().lists_subscriptions(screen_name: "_SNQ")
try await Twifter().search_tweets(q: "Swift")
try await Twifter().statuses_lookup(id: [1488101267243429889, 1516619027288043521])
try await Twifter().statuses_retweeters_ids(id: 1488101267243429889)
try await Twifter().statuses_retweets(id: 1488101267243429889)
try await Twifter().statuses_show(id: 1488101267243429889)
try await Twifter().statuses_user_timeline(user_id: 1218659670)
try await Twifter().statuses_user_timeline(screen_name: "_SNQ")
try await Twifter().trends_available()
try await Twifter().trends_closest(lat: 35.79449997305192, long: 139.79078800000002)
try await Twifter().trends_place(id: 1110809)
try await Twifter().users_lookup(user_id: [1218659670, 1468966997438640128])
try await Twifter().users_lookup(screen_name: ["_SNQ", "Shadow_Ban_Bot"])
try await Twifter().users_search(q: "_SNQ")
try await Twifter().user_show(user_id: 1218659670)
try await Twifter().user_show(screen_name: "_SNQ")
try await TwifterClient().generate_guest_token()
try await TwifterClient().rate_limit_status()
try await TwifterClient().collections_entries(id: "custom-539487832448843776")
try await TwifterClient().followers_ids(user_id: 1218659670)
try await TwifterClient().friends_ids(screen_name: "_SNQ")
try await TwifterClient().followers_list(user_id: 1218659670)
try await TwifterClient().followers_list(screen_name: "_SNQ")
try await TwifterClient().friends_ids(user_id: 1218659670)
try await TwifterClient().friends_ids(screen_name: "_SNQ")
try await TwifterClient().friends_list(user_id: 1218659670)
try await TwifterClient().friends_list(screen_name: "_SNQ")
try await TwifterClient().friendships_show(source_id: 1218659670, target_id: 1468966997438640128)
try await TwifterClient().friendships_show(source_screen_name: "_SNQ", target_screen_name: "Shadow_Ban_Bot")
try await TwifterClient().geo_id(place_id: "06ef846bfc783874")
try await TwifterClient().geo_reverse_geocode(lat: 35.79449997305192, long: 139.79078800000002)
try await TwifterClient().geo_search(query: "Tokyo")
try await TwifterClient().geo_search(lat: 35.79449997305192, long: 139.79078800000002)
try await TwifterClient().geo_search(ip: "1.2.3.4")
try await TwifterClient().lists_list(user_id: 1218659670)
try await TwifterClient().lists_list(screen_name: "_SNQ")
try await TwifterClient().lists_members(list_id: 1517792406514839552)
try await TwifterClient().lists_memberships(user_id: 1218659670)
try await TwifterClient().lists_memberships(screen_name: "_SNQ")
try await TwifterClient().lists_ownerships(user_id: 1218659670)
try await TwifterClient().lists_ownerships(screen_name: "_SNQ")
try await TwifterClient().lists_show(list_id: 1517792406514839552)
try await TwifterClient().lists_statuses(list_id: 1517792406514839552)
try await TwifterClient().lists_subscribers(list_id: 1517792406514839552)
try await TwifterClient().lists_subscriptions(user_id: 1218659670)
try await TwifterClient().lists_subscriptions(screen_name: "_SNQ")
try await TwifterClient().search_tweets(q: "Swift")
try await TwifterClient().statuses_lookup(id: [1488101267243429889, 1516619027288043521])
try await TwifterClient().statuses_retweeters_ids(id: 1488101267243429889)
try await TwifterClient().statuses_retweets(id: 1488101267243429889)
try await TwifterClient().statuses_show(id: 1488101267243429889)
try await TwifterClient().statuses_user_timeline(user_id: 1218659670)
try await TwifterClient().statuses_user_timeline(screen_name: "_SNQ")
try await TwifterClient().trends_available()
try await TwifterClient().trends_closest(lat: 35.79449997305192, long: 139.79078800000002)
try await TwifterClient().trends_place(id: 1110809)
try await TwifterClient().users_lookup(user_id: [1218659670, 1468966997438640128])
try await TwifterClient().users_lookup(screen_name: ["_SNQ", "Shadow_Ban_Bot"])
try await TwifterClient().users_search(q: "_SNQ")
try await TwifterClient().user_show(user_id: 1218659670)
try await TwifterClient().user_show(screen_name: "_SNQ")
```

## Usage
Expand All @@ -91,7 +91,7 @@ struct ContentView: View {
var body: some View {
Button(action: {
Task {
let user_info = try await Twifter().user_show(screen_name: "_SNQ")
let user_info = try await TwifterClient().user_show(screen_name: "_SNQ")
guard let id = user_info["id"] else { return }
print(id)
}
Expand All @@ -115,7 +115,7 @@ Task {
Add `try await`

```Swift
try await Twifter().user_show(screen_name: "_SNQ")
try await TwifterTwifterClient().user_show(screen_name: "_SNQ")
```

## Contributions
Expand Down
4 changes: 2 additions & 2 deletions Sources/Twifter/API-1.1/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public extension Client {
public extension TwifterClient {
/**
GET application/rate_limit_status
Expand All @@ -19,7 +19,7 @@ public extension Client {
- SeeAlso
https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
*/
public func rate_limit_status(resources: [Resources]? = nil) async throws -> [String: Any] {
func rate_limit_status(resources: [Resources]? = nil) async throws -> [String: Any] {
let guest_token = try await generate_guest_token().guest_token
var urlString: String = "https://api.twitter.com/1.1/application/rate_limit_status.json"
if resources != nil {
Expand Down
12 changes: 6 additions & 6 deletions Sources/Twifter/API-1.1/Collections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

import Foundation

public extension Client {
public extension TwifterClient {
/**
GET collections/entries
- Note: Retrieve the identified Collection, presented as a list of the Tweets curated within.
- Parameters:
- id: The identifier of the Collection for which to return results.
- count: Specifies the maximum number of results to include in the response. Specify a count between 1 and 200. A next_cursor value will be provided in the response if additional results are available.
- max_position: Returns results with a position value less than or equal to the specified position.
- min_position: Returns results with a position greater than the specified position.
- id: The identifier of the Collection for which to return results.
- count: Specifies the maximum number of results to include in the response. Specify a count between 1 and 200. A next_cursor value will be provided in the response if additional results are available.
- max_position: Returns results with a position value less than or equal to the specified position.
- min_position: Returns results with a position greater than the specified position.
- SeeAlso
https://developer.twitter.com/en/docs/twitter-api/v1/tweets/curate-a-collection/api-reference/get-collections-entries
*/
public func collections_entries(id: String, count: Int? = nil, max_position: Int? = nil, min_position: Int? = nil) async throws -> [String: Any] {
func collections_entries(id: String, count: Int? = nil, max_position: Int? = nil, min_position: Int? = nil) async throws -> [String: Any] {
let guest_token = try await generate_guest_token().guest_token
var urlString: String = "https://api.twitter.com/1.1/collections/entries.json?id=\(id.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)"
if count != nil {
Expand Down
26 changes: 13 additions & 13 deletions Sources/Twifter/API-1.1/Favorites.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

import Foundation

public extension Client {
public extension TwifterClient {
/**
GET favorites/list
- Note: Returns the 20 most recent Tweets liked by the authenticating or specified user.
- Parameters:
- user_id: The ID of the user for whom to return results.
- count: Specifies the number of records to retrieve. Must be less than or equal to 200; defaults to 20. The value of count is best thought of as a limit to the number of Tweets to return because suspended or deleted content is removed after the count has been applied.
- since_id: Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
- max_id: Returns results with an ID less than (that is, older than) or equal to the specified ID.
- include_entities: The entities node will be omitted when set to false .
- user_id: The ID of the user for whom to return results.
- count: Specifies the number of records to retrieve. Must be less than or equal to 200; defaults to 20. The value of count is best thought of as a limit to the number of Tweets to return because suspended or deleted content is removed after the count has been applied.
- since_id: Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
- max_id: Returns results with an ID less than (that is, older than) or equal to the specified ID.
- include_entities: The entities node will be omitted when set to false .
- SeeAlso
https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list
*/
public func favorites_list(user_id: String, count: Int? = nil, since_id: Int? = nil, max_id: Int? = nil, include_entities: Bool? = nil) async throws -> [[String: Any]] {
func favorites_list(user_id: String, count: Int? = nil, since_id: Int? = nil, max_id: Int? = nil, include_entities: Bool? = nil) async throws -> [[String: Any]] {
let guest_token = try await generate_guest_token().guest_token
var urlString: String = "https://api.twitter.com/1.1/favorites/list.json?user_id=\(user_id)"
if count != nil {
Expand All @@ -50,16 +50,16 @@ public extension Client {
- Note: Returns the 20 most recent Tweets liked by the authenticating or specified user.
- Parameters:
- screen_name: The screen name of the user for whom to return results.
- count: Specifies the number of records to retrieve. Must be less than or equal to 200; defaults to 20. The value of count is best thought of as a limit to the number of Tweets to return because suspended or deleted content is removed after the count has been applied.
- since_id: Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
- max_id: Returns results with an ID less than (that is, older than) or equal to the specified ID.
- include_entities: The entities node will be omitted when set to false .
- screen_name: The screen name of the user for whom to return results.
- count: Specifies the number of records to retrieve. Must be less than or equal to 200; defaults to 20. The value of count is best thought of as a limit to the number of Tweets to return because suspended or deleted content is removed after the count has been applied.
- since_id: Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
- max_id: Returns results with an ID less than (that is, older than) or equal to the specified ID.
- include_entities: The entities node will be omitted when set to false .
- SeeAlso
https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list
*/
public func favorites_list(screen_name: String, count: Int? = nil, since_id: Int? = nil, max_id: Int? = nil, include_entities: Bool? = nil) async throws -> [[String: Any]] {
func favorites_list(screen_name: String, count: Int? = nil, since_id: Int? = nil, max_id: Int? = nil, include_entities: Bool? = nil) async throws -> [[String: Any]] {
let guest_token = try await generate_guest_token().guest_token
var urlString: String = "https://api.twitter.com/1.1/favorites/list.json?screen_name=\(screen_name.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)"
if count != nil {
Expand Down
Loading

0 comments on commit 9afe465

Please sign in to comment.