-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring: Repetitive pattern #31
Milestone
Comments
agreed. Doing a lot of ctrl+c/ctr+v for the account endpoints atm |
we have this only twice though? Anything I miss what is problematic here? |
@schochastics With the poll, now thrice. Not as repetitive as the first dance, though. |
ah right yeah then we may want to tackle this too |
Closed
testing with this function atm process_request <- function(token = NULL,
path,
instance = NULL,
params,
anonymous = FALSE,
parse = TRUE,
FUN = identity
){
output <- make_get_request(token = token,path = path,
instance = instance, params = params,
anonymous = anonymous)
if (isTRUE(parse)) {
header <- attr(output,"headers")
if(length(output[[1]])==1){ #TODO:fragile?
output <- FUN(output)
} else{
output <- dplyr::bind_rows(lapply(output, FUN))
}
attr(output,"headers") <- header
}
return(output)
} this is how the new get functions would look like get_account_statuses <- function(id,instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE){
path <- paste0("api/v1/accounts/",id,"/statuses")
params <- list()
# output <- make_get_request(token = token,path = path,
# instance = instance, params = params,
# anonymous = anonymous)
# if (isTRUE(parse)) {
# output <- dplyr::bind_rows(lapply(output, parse_status))
# }
# return(output)
process_request(token = token,path = path,instance = instance,
params = params, anonymous = anonymous,
parse = parse, FUN = parse_status)
} |
schochastics
added a commit
that referenced
this issue
Nov 8, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/schochastics/rtoot/blob/2d322706fa8b71e2df37fff6c59421884006b945/R/timelines.R#L49-L52
This dance is getting repetitive for all functions using
make_get_request
. But in order to refactor it, we need to have tests first. #19The text was updated successfully, but these errors were encountered: