ropensci / crul

R6 based http client for R (for developers)
https://docs.ropensci.org/crul
Other
107 stars 17 forks source link

Making printing of HttpRequest objects more informative? #128

Closed maelle closed 4 years ago

maelle commented 4 years ago

I was looking at HttpRequest objects, and am wondering whether it could be more visible when one such object has a query associated with it e.g.

query <- list(city = "Delhi", 
              date_from = "2020-02-25", 
              limit = 100, 
              include_fields = "", 
              page = 1)

req1 <- crul::HttpRequest$new(url = "https://api.openaq.org/v1/measurements")
req1
#> <crul http request> 
#>   url: https://api.openaq.org/v1/measurements
#>   curl options: 
#>   proxies: 
#>   auth: 
#>   headers: 
#>   progress: FALSE

req2 <- crul::HttpRequest$new(url = "https://api.openaq.org/v1/measurements")$get(query = query)
req2
#> <crul http request> get
#>   url: https://api.openaq.org/v1/measurements
#>   curl options: 
#>   proxies: 
#>   auth: 
#>   headers: 
#>   progress: FALSE

Created on 2020-02-26 by the reprex package (v0.3.0)

I'd expect req2 to show the query?

sckott commented 4 years ago

thanks, having a look

sckott commented 4 years ago

@maelle let me know if that works for you now

maelle commented 4 years ago

What, 27 days ago already?! Sorry for the delay Scott. It looks great, thank you!

query <- list(city = "Delhi", 
              date_from = "2020-02-25", 
              limit = 100, 
              include_fields = "", 
              page = 1)

req1 <- crul::HttpRequest$new(url = "https://api.openaq.org/v1/measurements")
req1
#> <crul http request> 
#>   url: https://api.openaq.org/v1/measurements
#>   curl options: 
#>   proxies: 
#>   auth: 
#>   headers: 
#>   progress: FALSE

req2 <- crul::HttpRequest$new(url = "https://api.openaq.org/v1/measurements")$get(query = query)
req2
#> <crul http request> get
#>   url: https://api.openaq.org/v1/measurements?city=Delhi&date_from=2020-02-25&limit=100&include_fields=&page=1
#>   curl options: 
#>   proxies: 
#>   auth: 
#>   headers: 
#>   progress: FALSE

Created on 2020-03-24 by the reprex package (v0.3.0)

sckott commented 4 years ago

👍