diff --git a/NAMESPACE b/NAMESPACE index 20927465..a10b5602 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,8 +31,6 @@ export(osm_delete_gpx) export(osm_delete_note) export(osm_delete_object) export(osm_details_logged_user) -export(osm_details_user) -export(osm_details_users) export(osm_diff_upload_changeset) export(osm_download_changeset) export(osm_feed_notes) @@ -41,6 +39,7 @@ export(osm_get_metadata_gpx) export(osm_get_objects) export(osm_get_points_gps) export(osm_get_preferences_user) +export(osm_get_user_details) export(osm_hide_comment_changeset_discussion) export(osm_history_object) export(osm_list_gpxs) diff --git a/R/osm_get_user_details.R b/R/osm_get_user_details.R new file mode 100644 index 00000000..6d0cbc32 --- /dev/null +++ b/R/osm_get_user_details.R @@ -0,0 +1,26 @@ +#' Details of users +#' +#' @param user_id The ids of the users to retrieve the details for, represented by a numeric or a character value (not +#' the display names). +#' @param format Format of the output. Can be `R` (default), `xml`, or `json`. +#' +#' @return +#' @family users' functions +#' @export +#' +#' @examples +#' \dontrun{ +#' usrs <- osm_details_users(user_ids = c(1, 24, 44, 45, 46, 48, 49, 50)) +#' usrs +#' } +osm_get_user_details <- function(user_id, format = c("R", "xml", "json")) { + format <- match.arg(format) + + if (length(user_id) == 1) { + out <- osm_details_user(user_id = user_id, format = format) + } else { + out <- osm_details_users(user_ids = user_id, format = format) + } + + return(out) +} diff --git a/R/osmapi_user_data.R b/R/osmapi_user_data.R index e9dbc1c2..3dbe182c 100644 --- a/R/osmapi_user_data.R +++ b/R/osmapi_user_data.R @@ -48,8 +48,8 @@ #' @param format Format of the output. Can be `R` (default), `xml`, or `json`. #' #' @return -#' @family users' functions -#' @export +# @family users' functions +#' @noRd #' #' @examples #' \dontrun{ @@ -141,8 +141,8 @@ osm_details_user <- function(user_id, format = c("R", "xml", "json")) { #' @param format Format of the output. Can be `R` (default), `xml`, or `json`. #' #' @return -#' @family users' functions -#' @export +# @family users' functions +#' @noRd #' #' @examples #' \dontrun{ diff --git a/man/osm_details_logged_user.Rd b/man/osm_details_logged_user.Rd index a987c039..14cd8db2 100644 --- a/man/osm_details_logged_user.Rd +++ b/man/osm_details_logged_user.Rd @@ -23,8 +23,7 @@ usr_details } \seealso{ Other users' functions: -\code{\link{osm_details_users}()}, -\code{\link{osm_details_user}()}, -\code{\link{osm_get_preferences_user}()} +\code{\link{osm_get_preferences_user}()}, +\code{\link{osm_get_user_details}()} } \concept{users' functions} diff --git a/man/osm_details_user.Rd b/man/osm_details_user.Rd deleted file mode 100644 index 5c1b3151..00000000 --- a/man/osm_details_user.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/osmapi_user_data.R -\name{osm_details_user} -\alias{osm_details_user} -\title{Details of a user} -\usage{ -osm_details_user(user_id, format = c("R", "xml", "json")) -} -\arguments{ -\item{user_id}{The id of the user to retrieve represented by a numeric or a character value (not the display name).} - -\item{format}{Format of the output. Can be \code{R} (default), \code{xml}, or \code{json}.} -} -\description{ -Details of a user -} -\examples{ -\dontrun{ -usr <- osm_details_user(user_id = "11725140") -usr -} -} -\seealso{ -Other users' functions: -\code{\link{osm_details_logged_user}()}, -\code{\link{osm_details_users}()}, -\code{\link{osm_get_preferences_user}()} -} -\concept{users' functions} diff --git a/man/osm_get_preferences_user.Rd b/man/osm_get_preferences_user.Rd index f93c69cd..45f8758d 100644 --- a/man/osm_get_preferences_user.Rd +++ b/man/osm_get_preferences_user.Rd @@ -23,7 +23,6 @@ prefs \seealso{ Other users' functions: \code{\link{osm_details_logged_user}()}, -\code{\link{osm_details_users}()}, -\code{\link{osm_details_user}()} +\code{\link{osm_get_user_details}()} } \concept{users' functions} diff --git a/man/osm_details_users.Rd b/man/osm_get_user_details.Rd similarity index 52% rename from man/osm_details_users.Rd rename to man/osm_get_user_details.Rd index 7ec224a3..85af80bc 100644 --- a/man/osm_details_users.Rd +++ b/man/osm_get_user_details.Rd @@ -1,19 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/osmapi_user_data.R -\name{osm_details_users} -\alias{osm_details_users} -\title{Details of multiple users} +% Please edit documentation in R/osm_get_user_details.R +\name{osm_get_user_details} +\alias{osm_get_user_details} +\title{Details of users} \usage{ -osm_details_users(user_ids, format = c("R", "xml", "json")) +osm_get_user_details(user_id, format = c("R", "xml", "json")) } \arguments{ -\item{user_ids}{The ids of the users to retrieve represented by a numeric or a character value (not the display -names).} +\item{user_id}{The ids of the users to retrieve the details for, represented by a numeric or a character value (not +the display names).} \item{format}{Format of the output. Can be \code{R} (default), \code{xml}, or \code{json}.} } \description{ -Details of multiple users +Details of users } \examples{ \dontrun{ @@ -24,7 +24,6 @@ usrs \seealso{ Other users' functions: \code{\link{osm_details_logged_user}()}, -\code{\link{osm_details_user}()}, \code{\link{osm_get_preferences_user}()} } \concept{users' functions} diff --git a/tests/testthat/mock_details_user/osm.org/api/0.6/user/11725140.xml b/tests/testthat/mock_details_user/osm.org/api/0.6/user/11725140.xml index 205d5113..6d325584 100644 --- a/tests/testthat/mock_details_user/osm.org/api/0.6/user/11725140.xml +++ b/tests/testthat/mock_details_user/osm.org/api/0.6/user/11725140.xml @@ -1,11 +1,12 @@ - + [Fòrums d'OSM](https://community.openstreetmap.org/u/jmaspons) - [Wiki d'OSM](https://wiki.openstreetmap.org/wiki/User:Jmaspons) - [OSM help](https://help.openstreetmap.org/users/23509/jmaspons) + - + diff --git a/tests/testthat/mock_details_users/osm.org/api/0.6/users-c7389c.xml b/tests/testthat/mock_details_user/osm.org/api/0.6/user/61942.xml similarity index 73% rename from tests/testthat/mock_details_users/osm.org/api/0.6/users-c7389c.xml rename to tests/testthat/mock_details_user/osm.org/api/0.6/user/61942.xml index c5dc3738..50dcc0ff 100644 --- a/tests/testthat/mock_details_users/osm.org/api/0.6/users-c7389c.xml +++ b/tests/testthat/mock_details_user/osm.org/api/0.6/user/61942.xml @@ -7,20 +7,20 @@ I mainly map footpaths and other out-of-town things. Also see related profile o There are some bits and pieces (including [two](https://github.com/SomeoneElseOSM/SomeoneElse-style) [parts](https://github.com/SomeoneElseOSM/openstreetmap-carto-AJT) of an OSM-Carto-derived rendering style designed for out-of-town England and Wales) over at [Github](https://github.com/SomeoneElseOSM) that look like [this](https://map.atownsend.org.uk/maps/map/map.html). There are some wiki pages behind [here](https://wiki.openstreetmap.org/wiki/User:SomeoneElse) (mostly to do with tileserver setup). -I'm a member of the [Data Working Group](http://wiki.openstreetmap.org/wiki/Data_working_group) (that's what the blue star above means), but if you've you've got any issues to raise with the DWG the [group email address](http://wiki.osmfoundation.org/wiki/Data_Working_Group#Contact) is the best one to use. +I'm a member of the [Data Working Group](http://wiki.openstreetmap.org/wiki/Data_working_group) (that's what the blue star above means), but if you've got any issues to raise with the DWG the [group email address](http://wiki.osmfoundation.org/wiki/Data_Working_Group#Contact) is the best one to use. Other related accounts are [SomeoneElse2](http://www.openstreetmap.org/user/SomeoneElse2). [SomeoneElseSC](https://www.openstreetmap.org/user/SomeoneElseSC) and [SomeoneElse_Revert](http://www.openstreetmap.org/user/SomeoneElse_Revert), which is mainly used where people have requested that I help with reversions. - +The "User id" of this account is "61942". I mention that because there have been a few attempts over the years to impersonate DWG members, including me, using names such as "SomeoneEIse" (with a capital "i" instead of a lower case "l") and others with various UTF-8 versions of characters that look similar to, but are not, regular ascii characters. - - + + - + diff --git a/tests/testthat/mock_details_users/osm.org/api/0.6/users-48e738.xml b/tests/testthat/mock_details_users/osm.org/api/0.6/users-48e738.xml new file mode 100644 index 00000000..aa2c07c4 --- /dev/null +++ b/tests/testthat/mock_details_users/osm.org/api/0.6/users-48e738.xml @@ -0,0 +1,53 @@ + + + + I live near York (UK), though I do occasionally [venture further afield](http://yosmhm.neis-one.org/?zoom=6&lat=53.08324&lon=-2.42578&layers=B000TTF&u=SomeoneElse). +I mainly map footpaths and other out-of-town things. Also see related profile on +<a rel="me" href="https://en.osm.town/@SomeoneElse">Mastodon</a>. + +There are some bits and pieces (including [two](https://github.com/SomeoneElseOSM/SomeoneElse-style) [parts](https://github.com/SomeoneElseOSM/openstreetmap-carto-AJT) of an OSM-Carto-derived rendering style designed for out-of-town England and Wales) over at [Github](https://github.com/SomeoneElseOSM) that look like [this](https://map.atownsend.org.uk/maps/map/map.html). There are some wiki pages behind [here](https://wiki.openstreetmap.org/wiki/User:SomeoneElse) (mostly to do with tileserver setup). + +I'm a member of the [Data Working Group](http://wiki.openstreetmap.org/wiki/Data_working_group) (that's what the blue star above means), but if you've got any issues to raise with the DWG the [group email address](http://wiki.osmfoundation.org/wiki/Data_Working_Group#Contact) is the best one to use. + +Other related accounts are [SomeoneElse2](http://www.openstreetmap.org/user/SomeoneElse2). [SomeoneElseSC](https://www.openstreetmap.org/user/SomeoneElseSC) and [SomeoneElse_Revert](http://www.openstreetmap.org/user/SomeoneElse_Revert), which is mainly used where people have requested that I help with reversions. + +The "User id" of this account is "61942". I mention that because there have been a few attempts over the years to impersonate DWG members, including me, using names such as "SomeoneEIse" (with a capital "i" instead of a lower case "l") and others with various UTF-8 versions of characters that look similar to, but are not, regular ascii characters. + + + + + + + + + + + + + Занимаюсь Тюменской областью (Россия). Родной город – Заводоуковск. Также эта учётная запись была использована рабочей группой по данным (например, для откатов пакетов правок). +Je mappe Oblast de Tioumen (Russie). Ma ville natale est Zavodooukovsk. Aussi ce compte d'utilisateur été utilisé par le Data Working Group (par exemple, pour les retours des groupes des modifications). +I map Tyumen Oblast (Russia). My native town is Zavodoukovsk. Also this account was used by Data Working Group (for example, the reverts of the changesets). +============================================================= +*Забытые страницы сайта:* + +https://www.openstreetmap.org/fixthemap +https://www.openstreetmap.org/user_blocks +https://www.openstreetmap.org/redactions + +*Некоторые настройки сервера:* + +https://www.openstreetmap.org/api/versions +https://www.openstreetmap.org/api/capabilities + + + + + + + + + + + + + diff --git a/tests/testthat/mock_details_users/osm.org/api/0.6/users-ea3712.xml b/tests/testthat/mock_details_users/osm.org/api/0.6/users-ea3712.xml index 9b994166..0c2546f5 100644 --- a/tests/testthat/mock_details_users/osm.org/api/0.6/users-ea3712.xml +++ b/tests/testthat/mock_details_users/osm.org/api/0.6/users-ea3712.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -54,7 +54,7 @@ mm-&lt;date&gt;-mtk.gpx - maemo mapper + BT-Q1000 (MTK Chip) - + diff --git a/tests/testthat/test-user_data.R b/tests/testthat/test-user_data.R index 3218babe..43962ee5 100644 --- a/tests/testthat/test-user_data.R +++ b/tests/testthat/test-user_data.R @@ -14,17 +14,21 @@ class_columns <- list( ## Details of a user: `GET /api/0.6/user/#id` ---- test_that("osm_details_user works", { + usr <- list() with_mock_dir("mock_details_user", { - usr <- osm_details_user(user_id = "11725140") + usr$usr <- osm_get_user_details(user_id = "11725140") + usr$mod <- osm_get_user_details(user_id = 61942) }) - expect_s3_class(usr, "data.frame") - expect_named(usr, column_users) + lapply(usr, expect_s3_class, "data.frame") + lapply(usr, function(x) expect_named(x, column_users)) - mapply(function(x, cl) expect_true(inherits(x, cl)), x = usr, cl = class_columns[names(usr)]) + lapply(usr, lapply, function(x) { + mapply(function(y, cl) expect_true(inherits(y, cl)), y = x, cl = class_columns[names(x)]) + }) # Check that time is extracted, otherwise it's 00:00:00 in local time - expect_false(strftime(as.POSIXct(usr$account_created), format = "%M:%S") == "00:00") + lapply(usr, function(x) expect_false(all(strftime(as.POSIXct(x$account_created), format = "%M:%S") == "00:00"))) }) @@ -33,8 +37,8 @@ test_that("osm_details_user works", { test_that("osm_details_users works", { usrs <- list() with_mock_dir("mock_details_users", { - usrs$usrs <- osm_details_users(user_ids = c(1, 24, 44, 45, 46, 48, 49, 50)) - usrs$mod <- osm_details_users(user_ids = 61942) + usrs$usrs <- osm_get_user_details(user_id = c(1, 24, 44, 45, 46, 48, 49, 50)) + usrs$mod <- osm_get_user_details(user_id = c(61942, 564990)) }) lapply(usrs, expect_s3_class, "data.frame")