From 0d197b00b51138e65400fc5a16f99300d7385232 Mon Sep 17 00:00:00 2001 From: ericnewkirk <55846615+ericnewkirk@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:32:31 -0600 Subject: [PATCH] Fix the last fix Rework top n fix --- NAMESPACE | 1 - R/ats_auth.R | 37 ------------------------------------- R/fetch_ats.R | 8 ++++---- man/clear_cookie.Rd | 35 ----------------------------------- 4 files changed, 4 insertions(+), 77 deletions(-) delete mode 100644 man/clear_cookie.Rd diff --git a/NAMESPACE b/NAMESPACE index b07c74e..67d19d1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,7 +12,6 @@ export(ats_post) export(ats_select_collars) export(ats_trans_dates) export(check_cookie) -export(clear_cookie) export(cllr_add_id) export(cllr_remove_header) export(cllr_rename_id) diff --git a/R/ats_auth.R b/R/ats_auth.R index 4734c57..9426b7a 100644 --- a/R/ats_auth.R +++ b/R/ats_auth.R @@ -37,43 +37,6 @@ check_cookie <- function(url, cookie) { } -# * 2.2 - clear_cookie ---------------------------------------------------- - -#' @title Remove Cookie -#' -#' @description Remove a certain cookie from a request handle -#' -#' @param url http hostname (base url) -#' @param cookie name of the cookie to remove -#' -#' @return named character vector for \code{httr::set_cookies} -#' -#' @export -#' -#' @keywords internal -#' -#' @examples -#' \dontrun{ -#' -#' httr::GET( -#' url = ats_base_url, -#' path = list( -#' "download_all_transmission", -#' "download_all_transmission.aspx?dw=new" -#' ), -#' httr::set_cookies(clear_cookie(ats_base_url, "cgca")) -#' ) -#' -#' } -#' -clear_cookie <- function(url, cookie) { - - cookies <- httr::cookies(httr::handle_find(url)) %>% - dplyr::filter(.data$name != cookie) %>% - dplyr::pull(.data$value, name = .data$name) - -} - # 3 - Visible Functions --------------------------------------------------- # * 3.1 - ats_login ------------------------------------------------------- diff --git a/R/fetch_ats.R b/R/fetch_ats.R index 74d3af1..b417539 100644 --- a/R/fetch_ats.R +++ b/R/fetch_ats.R @@ -1312,10 +1312,11 @@ fetch_ats_positions <- function(device_id = NULL, } } - # post request only works with collars selected - if (!check_cookie(ats_base_url, "cgca")) { + if (any(missing(device_id), length(device_id) == 0)) { + # post request only works with collars selected ats_select_collars(fetch_ats_devices()) } + # otherwise collars are selected in fetch_ats_transmissions # send request and parse ats_post( @@ -1415,8 +1416,7 @@ fetch_ats_transmissions <- function(device_id = NULL, new = FALSE) { "download_all_transmission", paste0("download_all_transmission.aspx?dw=", type) ), - task = "download transmission data", - httr::set_cookies(clear_cookie(ats_base_url, "cgca")) + task = "download transmission data" ) %>% ats_parse_trans() diff --git a/man/clear_cookie.Rd b/man/clear_cookie.Rd deleted file mode 100644 index 34170ca..0000000 --- a/man/clear_cookie.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ats_auth.R -\name{clear_cookie} -\alias{clear_cookie} -\title{Remove Cookie} -\usage{ -clear_cookie(url, cookie) -} -\arguments{ -\item{url}{http hostname (base url)} - -\item{cookie}{name of the cookie to remove} -} -\value{ -named character vector for \code{httr::set_cookies} -} -\description{ -Remove a certain cookie from a request handle -} -\examples{ -\dontrun{ - -httr::GET( - url = ats_base_url, - path = list( - "download_all_transmission", - "download_all_transmission.aspx?dw=new" - ), - httr::set_cookies(clear_cookie(ats_base_url, "cgca")) -) - -} - -} -\keyword{internal}