File: lists_subscriptions.R

package info (click to toggle)
r-cran-rtweet 1.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,224 kB
  • sloc: sh: 13; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#' Get list subscriptions of a given user but does not include the user's own 
#' lists.
#'
#' @inheritParams TWIT_paginate_cursor
#' @inheritParams get_timeline
#' @examples
#' if (auth_has_default()) {
#' ## get ropensci subscriptions
#' rstats <- lists_subscriptions(user = "rladiesglobal", n = 1000)
#' }
#'
#' @family lists
#' @references <https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-subscriptions>
#' @export
lists_subscriptions <- function(user,
                                n = 20,
                                cursor = "-1",
                                parse = TRUE,
                                retryonratelimit = NULL,
                                verbose = TRUE,
                                token = NULL) {
  
  params <- list(
    count = n,
    cursor = cursor
  )
  params[[user_type(user)]] <- user

  r <- TWIT_paginate_cursor(token, "/1.1/lists/subscriptions", params,
    cursor = cursor,
    retryonratelimit = retryonratelimit,
    verbose = verbose,
    page_size = if (n >= 1000) 1000 else n,
    get_id = function(x) x$user_id
  )
  
  if (parse) {
    out <- parse_lists_list(r)
  }
  out
}