public = list(
+ validContentTypes = NULL,
+
initialize = function()
{
+ self$validContentTypes <- c("text", "raw")
},
- GET = function(url, headers = NULL, body = NULL,
- queryFilters = NULL, limit = NULL, offset = NULL)
+ GET = function(url, headers = NULL, queryFilters = NULL, limit = NULL, offset = NULL)
{
headers <- httr::add_headers(unlist(headers))
query <- private$createQuery(queryFilters, limit, offset)
url <- paste0(url, query)
serverResponse <- httr::DELETE(url = url, config = headers)
+ },
+
+ PROPFIND = function(url, headers = NULL)
+ {
+ h <- curl::new_handle()
+ curl::handle_setopt(h, customrequest = "PROPFIND")
+ curl::handle_setheaders(h, .list = headers)
+
+ propfindResponse <- curl::curl_fetch_memory(url, h)
+ },
+
+ MOVE = function(url, headers = NULL)
+ {
+ h <- curl::new_handle()
+ curl::handle_setopt(h, customrequest = "MOVE")
+ curl::handle_setheaders(h, .list = headers)
+
+ propfindResponse <- curl::curl_fetch_memory(url, h)
}
),
# Python array from R list (recursion?)
createQuery = function(filters, limit, offset)
{
- finalQuery <- "?alt=json"
+ finalQuery <- NULL
if(!is.null(filters))
{
encodedQuery <- URLencode(filters, reserved = T, repeated = T)
- finalQuery <- paste0(finalQuery, "&filters=", encodedQuery)
-
#Todo(Fudo): This is a hack for now. Find a proper solution.
- finalQuery <- stringr::str_replace_all(finalQuery, "%2B", "+")
+ encodedQuery <- stringr::str_replace_all(encodedQuery, "%2B", "+")
+
+ finalQuery <- c(finalQuery, paste0("filters=", encodedQuery))
+
+ finalQuery
}
if(!is.null(limit))
if(!is.numeric(limit))
stop("Limit must be a numeric type.")
- finalQuery <- paste0(finalQuery, "&limit=", limit)
+ finalQuery <- c(finalQuery, paste0("limit=", limit))
}
if(!is.null(offset))
if(!is.numeric(offset))
stop("Offset must be a numeric type.")
- finalQuery <- paste0(finalQuery, "&offset=", offset)
+ finalQuery <- c(finalQuery, paste0("offset=", offset))
+ }
+
+ if(length(finalQuery) > 1)
+ {
+ finalQuery <- paste0(finalQuery, collapse = "&")
+ finalQuery <- paste0("?", finalQuery)
}
finalQuery