Add getUserCountry and general API query function matomoQuery
Change-Id: Iedea1fcacf7329144e71f1412fc41238efc30bb2
diff --git a/R/usercountry.R b/R/usercountry.R
new file mode 100644
index 0000000..9eb3638
--- /dev/null
+++ b/R/usercountry.R
@@ -0,0 +1,30 @@
+#' Get user country report from matomo API server
+#'
+#' See matomo Reporting API Reference (\url{https://developer.matomo.org/api-reference/reporting-api}) for details.
+#'
+#' @references \url{https://developer.matomo.org/api-reference/reporting-api}
+#'
+#' @inheritParams matomoQuery
+#'
+#' @examples
+#' \dontrun{
+#' df <- getUserCountry("https://demo.matomo.org/", siteId=3, period="day", date="last60")
+#' }
+#'
+#' @export
+getUserCountry <- function(matomoUrl,
+ siteId,
+ period = "month",
+ date = "last36",
+ filter_limit = 100,
+ accessToken = getAccessToken(matomoUrl)
+) {
+ matomoQuery(matomoUrl = matomoUrl,
+ siteId = siteId,
+ period = period,
+ date = date,
+ removeFirst = FALSE,
+ removeLast = FALSE,
+ accessToken = accessToken,
+ getMethod = "UserCountry.getCountry")
+}