Skip to content

Commit

Permalink
Remove examples and tests for API v1
Browse files Browse the repository at this point in the history
  • Loading branch information
llrs committed Dec 16, 2023
1 parent 0d09ef1 commit ba947e9
Show file tree
Hide file tree
Showing 97 changed files with 143 additions and 1,195 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export(get_tokens)
export(get_trends)
export(ids)
export(invalidate_bearer)
export(lat_lng)
export(links)
export(list_expansions)
export(list_fields)
Expand Down Expand Up @@ -108,7 +107,6 @@ export(post_destroy)
export(post_favorite)
export(post_follow)
export(post_friendship)
export(post_list)
export(post_message)
export(post_mute)
export(post_tweet)
Expand Down
2 changes: 1 addition & 1 deletion R/api_v2_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ req_is_error <- function(resp) {
} else {
r <- resp
}
has_name_(r, "errors")
has_name_(r, "errors") || httr2::resp_is_error(resp)

Check warning on line 102 in R/api_v2_utils.R

View check run for this annotation

Codecov / codecov/patch

R/api_v2_utils.R#L102

Added line #L102 was not covered by tests
}

req_errors <- function(resp) {
Expand Down
4 changes: 1 addition & 3 deletions R/auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ auth_setup_default <- function() {
#' @export
#' @examples
#' \dontrun{
#' rtweet_user()
#' rtweet_bot()
#' rtweet_app()
#' }
rtweet_user <- function(client_id = NULL, client_secret = NULL,
Expand Down Expand Up @@ -195,7 +193,7 @@ rtweet_bearer <- function(client = NULL, scopes = set_scopes()) {
token_params = list(client_secret = client$secret,
client_type = "third_party_app",
grant_type = "refresh_token"))
attr(token, "app", TRUE) <- client
attr(token, "app") <- client
token

Check warning on line 197 in R/auth.R

View check run for this annotation

Codecov / codecov/patch

R/auth.R#L191-L197

Added lines #L191 - L197 were not covered by tests
}

Expand Down
10 changes: 1 addition & 9 deletions R/clean_tweets.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@
#'
#' Removes from the text, users mentions, hashtags, urls and media.
#' Some urls or other text might remain if it is not recognized as an entity by
#' the API.
#' the API. `r lifecycle::badge("deprecated")`
#' @param x Tweets
#' @param clean Type of elements to be removed.
#' @return A vector with the text without the entities selected
#' @export
#' @examples
#' if (auth_has_default()) {
#' tweets <- search_tweets("weather")
#' tweets
#'
#' # tweets
#' clean_tweets(tweets)
#' }
clean_tweets <- function(x, clean = c("users", "hashtags", "urls", "media")) {
if (is.character(x)) {
abort("You should provide tweets with all the users and hashtags information",
Expand Down
2 changes: 2 additions & 0 deletions R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ no_client <- function(call = caller_env()) {
#' @seealso scopes
#' @export
#' @examples
#' \donttest{
#' if (interactive()) {
#' rtweet_client()
#' }
#' }
rtweet_client <- function(client_id, client_secret,
app, scopes = NULL) {
if (missing(client_id) && missing(client_secret) ) {
Expand Down
6 changes: 0 additions & 6 deletions R/coords.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
#' lnd <- lookup_coords("london")
#' bz <- lookup_coords("brazil")
#'
#' ## pass a returned coords object to search_tweets
#' bztw <- search_tweets(geocode = bz)
#'
#' ## or stream tweets
#' ustw <- stream_tweets(usa, timeout = 10)
#'
#' }
#'
#' @family geo
Expand Down
15 changes: 2 additions & 13 deletions R/direct_messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#'
#' Returns all Direct Message events (both sent and received) within the last 30
#' days. Sorted in reverse-chronological order. Includes detailed information
#' about the sender and recipient.
#' about the sender and recipient. `r lifecycle::badge("deprecated")`
#'
#' @inheritParams TWIT_paginate_cursor
#' @inheritParams stream
Expand All @@ -13,10 +13,7 @@
#' \dontrun{
#'
#' ## get my direct messages
#' dms <- direct_messages()
#'
#' ## inspect data structure
#' str(dms)
#' direct_messages()
#'
#' }
#' @export
Expand Down Expand Up @@ -62,16 +59,8 @@ direct_messages <- function(n = 50,
#'
#' ## get my direct messages
#' dms <- direct_messages_received()
#'
#' ## inspect data structure
#' str(dms)
#'
#' ## get direct messages I've sent
#' sdms <- direct_messages_sent()
#'
#' ## inspect data structure
#' str(dms)
#'
#' }
#'
#' @details Includes detailed information about the sender and
Expand Down
24 changes: 1 addition & 23 deletions R/do_call_rbind.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' Binds list of data frames while preserving attribute (tweets or users) data.
#'
#' Row bind lists of tweets/users data whilst also preserving and binding
#' users/tweets attribute data.
#' users/tweets attribute data. `r lifecycle::badge("deprecated")`
#'
#' @param x List of parsed tweets data or users data, each of which
#' presumably contains an attribute of the other (i.e., users data
Expand All @@ -13,28 +13,6 @@
#' [users_data()] or [tweets_data()] extractor
#' functions.
#' @family parsing
#' @examples
#'
#' if (auth_has_default()) {
#'
#' ## lapply through three different search queries
#' lrt <- lapply(
#' c("rstats OR tidyverse", "data science", "python"),
#' search_tweets,
#' n = 100
#' )
#'
#' ## convert list object into single parsed data rame
#' rt <- do_call_rbind(lrt)
#'
#' ## preview tweets data
#' rt
#'
#' ## preview users data
#' users_data(rt)
#'
#' }
#'
#' @export
do_call_rbind <- function(x) {
do.call(rbind, x)
Expand Down
13 changes: 0 additions & 13 deletions R/entities.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@
#' for users mentions the ids of the mentioned users are "user_id", "user_id_str"
#' (not "id_str")
#' @export
#' @examples
#' if (auth_has_default()) {
#' statuses <- c(
#' "567053242429734913",
#' "266031293945503744",
#' "440322224407314432"
#' )
#'
#' ## lookup tweets data for given statuses
#' tw <- lookup_tweets(statuses)
#' entity(tw, "urls")
#'
#' }
entity <- function(x, entity, ...) {
UseMethod("entity")
}
Expand Down
12 changes: 0 additions & 12 deletions R/extractors.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@
#' rtweet instead stores in special attributes and allows you to show them
#' with the `user_data()` and `tweets_data()` helpers.
#'
#' @examples
#' if (auth_has_default()) {
#' # find users from tweets
#' tweets <- search_tweets("r")
#' users_data(tweets)
#' full_search <- cbind(tweets, users_data(tweets))
#'
#' # from tweets from users
#' users <- search_users("r")
#' tweets_data(users)
#' full_users <- cbind(users, tweets_data(users))
#' }
#' @return `user_data()` returns a data frame of users; `tweets_data()`
#' returns a data frame of tweets.
#' @param tweets A data frame of tweets.
Expand Down
13 changes: 3 additions & 10 deletions R/favorites.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
#' Get tweets liked/favorited by one or more users
#'
#' Returns up to 3,000 tweets liked/favorited for each `user`.
#' `r lifecycle::badge("deprecated")`
#'
#' @inheritParams TWIT_paginate_max_id
#' @inheritParams get_timeline
#' @inheritParams stream
#' @return A tibble with one row for each tweet.
#' @examples
#' if (auth_has_default()) {
#' # get likes for a single user
#' kfc <- get_favorites("KFC")
#' kfc
#' # get newer likes since last request
#' newer <- get_favorites("KFC", since_id = kfc)
#'
#' # get likes from multiple users
#' favs <- get_favorites(c("Lesdoggg", "pattonoswalt", "meganamram"))
#' favs
#' if (FALSE) {
#' get_favorites("KFC")
#' }
#' @family tweets
#' @references <https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list>
Expand Down
9 changes: 2 additions & 7 deletions R/followers.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#' Get user IDs for accounts following target user.
#'
#' Returns a list of user IDs for the accounts following specified
#' user.
#' user. `r lifecycle::badge("deprecated")`
#'
#' @inheritParams TWIT_paginate_cursor
#' @inheritParams get_timeline
#' @inheritParams stream
#' @param page `r lifecycle::badge("deprecated")` Please use `cursor` instead.
#' @references <https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids>
#' @examples
#' if (auth_has_default()) {
#' if (FALSE) {
#' users <- get_followers("_R_Foundation")
#' users
#'
#' # use `cursor` to find the next "page" of results
#' more_users <- get_followers("_R_Foundation", cursor = users)
#'
#' }
#' @return A tibble data frame with one column named "from_id" with the
#' followers and another one "to_id" with the user used as input.
Expand Down
7 changes: 3 additions & 4 deletions R/friends.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Get user IDs of accounts followed by target user(s).
#'
#' Returns a list of user IDs for the accounts following BY one or
#' more specified users.
#' more specified users. `r lifecycle::badge("deprecated")`
#'
#' Generally, you should not need to set `n` to more than 5,000 since Twitter
#' limits the number of people that you can follow (i.e. to follow more than
Expand All @@ -18,9 +18,8 @@
#' retrieved.
#' @references <https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids>
#' @examples
#' if (auth_has_default()) {
#' users <- get_friends("ropensci")
#' users
#' if (FALSE) {
#' get_friends("ropensci")
#' }
#' @return A tibble data frame with two columns, "from_id" for name or ID of target
#' user and "to_id" for accounts ID they follow.
Expand Down
25 changes: 1 addition & 24 deletions R/graph-network.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Network data
#'
#' Retrieve data to know which users are connected to which users.
#' `r lifecycle::badge("deprecated")`
#'
#' @description
#' * `network_data()` returns a data frame that can easily be converted to
Expand All @@ -16,30 +17,6 @@
#' default value of `c("mention", "retweet", "reply", "quote")`
#' @return A from/to data edge data frame
#' @seealso network_graph
#' @examples
#' if (auth_has_default()) {
#' ## search for #rstats tweets
#' rstats <- search_tweets("#rstats", n = 200)
#'
#' ## create from-to data frame representing retweet/mention/reply connections
#' rstats_net <- network_data(rstats, c("retweet","mention","reply"))
#'
#' ## view edge data frame
#' rstats_net
#'
#' ## view user_id->screen_name index
#' attr(rstats_net, "idsn")
#'
#' ## if igraph is installed...
#' if (requireNamespace("igraph", quietly = TRUE)) {
#'
#' ## (1) convert directly to graph object representing semantic network
#' rstats_net <- network_graph(rstats)
#'
#' ## (2) plot graph via igraph.plotting
#' plot(rstats_net)
#' }
#' }
#' @export
network_data <- function(x, e = c("mention", "retweet", "reply", "quote")) {
if (isTRUE(e) || (length(e) == 1 && e %in% c("semantics", "all"))) {
Expand Down
9 changes: 0 additions & 9 deletions R/ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
#' @param x An object of the rtweet package.
#' @param ... Other arguments currently unused.
#' @export
#' @examples
#' if (auth_has_default()) {
#' users <- lookup_users(c("twitter", "rladiesglobal", "_R_Foundation"))
#' ids(users)
#' followers <- get_followers("_R_Foundation")
#' head(ids(followers))
#' friends <- get_friends("_R_Foundation")
#' head(ids(friends))
#' }
ids <- function(x, ...) {
UseMethod("ids")
}
Expand Down
15 changes: 1 addition & 14 deletions R/lat_lng.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' Adds single-point latitude and longitude variables to tweets data.
#'
#' Appends parsed Twitter data with latitude and longitude variables
#' using all available geolocation information.
#' using all available geolocation information. `r lifecycle::badge("deprecated")`
#'
#' @param x Parsed Twitter data as returned by various rtweet
#' functions. This should be a data frame with variables such as
Expand All @@ -28,19 +28,6 @@
#' @return Returns updated data object with full information latitude
#' and longitude vars.
#' @family geo
#' @examples
#'
#' if (auth_has_default()) {
#'
#' ## stream tweets sent from the US
#' rt <- search_tweets(geocode = lookup_coords("usa"))
#'
#' ## use lat_lng to recover full information geolocation data
#' rtl_loc <- lat_lng(rt)
#' rtl_loc
#' }
#'
#' @export
lat_lng <- function(x, coords = c("coords_coords", "bbox_coords", "geo_coords"), prefs = "bbox_coords") {
stopifnot(is.data.frame(x))
coords <- match.arg(coords, several.ok = TRUE)
Expand Down
9 changes: 0 additions & 9 deletions R/links.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
#' @param x An object of the rtweet package.
#' @param ... Other arguments currently unused.
#' @export
#' @examples
#' if (auth_has_default()) {
#' users <- lookup_users(c("twitter", "rladiesglobal", "_R_Foundation"))
#' links(users)
#' followers <- get_followers("_R_Foundation")
#' head(links(followers))
#' friends <- get_friends("_R_Foundation")
#' head(links(friends))
#' }
links <- function(x, ...) {
UseMethod("links")
}
Expand Down
13 changes: 0 additions & 13 deletions R/lists_members.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
#' @param owner_user optional The screen name or user ID of the user
#' @param ... Other arguments used as parameters in query composition.
#' @inheritParams stream
#' @examples
#' if (auth_has_default()) {
#'
#' ## get list members for a list of rstats experts using list_id
#' (rstats <- lists_members("1260528710559694850"))
#'
#' ## get list members for an rstats list using list topic slug
#' ## list owner's screen name
#' rstats <- lists_members(slug = "r-people", owner_user = "Lluis_Revilla")
#' rstats
#'
#' }
#'
#' @family lists
#' @export
#' @references <https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-members>
Expand Down
Loading

0 comments on commit ba947e9

Please sign in to comment.