Skip to content

Commit e2c1887

Browse files
committed
examples added
1 parent 4d3568e commit e2c1887

File tree

7 files changed

+55
-0
lines changed

7 files changed

+55
-0
lines changed

R/index.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#' @param token The user access token that can be retrieved with the auth() function. Required when if the database rules specify the need for user authentications. {string}
88
#' @return returns http request answer which includes the random key.
99
#' @export
10+
#' @examples
11+
#' \dontrun{
12+
#' upload(x = mtcars, projectURL = "https://firedata-b0e54.firebaseio.com/", directory = "main")
13+
#' }
1014
upload <- function(x, projectURL, directory = "main", token = "none"){
1115
output = fileConversion(x)
1216
if (token == "none") {
@@ -38,6 +42,10 @@ fileConversion <- function(x){
3842
#' @param isClass In case a s4 class object is downloaded, fireData expects a isClass=TRUE
3943
#' @return returns optionally reformatted data.
4044
#' @export
45+
#' @examples
46+
#' \dontrun{
47+
#' download(projectURL = "https://firedata-b0e54.firebaseio.com/", fileName = "main/-KxwWNTVdplXFRZwGMkH")
48+
#' }
4149
download <- function(projectURL, fileName, secretKey = "none", token = "none", isClass = FALSE) {
4250

4351
if (secretKey == "none" && token == "none") {
@@ -68,6 +76,11 @@ download <- function(projectURL, fileName, secretKey = "none", token = "none", i
6876
#' @description The backup functionality allows to download the whole database into a .json file (which can later be uploaded in the firebase console to do a restore of the DB). Generally this function may allow to save costs by not relying on the Firebase automatic backup function that is only available with the Firebase Blaze premium payment contract.
6977
#' @return Returns either a warning or the backup file name.
7078
#' @export
79+
#' @examples
80+
#' \dontrun{
81+
#' dataBackup(projectURL = "https://firedata-efa5a.firebaseio.com", secretKey = "2bYA6k72wKna90MqPGa6yuMG7jAysoDJZwJqYXsm", "test.json")
82+
#' }
83+
7184
dataBackup <- function(projectURL, secretKey="prompt", fileName){
7285
if (secretKey == "prompt") {
7386
secretKey <- readline(prompt = "secretKey: ")
@@ -88,6 +101,10 @@ dataBackup <- function(projectURL, secretKey="prompt", fileName){
88101
#' @param password The user password {string}
89102
#' @return Returns the content of the firebase API request, such as the state of registration, idToken, and validity of the user password.
90103
#' @export
104+
#' @examples
105+
#' \dontrun{
106+
#' auth(projectAPI = "AIzaSyAjZLO9-CRV3gObpwdFz-k8AiTOxHSBmdc", email = "[email protected]", password = "12341234")
107+
#' }
91108
auth <- function(projectAPI, email="prompt", password="prompt"){
92109
if (password == "prompt" && email == "prompt") {
93110
email <- readline(prompt = "Email: ")
@@ -106,6 +123,10 @@ auth <- function(projectAPI, email="prompt", password="prompt"){
106123
#' @description Creates a new firebase user account. All user accounts can accessed at the firebase.com project console. One of the advantages of firebase accounts in R is the ability to access a website and analyse the data of the website with the very same login.
107124
#' @return Registers a new user and returns the status.
108125
#' @export
126+
#' @examples
127+
#' \dontrun{
128+
#' createUser(projectAPI = "AIzaSyAjZLO9-CRV3gObpwdFz-k8AiTOxHSBmdc", email = "[email protected]", password = "12341234" )
129+
#' }
109130
createUser <- function(projectAPI, email="prompt", password="prompt"){
110131
if (password == "prompt" && email == "prompt") {
111132
email <- readline(prompt = "Email: ")
@@ -123,6 +144,10 @@ createUser <- function(projectAPI, email="prompt", password="prompt"){
123144
#' @description Resets the user password and sends an email to the user account.
124145
#' @return Success or warning message.
125146
#' @export
147+
#' @examples
148+
#' \dontrun{
149+
#' resetPassword(projectAPI = "AIzaSyAjZLO9-CRV3gObpwdFz-k8AiTOxHSBmdc", email = "[email protected]")
150+
#' }
126151
resetPassword <- function(projectAPI, email){
127152
AuthUrl = paste0("https://www.googleapis.com/identitytoolkit/v3/relyingparty/getOobConfirmationCode?key=", projectAPI)
128153
userData = httr::POST(url = AuthUrl, body = list("email" = email, "requestType" = "PASSWORD_RESET"), encode = "json")

man/auth.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/createUser.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dataBackup.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/download.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/resetPassword.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/upload.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)