From 4c32b0f4bd60c114a5c31e1b0c7d3f6d46be09ac Mon Sep 17 00:00:00 2001
From: oliverpurschke <oliverpurschke@web.de>
Date: Fri, 8 Mar 2024 16:28:26 +0100
Subject: [PATCH] more changes

---
 DESCRIPTION           | 21 +++++++++++----------
 NAMESPACE             |  1 +
 R/digi_lime_auth.r    | 22 ++++++++++++++++++++++
 README.md             |  1 +
 man/digi_lime_auth.Rd | 21 +++++++++++++++++++++
 5 files changed, 56 insertions(+), 10 deletions(-)
 create mode 100644 R/digi_lime_auth.r
 create mode 100644 man/digi_lime_auth.Rd

diff --git a/DESCRIPTION b/DESCRIPTION
index a053bbe..650ac2f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,12 +1,13 @@
 Package: lsfun
-Title: What the Package Does (One Line, Title Case)
-Version: 0.0.0.9000
-Authors@R: 
-    person("First", "Last", , "first.last@example.com", role = c("aut", "cre"),
-           comment = c(ORCID = "YOUR-ORCID-ID"))
-Description: What the package does (one paragraph).
-License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
-    license
+Title: Helper functions to interact with LimeSurvey from within R
+Version: 0.0.3
+Authors@R: person(given = "Oliver",
+           family = "Purschke",
+           role = c("aut", "cre"),
+           email = "oliver.purschke@uk-halle.de",
+           comment = c(ORCID = "0000-0003-0444-0882"))
+Description: Currently contains a set of functions to interact with LimeSurvey from within R
+License: GNU General Public License v3.0
 Encoding: UTF-8
-Roxygen: list(markdown = TRUE)
-RoxygenNote: 7.2.0
+LazyData: true
+RoxygenNote: 7.2.3
diff --git a/NAMESPACE b/NAMESPACE
index d07a57f..72be8a9 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,3 +1,4 @@
 # Generated by roxygen2: do not edit by hand
 
+export(digi_lime_auth)
 export(digi_lime_get_part_chunks)
diff --git a/R/digi_lime_auth.r b/R/digi_lime_auth.r
new file mode 100644
index 0000000..09fb523
--- /dev/null
+++ b/R/digi_lime_auth.r
@@ -0,0 +1,22 @@
+#' Generate LimeSurvey authentification token
+#'
+#' @description In case there is no key set, run key_set("limesurvey.user", lime_user)
+#'
+#' @param lime_user LimeSurvey user name
+#'
+#' @return ...
+#' @export
+#' @examples
+#' digi_lime_auth()
+#'
+digi_lime_auth <- function(lime_user) {
+    safe_key_get <-
+        safely(
+            key_get # ,
+            # otherwise = key_set("limesurvey.user", lime_user)
+        )
+    options(lime_api = "https://webszh.uk-halle.de/limesurvey/index.php/admin/remotecontrol")
+    options(lime_username = lime_user)
+    options(lime_password = safe_key_get("limesurvey.user", lime_user)$result)
+    get_session_key()
+}
diff --git a/README.md b/README.md
index 6412385..f3e27e6 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ Load additional packages
 
 ``` r
 library(tidyverse)
+library(keyring)
 library(limer)
 ```
 
diff --git a/man/digi_lime_auth.Rd b/man/digi_lime_auth.Rd
new file mode 100644
index 0000000..c8e0738
--- /dev/null
+++ b/man/digi_lime_auth.Rd
@@ -0,0 +1,21 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/digi_lime_auth.r
+\name{digi_lime_auth}
+\alias{digi_lime_auth}
+\title{Generate LimeSurvey authentification token}
+\usage{
+digi_lime_auth(lime_user)
+}
+\arguments{
+\item{lime_user}{LimeSurvey user name}
+}
+\value{
+...
+}
+\description{
+In case there is no key set, run key_set("limesurvey.user", lime_user)
+}
+\examples{
+digi_lime_auth()
+
+}
-- 
GitLab